From: keith.busch@intel.com (Keith Busch)
Subject: [PATCHv3 9/9] nvme-pci: Don't wait for HMB completion on shutdown
Date: Thu, 24 May 2018 14:35:00 -0600 [thread overview]
Message-ID: <20180524203500.14081-10-keith.busch@intel.com> (raw)
In-Reply-To: <20180524203500.14081-1-keith.busch@intel.com>
An nvme controller reset can't depend on the timeout handling to
complete timed out commands since we're already trying to disable the
controller. The HMB disabling is the only command in this path that was
not handling its own timeout, so this patch fixes that by putting a time
limit on how long it will wait for completion.
Based-on-patch-by: Ming Lei <ming.lei at redhat.com>
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/nvme/host/pci.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index e12b4ee91254..83fc5bfe20e8 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1764,9 +1764,25 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
}
}
-static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
+static void nvme_set_host_mem_end_io(struct request *rq, blk_status_t sts)
+{
+ struct completion *wait = rq->end_io_data;
+
+ rq->end_io_data = NULL;
+ blk_mq_free_request(rq);
+ complete(wait);
+}
+
+/*
+ * Use 'wait' when sending this command in a context can't complete blocks the
+ * reset handler, as required for device shutdown.
+ */
+static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits,
+ struct completion *wait)
{
u64 dma_addr = dev->host_mem_descs_dma;
+ struct request_queue *q = dev->ctrl.admin_q;
+ struct request *req;
struct nvme_command c;
int ret;
@@ -1780,7 +1796,19 @@ static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
c.features.dword14 = cpu_to_le32(upper_32_bits(dma_addr));
c.features.dword15 = cpu_to_le32(dev->nr_host_mem_descs);
- ret = nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0);
+ if (!wait) {
+ ret = nvme_submit_sync_cmd(q, &c, NULL, 0);
+ } else {
+ req = nvme_alloc_request(q, &c, 0, NVME_QID_ANY);
+ if (IS_ERR(req))
+ return PTR_ERR(req);
+ req->timeout = ADMIN_TIMEOUT;
+ req->end_io_data = wait;
+ blk_execute_rq_nowait(q, NULL, req, false,
+ nvme_set_host_mem_end_io);
+ ret = wait_for_completion_io_timeout(wait, ADMIN_TIMEOUT);
+ }
+
if (ret) {
dev_warn(dev->ctrl.device,
"failed to set host mem (err %d, flags %#x).\n",
@@ -1934,7 +1962,7 @@ static int nvme_setup_host_mem(struct nvme_dev *dev)
dev->host_mem_size >> ilog2(SZ_1M));
}
- ret = nvme_set_host_mem(dev, enable_bits);
+ ret = nvme_set_host_mem(dev, enable_bits, NULL);
if (ret)
nvme_free_host_mem(dev);
return ret;
@@ -2235,6 +2263,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
int i;
bool dead = true;
struct pci_dev *pdev = to_pci_dev(dev->dev);
+ DECLARE_COMPLETION_ONSTACK(hmb_wait);
mutex_lock(&dev->shutdown_lock);
if (dev->ctrl.ctrl_config & NVME_CC_ENABLE &&
@@ -2267,7 +2296,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
* but I'd rather be safe than sorry..
*/
if (dev->host_mem_descs)
- nvme_set_host_mem(dev, 0);
+ nvme_set_host_mem(dev, 0, &hmb_wait);
nvme_disable_io_queues(dev);
}
if (dev->ctrl.queue_count > 0)
--
2.14.3
next prev parent reply other threads:[~2018-05-24 20:35 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 20:34 [PATCHv3 0/9] nvme timeout fixes, v3 Keith Busch
2018-05-24 20:34 ` [PATCHv3 1/9] nvme: Sync request queues on reset Keith Busch
2018-05-25 12:42 ` Christoph Hellwig
2018-05-25 14:22 ` Keith Busch
2018-05-25 14:32 ` Christoph Hellwig
2018-05-25 14:45 ` Keith Busch
2018-05-25 15:56 ` James Smart
2018-05-25 16:24 ` Keith Busch
2018-05-25 18:04 ` James Smart
2018-05-25 18:30 ` Keith Busch
2018-05-30 23:25 ` Sagi Grimberg
2018-06-05 16:25 ` Keith Busch
2018-05-30 23:24 ` Sagi Grimberg
2018-05-24 20:34 ` [PATCHv3 2/9] nvme-pci: Fix queue freeze criteria " Keith Busch
2018-05-25 12:43 ` Christoph Hellwig
2018-05-30 23:36 ` Sagi Grimberg
2018-05-24 20:34 ` [PATCHv3 3/9] nvme: Move all IO out of controller reset Keith Busch
2018-05-25 13:00 ` Christoph Hellwig
2018-05-25 14:41 ` Keith Busch
2018-05-24 20:34 ` [PATCHv3 4/9] nvme-pci: Rate limit the nvme timeout warnings Keith Busch
2018-05-25 13:01 ` Christoph Hellwig
2018-05-30 6:06 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 5/9] nvme-pci: End IO requests in CONNECTING state Keith Busch
2018-05-24 20:47 ` Christoph Hellwig
2018-05-24 21:03 ` Keith Busch
2018-05-25 12:31 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 6/9] nvme-pci: Unquiesce dead controller queues Keith Busch
2018-05-25 13:03 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 7/9] nvme-pci: Attempt reset retry for IO failures Keith Busch
2018-05-25 13:04 ` Christoph Hellwig
2018-05-25 14:25 ` Keith Busch
2018-05-30 23:40 ` Sagi Grimberg
2018-06-04 22:46 ` Keith Busch
2018-05-24 20:34 ` [PATCHv3 8/9] nvme-pci: Queue creation error handling Keith Busch
2018-05-25 12:35 ` Christoph Hellwig
2018-06-05 16:28 ` Keith Busch
2018-05-30 23:37 ` Sagi Grimberg
2018-05-24 20:35 ` Keith Busch [this message]
2018-05-24 20:45 ` [PATCHv3 9/9] nvme-pci: Don't wait for HMB completion on shutdown Christoph Hellwig
2018-05-24 21:15 ` Keith Busch
2018-05-25 3:10 ` jianchao.wang
2018-05-25 15:09 ` Keith Busch
2018-05-25 12:36 ` Christoph Hellwig
2018-07-13 0:48 ` [PATCHv3 0/9] nvme timeout fixes, v3 Ming Lei
2018-07-13 20:54 ` Keith Busch
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=20180524203500.14081-10-keith.busch@intel.com \
--to=keith.busch@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).