linux-stable/include
Ulf Hansson 17a17bf506 mmc: core: Fix hanging on I/O during system suspend for removable cards
The mmc core uses a PM notifier to temporarily during system suspend, turn
off the card detection mechanism for removal/insertion of (e)MMC/SD/SDIO
cards. Additionally, the notifier may be used to remove an SDIO card
entirely, if a corresponding SDIO functional driver don't have the system
suspend/resume callbacks assigned. This behaviour has been around for a
very long time.

However, a recent bug report tells us there are problems with this
approach. More precisely, when receiving the PM_SUSPEND_PREPARE
notification, we may end up hanging on I/O to be completed, thus also
preventing the system from getting suspended.

In the end what happens, is that the cancel_delayed_work_sync() in
mmc_pm_notify() ends up waiting for mmc_rescan() to complete - and since
mmc_rescan() wants to claim the host, it needs to wait for the I/O to be
completed first.

Typically, this problem is triggered in Android, if there is ongoing I/O
while the user decides to suspend, resume and then suspend the system
again. This due to that after the resume, an mmc_rescan() work gets punted
to the workqueue, which job is to verify that the card remains inserted
after the system has resumed.

To fix this problem, userspace needs to become frozen to suspend the I/O,
prior to turning off the card detection mechanism. Therefore, let's drop
the PM notifiers for mmc subsystem altogether and rely on the card
detection to be turned off/on as a part of the system_freezable_wq, that we
are already using.

Moreover, to allow and SDIO card to be removed during system suspend, let's
manage this from a ->prepare() callback, assigned at the mmc_host_class
level. In this way, we can use the parent device (the mmc_host_class
device), to remove the card device that is the child, in the
device_prepare() phase.

Reported-by: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210310152900.149380-1-ulf.hansson@linaro.org
Reviewed-by: Kiwoong Kim <kwmad.kim@samsung.com>
2021-03-30 11:42:03 +02:00
..
acpi ACPI: scan: Use unique number for instance_no 2021-03-22 17:45:53 +01:00
asm-generic RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
clocksource
crypto Keyrings miscellany 2021-02-23 16:09:23 -08:00
drm drm/ttm: make ttm_bo_unpin more defensive 2021-03-15 16:02:30 +01:00
dt-bindings RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
keys
kunit
kvm KVM: arm64: Turn kvm_arm_support_pmu_v3() into a static key 2021-03-06 04:18:40 -05:00
linux mmc: core: Fix hanging on I/O during system suspend for removable cards 2021-03-30 11:42:03 +02:00
math-emu
media media: rc: compile rc-cec.c into rc-core 2021-03-11 11:40:28 +01:00
memory
misc
net sch_red: Fix a typo 2021-03-19 11:51:03 -07:00
pcmcia
ras
rdma
scsi
soc RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
sound ALSA/ASoC/SOF/SoundWire: fix Kconfig issues 2021-03-02 18:30:07 +01:00
target scsi: target: core: Add cmd length set before cmd complete 2021-02-22 22:21:29 -05:00
trace workqueue/tracing: Copy workqueue name to buffer in trace event 2021-03-18 12:57:37 -04:00
uapi Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-03-24 18:16:04 -07:00
vdso
video
xen Xen/gnttab: introduce common INVALID_GRANT_{HANDLE,REF} 2021-03-10 16:39:29 -06:00