* [PATCH] misc: rtsx: Avoid wakeup events from runtime resume during system sleep
@ 2026-11-27 6:49 Adrian Hunter
2026-11-29 15:38 ` wisdomwebman
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Hunter @ 2026-11-27 6:49 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arnd Bergmann
Cc: Rafael J. Wysocki, Ulf Hansson, Ricky Wu, Tabby Kitten,
WisdomWebMan, linux-pm, linux-mmc, linux-kernel
Userspace such as KDE Plasma writes /sys/power/wakeup_count before
entering system sleep, so that the kernel aborts the transition if a
wakeup event is reported. On machines with a Realtek PCIe card reader,
suspend then fails:
PM: Wakeup pending, aborting suspend
PM: active wakeup source: mmc0
During a system sleep transition, the card reader gets runtime resumed,
for example by mmc_claim_host() in mmc_queue_suspend(), or by
pci_pm_suspend() and pci_pm_freeze(). rtsx_pci_runtime_resume() then
calls the SD slot card_event() callback, which calls mmc_detect_change(),
which reports a wakeup event that aborts the transition. Plasma writes
wakeup_count before hibernation too, so hibernation is affected as well.
The rescan is not needed then, because the mmc host class .complete()
callback always triggers a rescan at the end of the transition,
including when it is aborted.
Skip card_event() while dev->power.is_prepared is set. The PM core sets
it after the PCI device is prepared and clears it before the device is
completed. The PCI device is prepared before, and completed after, its
mmc host descendant, so every skipped card_event() is followed by that
rescan.
Fixes: 5b4258f6721f ("misc: rtsx: rts5249 support runtime PM")
Reported-by: Tabby Kitten <nyanpasu256@gmail.com>
Closes: https://lore.kernel.org/linux-mmc/a242799a-d427-48e1-85ef-923f34df843a@gmail.com/
Reported-by: WisdomWebMan <wisdomwebman@proton.me>
Closes: https://lore.kernel.org/linux-mmc/MiymQuzpi87stsM7XA5bfyMV6n_W41wNq15OMA_RnicheHtlyXzpdRw6_hg8wwrkFdSclRgrh6ZqKLg1xpBSUA7cBxO6sX0eIPHg3Mx2tw0=@proton.me/
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
Note, this patch has not been tested at all, however WisdomWebMan
offered to do testing.
drivers/misc/cardreader/rtsx_pcr.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
index c6e602523538..4b9585c961df 100644
--- a/drivers/misc/cardreader/rtsx_pcr.c
+++ b/drivers/misc/cardreader/rtsx_pcr.c
@@ -1800,7 +1800,13 @@ static int rtsx_pci_runtime_resume(struct device *device)
rtsx_pci_init_hw(pcr);
- if (pcr->slots[RTSX_SD_CARD].p_dev != NULL) {
+ /*
+ * card_event() triggers a rescan to catch card changes made while
+ * runtime suspended, but mmc_detect_change() reports a wakeup event
+ * that can abort a system sleep transition. Skip it then: the mmc host
+ * class .complete() callback rescans anyway.
+ */
+ if (pcr->slots[RTSX_SD_CARD].p_dev != NULL && !device->power.is_prepared) {
pcr->slots[RTSX_SD_CARD].card_event(
pcr->slots[RTSX_SD_CARD].p_dev);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] misc: rtsx: Avoid wakeup events from runtime resume during system sleep
2026-11-27 6:49 [PATCH] misc: rtsx: Avoid wakeup events from runtime resume during system sleep Adrian Hunter
@ 2026-11-29 15:38 ` wisdomwebman
0 siblings, 0 replies; 2+ messages in thread
From: wisdomwebman @ 2026-11-29 15:38 UTC (permalink / raw)
To: Adrian Hunter
Cc: Greg Kroah-Hartman, Arnd Bergmann, Rafael J. Wysocki, Ulf Hansson,
Ricky Wu, Tabby Kitten, linux-pm, linux-mmc, linux-kernel
On Friday, November 27th, 2026 at 10:49 AM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> Note, this patch has not been tested at all, however WisdomWebMan
> offered to do testing.
Tested on my HP ProBook 450 G8 (RTS522A [10ec:522a], s2idle) with
7.3.4-arch1-2. I built rtsx_pci from the v7.3.4 sources with this
patch applied and swapped it in at runtime, so the stock and patched
drivers were tested in the same boot. The SD slot was empty for these
first runs.
Writing wakeup_count, then "echo mem > /sys/power/state", woken by an
RTC alarm after 15 s (basically Tabby's badsleep.sh):
stock: 5 of 5 aborted, "active wakeup source: mmc0"
patched: 5 of 5 slept and resumed, no aborts
Closing the lid with KDE Plasma, which writes wakeup_count:
stock: 6 lid closes, the first attempt was aborted by mmc0 5 times
patched: 9 lid closes, all slept on the first attempt, no aborts
Hibernation, using pm_test=devices since I have no swap set up, with
wakeup_count written first and the SD slot empty:
stock: 3 of 3 aborted by mmc0
patched: 3 of 3 got to "hibernation debug: Waiting for 5 second(s)"
and came back, no aborts
I also tried it with a card (64 GB SDXC), same boot, both drivers:
card inserted, 3 cycles as above:
stock: 3 of 3 aborted by mmc0
patched: 3 of 3 slept, no aborts
card removed during suspend:
stock: "card e624 removed" after resume, card gone
patched: same, slept on the first attempt
card inserted during suspend:
stock: first attempt aborted by mmc0, card found after resume
patched: slept on the first attempt, card found after resume
(mmcblk0 back, 8 MiB read OK)
So the rescan at the end of the transition picks up card changes made
during suspend. These were single runs, and I didn't see the "card not
recognized" problem Tabby had in January with either driver.
Tested-by: WisdomWebMan <wisdomwebman@proton.me>
Thanks,
WisdomWebMan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 6:49 [PATCH] misc: rtsx: Avoid wakeup events from runtime resume during system sleep Adrian Hunter
2026-11-29 15:38 ` wisdomwebman
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.