linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Ulf Hansson <ulfh@kernel.org>, Ricky Wu <ricky_wu@realtek.com>,
	Tabby Kitten <nyanpasu256@gmail.com>,
	WisdomWebMan <wisdomwebman@proton.me>,
	linux-pm@vger.kernel.org, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] misc: rtsx: Avoid wakeup events from runtime resume during system sleep
Date: Fri, 27 Nov 2026 08:49:22 +0200	[thread overview]
Message-ID: <20261127064922.13791-1-adrian.hunter@intel.com> (raw)

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


                 reply	other threads:[~2026-11-27  6:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261127064922.13791-1-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nyanpasu256@gmail.com \
    --cc=rafael@kernel.org \
    --cc=ricky_wu@realtek.com \
    --cc=ulfh@kernel.org \
    --cc=wisdomwebman@proton.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).