Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Aug 2025 06:02:25 GMT
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9d5d9e723c4a - stable/14 - mmc_da: fix garbage in disk->d_attachment
Message-ID:  <202508060602.57662P0v076669@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by avg:

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

commit 9d5d9e723c4a73a3d816a5d2b0a1b7956d1cb87e
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2025-06-23 21:43:35 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2025-08-06 06:00:39 +0000

    mmc_da: fix garbage in disk->d_attachment
    
    The garbage resulted from reading the value from a ccb which was
    originally populated by XPT_PATH_INQ operation but then overwritten by
    XPT_GET_TRAN_SETTINGS operation.
    
    The problem could probably be fixed by re-ordering the
    XPT_GET_TRAN_SETTINGS operation, but it seems like the operation was
    redundant.  Besides, the ccb is declared not as union ccb but as struct
    ccb_pathinq, so using it for XPT_GET_TRAN_SETTINGS was questionable.
    
    I opted for replacing a call to sdda_get_max_data (which uses
    XPT_GET_TRAN_SETTINGS internally) with using maxio provided by the
    XPT_PATH_INQ operation.
    
    This also required fixing mmc_cam_sim_default_action as controllers
    return maximum I/O size in sectors, but maxio value should be in bytes.
    
    (cherry picked from commit 5aedb8b1d4a6c099eaa0a65f8fcbdcc4aba8f75b)
---
 sys/cam/mmc/mmc_da.c  | 4 +---
 sys/cam/mmc/mmc_sim.c | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c
index de6e89a4da38..594426d288cf 100644
--- a/sys/cam/mmc/mmc_da.c
+++ b/sys/cam/mmc/mmc_da.c
@@ -1573,9 +1573,7 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name,
 	part->disk->d_gone = sddadiskgonecb;
 	part->disk->d_name = part->name;
 	part->disk->d_drv1 = part;
-	part->disk->d_maxsize =
-	    MIN(maxphys, sdda_get_max_data(periph,
-		    (union ccb *)&cpi) * mmc_get_sector_size(periph));
+	part->disk->d_maxsize = MIN(maxphys, cpi.maxio);
 	part->disk->d_unit = cnt;
 	part->disk->d_flags = 0;
 	strlcpy(part->disk->d_descr, sc->card_id_string,
diff --git a/sys/cam/mmc/mmc_sim.c b/sys/cam/mmc/mmc_sim.c
index 3033e327d0d5..7170ffe397c7 100644
--- a/sys/cam/mmc/mmc_sim.c
+++ b/sys/cam/mmc/mmc_sim.c
@@ -110,7 +110,7 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb)
 			ccb->ccb_h.status = CAM_REQ_INVALID;
 		} else {
 			mmc_path_inq(&ccb->cpi, "Deglitch Networks",
-			    sim, mmc.host_max_data);
+			    sim, mmc.host_max_data * MMC_SECTOR_SIZE);
 		}
 		break;
 	case XPT_GET_TRAN_SETTINGS:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202508060602.57662P0v076669>