git: 042808f74707 - main - mpi3mr: Controller state check before enabling PEL

From: Sumit Saxena <ssaxena_at_FreeBSD.org>
Date: Thu, 06 Jun 2024 10:39:21 UTC
The branch main has been updated by ssaxena:

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

commit 042808f74707d3ce89e89463d4a03f81df6fd45a
Author:     Chandrakanth patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2024-03-14 17:14:53 +0000
Commit:     Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2024-06-06 10:39:14 +0000

    mpi3mr: Controller state check before enabling PEL
    
    Reviewed by:            imp
    Approved by:            imp
    Differential revision:  https://reviews.freebsd.org/D44422
---
 sys/dev/mpi3mr/mpi3mr_app.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/dev/mpi3mr/mpi3mr_app.c b/sys/dev/mpi3mr/mpi3mr_app.c
index 7bd926269018..60ef6765cb76 100644
--- a/sys/dev/mpi3mr/mpi3mr_app.c
+++ b/sys/dev/mpi3mr/mpi3mr_app.c
@@ -1641,6 +1641,18 @@ mpi3mr_pel_enable(struct mpi3mr_softc *sc,
 	struct mpi3mr_ioctl_pel_enable pel_enable;
 	mpi3mr_dprint(sc, MPI3MR_TRACE, "%s() line: %d\n", __func__, __LINE__);
 
+	if (sc->unrecoverable) {
+		device_printf(sc->mpi3mr_dev, "Issue IOCTL: controller is in unrecoverable state\n");
+		return EFAULT;
+	}
+	if (sc->reset_in_progress) {
+		device_printf(sc->mpi3mr_dev, "Issue IOCTL: reset in progress\n");
+		return EAGAIN;
+	}
+	if (sc->block_ioctls) {
+		device_printf(sc->mpi3mr_dev, "Issue IOCTL: IOCTLs are blocked\n");
+		return EAGAIN;
+	}
 
 	if ((data_out_sz != sizeof(pel_enable) || 
 	    (pel_enable.pel_class > MPI3_PEL_CLASS_FAULT))) {