mmc: retry a failed SD card resume after a power cycle - #3304
Jacob-Matthew-Cook wants to merge 1 commit into
Conversation
_mmc_sd_resume() hands its result to mmc_sd_runtime_resume(), which logs it and returns 0, so the PM core is told a resume succeeded even when the card was never brought back. Every request queued against it then hangs forever, and on a boot medium that wedges the machine. Retry once from a power cycle instead. Proven on two cards and two triggers: the GKD Pixel2's boot card still busy when the host re-initialises it, and the RG353M's games card timing out the optional SD cache-enable write. Both cards are healthy and come back on the retry. A second patch carried here previously made that cache-enable failure non-fatal. Hardware testing on 2026-09-11 dropped it: it fired, the card was removed anyway by the post-resume presence check, and by swallowing the error it stopped the retry from running at all. 99-automount.rules handles ACTION=="remove" so a card that does drop off the bus is remounted, instead of the stale mount blocking the add rule and leaving /storage/roms empty until reboot.
66a177e to
0e98425
Compare
|
Dropped the cache-enable patch: the retry alone covers both failures. Same RG353M, same card, same day. With the cache patch, it fired exactly as designed and the card was removed anyway: Rebuilt without it, so the retry sees the error: That boot: 0 card removals, 0 ext4 aborts, and the mount never left @sydarn @porschemad911 this is now a single generic patch in |
Summary
This addresses @sydarn's point on #3220 about being uneasy carrying custom mmc patches. Agreed — the intent was always to report these upstream, and splitting them out here makes that easier to track independently of the rk817 work.
_mmc_sd_resume()hands its result tommc_sd_runtime_resume(), which logs it and returns 0, so the PM core is told the resume worked even though the card was never brought back. Every queued request then waits forever: jbd2, the writeback worker and the block queue end up in uninterruptible sleep, and on a boot medium that takes the whole machine down — userspace stops responding while the kernel carries on answering pings. Retry once from a clean slate after a power cycle./proc/mounts, skips the remount, and the card stays unusable until reboot even though the kernel re-detected it immediately. Clear them on removal.The second patch was dropped after hardware testing (2026-09-11)
This PR previously also carried
0007-mmc-sd-do-not-fail-card-init-when-the-cache-cannot-be.patch, which made a failed SD "Cache Enable" write non-fatal to card init. Testing on the RG353M that produced the original failure removed it:could not enable card cache (-110), continuing without it— and the card was still removed 0.16 ms later, because the post-resume presence check found it unresponsive. ext4 aborted its journal, and only the automount rule above brought the card back.0008's retry from ever running.The cache failure is therefore not a separate bug needing its own fix. It is one more way a resume fails, and the retry covers it. What is broken at that moment is the card's state, not the return value, so suppressing the error only hides it from the code that can repair it.
Testing
Two triggers, two devices, two cards — the retry handles both.
0x000027, oemid0x5048, 03/2025), ext4, kernel 7.0.2, 2026-09-11. With the retry alone: the trigger fired, the retry fired 11 µs later, the card was back and re-tuned 212 ms later, and for that whole boot there were 0 card removals, 0 ext4 aborts and 0 failed retries. The mount never left/proc/mountsand userspace never re-ran its automount, so the filesystem was never torn down.-F0) across every kernel in the tree: 6.18.45 (RK3399), 7.0.2 (RK3566/76), 7.1.2 (RK3326) and 7.2 (H700/SM6115/SM8xxx), and to mainline 7.3-rc3.Additional Context
readl_poll_timeout_atomic(), so a longer wait means spinning longer in atomic context, and it would only help one host driver.mainline/rather thanmainline-rockchip/deliberately — this benefits every device with an SD card, not just the Rockchip ones.AI Usage
Did you use AI tools to help write this code? PARTIALLY