From 26910b2b4e427f956ad1469e5af808a832cb8c94 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 6 Sep 2022 13:22:53 +0200 Subject: [PATCH] 5.19-stable patches added patches: usb-dwc3-disable-usb-core-phy-management.patch usb-dwc3-fix-phy-disable-sequence.patch usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch --- queue-5.19/series | 3 + ...dwc3-disable-usb-core-phy-management.patch | 57 ++++++++++++++ .../usb-dwc3-fix-phy-disable-sequence.patch | 78 +++++++++++++++++++ ...uplicate-requests-to-enable-run-stop.patch | 51 ++++++++++++ 4 files changed, 189 insertions(+) create mode 100644 queue-5.19/usb-dwc3-disable-usb-core-phy-management.patch create mode 100644 queue-5.19/usb-dwc3-fix-phy-disable-sequence.patch create mode 100644 queue-5.19/usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch diff --git a/queue-5.19/series b/queue-5.19/series index 78abf7bf891..1103bec953a 100644 --- a/queue-5.19/series +++ b/queue-5.19/series @@ -107,3 +107,6 @@ thunderbolt-check-router-generation-before-connecting-xhci.patch usb-dwc3-pci-add-support-for-intel-raptor-lake.patch media-mceusb-use-new-usb_control_msg_-routines.patch xhci-add-grace-period-after-xhc-start-to-prevent-premature-runtime-suspend.patch +usb-dwc3-disable-usb-core-phy-management.patch +usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch +usb-dwc3-fix-phy-disable-sequence.patch diff --git a/queue-5.19/usb-dwc3-disable-usb-core-phy-management.patch b/queue-5.19/usb-dwc3-disable-usb-core-phy-management.patch new file mode 100644 index 00000000000..ea3950d49c5 --- /dev/null +++ b/queue-5.19/usb-dwc3-disable-usb-core-phy-management.patch @@ -0,0 +1,57 @@ +From 6000b8d900cd5f52fbcd0776d0cc396e88c8c2ea Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 25 Aug 2022 15:18:36 +0200 +Subject: usb: dwc3: disable USB core PHY management + +From: Johan Hovold + +commit 6000b8d900cd5f52fbcd0776d0cc396e88c8c2ea upstream. + +The dwc3 driver manages its PHYs itself so the USB core PHY management +needs to be disabled. + +Use the struct xhci_plat_priv hack added by commits 46034a999c07 ("usb: +host: xhci-plat: add platform data support") and f768e718911e ("usb: +host: xhci-plat: add priv quirk for skip PHY initialization") to +propagate the setting for now. + +Fixes: 4e88d4c08301 ("usb: add a flag to skip PHY initialization to struct usb_hcd") +Fixes: 178a0bce05cb ("usb: core: hcd: integrate the PHY wrapper into the HCD core") +Tested-by: Matthias Kaehlcke +Cc: stable +Reviewed-by: Matthias Kaehlcke +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20220825131836.19769-1-johan+linaro@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/host.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/usb/dwc3/host.c ++++ b/drivers/usb/dwc3/host.c +@@ -11,8 +11,13 @@ + #include + #include + ++#include "../host/xhci-plat.h" + #include "core.h" + ++static const struct xhci_plat_priv dwc3_xhci_plat_priv = { ++ .quirks = XHCI_SKIP_PHY_INIT, ++}; ++ + static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, + int irq, char *name) + { +@@ -92,6 +97,11 @@ int dwc3_host_init(struct dwc3 *dwc) + goto err; + } + ++ ret = platform_device_add_data(xhci, &dwc3_xhci_plat_priv, ++ sizeof(dwc3_xhci_plat_priv)); ++ if (ret) ++ goto err; ++ + memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props)); + + if (dwc->usb3_lpm_capable) diff --git a/queue-5.19/usb-dwc3-fix-phy-disable-sequence.patch b/queue-5.19/usb-dwc3-fix-phy-disable-sequence.patch new file mode 100644 index 00000000000..f2db226b7f6 --- /dev/null +++ b/queue-5.19/usb-dwc3-fix-phy-disable-sequence.patch @@ -0,0 +1,78 @@ +From d2ac7bef95c9ead307801ccb6cb6dfbeb14247bf Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 4 Aug 2022 17:09:53 +0200 +Subject: usb: dwc3: fix PHY disable sequence + +From: Johan Hovold + +commit d2ac7bef95c9ead307801ccb6cb6dfbeb14247bf upstream. + +Generic PHYs must be powered-off before they can be tore down. + +Similarly, suspending legacy PHYs after having powered them off makes no +sense. + +Fix the dwc3_core_exit() (e.g. called during suspend) and open-coded +dwc3_probe() error-path sequences that got this wrong. + +Note that this makes dwc3_core_exit() match the dwc3_core_init() error +path with respect to powering off the PHYs. + +Fixes: 03c1fd622f72 ("usb: dwc3: core: add phy cleanup for probe error handling") +Fixes: c499ff71ff2a ("usb: dwc3: core: re-factor init and exit paths") +Cc: stable@vger.kernel.org # 4.8 +Reviewed-by: Andrew Halaney +Reviewed-by: Matthias Kaehlcke +Reviewed-by: Manivannan Sadhasivam +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20220804151001.23612-2-johan+linaro@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/core.c | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -833,15 +833,16 @@ static void dwc3_core_exit(struct dwc3 * + { + dwc3_event_buffers_cleanup(dwc); + ++ usb_phy_set_suspend(dwc->usb2_phy, 1); ++ usb_phy_set_suspend(dwc->usb3_phy, 1); ++ phy_power_off(dwc->usb2_generic_phy); ++ phy_power_off(dwc->usb3_generic_phy); ++ + usb_phy_shutdown(dwc->usb2_phy); + usb_phy_shutdown(dwc->usb3_phy); + phy_exit(dwc->usb2_generic_phy); + phy_exit(dwc->usb3_generic_phy); + +- usb_phy_set_suspend(dwc->usb2_phy, 1); +- usb_phy_set_suspend(dwc->usb3_phy, 1); +- phy_power_off(dwc->usb2_generic_phy); +- phy_power_off(dwc->usb3_generic_phy); + dwc3_clk_disable(dwc); + reset_control_assert(dwc->reset); + } +@@ -1844,16 +1845,16 @@ err5: + dwc3_debugfs_exit(dwc); + dwc3_event_buffers_cleanup(dwc); + +- usb_phy_shutdown(dwc->usb2_phy); +- usb_phy_shutdown(dwc->usb3_phy); +- phy_exit(dwc->usb2_generic_phy); +- phy_exit(dwc->usb3_generic_phy); +- + usb_phy_set_suspend(dwc->usb2_phy, 1); + usb_phy_set_suspend(dwc->usb3_phy, 1); + phy_power_off(dwc->usb2_generic_phy); + phy_power_off(dwc->usb3_generic_phy); + ++ usb_phy_shutdown(dwc->usb2_phy); ++ usb_phy_shutdown(dwc->usb3_phy); ++ phy_exit(dwc->usb2_generic_phy); ++ phy_exit(dwc->usb3_generic_phy); ++ + dwc3_ulpi_exit(dwc); + + err4: diff --git a/queue-5.19/usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch b/queue-5.19/usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch new file mode 100644 index 00000000000..ca5d9665c27 --- /dev/null +++ b/queue-5.19/usb-dwc3-gadget-avoid-duplicate-requests-to-enable-run-stop.patch @@ -0,0 +1,51 @@ +From 040f2dbd2010c43f33ad27249e6dac48456f4d99 Mon Sep 17 00:00:00 2001 +From: Wesley Cheng +Date: Wed, 27 Jul 2022 19:06:47 -0700 +Subject: usb: dwc3: gadget: Avoid duplicate requests to enable Run/Stop + +From: Wesley Cheng + +commit 040f2dbd2010c43f33ad27249e6dac48456f4d99 upstream. + +Relocate the pullups_connected check until after it is ensured that there +are no runtime PM transitions. If another context triggered the DWC3 +core's runtime resume, it may have already enabled the Run/Stop. Do not +re-run the entire pullup sequence again, as it may issue a core soft +reset while Run/Stop is already set. + +This patch depends on + commit 69e131d1ac4e ("usb: dwc3: gadget: Prevent repeat pullup()") + +Fixes: 77adb8bdf422 ("usb: dwc3: gadget: Allow runtime suspend if UDC unbinded") +Cc: stable +Signed-off-by: Wesley Cheng +Link: https://lore.kernel.org/r/20220728020647.9377-1-quic_wcheng@quicinc.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/gadget.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -2538,9 +2538,6 @@ static int dwc3_gadget_pullup(struct usb + + is_on = !!is_on; + +- if (dwc->pullups_connected == is_on) +- return 0; +- + dwc->softconnect = is_on; + + /* +@@ -2564,6 +2561,11 @@ static int dwc3_gadget_pullup(struct usb + pm_runtime_put(dwc->dev); + return 0; + } ++ ++ if (dwc->pullups_connected == is_on) { ++ pm_runtime_put(dwc->dev); ++ return 0; ++ } + + if (!is_on) { + ret = dwc3_gadget_soft_disconnect(dwc); -- 2.47.3