From: Keith Busch Date: Fri, 20 Nov 2015 15:38:13 +0000 (-0700) Subject: NVMe: reap completion entries when deleting queue X-Git-Tag: v4.1.12-92~126^2~220 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c275a501741bd7a21d8d02ef3e844572f3fd8b63;p=users%2Fjedix%2Flinux-maple.git NVMe: reap completion entries when deleting queue Make sure that there are no unprocesssed entries on a completion queue before deleting it, and check for validity of the CQ door bell before writing completions to it. This fixes problems with doing a sysfs reset of the device while it's handling IO. Tested-by: Jon Derrick Signed-off-by: Jens Axboe (cherry picked from commit 604e8c8da8854351496215d269c3fa93859e3fee) Orabug: 22620486 Signed-off-by: Jason Luo --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 0ac79280bc432..78f8b22d8d3e0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -980,7 +980,8 @@ static int nvme_process_cq(struct nvme_queue *nvmeq) if (head == nvmeq->cq_head && phase == nvmeq->cq_phase) return 0; - writel(head, nvmeq->q_db + nvmeq->dev->db_stride); + if (likely(nvmeq->cq_vector >= 0)) + writel(head, nvmeq->q_db + nvmeq->dev->db_stride); nvmeq->cq_head = head; nvmeq->cq_phase = phase; @@ -2651,6 +2652,10 @@ static void nvme_del_queue_end(struct nvme_queue *nvmeq) { struct nvme_delq_ctx *dq = nvmeq->cmdinfo.ctx; nvme_put_dq(dq); + + spin_lock_irq(&nvmeq->q_lock); + nvme_process_cq(nvmeq); + spin_unlock_irq(&nvmeq->q_lock); } static int adapter_async_del_queue(struct nvme_queue *nvmeq, u8 opcode,