From: Greg Kroah-Hartman Date: Sat, 9 Dec 2017 17:10:19 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v3.18.87~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea423bd0be659ca5d211e0906a659ff98d64f55c;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: usb-dwc2-improve-gadget-state-disconnection-handling.patch --- diff --git a/queue-4.14/series b/queue-4.14/series index 57c2c1a0690..40f4e9adb6b 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -29,8 +29,6 @@ mmc-tmio-check-mmc_regulator_get_supply-return-value.patch mmc-sdhci-msm-fix-issue-with-power-irq.patch hwmon-pmbus-core-prevent-unintentional-setting-of-page-to-0xff.patch perf-core-fix-__perf_read_group_add-locking.patch -usb-dwc2-fix-udc-state-tracking.patch -usb-dwc2-error-out-of-dwc2_hsotg_ep_disable-if-we-re-in-host-mode.patch usb-phy-tahvo-fix-error-handling-in-tahvo_usb_probe.patch pci-dra7xx-create-functional-dependency-between-pcie-and-phy.patch x86-intel_rdt-initialize-bitmask-of-shareable-resource-if-cdp-enabled.patch @@ -73,3 +71,4 @@ usb-xhci-fix-panic-in-xhci_free_virt_devices_depth_first.patch usb-core-add-type-specific-length-check-of-bos-descriptors.patch usb-usbfs-filter-flags-passed-in-from-user-space.patch usb-host-fix-incorrect-updating-of-offset.patch +usb-dwc2-improve-gadget-state-disconnection-handling.patch diff --git a/queue-4.14/usb-dwc2-error-out-of-dwc2_hsotg_ep_disable-if-we-re-in-host-mode.patch b/queue-4.14/usb-dwc2-error-out-of-dwc2_hsotg_ep_disable-if-we-re-in-host-mode.patch deleted file mode 100644 index e3e176b4104..00000000000 --- a/queue-4.14/usb-dwc2-error-out-of-dwc2_hsotg_ep_disable-if-we-re-in-host-mode.patch +++ /dev/null @@ -1,109 +0,0 @@ -From foo@baz Wed Dec 6 18:04:41 CET 2017 -From: John Stultz -Date: Mon, 23 Oct 2017 14:32:49 -0700 -Subject: usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode - -From: John Stultz - - -[ Upstream commit 9b481092c2a31a6b630aff9c28f0145bf6683787 ] - -We've found that while in host mode, using Android, if one runs -the command: - stop adbd - -The existing usb devices being utilized in host mode are disconnected. -This is most visible with usb networking devices. - -This seems to be due to adbd closing the file: - /dev/usb-ffs/adb/ep0 -Which calls ffs_ep0_release() and the following backtrace: - -[] dwc2_hsotg_ep_disable+0x148/0x150 -[] dwc2_hsotg_udc_stop+0x60/0x110 -[] usb_gadget_remove_driver+0x58/0x78 -[] usb_gadget_unregister_driver+0x74/0xe8 -[] unregister_gadget+0x28/0x58 -[] unregister_gadget_item+0x2c/0x40 -[] ffs_data_clear+0xe8/0xf8 -[] ffs_data_reset+0x20/0x58 -[] ffs_data_closed+0x98/0xe8 -[] ffs_ep0_release+0x20/0x30 - -Then when dwc2_hsotg_ep_disable() is called, we call -kill_all_requests() which causes a bunch of the following -messages: - -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode -init: Service 'adbd' (pid 1915) killed by signal 9 -init: Sending signal 9 to service 'adbd' (pid 1915) process group... -init: Successfully killed process cgroup uid 0 pid 1915 in 0ms -init: processing action (init.svc.adbd=stopped) from (/init.usb.configfs.rc:15) -dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 8 - ChHltd set, but reason is unknown -dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 -dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 12 - ChHltd set, but reason is unknown -dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 -dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 15 - ChHltd set, but reason is unknown -dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 -dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 3 - ChHltd set, but reason is unknown -dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 -dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 4 - ChHltd set, but reason is unknown -dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 -dwc2 f72c0000.usb: dwc2_update_urb_state_abn(): trimming xfer length - -And the usb devices connected are basically hung at this point. - -It seems like if we're in host mode, we probably shouldn't run -the dwc2_hostg_ep_disable logic, so this patch returns an error -in that case. - -With this patch (along with the previous patch in this set), we avoid -the mismatched interrupts and connected usb devices continue to function. - -I'm not sure if some other solution would be better here, but this seems -to work, so I wanted to send it out for input on what the right approach -should be. - -Cc: Wei Xu -Cc: Guodong Xu -Cc: Amit Pundir -Cc: YongQin Liu -Cc: John Youn -Cc: Minas Harutyunyan -Cc: Douglas Anderson -Cc: Chen Yu -Cc: Felipe Balbi -Cc: Greg Kroah-Hartman -Cc: linux-usb@vger.kernel.org -Acked-by: Minas Harutyunyan -Tested-by: Minas Harutyunyan -Reported-by: YongQin Liu -Signed-off-by: John Stultz -Signed-off-by: Felipe Balbi -Signed-off-by: Sasha Levin -Signed-off-by: Greg Kroah-Hartman ---- - drivers/usb/dwc2/gadget.c | 5 +++++ - 1 file changed, 5 insertions(+) - ---- a/drivers/usb/dwc2/gadget.c -+++ b/drivers/usb/dwc2/gadget.c -@@ -4006,6 +4006,11 @@ static int dwc2_hsotg_ep_disable(struct - return -EINVAL; - } - -+ if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { -+ dev_err(hsotg->dev, "%s: called in host mode?\n", __func__); -+ return -EINVAL; -+ } -+ - epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); - - spin_lock_irqsave(&hsotg->lock, flags); diff --git a/queue-4.14/usb-dwc2-fix-udc-state-tracking.patch b/queue-4.14/usb-dwc2-fix-udc-state-tracking.patch deleted file mode 100644 index 57747e3142e..00000000000 --- a/queue-4.14/usb-dwc2-fix-udc-state-tracking.patch +++ /dev/null @@ -1,55 +0,0 @@ -From foo@baz Wed Dec 6 18:04:41 CET 2017 -From: John Stultz -Date: Mon, 23 Oct 2017 14:32:50 -0700 -Subject: usb: dwc2: Fix UDC state tracking - -From: John Stultz - - -[ Upstream commit ce2b21a4e5ce042c0a42c9db8fa9e0f849427d5e ] - -It has been noticed that the dwc2 udc state reporting doesn't -seem to work (at least on HiKey boards). Where after the initial -setup, the sysfs /sys/class/udc/f72c0000.usb/state file would -report "configured" no matter the state of the OTG port. - -This patch adds a call so that we report to the UDC layer when -the gadget device is disconnected. - -This patch does depend on the previous patch ("usb: dwc2: -Improve gadget state disconnection handling") in this patch set -in order to properly work. - -Cc: Wei Xu -Cc: Guodong Xu -Cc: Amit Pundir -Cc: YongQin Liu -Cc: John Youn -Cc: Minas Harutyunyan -Cc: Douglas Anderson -Cc: Chen Yu -Cc: Felipe Balbi -Cc: Greg Kroah-Hartman -Cc: linux-usb@vger.kernel.org -Acked-by: Minas Harutyunyan -Tested-by: Minas Harutyunyan -Reported-by: Amit Pundir -Signed-off-by: John Stultz -Signed-off-by: Felipe Balbi -Signed-off-by: Sasha Levin -Signed-off-by: Greg Kroah-Hartman ---- - drivers/usb/dwc2/gadget.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/drivers/usb/dwc2/gadget.c -+++ b/drivers/usb/dwc2/gadget.c -@@ -3202,6 +3202,8 @@ void dwc2_hsotg_disconnect(struct dwc2_h - - call_gadget(hsotg, disconnect); - hsotg->lx_state = DWC2_L3; -+ -+ usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); - } - - /** diff --git a/queue-4.14/usb-dwc2-improve-gadget-state-disconnection-handling.patch b/queue-4.14/usb-dwc2-improve-gadget-state-disconnection-handling.patch new file mode 100644 index 00000000000..6eeccdcbfcb --- /dev/null +++ b/queue-4.14/usb-dwc2-improve-gadget-state-disconnection-handling.patch @@ -0,0 +1,78 @@ +From d2471d4a24dfbff5e463d382e2c6fec7d7e25a09 Mon Sep 17 00:00:00 2001 +From: John Stultz +Date: Mon, 23 Oct 2017 14:32:48 -0700 +Subject: usb: dwc2: Improve gadget state disconnection handling + +From: John Stultz + +commit d2471d4a24dfbff5e463d382e2c6fec7d7e25a09 upstream. + +In the earlier commit dad3f793f20f ("usb: dwc2: Make sure we +disconnect the gadget state"), I was trying to fix up the +fact that we somehow weren't disconnecting the gadget state, +so that when the OTG port was plugged in the second time we +would get warnings about the state tracking being wrong. + +(This seems to be due to a quirk of the HiKey board where +we do not ever get any otg interrupts, particularly the session +end detected signal. Instead we only see status change +interrupt.) + +The fix there was somewhat simple, as it just made sure to +call dwc2_hsotg_disconnect() before we connected things up +in OTG mode, ensuring the state handling didn't throw errors. + +But in looking at a different issue I was seeing with UDC +state handling, I realized that it would be much better +to call dwc2_hsotg_disconnect when we get the state change +signal moving to host mode. + +Thus, this patch removes the earlier disconnect call I added +and moves it (and the needed locking) to the host mode +transition. + +Cc: Wei Xu +Cc: Guodong Xu +Cc: Amit Pundir +Cc: YongQin Liu +Cc: John Youn +Cc: Minas Harutyunyan +Cc: Douglas Anderson +Cc: Chen Yu +Cc: Felipe Balbi +Cc: linux-usb@vger.kernel.org +Acked-by: Minas Harutyunyan +Tested-by: Minas Harutyunyan +Signed-off-by: John Stultz +Signed-off-by: Felipe Balbi +Cc: Ben Hutchings +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/dwc2/hcd.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/usb/dwc2/hcd.c ++++ b/drivers/usb/dwc2/hcd.c +@@ -3277,7 +3277,6 @@ static void dwc2_conn_id_status_change(s + dwc2_core_init(hsotg, false); + dwc2_enable_global_interrupts(hsotg); + spin_lock_irqsave(&hsotg->lock, flags); +- dwc2_hsotg_disconnect(hsotg); + dwc2_hsotg_core_init_disconnected(hsotg, false); + spin_unlock_irqrestore(&hsotg->lock, flags); + dwc2_hsotg_core_connect(hsotg); +@@ -3296,8 +3295,12 @@ host: + if (count > 250) + dev_err(hsotg->dev, + "Connection id status change timed out\n"); +- hsotg->op_state = OTG_STATE_A_HOST; + ++ spin_lock_irqsave(&hsotg->lock, flags); ++ dwc2_hsotg_disconnect(hsotg); ++ spin_unlock_irqrestore(&hsotg->lock, flags); ++ ++ hsotg->op_state = OTG_STATE_A_HOST; + /* Initialize the Core for Host mode */ + dwc2_core_init(hsotg, false); + dwc2_enable_global_interrupts(hsotg);