[PATCH 5/5] misc: rtsx_usb: / memstick: rtsx_usb_ms: Avoid long delay before system suspend
From: Kai-Heng Feng
Date: Tue Jul 31 2018 - 02:17:53 EST
There's a long power-on delay at the end of rtsx_usb_ms_set_param().
This delay is noticeable right before system suspend.
To prevent already suspended memstick host from getting powered on by PM
core, use DPM_FLAG_SMART_SUSPEND to avoid the situation.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
---
drivers/memstick/host/rtsx_usb_ms.c | 4 ++++
drivers/misc/cardreader/rtsx_usb.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index 126eb310980a..e3b635d1220f 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -763,6 +763,10 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
msh->set_param = rtsx_usb_ms_set_param;
msh->caps = MEMSTICK_CAP_PAR4;
+ /* DPM_FLAG_LEAVE_SUSPENDED is not needed, the parent device will wake
+ * up memstick host.
+ */
+ dev_pm_set_driver_flags(ms_dev(host), DPM_FLAG_SMART_SUSPEND);
pm_runtime_set_active(ms_dev(host));
pm_runtime_enable(ms_dev(host));
diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index f7a66f614085..98bb878a6ade 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -671,6 +671,7 @@ static int rtsx_usb_probe(struct usb_interface *intf,
goto out_init_fail;
#ifdef CONFIG_PM
+ dev_pm_set_driver_flags(&intf->dev, DPM_FLAG_SMART_SUSPEND | DPM_FLAG_LEAVE_SUSPENDED);
intf->needs_remote_wakeup = 1;
usb_enable_autosuspend(usb_dev);
#endif
--
2.17.1