public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 05/13] nvme-pci: consolidate code for polling non-dedicated queues
Date: Sun,  2 Dec 2018 17:46:20 +0100	[thread overview]
Message-ID: <20181202164628.1116-6-hch@lst.de> (raw)
In-Reply-To: <20181202164628.1116-1-hch@lst.de>

We have three places that can poll for I/O completions on a normal
interrupt-enabled queue.  All of them are in slow path code, so
consolidate them to a single helper that uses spin_lock_irqsave and
removes the fast path cqe_pending check.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index d42bb76e5e78..10c26a2e355a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1072,17 +1072,19 @@ static irqreturn_t nvme_irq_check(int irq, void *data)
 	return IRQ_NONE;
 }
 
-static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
+/*
+ * Poll for completions any queue, including those not dedicated to polling.
+ * Can be called from any context.
+ */
+static int nvme_poll_irqdisable(struct nvme_queue *nvmeq, unsigned int tag)
 {
+	unsigned long flags;
 	u16 start, end;
 	int found;
 
-	if (!nvme_cqe_pending(nvmeq))
-		return 0;
-
-	spin_lock_irq(&nvmeq->cq_lock);
+	spin_lock_irqsave(&nvmeq->cq_lock, flags);
 	found = nvme_process_cq(nvmeq, &start, &end, tag);
-	spin_unlock_irq(&nvmeq->cq_lock);
+	spin_unlock_irqrestore(&nvmeq->cq_lock, flags);
 
 	nvme_complete_cqes(nvmeq, start, end);
 	return found;
@@ -1279,7 +1281,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
 	/*
 	 * Did we miss an interrupt?
 	 */
-	if (__nvme_poll(nvmeq, req->tag)) {
+	if (nvme_poll_irqdisable(nvmeq, req->tag)) {
 		dev_warn(dev->ctrl.device,
 			 "I/O %d QID %d timeout, completion polled\n",
 			 req->tag, nvmeq->qid);
@@ -1406,18 +1408,13 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
 static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown)
 {
 	struct nvme_queue *nvmeq = &dev->queues[0];
-	u16 start, end;
 
 	if (shutdown)
 		nvme_shutdown_ctrl(&dev->ctrl);
 	else
 		nvme_disable_ctrl(&dev->ctrl, dev->ctrl.cap);
 
-	spin_lock_irq(&nvmeq->cq_lock);
-	nvme_process_cq(nvmeq, &start, &end, -1);
-	spin_unlock_irq(&nvmeq->cq_lock);
-
-	nvme_complete_cqes(nvmeq, start, end);
+	nvme_poll_irqdisable(nvmeq, -1);
 }
 
 static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues,
@@ -2217,17 +2214,9 @@ static void nvme_del_queue_end(struct request *req, blk_status_t error)
 static void nvme_del_cq_end(struct request *req, blk_status_t error)
 {
 	struct nvme_queue *nvmeq = req->end_io_data;
-	u16 start, end;
 
-	if (!error) {
-		unsigned long flags;
-
-		spin_lock_irqsave(&nvmeq->cq_lock, flags);
-		nvme_process_cq(nvmeq, &start, &end, -1);
-		spin_unlock_irqrestore(&nvmeq->cq_lock, flags);
-
-		nvme_complete_cqes(nvmeq, start, end);
-	}
+	if (!error)
+		nvme_poll_irqdisable(nvmeq, -1);
 
 	nvme_del_queue_end(req, error);
 }
-- 
2.19.1

  parent reply	other threads:[~2018-12-02 16:46 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-02 16:46 block and nvme polling improvements V3 Christoph Hellwig
2018-12-02 16:46 ` [PATCH 01/13] block: move queues types to the block layer Christoph Hellwig
2018-12-04  0:49   ` Sagi Grimberg
2018-12-04 15:00     ` Christoph Hellwig
2018-12-04 17:08       ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 02/13] nvme-pci: use atomic bitops to mark a queue enabled Christoph Hellwig
2018-12-04  0:54   ` Sagi Grimberg
2018-12-04 15:04     ` Christoph Hellwig
2018-12-04 17:11       ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 03/13] nvme-pci: cleanup SQ allocation a bit Christoph Hellwig
2018-12-04  0:55   ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 04/13] nvme-pci: only allow polling with separate poll queues Christoph Hellwig
2018-12-03 18:23   ` Keith Busch
2018-12-04  0:56   ` Sagi Grimberg
2018-12-02 16:46 ` Christoph Hellwig [this message]
2018-12-04  0:58   ` [PATCH 05/13] nvme-pci: consolidate code for polling non-dedicated queues Sagi Grimberg
2018-12-04 15:04     ` Christoph Hellwig
2018-12-04 17:13       ` Sagi Grimberg
2018-12-04 18:19         ` Jens Axboe
2018-12-02 16:46 ` [PATCH 06/13] nvme-pci: refactor nvme_disable_io_queues Christoph Hellwig
2018-12-04  1:00   ` Sagi Grimberg
2018-12-04 15:05     ` Christoph Hellwig
2018-12-04 18:19       ` Jens Axboe
2018-12-02 16:46 ` [PATCH 07/13] nvme-pci: don't poll from irq context when deleting queues Christoph Hellwig
2018-12-03 18:15   ` Keith Busch
2018-12-04  1:05   ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 08/13] nvme-pci: remove the CQ lock for interrupt driven queues Christoph Hellwig
2018-12-04  1:08   ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 09/13] nvme-rdma: remove I/O polling support Christoph Hellwig
2018-12-02 16:46 ` [PATCH 10/13] nvme-mpath: " Christoph Hellwig
2018-12-03 18:22   ` Keith Busch
2018-12-04  1:11   ` Sagi Grimberg
2018-12-04 15:07     ` Christoph Hellwig
2018-12-04 17:18       ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 11/13] block: remove ->poll_fn Christoph Hellwig
2018-12-04  1:11   ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 12/13] block: only allow polling if a poll queue_map exists Christoph Hellwig
2018-12-04  1:14   ` Sagi Grimberg
2018-12-02 16:46 ` [PATCH 13/13] block: enable polling by default if a poll map is initalized Christoph Hellwig
2018-12-04  1:14   ` Sagi Grimberg
2018-12-04 18:40 ` block and nvme polling improvements V3 Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2018-11-29 19:12 block and nvme polling improvements V2 Christoph Hellwig
2018-11-29 19:13 ` [PATCH 05/13] nvme-pci: consolidate code for polling non-dedicated queues Christoph Hellwig
2018-11-21 16:23 block and nvme polling improvements Christoph Hellwig
2018-11-21 16:23 ` [PATCH 05/13] nvme-pci: consolidate code for polling non-dedicated queues Christoph Hellwig

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=20181202164628.1116-6-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