The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=5aedb8b1d4a6c099eaa0a65f8fcbdcc4aba8f75b
commit 5aedb8b1d4a6c099eaa0a65f8fcbdcc4aba8f75b Author: Andriy Gapon <a...@freebsd.org> AuthorDate: 2025-06-23 21:43:35 +0000 Commit: Andriy Gapon <a...@freebsd.org> CommitDate: 2025-06-27 07:19:15 +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. MFC after: 2 weeks --- 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 fc29a1925c66..1c455e1951d7 100644 --- a/sys/cam/mmc/mmc_da.c +++ b/sys/cam/mmc/mmc_da.c @@ -1572,9 +1572,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 104916a41782..ab6daffb0995 100644 --- a/sys/cam/mmc/mmc_sim.c +++ b/sys/cam/mmc/mmc_sim.c @@ -109,7 +109,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: