Re: [PATCH v2 RESEND 1/6] mmc: rtsx_usb_sdmmc: avoid false card-detect on tray readers
From: Ulf Hansson
Date: Tue Mar 24 2026 - 08:24:10 EST
On Tue, 24 Mar 2026 at 12:59, Sean Rhodes <sean@starlabs.systems> wrote:
>
> Hi Uffe
>
> Thanks for the feedback - to answer your questions:
>
> > Would you mind elaborating on this so I can better understand the problem?
>
> SD_CD is used for presence, but that's asserted by trays or blanking cards.
>
> > What prevents the MMC core from handling this correctly?
> >
> > Don't some of the commands time out, eventually causing mmc_rescan() to bail out?
>
> It does bail out, but SD_CD is still asserted, so it tries again. The
> main thing this breaks is S3 entry - it's either slow (like 100
> seconds), or never gets there.
First, please don't top post, but reply in-line below so we can follow
the discussion.
It's the mmc driver's ->runtime_resume() callback that calls
mmc_detect_change(host->mmc, 0).
It's sounds to me like the mmc host is being runtime resumed/suspended
over and over again, hence we end up calling mmc_detect_change() many
times when it's not really needed. Right?
>
> > I guess one key piece of information I'm missing is what happens when the mmc_recsan() work tries to send commands to initialize a card, when there is no card inserted?
>
> They fail, and we use that result.
> On Tue, 24 Mar 2026 at 11:26, Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
> >
> > + Matthew Schwartz
> >
> > On Thu, 12 Mar 2026 at 13:16, Sean Rhodes <sean@starlabs.systems> wrote:
> > >
> > > Some Realtek USB SD readers with a tray can assert SD_CD even when no
> > > card is present. This can make the MMC core believe a card exists and
> > > trigger unnecessary initialization and suspend/shutdown failures.
> >
> > Would you mind elaborating on this so I can better understand the problem?
> >
> > >
> > > Debounce the CD signal and validate a newly detected card by probing for
> > > a response (CMD0 + CMD8/CMD55/CMD1) before reporting it present. Also
> > > treat SD_INT as a removal indication even if SD_CD stays asserted.
> >
> > What prevents the MMC core from handling this correctly?
> >
> > Don't some of the commands time out, eventually causing mmc_rescan()
> > to bail out?
> >
> > >
> > > Tested: Realtek RTS5129 (0bda:0129), tray inserted, no card (2026-02-24)
> > > Tested: Realtek RTS5129 (0bda:0129), tray + SDXC card, mmcblk0 (2026-02-24)
> > >
> > > Signed-off-by: Sean Rhodes <sean@starlabs.systems>
> >
> > I have looped in Matthew who recently worked on some similar problems
> > for the PCI variant [1] of the driver. Perhaps he and Ricky have some
> > input on this series too.
> >
> > [1]
> > https://lore.kernel.org/all/20260105060236.400366-1-matthew.schwartz@xxxxxxxxx/
> >
[...]
Kind regards
Uffe