Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1742576
| Path | csiph.com!goblin2!goblin.stu.neva.ru!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Abhishek Shah <abhishek.shah@broadcom.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v2] nvme-pci: Use PCI bus address for data/queues in CMB |
| Date | Sat, 30 Sep 2017 11:30:01 +0200 |
| Message-ID | <uvmfT-2fB-3@gated-at.bofh.it> (permalink) |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=2ST9+Pq1+tDpCOgviUf/jWVXef1k6wTNkXIRoP7DSb4=; b=NJdGNARg1JtgU3ffzeS3D4+TFA3g/GGMuPZ33tNAx6bL/nZdtdYk5S/KqYrzfOL5Bh Fqgc7fYaDeV0rt6eAq/ZM8icF4ylICxSk22KYFEirh51Y/vCfeF4hAzHZekTywYP6Lj4 63znz7hKF3Yr2cF2PkpHBCJbFn+DMnrY7pc5Q= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2ST9+Pq1+tDpCOgviUf/jWVXef1k6wTNkXIRoP7DSb4=; b=AD7aoU1tM1Wrr3bcpBI3OSC0tOERqNvz5ruB3rP7IdyFgSt/PzX9hfQC6LhkDwv1n4 ibZLGkUqhJLOBXr6q6Kr/QJL682lNNYzWAdnKx28gl7DbpV6fQXVj5BZ+F5Mr5qwTxX9 8N2rL/uMO6Y7O0fcWjzifpfsyYbT1i/v7vaLANIJWPkm7iwKQGu3vuo8OL7WZRtBItA7 gMReVLCOBI0mlzau3UEcZnTwWUJBE0xMMjjXITvn3m6Zy0uI8QcPPwoVcwz/OCuC7eU9 ChrByhDzx5rwLZ49O9UacTUXZFWKjREtd9Z+e3CdAZIH9XPCiJYXGH3TMxsRuAnHpqD+ GbkQ== |
| X-Gm-Message-State | AHPjjUih/lCuOvlXJQ3renV4hsIZ0+Io0gcCUpwToOMWtE52vEUERSOf 4IAGAUEivJXTVtYlm8RJ3J4gKg== |
| X-Google-SMTP-Source | AOwi7QC1k/JfoBvZ1gqTNmqI+vDSJX/8ymDcOcCGwjHuL7/6wg5H23VkTYYDjl4SfQVoRoLiiqP5XQ== |
| X-Received | by 10.223.134.83 with SMTP id 19mr9069902wrw.223.1506763739976; Sat, 30 Sep 2017 02:28:59 -0700 (PDT) |
| X-Mailer | git-send-email 2.7.4 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 83 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Abhishek Shah <abhishek.shah@broadcom.com>, stable@vger.kernel.org |
| X-Original-Date | Sat, 30 Sep 2017 14:58:42 +0530 |
| X-Original-Message-ID | <1506763722-10687-1-git-send-email-abhishek.shah@broadcom.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1742576 |
Show key headers only | View raw
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.
The patch is tested on Broadcom Stingray platform(arm64), which
does not have 1:1 outbound mapping, as well as on x86 platform,
which has 1:1 outbound mapping.
Fixes: 8ffaadf7 ("NVMe: Use CMB for the IO SQes if available")
Cc: stable@vger.kernel.org
Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
Reviewed-by: Anup Patel <anup.patel@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
---
drivers/nvme/host/pci.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4a21213..1387050 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -94,6 +94,7 @@ struct nvme_dev {
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;
@@ -1220,7 +1221,7 @@ static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq,
if (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),
@@ -1514,6 +1515,25 @@ static ssize_t nvme_cmb_show(struct device *dev,
}
static DEVICE_ATTR(cmb, S_IRUGO, nvme_cmb_show, NULL);
+static int nvme_find_cmb_bus_addr(struct pci_dev *pdev,
+ dma_addr_t dma_addr,
+ u64 size,
+ pci_bus_addr_t *bus_addr)
+{
+ struct resource *res;
+ struct pci_bus_region region;
+ struct resource tres = DEFINE_RES_MEM(dma_addr, size);
+
+ res = pci_find_resource(pdev, &tres);
+ if (!res)
+ return -EIO;
+
+ pcibios_resource_to_bus(pdev->bus, ®ion, res);
+ *bus_addr = region.start + (dma_addr - res->start);
+
+ return 0;
+}
+
static void __iomem *nvme_map_cmb(struct nvme_dev *dev)
{
u64 szu, size, offset;
@@ -1547,6 +1567,9 @@ static void __iomem *nvme_map_cmb(struct nvme_dev *dev)
size = bar_size - offset;
dma_addr = pci_resource_start(pdev, NVME_CMB_BIR(dev->cmbloc)) + offset;
+ if (nvme_find_cmb_bus_addr(pdev, dma_addr, size, &dev->cmb_bus_addr))
+ return NULL;
+
cmb = ioremap_wc(dma_addr, size);
if (!cmb)
return NULL;
--
2.7.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v2] nvme-pci: Use PCI bus address for data/queues in CMB Abhishek Shah <abhishek.shah@broadcom.com> - 2017-09-30 11:30 +0200
Re: [PATCH v2] nvme-pci: Use PCI bus address for data/queues in CMB Christoph Hellwig <hch@lst.de> - 2017-10-01 09:50 +0200
Re: [PATCH v2] nvme-pci: Use PCI bus address for data/queues in CMB Keith Busch <keith.busch@intel.com> - 2017-10-02 22:50 +0200
csiph-web