From: Sean Rhodes <sean@starlabs.systems>
To: linux-mmc@vger.kernel.org, Ulf Hansson <ulf.hansson@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ricky Wu <ricky_wu@realtek.com>,
Avri Altman <avri.altman@sandisk.com>,
Binbin Zhou <zhoubinbin@loongson.cn>,
Dan Carpenter <dan.carpenter@linaro.org>,
Jisheng Zhang <jszhang@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Huacai Chen <chenhuacai@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 5/6] rtsx_usb: hold runtime PM during transfers
Date: Thu, 5 Mar 2026 19:40:51 +0000 [thread overview]
Message-ID: <20260305194052.5120-6-sean@starlabs.systems> (raw)
In-Reply-To: <20260305194052.5120-1-sean@starlabs.systems>
Hold a runtime-PM reference across bulk transfers, and mark the device
busy afterwards.
When runtime PM is already in progress (e.g. from rtsx_usb_suspend()),
avoid forcing a runtime resume from within the PM path by using
usb_autopm_get_interface_no_resume() unless the interface is already
runtime-suspended.
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
drivers/misc/cardreader/rtsx_usb.c | 38 ++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index 1830e9ed2521..5d818b632788 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -12,6 +12,7 @@
#include <linux/usb.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
+#include <linux/pm_runtime.h>
#include <linux/rtsx_usb.h>
static int polling_pipe = 1;
@@ -65,19 +66,42 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr,
}
int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe,
- void *buf, unsigned int len, int num_sg,
- unsigned int *act_len, int timeout)
+ void *buf, unsigned int len, int num_sg,
+ unsigned int *act_len, int timeout)
{
+ int ret;
+ struct device *dev = &ucr->pusb_intf->dev;
+
if (timeout < 600)
timeout = 600;
+ /*
+ * During runtime suspend/resume callbacks, avoid forcing a runtime resume
+ * from within the PM path. The device is still active when
+ * rtsx_usb_suspend() runs, but usb_autopm_get_interface() can block when
+ * runtime PM is already in progress.
+ */
+ if (pm_runtime_status_suspended(dev)) {
+ ret = usb_autopm_get_interface(ucr->pusb_intf);
+ } else {
+ usb_autopm_get_interface_no_resume(ucr->pusb_intf);
+ ret = 0;
+ }
+ if (ret)
+ return ret;
+
if (num_sg)
- return rtsx_usb_bulk_transfer_sglist(ucr, pipe,
- (struct scatterlist *)buf, num_sg, len, act_len,
- timeout);
+ ret = rtsx_usb_bulk_transfer_sglist(ucr, pipe,
+ (struct scatterlist *)buf,
+ num_sg, len, act_len,
+ timeout);
else
- return usb_bulk_msg(ucr->pusb_dev, pipe, buf, len, act_len,
- timeout);
+ ret = usb_bulk_msg(ucr->pusb_dev, pipe, buf, len, act_len,
+ timeout);
+
+ usb_mark_last_busy(ucr->pusb_dev);
+ usb_autopm_put_interface(ucr->pusb_intf);
+ return ret;
}
EXPORT_SYMBOL_GPL(rtsx_usb_transfer_data);
--
2.51.0
next prev parent reply other threads:[~2026-03-05 19:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 20:39 [PATCH] mmc: rtsx_usb_sdmmc: avoid false card-detect on tray readers Sean Rhodes
2026-03-05 19:40 ` [PATCH v2 0/6] rtsx_usb_sdmmc: tray CD fix + UHS + runtime PM Sean Rhodes
2026-03-05 19:40 ` [PATCH v2 1/6] mmc: rtsx_usb_sdmmc: avoid false card-detect on tray readers Sean Rhodes
2026-03-05 19:40 ` [PATCH v2 2/6] mmc: rtsx_usb_sdmmc: start card power-up at 3.3V Sean Rhodes
2026-03-05 19:40 ` [PATCH v2 3/6] mmc: rtsx_usb_sdmmc: advertise UHS SDR104 and DDR50 Sean Rhodes
2026-03-05 19:40 ` [PATCH v2 4/6] mmc: rtsx_usb_sdmmc: program SD30 mode for UHS SDR12/SDR25 Sean Rhodes
2026-03-05 19:40 ` Sean Rhodes [this message]
2026-03-05 19:40 ` [PATCH v2 6/6] rtsx_usb: avoid USB I/O in runtime autosuspend Sean Rhodes
2026-03-12 12:15 ` [PATCH v2 RESEND 0/6] rtsx_usb_sdmmc: tray CD fix + UHS + runtime PM Sean Rhodes
2026-03-12 12:15 ` [PATCH v2 RESEND 1/6] mmc: rtsx_usb_sdmmc: avoid false card-detect on tray readers Sean Rhodes
2026-03-24 11:26 ` Ulf Hansson
2026-03-24 11:27 ` Ulf Hansson
2026-03-24 11:59 ` Sean Rhodes
2026-03-24 12:23 ` Ulf Hansson
2026-03-24 12:30 ` Sean Rhodes
2026-03-24 12:57 ` Ulf Hansson
2026-03-24 13:13 ` Sean Rhodes
2026-03-24 13:34 ` Ulf Hansson
2026-03-12 12:15 ` [PATCH v2 RESEND 2/6] mmc: rtsx_usb_sdmmc: start card power-up at 3.3V Sean Rhodes
2026-03-24 11:41 ` Ulf Hansson
2026-03-24 12:02 ` Sean Rhodes
2026-03-12 12:15 ` [PATCH v2 RESEND 3/6] mmc: rtsx_usb_sdmmc: advertise UHS SDR104 and DDR50 Sean Rhodes
2026-03-24 11:49 ` Ulf Hansson
2026-03-12 12:15 ` [PATCH v2 RESEND 4/6] mmc: rtsx_usb_sdmmc: program SD30 mode for UHS SDR12/SDR25 Sean Rhodes
2026-03-12 12:15 ` [PATCH v2 RESEND 5/6] rtsx_usb: hold runtime PM during transfers Sean Rhodes
2026-03-24 12:10 ` Ulf Hansson
2026-03-12 12:15 ` [PATCH v2 RESEND 6/6] rtsx_usb: avoid USB I/O in runtime autosuspend Sean Rhodes
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=20260305194052.5120-6-sean@starlabs.systems \
--to=sean@starlabs.systems \
--cc=arnd@arndb.de \
--cc=avri.altman@sandisk.com \
--cc=chenhuacai@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jszhang@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=nathan@kernel.org \
--cc=ricky_wu@realtek.com \
--cc=tglx@linutronix.de \
--cc=ulf.hansson@linaro.org \
--cc=zhoubinbin@loongson.cn \
/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