From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 2/7] nvme-pci: simplify nvme_cqe_valid
Date: Thu, 17 May 2018 18:31:47 +0200 [thread overview]
Message-ID: <20180517163152.23155-3-hch@lst.de> (raw)
In-Reply-To: <20180517163152.23155-1-hch@lst.de>
We always look at the current CQ head and phase, so don't pass these
as separate arguments, and rename the function to nvme_cqe_pending.
Also micro-optimize by byte swapping the constant 1 instead of the status.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/pci.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index b58aebb347a0..4b8c3420ace6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -915,10 +915,10 @@ static void nvme_pci_complete_rq(struct request *req)
}
/* We read the CQE phase first to check if the rest of the entry is valid */
-static inline bool nvme_cqe_valid(struct nvme_queue *nvmeq, u16 head,
- u16 phase)
+static inline bool nvme_cqe_pending(struct nvme_queue *nvmeq)
{
- return (le16_to_cpu(nvmeq->cqes[head].status) & 1) == phase;
+ return ((nvmeq->cqes[nvmeq->cq_head].status) & cpu_to_le16(1)) ==
+ nvmeq->cq_phase;
}
static inline void nvme_ring_cq_doorbell(struct nvme_queue *nvmeq)
@@ -965,7 +965,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
static inline bool nvme_read_cqe(struct nvme_queue *nvmeq,
struct nvme_completion *cqe)
{
- if (nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) {
+ if (nvme_cqe_pending(nvmeq)) {
*cqe = nvmeq->cqes[nvmeq->cq_head];
if (++nvmeq->cq_head == nvmeq->q_depth) {
@@ -1006,7 +1006,7 @@ static irqreturn_t nvme_irq(int irq, void *data)
static irqreturn_t nvme_irq_check(int irq, void *data)
{
struct nvme_queue *nvmeq = data;
- if (nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase))
+ if (nvme_cqe_pending(nvmeq))
return IRQ_WAKE_THREAD;
return IRQ_NONE;
}
@@ -1016,7 +1016,7 @@ static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
struct nvme_completion cqe;
int found = 0, consumed = 0;
- if (!nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase))
+ if (!nvme_cqe_pending(nvmeq))
return 0;
spin_lock_irq(&nvmeq->q_lock);
--
2.17.0
next prev parent reply other threads:[~2018-05-17 16:31 UTC|newest]
Thread overview: 17+ 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 ` Christoph Hellwig [this message]
2018-05-17 16:31 ` [PATCH 3/7] nvme-pci: remove cq check after submission Christoph Hellwig
2018-05-17 16:31 ` [PATCH 4/7] nvme-pci: move ->cq_vector == -1 check outside of ->q_lock Christoph Hellwig
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 2/7] nvme-pci: simplify nvme_cqe_valid Jens Axboe
2018-05-18 20:49 ` Keith Busch
2018-05-18 20:48 ` 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-3-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).