]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nvme-pci: Hold cq_poll_lock while completing CQEs
authorBijan Mottahedeh <bijan.mottahedeh@oracle.com>
Thu, 27 Feb 2020 02:53:43 +0000 (18:53 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Mar 2020 15:45:19 +0000 (16:45 +0100)
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 <bijan.mottahedeh@oracle.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/host/pci.c

index 9c80f9f081496b09c8e17487624dec9008817863..bb5e13ad1aff2b9d3b80fa9ad1c4cab1b114fba7 100644 (file)
@@ -1078,9 +1078,9 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx)
 
        spin_lock(&nvmeq->cq_poll_lock);
        found = nvme_process_cq(nvmeq, &start, &end, -1);
+       nvme_complete_cqes(nvmeq, start, end);
        spin_unlock(&nvmeq->cq_poll_lock);
 
-       nvme_complete_cqes(nvmeq, start, end);
        return found;
 }