Patch "nvme-pci: Use PCI bus address for data/queues in CMB" has been added to the 4.13-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
nvme-pci: Use PCI bus address for data/queues in CMB
to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
nvme-pci-use-pci-bus-address-for-data-queues-in-cmb.patch
and it can be found in the queue-4.13 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
8969f1f8291762c13147c1ba89d46238af01675bMon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Sun, 1 Oct 2017 09:37:35 +0200
Subject: nvme-pci: Use PCI bus address for data/queues in CMB
From: Christoph Hellwig <[email protected]>
commit 8969f1f8291762c13147c1ba89d46238af01675b upstream.
Currently, NVMe PCI host driver is programming CMB dma address as I/O SQs addresses. This results in failures on systems where 1:1 outbound mapping is not used (example Broadcom iProc SOCs) because CMB BAR will be progammed with PCI bus address but NVMe PCI EP will try to access CMB using dma address.
To have CMB working on systems without 1:1 outbound mapping, we program PCI bus address for I/O SQs instead of dma address. This approach will work on systems with/without 1:1 outbound mapping.
Based on a report and previous patch from Abhishek Shah.
--- drivers/nvme/host/pci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/nvme/host/pci.c +7 -7
@@ -93,7 +93,7 @@ struct nvme_dev {struct mutex shutdown_lock;bool subsystem;void __iomem *cmb; -dma_addr_t cmb_dma_addr; +pci_bus_addr_t cmb_bus_addr;u64 cmb_size;u32 cmbsz;u32 cmbloc;
@@ -1218,7 +1218,7 @@ static int nvme_alloc_sq_cmds(struct nvmif (qid && dev->cmb && use_cmb_sqes &&NVME_CMB_SQS (dev->cmbsz)) {unsigned offset = (qid -1 ) *roundup (SQ_SIZE (depth), dev->ctrl.page_size); - nvmeq->sq_dma_addr = dev->cmb_dma_addr + offset; + nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset; nvmeq->sq_cmds_io = dev->cmb + offset; }else { nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth),
@@ -1517,7 +1517,7 @@ static void __iomem *nvme_map_cmb(structresource_size_t bar_size;struct pci_dev *pdev =to_pci_dev (dev->dev);void __iomem *cmb; -dma_addr_t dma_addr; +int bar; dev->cmbsz =readl (dev->bar +NVME_REG_CMBSZ );if (!(NVME_CMB_SZ (dev->cmbsz)))
@@ -1530,7 +1530,8 @@ static void __iomem *nvme_map_cmb(struct szu = (u64 )1 << (12 +4 *NVME_CMB_SZU (dev->cmbsz)); size = szu *NVME_CMB_SZ (dev->cmbsz); offset = szu *NVME_CMB_OFST (dev->cmbloc); - bar_size =pci_resource_len (pdev,NVME_CMB_BIR (dev->cmbloc)); + bar =NVME_CMB_BIR (dev->cmbloc); + bar_size =pci_resource_len (pdev, bar);if (offset > bar_size)return NULL ;
@@ -1543,12 +1544,11 @@ static void __iomem *nvme_map_cmb(structif (size > bar_size - offset) size = bar_size - offset; - dma_addr =pci_resource_start (pdev,NVME_CMB_BIR (dev->cmbloc)) + offset; - cmb =ioremap_wc (dma_addr, size); + cmb =ioremap_wc (pci_resource_start (pdev, bar) + offset, size);if (!cmb)return NULL ; - dev->cmb_dma_addr = dma_addr; + dev->cmb_bus_addr =pci_bus_address (pdev, bar) + offset; dev->cmb_size = size;return cmb; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.13/nvme-pci-use-pci-bus-address-for-data-queues-in-cmb.patch queue-4.13/bsg-lib-fix-use-after-free-under-memory-pressure.patch