From 26f3eab75f321b6d7fbf4b4ae6023f7bf078ccc2 Mon Sep 17 00:00:00 2001 From: Bijan Mottahedeh Date: Wed, 26 Feb 2020 18:53:43 -0800 Subject: [PATCH 1786/2944] nvme-pci: Hold cq_poll_lock while completing CQEs to #28991349 commit 9515743bfb39c61aaf3d4f3219a645c8d1fe9a0e upstream Completions need to consumed in the same order the controller submitted them, otherwise future completion entries may overwrite ones we haven't handled yet. Hold the nvme queue's poll lock while completing new CQEs to prevent another thread from freeing command tags for reuse out-of-order. Fixes: dabcefab45d3 ("nvme: provide optimized poll function for separate poll queues") Signed-off-by: Bijan Mottahedeh Reviewed-by: Sagi Grimberg Reviewed-by: Jens Axboe Signed-off-by: Keith Busch Signed-off-by: Xiaoguang Wang Reviewed-by: Joseph Qi --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 440df6b..1ea9423 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1102,9 +1102,9 @@ static int nvme_poll_noirq(struct blk_mq_hw_ctx *hctx, unsigned int tag) spin_lock(&nvmeq->cq_lock); found = nvme_process_cq(nvmeq, &start, &end, tag); + nvme_complete_cqes(nvmeq, start, end); spin_unlock(&nvmeq->cq_lock); - nvme_complete_cqes(nvmeq, start, end); return found; } -- 1.8.3.1