--- /dev/null
+From 3e619d04159be54b3daa0b7036b0ce9e067f4b5d Mon Sep 17 00:00:00 2001
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Wed, 30 Jan 2013 16:36:40 -0500
+Subject: USB: EHCI: fix bug in scheduling periodic split transfers
+
+From: Alan Stern <stern@rowland.harvard.edu>
+
+commit 3e619d04159be54b3daa0b7036b0ce9e067f4b5d upstream.
+
+This patch (as1654) fixes a very old bug in ehci-hcd, connected with
+scheduling of periodic split transfers. The calculations for
+full/low-speed bus usage are all carried out after the correction for
+bit-stuffing has been applied, but the values in the max_tt_usecs
+array assume it hasn't been. The array should allow for allocation of
+up to 90% of the bus capacity, which is 900 us, not 780 us.
+
+The symptom caused by this bug is that any isochronous transfer to a
+full-speed device with a maxpacket size larger than about 980 bytes is
+always rejected with a -ENOSPC error.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/host/ehci-sched.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/usb/host/ehci-sched.c
++++ b/drivers/usb/host/ehci-sched.c
+@@ -236,7 +236,7 @@ static inline unsigned char tt_start_ufr
+ }
+
+ static const unsigned char
+-max_tt_usecs[] = { 125, 125, 125, 125, 125, 125, 30, 0 };
++max_tt_usecs[] = { 125, 125, 125, 125, 125, 125, 125, 25 };
+
+ /* carryover low/fullspeed bandwidth that crosses uframe boundries */
+ static inline void carryover_tt_bandwidth(unsigned short tt_usecs[8])
--- /dev/null
+From ee74290b7853db9d5fd64db70e5c175241c59fba Mon Sep 17 00:00:00 2001
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Fri, 25 Jan 2013 17:17:43 -0500
+Subject: USB: EHCI: fix timer bug affecting port resume
+
+From: Alan Stern <stern@rowland.harvard.edu>
+
+commit ee74290b7853db9d5fd64db70e5c175241c59fba upstream.
+
+This patch (as1652) fixes a long-standing bug in ehci-hcd. The driver
+relies on status polls to know when to stop port-resume signalling.
+It uses the root-hub status timer to schedule these status polls. But
+when the driver for the root hub is resumed, the timer is rescheduled
+to go off immediately -- before the port is ready. When this happens
+the timer does not get re-enabled, which prevents the port resume from
+finishing until some other event occurs.
+
+The symptom is that when a new device is plugged in, it doesn't get
+recognized or enumerated until lsusb is run or something else happens.
+
+The solution is to re-enable the root-hub status timer after every
+status poll while a port resume is in progress.
+
+This bug hasn't surfaced before now because we never used to try to
+suspend the root hub in the middle of a port resume (except by
+coincidence).
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Reported-and-tested-by: Norbert Preining <preining@logic.at>
+Tested-by: Ming Lei <ming.lei@canonical.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/host/ehci-hub.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/host/ehci-hub.c
++++ b/drivers/usb/host/ehci-hub.c
+@@ -612,7 +612,11 @@ ehci_hub_status_data (struct usb_hcd *hc
+ status = STS_PCD;
+ }
+ }
+- /* FIXME autosuspend idle root hubs */
++
++ /* If a resume is in progress, make sure it can finish */
++ if (ehci->resuming_ports)
++ mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(25));
++
+ spin_unlock_irqrestore (&ehci->lock, flags);
+ return status ? retval : 0;
+ }
--- /dev/null
+From 54a3ac0c9e5b7213daa358ce74d154352657353a Mon Sep 17 00:00:00 2001
+From: Lan Tianyu <tianyu.lan@intel.com>
+Date: Thu, 24 Jan 2013 10:31:28 +0800
+Subject: usb: Using correct way to clear usb3.0 device's remote wakeup feature.
+
+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. */