hw/scsi/mptsas: Reset doorbell state on reset

Currently the mptsas reset function clears intr_status, but it
doesn't reset the doorbell state machine.  This means that the state
machine and the interrupt state get out of sync, and the guest can
trigger an assertion failure in mptsas_doorbell_read() where
s->doorbell_state is still DOORBELL_READ but s->intr_status does not
have MPI_HIS_DOORBELL_INTERRUPT set.

Fix this by having reset also reset the doorbell state.  Strictly
speaking we don't need to also clear doorbell_reply_idx and
doorbell_reply_size, because those are only read when in
DOORBELL_READ state, and the code always sets them up before
transitioning into that state.  But it's less confusing to clear them
out on reset.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/304
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260629185035.2138238-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
This commit is contained in:
Peter Maydell
2026-06-29 19:50:35 +01:00
committed by Philippe Mathieu-Daudé
parent 9e41b5d22a
commit 831a13665a

View File

@@ -811,6 +811,10 @@ static void mptsas_soft_reset(MPTSASState *s)
s->intr_status = 0;
s->intr_mask = save_mask;
s->doorbell_state = DOORBELL_NONE;
s->doorbell_reply_idx = 0;
s->doorbell_reply_size = 0;
s->reply_free_tail = 0;
s->reply_free_head = 0;
s->reply_post_tail = 0;