aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorMurali Iyer <mniyer@us.ibm.com>2015-03-26 12:07:51 -0400
committerJens Axboe <axboe@fb.com>2015-03-31 12:39:56 -0400
commitf137e0f15101c0a0ff8a5d956042e50247f1fef9 (patch)
treedf638613293871220dc168438bd4f74f6db68061 /drivers/block
parent1efccc9ddb98fd533169669160201b027562af7e (diff)
nvme: Fix PRP list calculation for non-4k system page size
PRP list calculation is supposed to be based on device's page size. Systems with page size larger than device's page size cause corruption to the name space as well as system memory with out this fix. Systems like x86 might not experience this issue because it uses PAGE_SIZE of 4K where as powerpc uses PAGE_SIZE of 64k while NVMe device's page size varies depending upon the vendor. Signed-off-by: Murali Iyer <mniyer@us.ibm.com> Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Acked-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nvme-core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index c12c95cf2e55..4dc858b43c92 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -640,12 +640,12 @@ int nvme_setup_prps(struct nvme_dev *dev, struct nvme_iod *iod, int total_len,
640 struct scatterlist *sg = iod->sg; 640 struct scatterlist *sg = iod->sg;
641 int dma_len = sg_dma_len(sg); 641 int dma_len = sg_dma_len(sg);
642 u64 dma_addr = sg_dma_address(sg); 642 u64 dma_addr = sg_dma_address(sg);
643 int offset = offset_in_page(dma_addr); 643 u32 page_size = dev->page_size;
644 int offset = dma_addr & (page_size - 1);
644 __le64 *prp_list; 645 __le64 *prp_list;
645 __le64 **list = iod_list(iod); 646 __le64 **list = iod_list(iod);
646 dma_addr_t prp_dma; 647 dma_addr_t prp_dma;
647 int nprps, i; 648 int nprps, i;
648 u32 page_size = dev->page_size;
649 649
650 length -= (page_size - offset); 650 length -= (page_size - offset);
651 if (length <= 0) 651 if (length <= 0)