lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 10 Aug 2016 16:44:33 +0800
From:	Baolin Wang <baolin.wang@...aro.org>
To:	gregkh@...uxfoundation.org, stefan.koch10@...il.com,
	stern@...land.harvard.edu
Cc:	oneukum@...e.com, falakreyaz@...il.com, broonie@...nel.org,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	baolin.wang@...aro.org
Subject: [PATCH v2] usb: core: Add runtime resume checking in choose_wakeup()

Considering strict power management for mobile device, we should also power
off the usb controller if there are no slaves attached even though it is usb
host function, but it will meet usb device resume failure in below situation.

Suppose that no slave attached ----> usb interface runtime suspend ---->
usb device runtime suspend -----> xhci suspend -----> power off usb controller.
After that if the system wants to enter suspend state, then it also will issue
usb_dev_suspend(), then the pm_runtime_resume() issued in choose_wakeup()
function will return '-ESHUTDOWN' due to xhci has been suspend and hardware is
not accessible.

After system entering resume state, if there is slave attached ----> power on
usb controller ----> xhci resume ----> usb device runtime resume ---->
usb interface runtime resume. But usb device will resume failed if runtime
errors is set ('-ESHUTDOWN'), thus we should clear the runtime errors in
choose_wakeup() function to avoid this situation.

Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
changes since v1:
 - Modify the changelog to explain clearly.
 - Remove 'ret' variable in choose_wakeup().
---
 drivers/usb/core/driver.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index dadd1e8d..bce283c 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1431,8 +1431,11 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
 	/* If the device is autosuspended with the wrong wakeup setting,
 	 * autoresume now so the setting can be changed.
 	 */
-	if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
-		pm_runtime_resume(&udev->dev);
+	if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup) {
+		if (pm_runtime_resume(&udev->dev) == -ESHUTDOWN)
+			pm_runtime_set_suspended(&udev->dev);
+	}
+
 	udev->do_remote_wakeup = w;
 }
 
-- 
1.7.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