Skip to content

Commit 604e8c8

Browse files
Keith Buschaxboe
authored andcommitted
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 <jonathan.derrick@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 2fde0e4 commit 604e8c8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/nvme/host/pci.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,8 @@ static void __nvme_process_cq(struct nvme_queue *nvmeq, unsigned int *tag)
968968
if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
969969
return;
970970

971-
writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
971+
if (likely(nvmeq->cq_vector >= 0))
972+
writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
972973
nvmeq->cq_head = head;
973974
nvmeq->cq_phase = phase;
974975

@@ -2787,6 +2788,10 @@ static void nvme_del_queue_end(struct nvme_queue *nvmeq)
27872788
{
27882789
struct nvme_delq_ctx *dq = nvmeq->cmdinfo.ctx;
27892790
nvme_put_dq(dq);
2791+
2792+
spin_lock_irq(&nvmeq->q_lock);
2793+
nvme_process_cq(nvmeq);
2794+
spin_unlock_irq(&nvmeq->q_lock);
27902795
}
27912796

27922797
static int adapter_async_del_queue(struct nvme_queue *nvmeq, u8 opcode,

0 commit comments

Comments
 (0)