git: b854677d970a - main - mpi3mr: Enable Diag Save for All Diagnostic Fault Cases

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 28 Apr 2025 03:25:24 UTC
The branch main has been updated by imp:

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

commit b854677d970a11e87929fa95d0e4067f911faa62
Author:     Chandrakanth patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2025-04-27 23:40:04 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-28 03:22:56 +0000

    mpi3mr: Enable Diag Save for All Diagnostic Fault Cases
    
    This patch ensures the driver sets the Diag Save bit for all
    diagnostic fault conditions before issuing a Diagnostic Fault Reset.
    
    The firmware now incorporates logic to manage snapdump saving
    and requires the driver to always set the Diag Save bit to enable
    this feature. This change supports improved diagnostic data
    collection and fault handling.
    
    Reviewed by:    ssaxena, imp
    Differential Revision:  https://reviews.freebsd.org/D49750
---
 sys/dev/mpi3mr/mpi3mr.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr.c b/sys/dev/mpi3mr/mpi3mr.c
index 398569a3963c..26c0cb06282a 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -6213,6 +6213,9 @@ static int mpi3mr_issue_reset(struct mpi3mr_softc *sc, U16 reset_type,
 		    unlock_retry_count, host_diagnostic);
 	} while (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_DIAG_WRITE_ENABLE));
 
+	if (reset_type == MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
+		mpi3mr_set_diagsave(sc);
+
 	scratch_pad0 = ((MPI3MR_RESET_REASON_OSTYPE_FREEBSD <<
 			MPI3MR_RESET_REASON_OSTYPE_SHIFT) |
 			(sc->facts.ioc_num <<
@@ -6406,10 +6409,14 @@ out:
 			mpi3mr_app_send_aen(sc);
 		}
 	} else {
-		mpi3mr_issue_reset(sc,
-		    MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
+		ioc_state = mpi3mr_get_iocstate(sc);
+		if (ioc_state != MRIOC_STATE_FAULT)
+			mpi3mr_issue_reset(sc,
+			    MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
+
 		sc->unrecoverable = 1;
 		sc->reset_in_progress = 0;
+		sc->block_ioctls = 0;
 	}
 
 	mpi3mr_dprint(sc, MPI3MR_INFO, "Soft Reset: %s\n", ((retval == 0) ? "SUCCESS" : "FAILED"));