From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 4/7] nvme-pci: move ->cq_vector == -1 check outside of ->q_lock
Date: Thu, 17 May 2018 18:31:49 +0200 [thread overview]
Message-ID: <20180517163152.23155-5-hch@lst.de> (raw)
In-Reply-To: <20180517163152.23155-1-hch@lst.de>
From: Jens Axboe <axboe@kernel.dk>
We only clear it dynamically in nvme_suspend_queue(). When we do, ensure
to do a full flush so that any nvme_queue_rq() invocation will see it.
Ideally we'd kill this check completely, but we're using it to flush
requests on a dying queue.
Signed-off-by: Jens Axboe <axboe at kernel.dk>
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/pci.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 16eacae3b69d..258f097fddbc 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -872,6 +872,13 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
struct nvme_command cmnd;
blk_status_t ret;
+ /*
+ * We should not need to do this, but we're still using this to
+ * ensure we can drain requests on a dying queue.
+ */
+ if (unlikely(nvmeq->cq_vector < 0))
+ return BLK_STS_IOERR;
+
ret = nvme_setup_cmd(ns, req, &cmnd);
if (ret)
return ret;
@@ -889,11 +896,6 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
blk_mq_start_request(req);
spin_lock_irq(&nvmeq->q_lock);
- if (unlikely(nvmeq->cq_vector < 0)) {
- ret = BLK_STS_IOERR;
- spin_unlock_irq(&nvmeq->q_lock);
- goto out_cleanup_iod;
- }
__nvme_submit_cmd(nvmeq, &cmnd);
spin_unlock_irq(&nvmeq->q_lock);
return BLK_STS_OK;
@@ -1321,6 +1323,12 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
nvmeq->cq_vector = -1;
spin_unlock_irq(&nvmeq->q_lock);
+ /*
+ * Ensure that nvme_queue_rq() sees it ->cq_vector == -1 without
+ * having to grab the lock.
+ */
+ mb();
+
if (!nvmeq->qid && nvmeq->dev->ctrl.admin_q)
blk_mq_quiesce_queue(nvmeq->dev->ctrl.admin_q);
--
2.17.0
next prev parent reply other threads:[~2018-05-17 16:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-17 16:31 RFC: handle completions outside the queue lock and split the queue lock Christoph Hellwig
2018-05-17 16:31 ` [PATCH 1/7] nvme: mark the result argument to nvme_complete_async_event volatile Christoph Hellwig
2018-05-17 16:31 ` [PATCH 2/7] nvme-pci: simplify nvme_cqe_valid Christoph Hellwig
2018-05-17 16:31 ` [PATCH 3/7] nvme-pci: remove cq check after submission Christoph Hellwig
2018-05-17 16:31 ` Christoph Hellwig [this message]
2018-05-17 16:31 ` [PATCH 5/7] nvme-pci: handle completions outside of the queue lock Christoph Hellwig
2018-05-17 16:31 ` [PATCH 6/7] nvme-pci: split the nvme queue lock into submission and completion locks Christoph Hellwig
2018-05-17 16:31 ` [PATCH 7/7] nvme-pci: drop IRQ disabling on submission queue lock Christoph Hellwig
2018-05-17 16:36 ` RFC: handle completions outside the queue lock and split the " Jens Axboe
2018-05-17 16:44 ` Christoph Hellwig
2018-05-17 16:55 ` Keith Busch
2018-05-17 17:00 ` Christoph Hellwig
2018-05-17 17:05 ` Keith Busch
2018-05-17 17:08 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2018-05-18 14:52 [PATCHSET v2 0/7] Improve nvme completion handling Jens Axboe
2018-05-18 14:52 ` [PATCH 4/7] nvme-pci: move ->cq_vector == -1 check outside of ->q_lock Jens Axboe
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=20180517163152.23155-5-hch@lst.de \
--to=hch@lst.de \
/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).