From: "Chai, Chong Yi" <chong.yi.c...@intel.com> --- features/soc/baytrail/baytrail.scc | 5 + .../usb-core-hub-Fix-checkpatch.pl-error.patch | 29 +++++ ...hub-Generate-uevent-for-overcurrent-event.patch | 142 +++++++++++++++++++++ ...core-Fix-gadget-for-system-suspend-resume.patch | 92 +++++++++++++ ...ange-how-we-indicate-a-host-supports-Link.patch | 128 +++++++++++++++++++ 5 files changed, 396 insertions(+) create mode 100644 features/soc/baytrail/usb-core-hub-Fix-checkpatch.pl-error.patch create mode 100644 features/soc/baytrail/usb-core-hub-Generate-uevent-for-overcurrent-event.patch create mode 100644 features/soc/baytrail/usb-dwc3-core-Fix-gadget-for-system-suspend-resume.patch create mode 100644 features/soc/baytrail/usb-xhci-Change-how-we-indicate-a-host-supports-Link.patch
diff --git a/features/soc/baytrail/baytrail.scc b/features/soc/baytrail/baytrail.scc index 33a6ecd..b1638a1 100644 --- a/features/soc/baytrail/baytrail.scc +++ b/features/soc/baytrail/baytrail.scc @@ -12,3 +12,8 @@ include features/usb/ehci-hcd.scc include features/intel-pinctrl/intel-pinctrl.scc kconf hardware baytrail.cfg + +patch usb-dwc3-core-Fix-gadget-for-system-suspend-resume.patch +patch usb-xhci-Change-how-we-indicate-a-host-supports-Link.patch +patch usb-core-hub-Generate-uevent-for-overcurrent-event.patch +patch usb-core-hub-Fix-checkpatch.pl-error.patch diff --git a/features/soc/baytrail/usb-core-hub-Fix-checkpatch.pl-error.patch b/features/soc/baytrail/usb-core-hub-Fix-checkpatch.pl-error.patch new file mode 100644 index 0000000..458e73d --- /dev/null +++ b/features/soc/baytrail/usb-core-hub-Fix-checkpatch.pl-error.patch @@ -0,0 +1,29 @@ +From 929f063346721d98574147bcf905c7e8b3357e75 Mon Sep 17 00:00:00 2001 +From: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com> +Date: Fri, 21 Aug 2015 12:01:37 +0800 +Subject: [PATCH 154/164] usb: core: hub: Fix checkpatch.pl error + +This commit is to fix the result of running scripts/checkpatch.pl against +0113-usb-core-hub-Generate-uevent-for-overcurrent-event.patch + +Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com> +--- + drivers/usb/core/hub.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index a83be1c..fa54931 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -4895,7 +4895,7 @@ static void hub_events(void) + u16 unused; + #ifdef CONFIG_USB_OC_NOTIFICATION + int retval; +- static int oc_flag = 0; ++ static int oc_flag; + #endif + + dev_dbg(hub_dev, "over-current change on port " +-- +1.7.7.6 + diff --git a/features/soc/baytrail/usb-core-hub-Generate-uevent-for-overcurrent-event.patch b/features/soc/baytrail/usb-core-hub-Generate-uevent-for-overcurrent-event.patch new file mode 100644 index 0000000..a3700db --- /dev/null +++ b/features/soc/baytrail/usb-core-hub-Generate-uevent-for-overcurrent-event.patch @@ -0,0 +1,142 @@ +From 478feddadc397bb33ab045a9eab25b5f7054f6b8 Mon Sep 17 00:00:00 2001 +From: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com> +Date: Wed, 29 Jul 2015 18:13:08 +0800 +Subject: [PATCH 113/164] usb: core: hub: Generate uevent for overcurrent + event + +This modification generates a 'uevent' to userland and adds the +'OVERCURRENT=1' environment when overcurrent event happens and +adds the 'OVERCURRENT=0' environment when returning to normal +current, with PORT number. + +Any userland program listening to the 'uevent' interface can filter +for the presence of this environment variable to distinguish this +special 'uevent' from other 'add' or 'remove' events. + +Current disadvantage: Due to the fact, the hub driver tries to enable the +port again immediately (it does not wait for user interaction) this powerfail +event gets reported twice: First time when it really happens and second time +when the external overcurrent detection device will be reset. The second +false positive report must be sorted out by the userland application. + +This patch is derived from [PATCH] Generate a uevent when an overcurrent +event happens by Juergen Beisert <jbe@@pengutronix.de> and +Michael Grzeschik <m.grzeschik@@pengutronix> + +Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com> +--- + drivers/usb/core/Kconfig | 9 ++++++ + drivers/usb/core/hub.c | 63 +++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 71 insertions(+), 1 deletions(-) + +diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig +index fed7f68..0f6f565 100644 +--- a/drivers/usb/core/Kconfig ++++ b/drivers/usb/core/Kconfig +@@ -89,3 +89,12 @@ config USB_OTG_BLACKLIST_HUB + and software costs by not supporting external hubs. So + are "Embedded Hosts" that don't offer OTG support. + ++config USB_OC_NOTIFICATION ++ bool "Enable Overcurrent Notification" ++ default N ++ help ++ Say Y here if you want the send the uevents to userland ++ for overcurrent condition on USB ports and ports coming to ++ normal state after over current condition has occured. ++ ++ This feature was tested on platforms using Bay Trail. +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 975e2f2..a83be1c 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -4756,6 +4756,16 @@ static void hub_events(void) + u16 portchange; + int i, ret; + int connect_change, wakeup_change; ++#ifdef CONFIG_USB_OC_NOTIFICATION ++ char overcurrent_event[] = "OVERCURRENT=1"; ++ char overcurrent_port[10]; ++ char *overcurrent_envp[] = { ++ overcurrent_event, overcurrent_port, NULL }; ++ char normalcurrent_event[] = "OVERCURRENT=0"; ++ char normalcurrent_port[10]; ++ char *normalcurrent_envp[] = { ++ normalcurrent_event, normalcurrent_port, NULL }; ++#endif + + /* + * We restart the list every time to avoid a deadlock with +@@ -4883,17 +4893,68 @@ static void hub_events(void) + if (portchange & USB_PORT_STAT_C_OVERCURRENT) { + u16 status = 0; + u16 unused; ++#ifdef CONFIG_USB_OC_NOTIFICATION ++ int retval; ++ static int oc_flag = 0; ++#endif + + dev_dbg(hub_dev, "over-current change on port " + "%d\n", i); ++#ifdef CONFIG_USB_OC_NOTIFICATION ++ /* ++ * Send event to userland for port ++ * coming back to normal current condition ++ * from overcurrent condition. ++ */ ++ if (oc_flag & BIT(i - 1)) { ++ snprintf(normalcurrent_port, ++ sizeof(normalcurrent_port), ++ "NPORT=%d", i); ++ ++ retval = kobject_uevent_env( ++ &hub->intfdev->kobj, ++ KOBJ_CHANGE, ++ normalcurrent_envp); ++ if (retval) { ++ dev_err(hub_dev, ++ "failed to send event\n"); ++ } ++ ++ /* Clear individual port flag. */ ++ oc_flag &= ~(BIT(i - 1)); ++ } ++#endif + usb_clear_port_feature(hdev, i, + USB_PORT_FEAT_C_OVER_CURRENT); + msleep(100); /* Cool down */ + hub_power_on(hub, true); + hub_port_status(hub, i, &status, &unused); +- if (status & USB_PORT_STAT_OVERCURRENT) ++ if (status & USB_PORT_STAT_OVERCURRENT) { + dev_err(hub_dev, "over-current " + "condition on port %d\n", i); ++#ifdef CONFIG_USB_OC_NOTIFICATION ++ /* ++ * Send events to userland for ++ * overcurrent condition with ++ * port number. ++ */ ++ snprintf(overcurrent_port, ++ sizeof(overcurrent_port), ++ "OCPORT=%d", i); ++ ++ retval = kobject_uevent_env( ++ &hub->intfdev->kobj, ++ KOBJ_CHANGE, ++ overcurrent_envp); ++ if (retval) { ++ dev_err(hub_dev, ++ "failed to send OC event\n"); ++ } ++ ++ /* Set individual port flag. */ ++ oc_flag |= BIT(i - 1); ++#endif ++ } + } + + if (portchange & USB_PORT_STAT_C_RESET) { +-- +1.7.7.6 + diff --git a/features/soc/baytrail/usb-dwc3-core-Fix-gadget-for-system-suspend-resume.patch b/features/soc/baytrail/usb-dwc3-core-Fix-gadget-for-system-suspend-resume.patch new file mode 100644 index 0000000..3c9b366 --- /dev/null +++ b/features/soc/baytrail/usb-dwc3-core-Fix-gadget-for-system-suspend-resume.patch @@ -0,0 +1,92 @@ +From ee2c236f33430ef1293d3adb3d630398b96d6c5a Mon Sep 17 00:00:00 2001 +From: Roger Quadros <rog...@ti.com> +Date: Wed, 26 Mar 2014 11:43:09 +0200 +Subject: [PATCH 018/164] usb: dwc3: core: Fix gadget for system + suspend/resume + +During system resume, if the event buffers are not setup before +the gadget controller starts then we start with invalid context +and this can lead to bus access errors. This is especially true for +platforms that loose the controller context during system suspend. +e.g. AM437x. + +The following backtrace was found when the system is suspended +and resumed with g_zero loaded on AM437x-evm (USB cable connected +to host all the while). + +[ 120.981506] WARNING: CPU: 0 PID: 1656 at drivers/bus/omap_l3_noc.c:137 l3_interrupt_handler+0x198/0x28c() +[ 120.981514] L3 custom error: MASTER:USB0 WR TARGET:GPMC +[ 120.981638] Modules linked in: g_mass_storage usb_f_mass_storage libcomposite configfs bufferclass_ti(O) omaplfb(O) cryptodev(O) dwc3 snd_soc_evm snd_soc_omap snd_pe +[ 120.981659] CPU: 0 PID: 1656 Comm: sh Tainted: G O 3.12.10-gc559824 #1 +[ 120.981669] Backtrace: +[ 120.981705] [<c0017880>] (dump_backtrace+0x0/0x10c) from [<c0017a1c>] (show_stack+0x18/0x1c) +[ 120.981730] r6:c02819ac r5:00000009 r4:ec137cb8 r3:00000000 +[ 120.981767] [<c0017a04>] (show_stack+0x0/0x1c) from [<c056c0b0>] (dump_stack+0x20/0x28) +[ 120.981802] [<c056c090>] (dump_stack+0x0/0x28) from [<c0046d08>] (warn_slowpath_common+0x70/0x90) +[ 120.981830] [<c0046c98>] (warn_slowpath_common+0x0/0x90) from [<c0046dcc>] (warn_slowpath_fmt+0x38/0x40) +[ 120.981856] r8:c0855eb0 r7:00000002 r6:f1000700 r5:00000007 r4:80080003 +[ 120.981886] [<c0046d94>] (warn_slowpath_fmt+0x0/0x40) from [<c02819ac>] (l3_interrupt_handler+0x198/0x28c) +[ 120.981900] r3:c0801ab8 r2:c06cb354 +[ 120.981936] [<c0281814>] (l3_interrupt_handler+0x0/0x28c) from [<c007162c>] (handle_irq_event_percpu+0x54/0x1b8) +[ 120.981962] [<c00715d8>] (handle_irq_event_percpu+0x0/0x1b8) from [<c00717c0>] (handle_irq_event+0x30/0x40) +[ 120.981993] [<c0071790>] (handle_irq_event+0x0/0x40) from [<c0074058>] (handle_fasteoi_irq+0x74/0x128) +[ 120.982006] r4:ed0056c0 r3:00000000 +[ 120.982033] [<c0073fe4>] (handle_fasteoi_irq+0x0/0x128) from [<c0070f34>] (generic_handle_irq+0x28/0x38) +[ 120.982046] r4:0000002a r3:c0073fe4 +[ 120.982085] [<c0070f0c>] (generic_handle_irq+0x0/0x38) from [<c0015560>] (handle_IRQ+0x38/0x8c) +[ 120.982098] r4:c080137c r3:00000182 +[ 120.982124] [<c0015528>] (handle_IRQ+0x0/0x8c) from [<c00087e0>] (gic_handle_irq+0x30/0x5c) +[ 120.982145] r6:ec137dd0 r5:c07ac480 r4:fa24010c r3:00000100 +[ 120.982169] [<c00087b0>] (gic_handle_irq+0x0/0x5c) from [<c056fcc0>] (__irq_svc+0x40/0x54) +[ 120.982179] Exception stack(0xec137dd0 to 0xec137e18) +[ 120.982195] 7dc0: 00000000 a00001d3 00000000 00000004 +[ 120.982216] 7de0: a0000153 ec1d9010 c080de90 ec137e30 c080debc 00000000 ed756e44 ec137e2c +[ 120.982232] 7e00: ec137de0 ec137e18 bf1150e4 bf115474 60000153 ffffffff +[ 120.982253] r7:ec137e04 r6:ffffffff r5:60000153 r4:bf115474 +[ 120.982327] [<bf115438>] (dwc3_complete+0x0/0x40 [dwc3]) from [<c0338f50>] (dpm_complete+0xd4/0x19c) +[ 120.982341] r5:ed756e10 r4:ed756e64 +[ 120.982370] [<c0338e7c>] (dpm_complete+0x0/0x19c) from [<c0339034>] (dpm_resume_end+0x1c/0x20) +[ 120.982400] [<c0339018>] (dpm_resume_end+0x0/0x20) from [<c006d4ec>] (suspend_devices_and_enter+0x118/0x33c) +[ 120.982412] r4:c0833da4 r3:00000000 +[ 120.982436] [<c006d3d4>] (suspend_devices_and_enter+0x0/0x33c) from [<c006d928>] (pm_suspend+0x218/0x254) +[ 120.982458] [<c006d710>] (pm_suspend+0x0/0x254) from [<c006c594>] (state_store+0x70/0xc0) +[ 120.982478] r6:c057a6cc r5:c06a8320 r4:00000003 r3:0000006d +[ 120.982515] [<c006c524>] (state_store+0x0/0xc0) from [<c0264cc0>] (kobj_attr_store+0x1c/0x28) +[ 120.982546] [<c0264ca4>] (kobj_attr_store+0x0/0x28) from [<c012ccb8>] (sysfs_write_file+0x170/0x1a4) +[ 120.982583] [<c012cb48>] (sysfs_write_file+0x0/0x1a4) from [<c00d17e4>] (vfs_write+0xb8/0x190) +[ 120.982611] [<c00d172c>] (vfs_write+0x0/0x190) from [<c00d1bf8>] (SyS_write+0x44/0x78) +[ 120.982641] [<c00d1bb4>] (SyS_write+0x0/0x78) from [<c0014660>] (ret_fast_syscall+0x0/0x30) + +Signed-off-by: Roger Quadros <rog...@ti.com> +Acked-by: Felipe Balbi <ba...@ti.com> +Signed-off-by: Felipe Balbi <ba...@ti.com> +(cherry picked from commit f45e5f00dacf09362a16339d372fcc96705e40c7) + +Signed-off-by: Maurice Petallo <mauricex.r.peta...@intel.com> +--- + drivers/usb/dwc3/core.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index f074755..86b1e69 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -646,6 +646,7 @@ static void dwc3_complete(struct device *dev) + + spin_lock_irqsave(&dwc->lock, flags); + ++ dwc3_event_buffers_setup(dwc); + switch (dwc->dr_mode) { + case USB_DR_MODE_PERIPHERAL: + case USB_DR_MODE_OTG: +@@ -653,7 +654,6 @@ static void dwc3_complete(struct device *dev) + /* FALLTHROUGH */ + case USB_DR_MODE_HOST: + default: +- dwc3_event_buffers_setup(dwc); + break; + } + +-- +1.7.7.6 + diff --git a/features/soc/baytrail/usb-xhci-Change-how-we-indicate-a-host-supports-Link.patch b/features/soc/baytrail/usb-xhci-Change-how-we-indicate-a-host-supports-Link.patch new file mode 100644 index 0000000..d3af73f --- /dev/null +++ b/features/soc/baytrail/usb-xhci-Change-how-we-indicate-a-host-supports-Link.patch @@ -0,0 +1,128 @@ +From 15eefa1ce9694e7601d171b9b8a49bd659804f65 Mon Sep 17 00:00:00 2001 +From: Sarah Sharp <sarah.a.sh...@linux.intel.com> +Date: Fri, 17 Jan 2014 14:15:44 -0800 +Subject: [PATCH 086/164] usb/xhci: Change how we indicate a host supports + Link PM. + +The xHCI driver currently uses a USB core internal field, +udev->lpm_capable, to indicate the xHCI driver knows how to calculate +the LPM timeout values. If this value is set for the host controller +udev, it means Link PM can be enabled for child devices under that host. + +Change the code so the xHCI driver isn't mucking with USB core internal +fields. Instead, indicate the xHCI driver doesn't support Link PM on +this host by clearing the U1 and U2 exit latencies in the roothub +SuperSpeed Extended Capabilities BOS descriptor. + +The code to check for the roothub setting U1 and U2 exit latencies to +zero will also disable LPM for external devices that do that same. This +was already effectively done with commit +ae8963adb4ad8c5f2a89ca1d99fb7bb721e7599f "usb: Don't enable LPM if the +exit latency is zero." Leave that code in place, so that if a device +sets one exit latency value to zero, but the other is set to a valid +value, LPM is only enabled for the U1 or U2 state that had the valid +value. This is the same behavior the code had before. + +Also, change messages about missing Link PM information from warning +level to info level. Only print a warning about the first device that +doesn't support LPM, to avoid log spam. Further, cleanup some +unnecessary line breaks to help people to grep for the error messages. + +Signed-off-by: Sarah Sharp <sarah.a.sh...@linux.intel.com> +Cc: Alan Stern <st...@rowland.harvard.edu> +(cherry picked from commit 25cd2882e2fc8bd8ed7acaee0ec979f11feda6d7) +Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com> + +Conflicts: + drivers/usb/host/xhci-pci.c + + Cherry-pick'd mainline commit bcffae7 "xhci: Prevent runtime pm + from autosuspending during initialization" added new lines that + caused conflict. That patch is cherry-pick'd to linux-stable + kernel 3.14.27 first. If this patch "25cd288" could have been + added first before "bcffae7", then we won't have conflicts. +--- + drivers/usb/core/hub.c | 24 ++++++++++++++++-------- + drivers/usb/host/xhci-hub.c | 8 +++++--- + drivers/usb/host/xhci-pci.c | 6 ------ + 3 files changed, 21 insertions(+), 17 deletions(-) + +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 1847a7d..975e2f2 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -141,19 +141,27 @@ static int usb_device_supports_lpm(struct usb_device *udev) + return 0; + } + +- /* All USB 3.0 must support LPM, but we need their max exit latency +- * information from the SuperSpeed Extended Capabilities BOS descriptor. ++ /* ++ * According to the USB 3.0 spec, all USB 3.0 devices must support LPM. ++ * However, there are some that don't, and they set the U1/U2 exit ++ * latencies to zero. + */ + if (!udev->bos->ss_cap) { +- dev_warn(&udev->dev, "No LPM exit latency info found. " +- "Power management will be impacted.\n"); ++ dev_info(&udev->dev, "No LPM exit latency info found, disabling LPM.\n"); + return 0; + } +- if (udev->parent->lpm_capable) +- return 1; + +- dev_warn(&udev->dev, "Parent hub missing LPM exit latency info. " +- "Power management will be impacted.\n"); ++ if (udev->bos->ss_cap->bU1devExitLat == 0 && ++ udev->bos->ss_cap->bU2DevExitLat == 0) { ++ if (udev->parent) ++ dev_info(&udev->dev, "LPM exit latency is zeroed, disabling LPM.\n"); ++ else ++ dev_info(&udev->dev, "We don't know the algorithms for LPM for this host, disabling LPM.\n"); ++ return 0; ++ } ++ ++ if (!udev->parent || udev->parent->lpm_capable) ++ return 1; + return 0; + } + +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c +index b9e16ab..2ba51fc 100644 +--- a/drivers/usb/host/xhci-hub.c ++++ b/drivers/usb/host/xhci-hub.c +@@ -740,9 +740,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, + /* Set the U1 and U2 exit latencies. */ + memcpy(buf, &usb_bos_descriptor, + USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE); +- temp = readl(&xhci->cap_regs->hcs_params3); +- buf[12] = HCS_U1_LATENCY(temp); +- put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]); ++ if ((xhci->quirks & XHCI_LPM_SUPPORT)) { ++ temp = readl(&xhci->cap_regs->hcs_params3); ++ buf[12] = HCS_U1_LATENCY(temp); ++ put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]); ++ } + + /* Indicate whether the host has LTM support. */ + temp = readl(&xhci->cap_regs->hcc_params); +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c +index eb3399f..8a3f0e6 100644 +--- a/drivers/usb/host/xhci-pci.c ++++ b/drivers/usb/host/xhci-pci.c +@@ -230,12 +230,6 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) + goto put_usb3_hcd; + /* Roothub already marked as USB 3.0 speed */ + +- /* We know the LPM timeout algorithms for this host, let the USB core +- * enable and disable LPM for devices under the USB 3.0 roothub. +- */ +- if (xhci->quirks & XHCI_LPM_SUPPORT) +- hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1; +- + /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ + pm_runtime_put_noidle(&dev->dev); + +-- +1.7.7.6 + -- 1.9.1 -- _______________________________________________ linux-yocto mailing list linux-yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/linux-yocto