Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme-pci: Set the prp2 correctly when using more than 4k page

In the current code, the nvme is using a fixed 4k PRP entry size,
but if the kernel use a page size which is more than 4k, we should
consider the situation that the bv_offset may be larger than the
dev->ctrl.page_size. Otherwise we may miss setting the prp2 and then
cause the command can't be executed correctly.

Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment requests")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Kevin Hao and committed by
Keith Busch
a4f40484 28a4cac4

+2 -1
+2 -1
drivers/nvme/host/pci.c
··· 773 773 struct bio_vec *bv) 774 774 { 775 775 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 776 - unsigned int first_prp_len = dev->ctrl.page_size - bv->bv_offset; 776 + unsigned int offset = bv->bv_offset & (dev->ctrl.page_size - 1); 777 + unsigned int first_prp_len = dev->ctrl.page_size - offset; 777 778 778 779 iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0); 779 780 if (dma_mapping_error(dev->dev, iod->first_dma))