--- /dev/null
+From d115d7050a0d2c4967532f18c9cb522fea6b7280 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
+Date: Mon, 31 Aug 2015 19:48:28 +0300
+Subject: Revert "usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
+
+commit d115d7050a0d2c4967532f18c9cb522fea6b7280 upstream.
+
+This reverts commit 8f2c9544aba636134303105ecb164190a39dece4.
+
+As it breaks g_ether on my Baytrail FFRD8 device. Everything starts out
+fine, but after a bit of data has been transferred it just stops
+flowing.
+
+Note that I do get a bunch of these "NOHZ: local_softirq_pending 08"
+when booting the machine, but I'm not really sure if they're related
+to this problem.
+
+Cc: Felipe Balbi <balbi@ti.com>
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-usb@vger.kernel.org
+Cc: stable@vger.kernel.org
+Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/gadget.c | 37 +++++++++++++++++++++----------------
+ 1 file changed, 21 insertions(+), 16 deletions(-)
+
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -1859,27 +1859,32 @@ static int dwc3_cleanup_done_reqs(struct
+ unsigned int i;
+ int ret;
+
+- req = next_request(&dep->req_queued);
+- if (!req) {
+- WARN_ON_ONCE(1);
+- return 1;
+- }
+- i = 0;
+ do {
+- slot = req->start_slot + i;
+- if ((slot == DWC3_TRB_NUM - 1) &&
++ req = next_request(&dep->req_queued);
++ if (!req) {
++ WARN_ON_ONCE(1);
++ return 1;
++ }
++ i = 0;
++ do {
++ slot = req->start_slot + i;
++ if ((slot == DWC3_TRB_NUM - 1) &&
+ usb_endpoint_xfer_isoc(dep->endpoint.desc))
+- slot++;
+- slot %= DWC3_TRB_NUM;
+- trb = &dep->trb_pool[slot];
++ slot++;
++ slot %= DWC3_TRB_NUM;
++ trb = &dep->trb_pool[slot];
++
++ ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
++ event, status);
++ if (ret)
++ break;
++ } while (++i < req->request.num_mapped_sgs);
++
++ dwc3_gadget_giveback(dep, req, status);
+
+- ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
+- event, status);
+ if (ret)
+ break;
+- } while (++i < req->request.num_mapped_sgs);
+-
+- dwc3_gadget_giveback(dep, req, status);
++ } while (1);
+
+ if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
+ list_empty(&dep->req_queued)) {
kvm-s390-sca-must-not-cross-page-boundaries.patch
kvm-s390-fix-wrong-lookup-of-vcpus-by-array-index.patch
kvm-s390-avoid-memory-overwrites-on-emergency-signal-injection.patch
+revert-usb-dwc3-gadget-drop-unnecessary-loop-when-cleaning-up-trbs.patch
+usb-gadget-atmel_usba_udc-expose-correct-device-speed.patch
+usb-dwc3-gadget-let-us-set-lower-max_speed.patch
+usb-chipidea-otg-gadget-module-load-and-unload-support.patch
+usb-dwc3-pci-add-the-synopsys-haps-axi-product-id.patch
+usb-dwc3-pci-add-the-pci-product-id-for-synopsys-usb-3.1.patch
+usb-dwc3-support-synopsys-usb-3.1-ip.patch
+usb-dwc3-pci-add-platform-data-for-synopsys-haps.patch
--- /dev/null
+From 85da852df66e5e0d3aba761b0fece7c958ff0685 Mon Sep 17 00:00:00 2001
+From: Li Jun <B47624@freescale.com>
+Date: Fri, 12 Dec 2014 09:11:42 +0800
+Subject: usb: chipidea: otg: gadget module load and unload support
+
+From: Li Jun <B47624@freescale.com>
+
+commit 85da852df66e5e0d3aba761b0fece7c958ff0685 upstream.
+
+This patch is to support load and unload gadget driver in full OTG mode.
+
+Signed-off-by: Li Jun <jun.li@freescale.com>
+Signed-off-by: Peter Chen <peter.chen@freescale.com>
+Tested-by: Jiada Wang <jiada_wang@mentor.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/chipidea/udc.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+--- a/drivers/usb/chipidea/udc.c
++++ b/drivers/usb/chipidea/udc.c
+@@ -1730,6 +1730,22 @@ static int ci_udc_start(struct usb_gadge
+ return retval;
+ }
+
++static void ci_udc_stop_for_otg_fsm(struct ci_hdrc *ci)
++{
++ if (!ci_otg_is_fsm_mode(ci))
++ return;
++
++ mutex_lock(&ci->fsm.lock);
++ if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) {
++ ci->fsm.a_bidl_adis_tmout = 1;
++ ci_hdrc_otg_fsm_start(ci);
++ } else if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) {
++ ci->fsm.protocol = PROTO_UNDEF;
++ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
++ }
++ mutex_unlock(&ci->fsm.lock);
++}
++
+ /**
+ * ci_udc_stop: unregister a gadget driver
+ */
+@@ -1754,6 +1770,7 @@ static int ci_udc_stop(struct usb_gadget
+ ci->driver = NULL;
+ spin_unlock_irqrestore(&ci->lock, flags);
+
++ ci_udc_stop_for_otg_fsm(ci);
+ return 0;
+ }
+
--- /dev/null
+From b9e51b2b1fda19143f48d182ed7a2943f21e1ae4 Mon Sep 17 00:00:00 2001
+From: Ben McCauley <ben.mccauley@garmin.com>
+Date: Mon, 16 Nov 2015 10:47:24 -0600
+Subject: usb: dwc3: gadget: let us set lower max_speed
+
+From: Ben McCauley <ben.mccauley@garmin.com>
+
+commit b9e51b2b1fda19143f48d182ed7a2943f21e1ae4 upstream.
+
+In some SoCs, dwc3 is implemented as a USB2.0 only
+core, meaning that it can't ever achieve SuperSpeed.
+
+Currect driver always sets gadget.max_speed to
+USB_SPEED_SUPER unconditionally. This can causes
+issues to some Host stacks where the host will issue
+a GetBOS() request and we will reply with a BOS
+containing Superspeed Capability Descriptor.
+
+At least Windows seems to be upset by this fact and
+prints a warning that we should connect $this device
+to another port.
+
+[ balbi@ti.com : rewrote entire commit, including
+source code comment to make a lot clearer what the
+problem is ]
+
+Signed-off-by: Ben McCauley <ben.mccauley@garmin.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/gadget.c | 24 +++++++++++++++++++++++-
+ 1 file changed, 23 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -2714,12 +2714,34 @@ int dwc3_gadget_init(struct dwc3 *dwc)
+ }
+
+ dwc->gadget.ops = &dwc3_gadget_ops;
+- dwc->gadget.max_speed = USB_SPEED_SUPER;
+ dwc->gadget.speed = USB_SPEED_UNKNOWN;
+ dwc->gadget.sg_supported = true;
+ dwc->gadget.name = "dwc3-gadget";
+
+ /*
++ * FIXME We might be setting max_speed to <SUPER, however versions
++ * <2.20a of dwc3 have an issue with metastability (documented
++ * elsewhere in this driver) which tells us we can't set max speed to
++ * anything lower than SUPER.
++ *
++ * Because gadget.max_speed is only used by composite.c and function
++ * drivers (i.e. it won't go into dwc3's registers) we are allowing this
++ * to happen so we avoid sending SuperSpeed Capability descriptor
++ * together with our BOS descriptor as that could confuse host into
++ * thinking we can handle super speed.
++ *
++ * Note that, in fact, we won't even support GetBOS requests when speed
++ * is less than super speed because we don't have means, yet, to tell
++ * composite.c that we are USB 2.0 + LPM ECN.
++ */
++ if (dwc->revision < DWC3_REVISION_220A)
++ dwc3_trace(trace_dwc3_gadget,
++ "Changing max_speed on rev %08x\n",
++ dwc->revision);
++
++ dwc->gadget.max_speed = dwc->maximum_speed;
++
++ /*
+ * Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize
+ * on ep out.
+ */
--- /dev/null
+From bb7f3d6d323a56b9c3b3e727380d1395a7f10107 Mon Sep 17 00:00:00 2001
+From: John Youn <John.Youn@synopsys.com>
+Date: Sat, 26 Sep 2015 00:11:15 -0700
+Subject: usb: dwc3: pci: Add platform data for Synopsys HAPS
+
+From: John Youn <John.Youn@synopsys.com>
+
+commit bb7f3d6d323a56b9c3b3e727380d1395a7f10107 upstream.
+
+Add platform data and set usb3_lpm_capable and has_lpm_erratum.
+
+Signed-off-by: John Youn <johnyoun@synopsys.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/dwc3-pci.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+--- a/drivers/usb/dwc3/dwc3-pci.c
++++ b/drivers/usb/dwc3/dwc3-pci.c
+@@ -67,6 +67,21 @@ static int dwc3_pci_quirks(struct pci_de
+ sizeof(pdata));
+ }
+
++ if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS &&
++ (pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 ||
++ pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI ||
++ pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31)) {
++
++ struct dwc3_platform_data pdata;
++
++ memset(&pdata, 0, sizeof(pdata));
++ pdata.usb3_lpm_capable = true;
++ pdata.has_lpm_erratum = true;
++
++ return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
++ sizeof(pdata));
++ }
++
+ return 0;
+ }
+
--- /dev/null
+From e8095a25364a30216ad40dbe8893ed5c3c235949 Mon Sep 17 00:00:00 2001
+From: John Youn <John.Youn@synopsys.com>
+Date: Fri, 7 Aug 2015 11:47:25 -0700
+Subject: usb: dwc3: pci: Add the PCI Product ID for Synopsys USB 3.1
+
+From: John Youn <John.Youn@synopsys.com>
+
+commit e8095a25364a30216ad40dbe8893ed5c3c235949 upstream.
+
+This adds the PCI product ID for the Synopsys USB 3.1 IP core
+(DWC_usb31) on a HAPS-based PCI development platform.
+
+Signed-off-by: John Youn <johnyoun@synopsys.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/dwc3-pci.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/usb/dwc3/dwc3-pci.c
++++ b/drivers/usb/dwc3/dwc3-pci.c
+@@ -26,6 +26,7 @@
+
+ #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
+ #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI 0xabce
++#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31 0xabcf
+ #define PCI_DEVICE_ID_INTEL_BYT 0x0f37
+ #define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
+ #define PCI_DEVICE_ID_INTEL_BSW 0x22B7
+@@ -141,6 +142,10 @@ static const struct pci_device_id dwc3_p
+ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
+ PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI),
+ },
++ {
++ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
++ PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31),
++ },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
--- /dev/null
+From 41adc59caece02aa2e988a0e8f9fe8e6f426f82e Mon Sep 17 00:00:00 2001
+From: John Youn <John.Youn@synopsys.com>
+Date: Fri, 7 Aug 2015 11:04:14 -0700
+Subject: usb: dwc3: pci: Add the Synopsys HAPS AXI Product ID
+
+From: John Youn <John.Youn@synopsys.com>
+
+commit 41adc59caece02aa2e988a0e8f9fe8e6f426f82e upstream.
+
+This ID is for the Synopsys DWC_usb3 core with AXI interface on PCIe
+HAPS platform. This core has the debug registers mapped at a separate
+BAR in order to support enhanced hibernation.
+
+Signed-off-by: John Youn <johnyoun@synopsys.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/dwc3-pci.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/usb/dwc3/dwc3-pci.c
++++ b/drivers/usb/dwc3/dwc3-pci.c
+@@ -25,6 +25,7 @@
+ #include "platform_data.h"
+
+ #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
++#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI 0xabce
+ #define PCI_DEVICE_ID_INTEL_BYT 0x0f37
+ #define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
+ #define PCI_DEVICE_ID_INTEL_BSW 0x22B7
+@@ -136,6 +137,10 @@ static const struct pci_device_id dwc3_p
+ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
+ PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
+ },
++ {
++ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
++ PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI),
++ },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
--- /dev/null
+From 690fb3718a70c66004342f6f5e2e8a5f95b977db Mon Sep 17 00:00:00 2001
+From: John Youn <John.Youn@synopsys.com>
+Date: Fri, 4 Sep 2015 19:15:10 -0700
+Subject: usb: dwc3: Support Synopsys USB 3.1 IP
+
+From: John Youn <John.Youn@synopsys.com>
+
+commit 690fb3718a70c66004342f6f5e2e8a5f95b977db upstream.
+
+This patch allows the dwc3 driver to run on the new Synopsys USB 3.1
+IP core, albeit in USB 3.0 mode only.
+
+The Synopsys USB 3.1 IP (DWC_usb31) retains mostly the same register
+interface and programming model as the existing USB 3.0 controller IP
+(DWC_usb3). However the GSNPSID and version numbers are different.
+
+Add checking for the new ID to pass driver probe.
+
+Also, since the DWC_usb31 version number is lower in value than the
+full GSNPSID of the DWC_usb3 IP, we set the high bit to identify
+DWC_usb31 and to ensure the values are higher.
+
+Finally, add a documentation note about the revision numbering scheme.
+Any future revision checks (for STARS, workarounds, and new features)
+should take into consideration how it applies to both the 3.1/3.0 IP.
+
+Signed-off-by: John Youn <johnyoun@synopsys.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/dwc3/core.c | 10 ++++++++--
+ drivers/usb/dwc3/core.h | 18 ++++++++++++++++++
+ 2 files changed, 26 insertions(+), 2 deletions(-)
+
+--- a/drivers/usb/dwc3/core.c
++++ b/drivers/usb/dwc3/core.c
+@@ -445,12 +445,18 @@ static int dwc3_core_init(struct dwc3 *d
+
+ reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
+ /* This should read as U3 followed by revision number */
+- if ((reg & DWC3_GSNPSID_MASK) != 0x55330000) {
++ if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) {
++ /* Detected DWC_usb3 IP */
++ dwc->revision = reg;
++ } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) {
++ /* Detected DWC_usb31 IP */
++ dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER);
++ dwc->revision |= DWC3_REVISION_IS_DWC31;
++ } else {
+ dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
+ ret = -ENODEV;
+ goto err0;
+ }
+- dwc->revision = reg;
+
+ /*
+ * Write Linux Version Code to our GUID register so it's easy to figure
+--- a/drivers/usb/dwc3/core.h
++++ b/drivers/usb/dwc3/core.h
+@@ -107,6 +107,9 @@
+ #define DWC3_GPRTBIMAP_FS0 0xc188
+ #define DWC3_GPRTBIMAP_FS1 0xc18c
+
++#define DWC3_VER_NUMBER 0xc1a0
++#define DWC3_VER_TYPE 0xc1a4
++
+ #define DWC3_GUSB2PHYCFG(n) (0xc200 + (n * 0x04))
+ #define DWC3_GUSB2I2CCTL(n) (0xc240 + (n * 0x04))
+
+@@ -752,6 +755,14 @@ struct dwc3 {
+ u32 num_event_buffers;
+ u32 u1u2;
+ u32 maximum_speed;
++
++ /*
++ * All 3.1 IP version constants are greater than the 3.0 IP
++ * version constants. This works for most version checks in
++ * dwc3. However, in the future, this may not apply as
++ * features may be developed on newer versions of the 3.0 IP
++ * that are not in the 3.1 IP.
++ */
+ u32 revision;
+
+ #define DWC3_REVISION_173A 0x5533173a
+@@ -774,6 +785,13 @@ struct dwc3 {
+ #define DWC3_REVISION_270A 0x5533270a
+ #define DWC3_REVISION_280A 0x5533280a
+
++/*
++ * NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really
++ * just so dwc31 revisions are always larger than dwc3.
++ */
++#define DWC3_REVISION_IS_DWC31 0x80000000
++#define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_USB31)
++
+ enum dwc3_ep0_next ep0_next_event;
+ enum dwc3_ep0_state ep0state;
+ enum dwc3_link_state link_state;
--- /dev/null
+From d134c48d889ddceadf4c990e6f3df16b816ed5d4 Mon Sep 17 00:00:00 2001
+From: Douglas Gilbert <dgilbert@interlog.com>
+Date: Mon, 16 Nov 2015 19:22:08 +0100
+Subject: usb: gadget: atmel_usba_udc: Expose correct device speed
+
+From: Douglas Gilbert <dgilbert@interlog.com>
+
+commit d134c48d889ddceadf4c990e6f3df16b816ed5d4 upstream.
+
+Following changes that appeared in lk 4.0.0, the gadget udc driver for
+some ARM based Atmel SoCs (e.g. at91sam9x5 and sama5d3 families)
+incorrectly deduced full-speed USB link speed even when the hardware
+had negotiated a high-speed link. The fix is to make sure that the
+UDPHS Interrupt Enable Register value does not mask the SPEED bit
+in the Interrupt Status Register.
+
+For a mass storage gadget this problem lead to failures when the host
+had a USB 3 port with the xhci_hcd driver. If the host was a USB 2
+port using the ehci_hcd driver then the mass storage gadget worked
+(but probably at a lower speed than it should have).
+
+Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
+Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Fixes: 9870d895ad87 ("usb: atmel_usba_udc: Mask status with enabled irqs")
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
++++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
+@@ -1634,7 +1634,7 @@ static irqreturn_t usba_udc_irq(int irq,
+ spin_lock(&udc->lock);
+
+ int_enb = usba_int_enb_get(udc);
+- status = usba_readl(udc, INT_STA) & int_enb;
++ status = usba_readl(udc, INT_STA) & (int_enb | USBA_HIGH_SPEED);
+ DBG(DBG_INT, "irq, status=%#08x\n", status);
+
+ if (status & USBA_DET_SUSPEND) {