build/patch/kernel/archive/sunxi-6.1/patches.megous/usb-dwc3-Track-the-power-state-of-usb3_generic_phy.patch

64 lines
1.9 KiB
Diff
Raw Normal View History

From 6e3b20f484c3da0da2ebc415d16c91f3c76ae025 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Mon, 5 Sep 2022 01:02:15 +0200
Subject: [PATCH 377/388] usb: dwc3: Track the power state of usb3_generic_phy
We will need to manage power state of this phy inisde set_mode work,
without any ability to perform recovery if power on fails, so we'll
need to track result of power on separately, to be able to balance
the phy on/off calls.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/usb/dwc3/core.c | 7 ++++++-
drivers/usb/dwc3/core.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 476b63618..5655569b5 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -844,7 +844,9 @@ static void dwc3_core_exit(struct dwc3 *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);
+ if (dwc->usb3_phy_powered)
+ phy_power_off(dwc->usb3_generic_phy);
+ dwc->usb3_phy_powered = false;
usb_phy_shutdown(dwc->usb2_phy);
usb_phy_shutdown(dwc->usb3_phy);
@@ -1176,6 +1178,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
if (ret < 0)
goto err3;
+ dwc->usb3_phy_powered = true;
+
ret = dwc3_event_buffers_setup(dwc);
if (ret) {
dev_err(dwc->dev, "failed to setup event buffers\n");
@@ -1298,6 +1302,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
err4:
phy_power_off(dwc->usb3_generic_phy);
+ dwc->usb3_phy_powered = false;
err3:
phy_power_off(dwc->usb2_generic_phy);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 8f9959ba9..189b436a9 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1159,6 +1159,7 @@ struct dwc3 {
struct phy *usb2_generic_phy;
struct phy *usb3_generic_phy;
+ bool usb3_phy_powered;
bool phys_ready;
--
2.35.3