linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Lan Tianyu <tianyu.lan@intel.com>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>
Subject: [ 19/26] usb: Using correct way to clear usb3.0 devices remote wakeup feature.
Date: Thu,  7 Feb 2013 16:57:47 -0800	[thread overview]
Message-ID: <20130208004630.525902793@linuxfoundation.org> (raw)
In-Reply-To: <20130208004627.258272404@linuxfoundation.org>

3.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lan Tianyu <tianyu.lan@intel.com>

commit 54a3ac0c9e5b7213daa358ce74d154352657353a upstream.

Usb3.0 device defines function remote wakeup which is only for interface
recipient rather than device recipient. This is different with usb2.0 device's
remote wakeup feature which is defined for device recipient. According usb3.0
spec 9.4.5, the function remote wakeup can be modified by the SetFeature()
requests using the FUNCTION_SUSPEND feature selector. This patch is to use
correct way to disable usb3.0 device's function remote wakeup after suspend
error and resuming.

This should be backported to kernels as old as 3.4, that contain the
commit 623bef9e03a60adc623b09673297ca7a1cdfb367 "USB/xhci: Enable remote
wakeup for USB3 devices."

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/hub.c  |   70 +++++++++++++++++++++++++++++++++++-------------
 include/linux/usb/ch9.h |    6 ++++
 2 files changed, 58 insertions(+), 18 deletions(-)

--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2463,6 +2463,23 @@ static int check_port_resume_type(struct
 }
 
 #ifdef	CONFIG_USB_SUSPEND
+/*
+ * usb_disable_function_remotewakeup - disable usb3.0
+ * device's function remote wakeup
+ * @udev: target device
+ *
+ * Assume there's only one function on the USB 3.0
+ * device and disable remote wake for the first
+ * interface. FIXME if the interface association
+ * descriptor shows there's more than one function.
+ */
+static int usb_disable_function_remotewakeup(struct usb_device *udev)
+{
+	return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+				USB_REQ_CLEAR_FEATURE, USB_RECIP_INTERFACE,
+				USB_INTRF_FUNC_SUSPEND,	0, NULL, 0,
+				USB_CTRL_SET_TIMEOUT);
+}
 
 /*
  * usb_port_suspend - suspend a usb device's upstream port
@@ -2569,12 +2586,19 @@ int usb_port_suspend(struct usb_device *
 		dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
 				port1, status);
 		/* paranoia:  "should not happen" */
-		if (udev->do_remote_wakeup)
-			(void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
-				USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
-				USB_DEVICE_REMOTE_WAKEUP, 0,
-				NULL, 0,
-				USB_CTRL_SET_TIMEOUT);
+		if (udev->do_remote_wakeup) {
+			if (!hub_is_superspeed(hub->hdev)) {
+				(void) usb_control_msg(udev,
+						usb_sndctrlpipe(udev, 0),
+						USB_REQ_CLEAR_FEATURE,
+						USB_RECIP_DEVICE,
+						USB_DEVICE_REMOTE_WAKEUP, 0,
+						NULL, 0,
+						USB_CTRL_SET_TIMEOUT);
+			} else
+				(void) usb_disable_function_remotewakeup(udev);
+
+		}
 
 		/* Try to enable USB2 hardware LPM again */
 		if (udev->usb2_hw_lpm_capable == 1)
@@ -2661,20 +2685,30 @@ static int finish_port_resume(struct usb
 	 * udev->reset_resume
 	 */
 	} else if (udev->actconfig && !udev->reset_resume) {
-		le16_to_cpus(&devstatus);
-		if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) {
-			status = usb_control_msg(udev,
-					usb_sndctrlpipe(udev, 0),
-					USB_REQ_CLEAR_FEATURE,
+		if (!hub_is_superspeed(udev->parent)) {
+			le16_to_cpus(&devstatus);
+			if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
+				status = usb_control_msg(udev,
+						usb_sndctrlpipe(udev, 0),
+						USB_REQ_CLEAR_FEATURE,
 						USB_RECIP_DEVICE,
-					USB_DEVICE_REMOTE_WAKEUP, 0,
-					NULL, 0,
-					USB_CTRL_SET_TIMEOUT);
-			if (status)
-				dev_dbg(&udev->dev,
-					"disable remote wakeup, status %d\n",
-					status);
+						USB_DEVICE_REMOTE_WAKEUP, 0,
+						NULL, 0,
+						USB_CTRL_SET_TIMEOUT);
+		} else {
+			status = usb_get_status(udev, USB_RECIP_INTERFACE, 0,
+					&devstatus);
+			le16_to_cpus(&devstatus);
+			if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
+					| USB_INTRF_STAT_FUNC_RW))
+				status =
+					usb_disable_function_remotewakeup(udev);
 		}
