git: d22c5b277ae4 - stable/14 - mpi3mr: Decrement per controller and per target counter post reset

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

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

commit d22c5b277ae412c5bb21d5badbdf4e2901d6a189
Author:     Chandrakanth patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2024-03-14 18:12:49 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-30 17:05:51 +0000

    mpi3mr: Decrement per controller and per target counter post reset
    
    Post controller reset, If any device removal events arrive, and if
    there are any outstanding IOs then the driver will unnecessarily wait
    in the loop for 30 seconds before removing the device from the OS.
    
    reset target outstanding IO counter and controller outstanding IO counter
    and remove the redundant wait loop.
    
    Reviewed by:            imp
    Approved by:            imp
    Differential revision:  https://reviews.freebsd.org/D44424
    
    (cherry picked from commit 571f1d0638fa6b3a08f84118a33e53f941f0820c)
---
 sys/dev/mpi3mr/mpi3mr.c     |  2 ++
 sys/dev/mpi3mr/mpi3mr_cam.c | 12 ------------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr.c b/sys/dev/mpi3mr/mpi3mr.c
index a5f4215f29ca..ab17ea4e2692 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -5693,6 +5693,8 @@ static void mpi3mr_flush_io(struct mpi3mr_softc *sc)
 			if (cmd->callout_owner) {
 				ccb = (union ccb *)(cmd->ccb);
 				ccb->ccb_h.status = CAM_SCSI_BUS_RESET;
+				mpi3mr_atomic_dec(&sc->fw_outstanding);
+				mpi3mr_atomic_dec(&cmd->targ->outstanding);
 				mpi3mr_cmd_done(sc, cmd);
 			} else {
 				cmd->ccb = NULL;
diff --git a/sys/dev/mpi3mr/mpi3mr_cam.c b/sys/dev/mpi3mr/mpi3mr_cam.c
index 6d9869e74235..c4e08b399712 100644
--- a/sys/dev/mpi3mr/mpi3mr_cam.c
+++ b/sys/dev/mpi3mr/mpi3mr_cam.c
@@ -1803,7 +1803,6 @@ out:
 
 int mpi3mr_remove_device_from_os(struct mpi3mr_softc *sc, U16 handle)
 {
-	U32 i = 0;
 	int retval = 0;
 	struct mpi3mr_target *target;
 
@@ -1834,17 +1833,6 @@ int mpi3mr_remove_device_from_os(struct mpi3mr_softc *sc, U16 handle)
 				      target->per_id);
 	}
 
-	while (mpi3mr_atomic_read(&target->outstanding) && (i < 30)) {
-		i++;
-		if (!(i % 2)) {
-			mpi3mr_dprint(sc, MPI3MR_INFO,
-			    "[%2d]waiting for "
-			    "waiting for outstanding commands to complete on target: %d\n",
-			    i, target->per_id);
-		}
-		DELAY(1000 * 1000);
-	}
-	
 	if (target->exposed_to_os && !sc->reset_in_progress) {
 		mpi3mr_rescan_target(sc, target);
 		mpi3mr_dprint(sc, MPI3MR_INFO,