git: ec6fea480da5 - stable/14 - mpi3mr: Enable Diag Save for All Diagnostic Fault Cases

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 30 Apr 2025 17:21:56 UTC
The branch stable/14 has been updated by imp:

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

commit ec6fea480da5570534a4d9e8af7af56de411df79
Author:     Chandrakanth patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2025-04-27 23:40:04 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-30 17:05:53 +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
    
    (cherry picked from commit b854677d970a11e87929fa95d0e4067f911faa62)
---
 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 407947fa812b..5c4df9cef0b6 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -6214,6 +6214,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 <<
@@ -6407,10 +6410,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"));