[PATCH] misc: rtsx: Don't signal card event on runtime resume during system suspend

From: Chia-Lin Kao (AceLan)

Date: Mon Oct 12 2026 - 20:10:29 EST


rtsx_pci_runtime_resume() unconditionally calls the SD slot card_event()
callback, which ends up in mmc_detect_change(). That takes a 5s
__pm_wakeup_event() on the mmc host wakeup source.

pci_pm_suspend() runtime-resumes the idle reader before system suspend,
so every s2idle entry signals the mmc0 wakeup source, which aborts or
shortens sleep and fails FWTS S2idleNotDeepest checks (seen on HP ZBook
X G2i with RTS525A, mmc0 event_count/active_count incremented per cycle).

While a system suspend is in progress, only report a card event when the
SD present bit refreshed by rtsx_pci_init_hw() differs from the value
saved before the resume. Outside of system suspend keep signalling the
event unconditionally, so mmc core still re-checks the card and notices
one swapped while the reader was in D3, which the present bit alone
cannot reveal.

Fixes: 5b4258f6721f ("misc: rtsx: rts5249 support runtime PM")
Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@xxxxxxxxxxxxx>
---
drivers/misc/cardreader/rtsx_pcr.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
index 2b6a994c6fe1f..b4c1723c95375 100644
--- a/drivers/misc/cardreader/rtsx_pcr.c
+++ b/drivers/misc/cardreader/rtsx_pcr.c
@@ -22,6 +22,7 @@
#include <linux/unaligned.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
+#include <linux/suspend.h>

#include "rtsx_pcr.h"
#include "rts5261.h"
@@ -1789,16 +1790,28 @@ static int rtsx_pci_runtime_resume(struct device *device)
struct pci_dev *pcidev = to_pci_dev(device);
struct pcr_handle *handle = pci_get_drvdata(pcidev);
struct rtsx_pcr *pcr = handle->pcr;
+ unsigned int old_card_exist;

dev_dbg(device, "--> %s\n", __func__);

mutex_lock(&pcr->pcr_mutex);

+ old_card_exist = pcr->card_exist;
+
rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, 0x00);

rtsx_pci_init_hw(pcr);

- if (pcr->slots[RTSX_SD_CARD].p_dev != NULL) {
+ /*
+ * System suspend runtime-resumes the idle reader, and an
+ * unconditional card event would take an mmc host wakeup event and
+ * abort/shorten the sleep. Only signal it then if the card presence
+ * actually changed; otherwise keep signalling so mmc core can detect
+ * a card swapped while the reader was in D3.
+ */
+ if (pcr->slots[RTSX_SD_CARD].p_dev != NULL &&
+ (((old_card_exist ^ pcr->card_exist) & SD_EXIST) ||
+ !pm_suspend_in_progress())) {
pcr->slots[RTSX_SD_CARD].card_event(
pcr->slots[RTSX_SD_CARD].p_dev);
}
--
2.53.0