+
+		if (status)
+			dev_dbg(&udev->dev,
+				"disable remote wakeup, status %d\n",
+				status);
 		status = 0;
 	}
 	return status;
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -150,6 +150,12 @@
 #define USB_INTRF_FUNC_SUSPEND_LP	(1 << (8 + 0))
 #define USB_INTRF_FUNC_SUSPEND_RW	(1 << (8 + 1))
 
+/*
+ * Interface status, Figure 9-5 USB 3.0 spec
+ */
+#define USB_INTRF_STAT_FUNC_RW_CAP     1
+#define USB_INTRF_STAT_FUNC_RW         2
+
 #define USB_ENDPOINT_HALT		0	/* IN/OUT will STALL */
 
 /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */



  parent reply	other threads:[~2013-02-08  0:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08  0:57 [ 00/26] 3.4.30-stable review Greg Kroah-Hartman
2013-02-08  0:57 ` [ 01/26] digsig: Fix memory leakage in digsig_verify_rsa() Greg Kroah-Hartman
2013-02-08  0:57 ` [ 02/26] drm/radeon/evergreen+: wait for the MC to settle after MC blackout Greg Kroah-Hartman
2013-02-08  0:57 ` [ 03/26] drm/radeon: add WAIT_UNTIL to the non-VM safe regs list for cayman/TN Greg Kroah-Hartman
2013-02-08  0:57 ` [ 04/26] drm/radeon: add quirk for RV100 board Greg Kroah-Hartman
2013-02-08  0:57 ` [ 05/26] drm/radeon: fix MC blackout on evergreen+ Greg Kroah-Hartman
2013-02-08  0:57 ` [ 06/26] drm/radeon: prevent crash in the ring space allocation Greg Kroah-Hartman
2013-02-08  0:57 ` [ 07/26] drm/radeon: Calling object_unrefer() when creating fb failure Greg Kroah-Hartman
2013-02-08  0:57 ` [ 08/26] x86-64: Replace left over sti/cli in ia32 audit exit code Greg Kroah-Hartman
2013-02-08  0:57 ` [ 09/26] sched/rt: Use root_domain of rt_rq not current processor Greg Kroah-Hartman
2013-02-08  0:57 ` [ 10/26] nilfs2: fix fix very long mount time issue Greg Kroah-Hartman
2013-02-08  0:57 ` [ 11/26] drivers/rtc/rtc-isl1208.c: call rtc_update_irq() from the alarm irq handler Greg Kroah-Hartman
2013-02-08  0:57 ` [ 12/26] USB: ftdi_sio: add Zolix FTDI PID Greg Kroah-Hartman
2013-02-08  0:57 ` [ 13/26] USB: ftdi_sio: add PID/VID entries for ELV WS 300 PC II Greg Kroah-Hartman
2013-02-08  0:57 ` [ 14/26] USB: option: add support for Telit LE920 Greg Kroah-Hartman
2013-02-08  0:57 ` [ 15/26] USB: option: add Changhong CH690 Greg Kroah-Hartman
2013-02-08  0:57 ` [ 16/26] USB: qcserial: add Telit Gobi QDL device Greg Kroah-Hartman
2013-02-08  0:57 ` [ 17/26] USB: EHCI: fix timer bug affecting port resume Greg Kroah-Hartman
2013-02-08  0:57 ` [ 18/26] USB: EHCI: fix bug in scheduling periodic split transfers Greg Kroah-Hartman
2013-02-08  0:57 ` Greg Kroah-Hartman [this message]
2013-02-08  0:57 ` [ 20/26] USB: storage: Define a new macro for USB storage match rules Greg Kroah-Hartman
2013-02-08  0:57 ` [ 21/26] USB: storage: optimize to match the Huawei USB storage devices and support new switch command Greg Kroah-Hartman
2013-02-08  0:57 ` [ 22/26] drivers: xhci: fix incorrect bit test Greg Kroah-Hartman
2013-02-08  0:57 ` [ 23/26] xhci: Fix isoc TD encoding Greg Kroah-Hartman
2013-02-08  0:57 ` [ 24/26] xhci: Fix TD size for isochronous URBs Greg Kroah-Hartman
2013-02-08  0:57 ` [ 25/26] USB: XHCI: fix memory leak of URB-private data Greg Kroah-Hartman
2013-02-08  0:57 ` [ 26/26] usb: Prevent dead ports when xhci is not enabled Greg Kroah-Hartman
2013-02-08 20:28 ` [ 00/26] 3.4.30-stable review Shuah Khan
2013-02-09 12:12 ` Satoru Takeuchi

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=20130208004630.525902793@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tianyu.lan@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).