All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Ulf Hansson <ulf.hansson@oss.qualcomm.com>
Cc: Ulf Hansson <ulfh@kernel.org>, Ricky Wu <ricky_wu@realtek.com>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	Matthew Schwartz <matthew.schwartz@linux.dev>,
	"Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>,
	linux-mmc@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH] mmc: rtsx_pci: Cope with hot-removal of MMC host
Date: Tue, 8 Sep 2026 18:30:02 +0200	[thread overview]
Message-ID: <aqA4CrSWVzReITXY@wunner.de> (raw)
In-Reply-To: <CAPx+jO9zmCd5qnPooexeRbNfOo7g4-BKBvsW6ZVpxvR22bw8xQ@mail.gmail.com>

On Tue, Sep 08, 2026 at 05:38:29PM +0200, Ulf Hansson wrote:
> On Sat, Aug 15, 2026 at 10:10AM Lukas Wunner <lukas@wunner.de> wrote:
> > Derek reports a lockup on hot-removal of a PCI-attached Realtek RTS525A
> > MMC host if a card is inserted.  He has root-caused it to the block
> > layer being unaware of the hot-removal and waiting indefinitely in
> > sync_filesystem().
> 
> Is this specific for a PCI based mmc host?

It is specific to *removable* mmc hosts.

> Can this be triggered by just removing a removable SD card?

I don't really know.  The reporter witnessed a lockup because the
card reader was removed upon resume from system sleep.  After
some digging it turned out that the lockup occurred in the call
to blk_report_disk_dead() from __del_gendisk():

https://lore.kernel.org/all/anqw0M6cQLEA0J6d@wunner.de/

Clearly, a call to blk_mark_disk_dead() is missing.  That changes
the behavior to avoid writing dirty data to disk if it's gone.

So the issue can be triggered by removing the SD card reader itself
while a card is inserted.  I cannot tell you whether hot-removing
only the card (but not the card reader) also triggers the issue.
I'm just trying to help fix an issue observed by someone else.
I do not have the hardware at my disposal for testing.
I was assuming that the mmc subsystem already has precautions in place
to support hot removal of cards and that only support for hot removal
of the card reader itself is missing.

There are plenty of Thunderbolt or USB-C docks with integrated MMC
card readers on the market, so this seems like an issue a lot of
users may run into.

> > For comparison, the NVMe subsystem copes with hot-removal by setting the
> > controller state to NVME_CTRL_DEAD in nvme_remove(), which in turn leads
> > to blk_mark_disk_dead() being called from nvme_mark_namespaces_dead().
> > That avoids the indefinite wait in sync_filesystem().
> >
> > Adopt this approach:  Detect hot-removal in rtsx_pci_sdmmc_drv_remove()
> > and invoke a new mmc_host_set_removed() helper which in turn invokes
> > mmc_card_set_removed().  Before flushing outstanding requests to the
> > card in mmc_blk_remove_req(), check for its removal and call
> > blk_mark_disk_dead().
> 
> I need more information to understand the problem and whether the NVMe
> approach is really suitable here.
> 
> What do other block subsystems do?

blk_mark_disk_dead() is the API made available by the block layer
to inform it that the disk is hot-removed.  I just followed the example
of the nvme system, which uses that API.

> > Other removable MMC hosts, in particular if attached via PCI or USB,
> > may need to be amended with a similar check for hot-removal.  The
> > present commit seeks to get that process going.
> 
> So it's specific for USB and PCI, why?

Because those buses allow hot-removal of the card reader.

Thanks,

Lukas

      reply	other threads:[~2026-09-08 16:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15  8:10 [PATCH] mmc: rtsx_pci: Cope with hot-removal of MMC host Lukas Wunner
2026-09-08 15:38 ` Ulf Hansson
2026-09-08 16:30   ` Lukas Wunner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqA4CrSWVzReITXY@wunner.de \
    --to=lukas@wunner.de \
    --cc=derekjohn.clark@gmail.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=matthew.schwartz@linux.dev \
    --cc=pgriffais@valvesoftware.com \
    --cc=ricky_wu@realtek.com \
    --cc=ulf.hansson@oss.qualcomm.com \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.