From: Sean Rhodes <sean@starlabs.systems>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sean Rhodes <sean@starlabs.systems>,
Ulf Hansson <ulf.hansson@linaro.org>,
Ricky Wu <ricky_wu@realtek.com>, Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org
Subject: [RFC PATCH 2/2] rtsx_usb: avoid USB I/O in runtime autosuspend
Date: Mon, 13 Apr 2026 12:42:31 +0100 [thread overview]
Message-ID: <00a2cae4c8243a39d254edb329b5a76c24d38373.1776080528.git.sean@starlabs.systems> (raw)
In-Reply-To: <cover.1776080528.git.sean@starlabs.systems>
The runtime autosuspend callback currently queries card status and clears
OCP via USB register accesses.
On some systems this can deadlock runtime PM and leave the USB device
stuck in the "suspending" state.
Avoid issuing USB commands from the runtime autosuspend callback.
Instead, use the last cached card status (updated on successful status
reads) and conservatively assume a card may be present until status is
known.
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
drivers/misc/cardreader/rtsx_usb.c | 11 +++++++----
include/linux/rtsx_usb.h | 3 +++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index c8badd0db87b..727205e84640 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -336,6 +336,9 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
if (ret < 0)
return ret;
+ ucr->card_status_cache = *status;
+ ucr->card_status_valid = true;
+
return 0;
}
EXPORT_SYMBOL_GPL(rtsx_usb_get_card_status);
@@ -753,16 +756,16 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
if (PMSG_IS_AUTO(message)) {
if (mutex_trylock(&ucr->dev_mutex)) {
- rtsx_usb_get_card_status(ucr, &val);
+ if (ucr->card_status_valid)
+ val = ucr->card_status_cache;
+ else
+ val = SD_CD | MS_CD;
mutex_unlock(&ucr->dev_mutex);
/* Defer the autosuspend if card exists */
if (val & (SD_CD | MS_CD)) {
device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
return -EAGAIN;
- } else {
- /* if the card does not exists, clear OCP status */
- rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR);
}
} else {
/* There is an ongoing operation*/
diff --git a/include/linux/rtsx_usb.h b/include/linux/rtsx_usb.h
index 54c6ea82bf43..fed695760691 100644
--- a/include/linux/rtsx_usb.h
+++ b/include/linux/rtsx_usb.h
@@ -62,6 +62,9 @@ struct rtsx_ucr {
struct usb_interface *pusb_intf;
struct usb_sg_request current_sg;
+ u16 card_status_cache;
+ bool card_status_valid;
+
struct timer_list sg_timer;
struct mutex dev_mutex;
};
prev parent reply other threads:[~2026-04-13 11:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 11:42 [RFC PATCH 0/2] rtsx_usb: runtime PM fixes before tray-reader detect rework Sean Rhodes
2026-04-13 11:42 ` [RFC PATCH 1/2] rtsx_usb: hold runtime PM during transfers Sean Rhodes
2026-05-11 14:04 ` Ulf Hansson
2026-07-06 10:30 ` Ulf Hansson
2026-04-13 11:42 ` Sean Rhodes [this message]
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=00a2cae4c8243a39d254edb329b5a76c24d38373.1776080528.git.sean@starlabs.systems \
--to=sean@starlabs.systems \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=ricky_wu@realtek.com \
--cc=tglx@linutronix.de \
--cc=ulf.hansson@linaro.org \
/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
all inboxes | Powered by JetHome®