Skip to content

mmc: misc fixes across MMC/SDHCI/RPMB

Peng Fan (OSS) u-boot 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20260712-mmc-fix-cc14724541b8

Versions newest first

  1. v2 Latest5 patches 3 repliesIn review
  2. v15 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Add R-b for patch 3
- Update commit message and Simplify code logic for patch 5
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5mmc: fix mmc_poll_for_busy() false timeout when card is readydrivers/mmc/mmc.c+3 -71 reply
2/5mmc: rpmb: fix tautological condition in RPMB_REQ_READ_DATA validationdrivers/mmc/rpmb.c+1 -10 replies
3/5mmc: sdhci: fix align_buffer memory leak on re-initializationdrivers/mmc/sdhci.c+2 -10 replies
4/5mmc: fix mmc_bwrite() ignoring host get_b_max() callbackdrivers/mmc/mmc.c drivers/mmc/mmc_private.h drivers/mmc/mmc_write.c+9 -31 reply
5/5mmc: fix mmc_deinit regression when card is at 1.8V signalingdrivers/mmc/mmc.c+13 -41 reply

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchTanmay Kathpalia
1/5R-b
2/5
3/5R-b
4/5R-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] mmc: misc fixes across MMC/SDHCI/RPMB

Patches 1-4 are straightforward single-site fixes found through code review. Patch 5 fixes a regression introduced by commit 906ee6785b1 ("mmc: sd: Handle UHS-I voltage signaling without power cycle").

1. mmc_poll_for_busy() can return a false -ETIMEDOUT if the card becomes ready on the exact iteration where the timeout counter reaches zero. Fix by returning 0 directly on card-ready.

2. rpmb_route_frames() has a tautological condition "req_cnt != 1 || !req_cnt" in the RPMB_REQ_READ_DATA case. The second operand is dead code. Based on the pattern of the other cases, this should be "req_cnt != 1 || !rsp_cnt" to validate the response count.

3. sdhci_init() allocates a 512KB aligned bounce buffer on every call without checking if one was already allocated, leaking memory on re-initialization in the non-DM code path.

4. mmc_bwrite() uses mmc->cfg->b_max directly instead of calling mmc_get_b_max(), which the read path (mmc_bread) uses. This means host drivers that implement get_b_max() for DMA boundary constraints have those constraints ignored for writes.

5. mmc_deinit() strips all UHS capabilities before calling sd_select_mode_and_width(). After commit 906ee6785b1, that function detects cards already at 1.8V and enables UHS mode selection, but no UHS modes remain in the filtered caps. The non-UHS fallbacks (SD_HS, Legacy) require 3.3V which the card cannot revert to without a power cycle. Fix by preserving UHS_SDR12 as the minimum fallback when the card is at 1.8V.

---
Changes in v2:
- Add R-b for patch 3
- Update commit message and Simplify code logic for patch 5
- Link to v1: https://patch.msgid.link/[email protected]

---
Peng Fan (5):
mmc: fix mmc_poll_for_busy() false timeout when card is ready
mmc: rpmb: fix tautological condition in RPMB_REQ_READ_DATA validation
mmc: sdhci: fix align_buffer memory leak on re-initialization
mmc: fix mmc_bwrite() ignoring host get_b_max() callback
mmc: fix mmc_deinit regression when card is at 1.8V signaling

 drivers/mmc/mmc.c         | 29 +++++++++++++++++------------
 drivers/mmc/mmc_private.h |  4 ++++
 drivers/mmc/mmc_write.c   |  6 ++++--
 drivers/mmc/rpmb.c        |  2 +-
 drivers/mmc/sdhci.c       |  3 ++-
 5 files changed, 28 insertions(+), 16 deletions(-)

---
base-commit: 6741b0dfb41dc82a284ab1cff4c58af6ef2f3f9c
change-id: 20260712-mmc-fix-cc14724541b8

Best regards,

Signature · 1 line
Peng Fan <[email protected]>