1 From 161b8be2bd6abad250d4b3f674bdd5480f15beeb Mon Sep 17 00:00:00 2001
2 From: Keith Busch <keith.busch@intel.com>
3 Date: Thu, 14 Sep 2017 13:54:39 -0400
4 Subject: nvme-pci: initialize queue memory before interrupts
6 From: Keith Busch <keith.busch@intel.com>
8 commit 161b8be2bd6abad250d4b3f674bdd5480f15beeb upstream.
10 A spurious interrupt before the nvme driver has initialized the completion
11 queue may inadvertently cause the driver to believe it has a completion
12 to process. This may result in a NULL dereference since the nvmeq's tags
13 are not set at this point.
15 The patch initializes the host's CQ memory so that a spurious interrupt
16 isn't mistaken for a real completion.
18 Signed-off-by: Keith Busch <keith.busch@intel.com>
19 Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
20 Signed-off-by: Christoph Hellwig <hch@lst.de>
21 Signed-off-by: Jens Axboe <axboe@kernel.dk>
22 [bwh: Backported to 4.4: adjust context]
23 Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 drivers/nvme/host/pci.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
29 --- a/drivers/nvme/host/pci.c
30 +++ b/drivers/nvme/host/pci.c
31 @@ -1589,11 +1589,11 @@ static int nvme_create_queue(struct nvme
35 + nvme_init_queue(nvmeq, qid);
36 result = queue_request_irq(dev, nvmeq, nvmeq->irqname);
40 - nvme_init_queue(nvmeq, qid);
44 @@ -1797,6 +1797,7 @@ static int nvme_configure_admin_queue(st
48 + nvme_init_queue(nvmeq, 0);
49 result = queue_request_irq(dev, nvmeq, nvmeq->irqname);
51 nvmeq->cq_vector = -1;
52 @@ -3165,7 +3166,6 @@ static void nvme_probe_work(struct work_
56 - nvme_init_queue(dev->queues[0], 0);
57 result = nvme_alloc_admin_tags(dev);