diff mbox series

[10/10] nvme-pci: set min_align_mask

Message ID 20210917054856.26152-11-khalid.elmously@canonical.com
State New
Headers show
Series [01/10] driver core: add a min_align_mask field to struct device_dma_parameters | expand

Commit Message

Khalid Elmously Sept. 17, 2021, 5:48 a.m. UTC
From: Jianxiong Gao <jxgao@google.com>

BugLink: https://bugs.launchpad.net/bugs/1943902

The PRP addressing scheme requires all PRP entries except for the
first one to have a zero offset into the NVMe controller pages (which
can be different from the Linux PAGE_SIZE).  Use the min_align_mask
device parameter to ensure that swiotlb does not change the address
of the buffer modulo the device page size to ensure that the PRPs
won't be malformed.

Signed-off-by: Jianxiong Gao <jxgao@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Jianxiong Gao <jxgao@google.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
(cherry picked from commit 3d2d861eb03e8ee96dc430a54361c900cbe28afd)
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
---
 drivers/nvme/host/pci.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index af516c35afe6f..d4477c0d126d6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2630,6 +2630,7 @@  static void nvme_reset_work(struct work_struct *work)
 	 * Don't limit the IOMMU merged segment size.
 	 */
 	dma_set_max_seg_size(dev->dev, 0xffffffff);
+	dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1);
 
 	mutex_unlock(&dev->shutdown_lock);