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.
Signed-off-by: Peng Fan <[email protected]>
---
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,
--
Peng Fan <[email protected]>