Skip to content

Commit 8417342

Browse files
keithbuschChristoph Hellwig
authored andcommitted
nvme-pci: fix page size checks
The size allocated out of the dma pool is at most NVME_CTRL_PAGE_SIZE, which may be smaller than the PAGE_SIZE. Fixes: c61b82c ("nvme-pci: fix PRP pool size") Signed-off-by: Keith Busch <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent c89a529 commit 8417342

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/nvme/host/pci.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define SQ_SIZE(q) ((q)->q_depth << (q)->sqes)
3737
#define CQ_SIZE(q) ((q)->q_depth * sizeof(struct nvme_completion))
3838

39-
#define SGES_PER_PAGE (PAGE_SIZE / sizeof(struct nvme_sgl_desc))
39+
#define SGES_PER_PAGE (NVME_CTRL_PAGE_SIZE / sizeof(struct nvme_sgl_desc))
4040

4141
/*
4242
* These can be higher, but we need to ensure that any command doesn't
@@ -383,7 +383,7 @@ static int nvme_pci_npages_prp(void)
383383
{
384384
unsigned max_bytes = (NVME_MAX_KB_SZ * 1024) + NVME_CTRL_PAGE_SIZE;
385385
unsigned nprps = DIV_ROUND_UP(max_bytes, NVME_CTRL_PAGE_SIZE);
386-
return DIV_ROUND_UP(8 * nprps, PAGE_SIZE - 8);
386+
return DIV_ROUND_UP(8 * nprps, NVME_CTRL_PAGE_SIZE - 8);
387387
}
388388

389389
/*
@@ -393,7 +393,7 @@ static int nvme_pci_npages_prp(void)
393393
static int nvme_pci_npages_sgl(void)
394394
{
395395
return DIV_ROUND_UP(NVME_MAX_SEGS * sizeof(struct nvme_sgl_desc),
396-
PAGE_SIZE);
396+
NVME_CTRL_PAGE_SIZE);
397397
}
398398

399399
static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
@@ -709,7 +709,7 @@ static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,
709709
sge->length = cpu_to_le32(entries * sizeof(*sge));
710710
sge->type = NVME_SGL_FMT_LAST_SEG_DESC << 4;
711711
} else {
712-
sge->length = cpu_to_le32(PAGE_SIZE);
712+
sge->length = cpu_to_le32(NVME_CTRL_PAGE_SIZE);
713713
sge->type = NVME_SGL_FMT_SEG_DESC << 4;
714714
}
715715
}

0 commit comments

Comments
 (0)