git: cf8c23230aab - main - mpi3mr: Cleaup setting of status in processing scsiio requests

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 29 Nov 2023 01:55:36 UTC
The branch main has been updated by imp:

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

commit cf8c23230aabd30aa9251975dbe705da559a2d02
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-11-29 01:49:30 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-11-29 01:49:30 +0000

    mpi3mr: Cleaup setting of status in processing scsiio requests
    
    More uniformly use mpi3mr_set_ccbstatus in mpi3mr_action_scsiio.  The
    routine mostly used it, but also has setting of status by hand. In those
    cases where we want to error out the request, use this routine.
    
    As part of this, move setting CAM_SIM_QUEUED later in the function to
    when we're sure it's been queued. Remove the places we clear it before
    this.
    
    Sponsored by:           Netflix
    Reviewed by:            mav, jhb
    Differential Revision:  https://reviews.freebsd.org/D42542
---
 sys/dev/mpi3mr/mpi3mr_cam.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr_cam.c b/sys/dev/mpi3mr/mpi3mr_cam.c
index 691be827cf89..4a525a222577 100644
--- a/sys/dev/mpi3mr/mpi3mr_cam.c
+++ b/sys/dev/mpi3mr/mpi3mr_cam.c
@@ -1024,7 +1024,7 @@ mpi3mr_action_scsiio(struct mpi3mr_cam_softc *cam_sc, union ccb *ccb)
 			cam_sc->flags |= MPI3MRSAS_QUEUE_FROZEN;
 		}
 		ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
-		ccb->ccb_h.status |= CAM_REQUEUE_REQ;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQUEUE_REQ);
 		xpt_done(ccb);
 		return;
 	}
@@ -1098,39 +1098,38 @@ mpi3mr_action_scsiio(struct mpi3mr_cam_softc *cam_sc, union ccb *ccb)
 	mpi3mr_dprint(sc, MPI3MR_TRACE, "[QID:%d]: func: %s line:%d CDB: 0x%x targetid: %x SMID: 0x%x\n",
 		(queue_idx + 1), __func__, __LINE__, scsi_opcode, csio->ccb_h.target_id, cm->hosttag);
 
-	ccb->ccb_h.status |= CAM_SIM_QUEUED;
-
 	switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
 	case CAM_DATA_PADDR:
 	case CAM_DATA_SG_PADDR:
 		device_printf(sc->mpi3mr_dev, "%s: physical addresses not supported\n",
 		    __func__);
 		mpi3mr_release_command(cm);
-		ccb->ccb_h.status = CAM_REQ_INVALID;
-		ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	case CAM_DATA_SG:
 		device_printf(sc->mpi3mr_dev, "%s: scatter gather is not supported\n",
 		    __func__);
 		mpi3mr_release_command(cm);
-		ccb->ccb_h.status = CAM_REQ_INVALID;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	case CAM_DATA_VADDR:
 	case CAM_DATA_BIO:
 		if (csio->dxfer_len > (MPI3MR_SG_DEPTH * MPI3MR_4K_PGSZ)) {
+			mpi3mr_set_ccbstatus(ccb, CAM_REQ_TOO_BIG);
 			mpi3mr_release_command(cm);
-			ccb->ccb_h.status = CAM_REQ_TOO_BIG;
 			xpt_done(ccb);
 			return;
 		}
+		ccb->ccb_h.status |= CAM_SIM_QUEUED;
 		cm->length = csio->dxfer_len;
 		if (cm->length)
 			cm->data = csio->data_ptr;
 		break;
 	default:
-		ccb->ccb_h.status = CAM_REQ_INVALID;
+		mpi3mr_release_command(cm);
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	}