From ff7e2122c74b09e5961cbcb2622fda9c0087f48f Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 22 Jan 2016 13:21:26 -0700 Subject: [PATCH] nvme: reduce number of mmio writes in completion path Instead of writing the completion doorbell once per completion, just write it once at the end of the completion while loop. This reduces the number of mmio writes by coalescing several writes into one when we get multiple completions at a time. Signed-off-by: Jim Harris Change-Id: I3cc3864dcfe43186bec51be1a732e84ef3be05ae --- lib/nvme/nvme_qpair.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index b3e5586ae..feaf3e792 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -509,13 +509,15 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair, uint32_t max_completion qpair->phase = !qpair->phase; } - spdk_mmio_write_4(qpair->cq_hdbl, qpair->cq_head); - if (++num_completions == max_completions) { break; } } + if (num_completions > 0) { + spdk_mmio_write_4(qpair->cq_hdbl, qpair->cq_head); + } + return num_completions; }