Skip to content

Commit a4f4048

Browse files
haokexinkeithbusch
authored andcommitted
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: dff824b ("nvme-pci: optimize mapping of small single segment requests") Cc: [email protected] Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Kevin Hao <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 28a4cac commit a4f4048

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev,
773773
struct bio_vec *bv)
774774
{
775775
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;
777778

778779
iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0);
779780
if (dma_mapping_error(dev->dev, iod->first_dma))

0 commit comments

Comments
 (0)