Page MenuHomeFreeBSD

mmc: fix intrhook not being cleaned up when booting without SD card in slot
ClosedPublic

Authored by yzhong_freebsdfoundation.org on Wed, Jul 21, 6:52 PM.

Details

Summary

When booting on a Thinkpad T440p with an empty SD card slot, the rtsx driver starts up an instance of the mmc driver. This calls mmc_attach(), which establishes an intrhook to later run mmc_delayed_attach(); mmc_delayed_attach() is responsible for disestablishing the intrhook. Then, since there's no card in the SD card slot, rtsx immediately deletes the mmc driver instance. This causes mmc_detach() to run, which cleans everything up. However, this means that mmc_delayed_attach() doesn't get the chance to properly disestablish the intrhook, leading to a kernel panic.

To fix this, this change adds a call to config_intrhook_drain(), which does nothing if the intrhook is running or has already ran (the SD card was plugged in), and disestablishes the hook if it hasn't ran yet (the SD card was not plugged in).

This should fix https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257293 and https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254373.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

yzhong_freebsdfoundation.org retitled this revision from mmc: to mmc: fix intrhook not being cleaned up when booting without SD card in slot.Wed, Jul 21, 7:15 PM
yzhong_freebsdfoundation.org edited the summary of this revision. (Show Details)

Call drain earlier so that mmc_delayed_attach() and mmc_delete_cards() can't run concurrently.

To elaborate a bit more, part of the problem seems to be that rtsx detects that a card is inserted during attach, even when one isn't there. It then changes its mind shortly after and destroys the child mmc device. So there is probably an rtsx bug here too, but it seems like mmc could be more careful and drain its intrhook when detaching.

This revision is now accepted and ready to land.Wed, Jul 21, 7:39 PM

To elaborate a bit more, part of the problem seems to be that rtsx detects that a card is inserted during attach, even when one isn't there. It then changes its mind shortly after and destroys the child mmc device. So there is probably an rtsx bug here too, but it seems like mmc could be more careful and drain its intrhook when detaching.

Hmm, looks like the rtsx problem is being investigated here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255130

This revision was automatically updated to reflect the committed changes.