From: Xu Yu <yu.a.xu@intel.com>
To: linux-nvme@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, keith.busch@intel.com,
axboe@fb.com, hch@lst.de, sagi@grimberg.me, yu.a.xu@intel.com,
haozhong.zhang@intel.com
Subject: [PATCH] nvme/pci: remap BAR0 to cover admin CQ doorbell for large stride
Date: Thu, 18 May 2017 06:35:47 +0800 [thread overview]
Message-ID: <1495060547-6180-1-git-send-email-yu.a.xu@intel.com> (raw)
The existing driver initially maps 8192 bytes of BAR0 which is
intended to cover doorbells of admin SQ and CQ. However, if a
large stride, e.g. 10, is used, the doorbell of admin CQ will
be out of 8192 bytes. Consequently, a page fault will be raised
when the admin CQ doorbell is accessed in nvme_configure_admin_queue().
This patch fixes this issue by remapping BAR0 before accessing
admin CQ doorbell if the initial mapping is not enough.
Signed-off-by: "Xu, Yu A" <yu.a.xu@intel.com>
---
drivers/nvme/host/pci.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 9d4640a..7c991eb 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1322,6 +1322,17 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
u32 aqa;
u64 cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
struct nvme_queue *nvmeq;
+ struct pci_dev *pdev = to_pci_dev(dev->dev);
+ unsigned long size;
+
+ size = 4096 + 2 * 4 * dev->db_stride;
+ if (size > 8192) {
+ iounmap(dev->bar);
+ dev->bar = ioremap(pci_resource_start(pdev, 0), size);
+ if (!dev->bar)
+ return -ENOMEM;
+ dev->dbs = dev->bar + 4096;
+ }
dev->subsystem = readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 1, 0) ?
NVME_CAP_NSSRC(cap) : 0;
--
2.10.1
next reply other threads:[~2017-05-18 6:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-17 22:35 Xu Yu [this message]
2017-05-18 13:43 ` Christoph Hellwig
2017-05-19 9:22 ` Xu, Yu A
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495060547-6180-1-git-send-email-yu.a.xu@intel.com \
--to=yu.a.xu@intel.com \
--cc=axboe@fb.com \
--cc=haozhong.zhang@intel.com \
--cc=hch@lst.de \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome