Page MenuHomeFreeBSD

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

Authored by yzhong_freebsdfoundation.org on Jul 21 2021, 6:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 7, 5:03 PM
Unknown Object (File)
Fri, Apr 5, 10:57 PM
Unknown Object (File)
Mar 2 2024, 12:43 PM
Unknown Object (File)
Jan 16 2024, 2:22 PM
Unknown Object (File)
Jan 3 2024, 7:14 AM
Unknown Object (File)
Dec 20 2023, 5:56 AM
Unknown Object (File)
Dec 14 2023, 2:44 AM
Unknown Object (File)
Nov 28 2023, 5:24 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

Lint
Lint Skipped
Unit
Tests Skipped

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.Jul 21 2021, 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.Jul 21 2021, 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.