git: e8f693131c65 - stable/13 - nvme: start qpair in state RECOVERY_WAITING

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 21 Jan 2022 02:26:51 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=e8f693131c65cd29ff23086865e87e974563861f

commit e8f693131c65cd29ff23086865e87e974563861f
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-09-29 03:09:45 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-01-21 02:07:30 +0000

    nvme: start qpair in state RECOVERY_WAITING
    
    An interrupt happens on the admin queue right away after the reset, so
    as soon as we enable interrupts, we'll get a call to our interrupt
    handler. It is safe to ignore this interrupt if we're not yet
    initialized, or to process it if we are. If we are initialized, we'll
    see there's no completion records and return. If we're not, we'll
    process no completion records and return. Either way, nothing is
    processed and nothing is lost.
    
    Until we've completely setup the qpair, we need to avoid processing
    completion records. Start the qpair in the waiting recovery state so we
    return immediately when we try to process completions. The code already
    sets it to 'NONE' when we're initialization is complete. It's safe to
    defer completion processing here because we don't send any commands
    before the initialization of the software state of the qpair is
    complete. And even if we were to somehow send a command prior to that
    completing, the completion record for that command would be processed
    when we send commands to the admin qpair after we've setup the software
    state. There's no good central point to add an assert for this last
    condition.
    
    This fixes an KASSERT "received completion for unknown cmd" panic on
    boot.
    
    Fixes:                  502dc84a8b6703e7c0626739179a3cdffdd22d81
    Sponsored by:           Netflix
    Reviewed by:            mav, cperciva, gallatin
    Differential Revision:  https://reviews.freebsd.org/D32210
    
    (cherry picked from commit fa81f3731d1a2984a28ae44e60d12a0659b8fd2f)
---
 sys/dev/nvme/nvme_qpair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 7a17a057f319..6ee5fa9d4c30 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -740,7 +740,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair,
 
 	callout_init(&qpair->timer, 1);
 	qpair->timer_armed = false;
-	qpair->recovery_state = RECOVERY_NONE;
+	qpair->recovery_state = RECOVERY_WAITING;
 
 	/*
 	 * Calcuate the stride of the doorbell register. Many emulators set this