Commit 750dde44 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Keith Busch

nvme-pci: simplify nvme_cqe_valid

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.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 287a63eb
...@@ -915,10 +915,10 @@ static void nvme_pci_complete_rq(struct request *req) ...@@ -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 */ /* 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, static inline bool nvme_cqe_pending(struct nvme_queue *nvmeq)
u16 phase)
{ {
return (le16_to_cpu(nvmeq->cqes[head].status) & 1) == phase; return (le16_to_cpu(nvmeq->cqes[nvmeq->cq_head].status) & 1) ==
nvmeq->cq_phase;
} }
static inline void nvme_ring_cq_doorbell(struct nvme_queue *nvmeq) 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, ...@@ -965,7 +965,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
static inline bool nvme_read_cqe(struct nvme_queue *nvmeq, static inline bool nvme_read_cqe(struct nvme_queue *nvmeq,
struct nvme_completion *cqe) 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]; *cqe = nvmeq->cqes[nvmeq->cq_head];
if (++nvmeq->cq_head == nvmeq->q_depth) { if (++nvmeq->cq_head == nvmeq->q_depth) {
...@@ -1006,7 +1006,7 @@ static irqreturn_t nvme_irq(int irq, void *data) ...@@ -1006,7 +1006,7 @@ static irqreturn_t nvme_irq(int irq, void *data)
static irqreturn_t nvme_irq_check(int irq, void *data) static irqreturn_t nvme_irq_check(int irq, void *data)
{ {
struct nvme_queue *nvmeq = 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_WAKE_THREAD;
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -1016,7 +1016,7 @@ static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag) ...@@ -1016,7 +1016,7 @@ static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
struct nvme_completion cqe; struct nvme_completion cqe;
int found = 0, consumed = 0; int found = 0, consumed = 0;
if (!nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) if (!nvme_cqe_pending(nvmeq))
return 0; return 0;
spin_lock_irq(&nvmeq->q_lock); spin_lock_irq(&nvmeq->q_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment