git: 835b12a5f9c5 - main - mrsas: don't reference the removed physical disk of RAID1 during IO submission

From: Sumit Saxena <ssaxena_at_FreeBSD.org>
Date: Tue, 12 Mar 2024 10:08:14 UTC
The branch main has been updated by ssaxena:

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

commit 835b12a5f9c5dfaec3bcd9446369fdad995ee538
Author:     Sumit Saxena <ssaxena@FreeBSD.org>
AuthorDate: 2024-03-12 06:51:09 +0000
Commit:     Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2024-03-12 09:51:48 +0000

    mrsas: don't reference the removed physical disk of RAID1 during IO submission
    
    When a physical disk(PD) [belonging to a RAID1 Virtual disk(VD)] is
    removed, driver may still use the reference to the removed PD while submitting
    IO to the controller. Controller firmware faults upon receipt of such IO.
    This patch fixes this issue by not using any reference to the removed PD.
    
    Reviewed by:    imp
    Approved by:    imp
    Sponsored by:   Broadcom Inc
    Differential Revision:  https://reviews.freebsd.org/D44282
---
 sys/dev/mrsas/mrsas_fp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mrsas/mrsas_fp.c b/sys/dev/mrsas/mrsas_fp.c
index 9fdb24cc0569..c08558e78b46 100644
--- a/sys/dev/mrsas/mrsas_fp.c
+++ b/sys/dev/mrsas/mrsas_fp.c
@@ -964,7 +964,8 @@ mr_spanset_get_phy_params(struct mrsas_softc *sc, u_int32_t ld, u_int64_t stripR
 			raid->regTypeReqOnRead != REGION_TYPE_UNUSED)))
 			pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
 		else if (raid->level == 1) {
-			pd = MR_ArPdGet(arRef, physArm + 1, map);
+			physArm++;
+			pd = MR_ArPdGet(arRef, physArm, map);
 			if (pd != MR_PD_INVALID) {
 				*pDevHandle = MR_PdDevHandleGet(pd, map);
 				*pPdInterface = MR_PdInterfaceTypeGet(pd, map);
@@ -1711,7 +1712,8 @@ MR_GetPhyParams(struct mrsas_softc *sc, u_int32_t ld,
 			pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
 		else if (raid->level == 1) {
 			/* Get Alternate Pd. */
-			pd = MR_ArPdGet(arRef, physArm + 1, map);
+			physArm++;
+			pd = MR_ArPdGet(arRef, physArm, map);
 			if (pd != MR_PD_INVALID) {
 				/* Get dev handle from Pd. */
 				*pDevHandle = MR_PdDevHandleGet(pd, map);