* [PATCH AUTOSEL 6.15 19/35] usb: dwc2: also exit clock_gating when stopping udc while suspended
[not found] <20250609134355.1341953-1-sashal@kernel.org>
@ 2025-06-09 13:43 ` Sasha Levin
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 32/35] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode Sasha Levin
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 35/35] usb: typec: mux: do not return on EOPNOTSUPP in {mux, switch}_set Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-09 13:43 UTC (permalink / raw)
To: patches, stable
Cc: Michael Grzeschik, Minas Harutyunyan, Greg Kroah-Hartman,
Sasha Levin, linux-usb
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
[ Upstream commit af076a41f8a28faf9ceb9dd2d88aef2c202ef39a ]
It is possible that the gadget will be disabled, while the udc is
suspended. When enabling the udc in that case, the clock gating
will not be enabled again. Leaving the phy unclocked. Even when the
udc is not enabled, connecting this powered but not clocked phy leads
to enumeration errors on the host side.
To ensure that the clock gating will be in an valid state, we ensure
that the clock gating will be enabled before stopping the udc.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Link: https://lore.kernel.org/r/20250417-dwc2_clock_gating-v1-1-8ea7c4d53d73@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Based on my analysis of the code, similar commits, and the context, here
is my assessment:
**YES**
This commit should be backported to stable kernel trees. Here's my
extensive analysis:
## Code Analysis
The commit adds clock gating exit logic to the `dwc2_hsotg_udc_stop()`
function in drivers/usb/dwc2/gadget.c. Specifically, it adds these lines
before shutting down endpoints:
```c
/* Exit clock gating when driver is stopped. */
if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
dwc2_gadget_exit_clock_gating(hsotg, 0);
}
```
## Rationale for Backporting
1. **Follows Established Pattern**: The code change exactly matches the
pattern used throughout the dwc2 driver in other similar contexts. I
found identical condition checks and dwc2_gadget_exit_clock_gating()
calls in:
- `drivers/usb/dwc2/platform.c:333-336` (driver removal)
- `drivers/usb/dwc2/core_intr.c:314-317` (session request interrupt)
- `drivers/usb/dwc2/core_intr.c:447-450` (wakeup detected interrupt)
- `drivers/usb/dwc2/gadget.c:3738-3741` (USB reset detect interrupt)
2. **Fixes a Real Bug**: The commit message describes a specific
hardware state issue: "Even when the udc is not enabled, connecting
this powered but not clocked phy leads to enumeration errors on the
host side." This indicates a functional problem that affects users.
3. **Low Risk, High Consistency**: The fix simply adds the same clock
gating exit pattern that already exists in 4+ other locations in the
same driver. This demonstrates it's a well-tested, safe pattern.
4. **Critical Hardware State Management**: Clock gating is a fundamental
power management feature, and incorrect state handling can cause
system hangs or hardware enumeration failures, as evidenced by the
related fix in commit 2c6b6afa59e7 which had to be marked for stable.
5. **Matches Historical Precedent**: Looking at the reference commits:
- Similar Commit #2 (YES): "usb: dwc2: gadget: Fix exiting from clock
gating" - This shows clock gating exit fixes are considered
backport-worthy
- Similar Commit #3 (YES): "usb: dwc2: do not gate off the hardware
if it does not support clock gating" - This reinforces that clock
gating correctness is critical
6. **Stable Tree Criteria Met**:
- ✅ Fixes important bug (PHY enumeration errors)
- ✅ Small and contained change (6 lines)
- ✅ No architectural changes
- ✅ Minimal regression risk (uses existing, proven pattern)
- ✅ Confined to dwc2 subsystem
7. **Recent Historical Context**: The git history shows multiple recent
clock gating fixes that were marked for stable (31f42da31417,
2c6b6afa59e7), indicating this subsystem area is actively maintained
and these types of fixes are important for stable trees.
The commit addresses a state consistency issue where the clock gating
state becomes invalid when the UDC is stopped while suspended, leading
to hardware enumeration problems. This is exactly the type of subtle but
important hardware state management bug that stable trees are designed
to fix.
drivers/usb/dwc2/gadget.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 300ea4969f0cf..f323fb5597b32 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4604,6 +4604,12 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
if (!hsotg)
return -ENODEV;
+ /* Exit clock gating when driver is stopped. */
+ if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
+ hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
+ dwc2_gadget_exit_clock_gating(hsotg, 0);
+ }
+
/* all endpoints should be shutdown */
for (ep = 1; ep < hsotg->num_of_eps; ep++) {
if (hsotg->eps_in[ep])
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 32/35] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
[not found] <20250609134355.1341953-1-sashal@kernel.org>
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 19/35] usb: dwc2: also exit clock_gating when stopping udc while suspended Sasha Levin
@ 2025-06-09 13:43 ` Sasha Levin
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 35/35] usb: typec: mux: do not return on EOPNOTSUPP in {mux, switch}_set Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-09 13:43 UTC (permalink / raw)
To: patches, stable
Cc: Jos Wang, Heikki Krogerus, Greg Kroah-Hartman, Sasha Levin,
linux-usb
From: Jos Wang <joswang@lenovo.com>
[ Upstream commit b4b38ffb38c91afd4dc387608db26f6fc34ed40b ]
Although some Type-C DRD devices that do not support the DP Sink
function (such as Huawei Mate 40Pro), the Source Port initiates
Enter Mode CMD, but the device responds to Enter Mode ACK, the
Source port then initiates DP Status Update CMD, and the device
responds to DP Status Update NAK.
As PD2.0 spec ("6.4.4.3.4 Enter Mode Command"),A DR_Swap Message
Shall Not be sent during Modal Operation between the Port Partners.
At this time, the source port initiates DR_Swap message through the
"echo device > /sys/class/typec/port0/data_role" command to switch
the data role from host to device. The device will initiate a Hard
Reset for recovery, resulting in the failure of data role swap.
Therefore, when DP Status Update NAK is received, Exit Mode CMD is
initiated to exit the currently entered DP altmode.
Signed-off-by: Jos Wang <joswang@lenovo.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250209071926.69625-1-joswang1221@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Based on my analysis of the commit and the code, here is my assessment:
**YES**
This commit should be backported to stable kernel trees. Here's my
extensive analysis:
## Code Analysis
The commit adds a simple but important fix to handle a specific NAK
response scenario in the DisplayPort alternate mode driver.
Specifically, it adds this code block:
```c
case CMDT_RSP_NAK:
switch (cmd) {
+ case DP_CMD_STATUS_UPDATE:
+ if (typec_altmode_exit(alt))
+ dev_err(&dp->alt->dev, "Exit Mode Failed!\n");
+ break;
case DP_CMD_CONFIGURE:
dp->data.conf = 0;
ret = dp_altmode_configured(dp);
break;
```
## Why This Should Be Backported
**1. Fixes a Real Hardware Compatibility Issue**
- The commit specifically addresses compatibility with devices like
"Huawei Mate 40Pro" that don't support DP Sink function
- These devices respond with NAK to DP Status Update commands, creating
a problematic state
**2. Prevents System Instability**
- According to the commit message, without this fix, attempts to perform
DR_Swap operations result in Hard Reset from the device
- This causes data role swap failures, which is a significant functional
regression
**3. Follows USB PD Specification**
- The fix aligns with PD2.0 spec section 6.4.4.3.4 which states "A
DR_Swap Message Shall Not be sent during Modal Operation"
- By exiting DP altmode when NAK is received, it allows proper DR_Swap
operation
**4. Small, Contained, Low-Risk Change**
- The change is only 4 lines of code
- It's confined to a specific error handling path (NAK response to
STATUS_UPDATE)
- Uses existing, well-tested `typec_altmode_exit()` function
- No new functionality or architectural changes
**5. Clear Bug Fix Pattern**
- Similar to commit #4 in the reference examples (which was marked YES
for backport)
- Both involve adding proper exit handling in response to specific
conditions
- Both are small, targeted fixes for real-world device compatibility
**6. Stable Tree Criteria Met**
- ✅ Fixes important bugs affecting real hardware
- ✅ Minimal risk of regression
- ✅ Doesn't introduce new features
- ✅ No architectural changes
- ✅ Confined to specific subsystem (USB Type-C DP altmode)
**7. Reference Pattern Alignment**
The commit pattern closely matches Similar Commit #4 which was marked
for backport:
- Both add exit mode handling for specific error conditions
- Both are small, targeted fixes for real device compatibility
- Both prevent system-level issues (Hard Reset in this case)
The change correctly handles an edge case where devices NAK the Status
Update command, ensuring clean exit from DP altmode to prevent
subsequent operational issues. This is exactly the type of hardware
compatibility fix that stable trees are designed to address.
drivers/usb/typec/altmodes/displayport.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index ac84a6d64c2fb..b09b58d7311de 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -393,6 +393,10 @@ static int dp_altmode_vdm(struct typec_altmode *alt,
break;
case CMDT_RSP_NAK:
switch (cmd) {
+ case DP_CMD_STATUS_UPDATE:
+ if (typec_altmode_exit(alt))
+ dev_err(&dp->alt->dev, "Exit Mode Failed!\n");
+ break;
case DP_CMD_CONFIGURE:
dp->data.conf = 0;
ret = dp_altmode_configured(dp);
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 35/35] usb: typec: mux: do not return on EOPNOTSUPP in {mux, switch}_set
[not found] <20250609134355.1341953-1-sashal@kernel.org>
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 19/35] usb: dwc2: also exit clock_gating when stopping udc while suspended Sasha Levin
2025-06-09 13:43 ` [PATCH AUTOSEL 6.15 32/35] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode Sasha Levin
@ 2025-06-09 13:43 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-09 13:43 UTC (permalink / raw)
To: patches, stable
Cc: Michael Grzeschik, Heikki Krogerus, Greg Kroah-Hartman,
Sasha Levin, linux-usb
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
[ Upstream commit 0f7bbef1794dc87141897f804e5871a293aa174b ]
Since the typec connectors can have many muxes or switches for different
lanes (sbu, usb2, usb3) going into different modal states (usb2, usb3,
audio, debug) all of them will be called on typec_switch_set and
typec_mux_set. But not all of them will be handling the expected mode.
If one of the mux or switch will come back with EOPTNOSUPP this is no
reason to stop running through the next ones. Therefor we skip this
particular error value and continue calling the next.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250404-ml-topic-typec-mux-v1-1-22c0526381ba@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
This appears to be a recent Linux kernel tree. Let me simulate what the
issue would be by looking at the original problematic code. Based on the
commit diff provided, the issue is:
**Original problematic code:**
```c
ret = sw_dev->set(sw_dev, orientation);
if (ret)
return ret;
```
**Fixed code:**
```c
ret = sw_dev->set(sw_dev, orientation);
if (ret && ret != -EOPNOTSUPP)
return ret;
```
Now I can analyze this commit properly:
**Analysis:**
**YES** - This commit should be backported to stable kernel trees.
**Detailed Analysis:**
1. **Bug Description**: The commit fixes a functional bug where multiple
USB Type-C muxes/switches connected to a single connector would fail
to be configured if any one of them returned `-EOPNOTSUPP` (Operation
Not Supported). This is a common scenario in modern Type-C connectors
that have separate muxes for different signal paths (SBU, USB2, USB3,
etc.).
2. **Specific Code Changes**:
- In `typec_switch_set()` at line 217: Changes `if (ret)` to `if (ret
&& ret != -EOPNOTSUPP)`
- In `typec_mux_set()` at line 381: Changes `if (ret)` to `if (ret &&
ret != -EOPNOTSUPP)`
3. **Problem Impact**: Before this fix, when `typec_set_orientation()`
or `typec_set_mode()` were called:
- The functions would iterate through all mux/switch devices
- If ANY mux returned `-EOPNOTSUPP` (which is legitimate - some muxes
only handle specific modes), the entire operation would fail
- This prevented other muxes that COULD handle the mode from being
configured
- Result: Type-C connectors with multiple muxes would not work
properly
4. **Risk Assessment**:
- **Very Low Risk**: The change only affects error handling logic
- **Minimal Code Change**: Only two lines changed, both adding the
same condition
- **Backward Compatible**: Does not change API or behavior for
successful cases
- **Well-Contained**: Limited to the USB Type-C mux subsystem
5. **Stable Tree Criteria Met**:
- ✅ **Important Bug Fix**: Fixes functional issues with Type-C
connectors
- ✅ **Minimal Risk**: Very small, contained change
- ✅ **No New Features**: Pure bug fix, no new functionality
- ✅ **Clear Side Effects**: No unintended side effects beyond fixing
the issue
- ✅ **Affects Users**: Type-C devices with multiple muxes (common in
modern systems) would malfunction
6. **Evidence from Mux Drivers**: The examination of actual mux drivers
like `fsa4480.c` and `gpio-sbu-mux.c` shows they legitimately return
`-EOPNOTSUPP` for unsupported modes, confirming this is expected
behavior that should not abort the entire chain.
7. **Comparison to Similar Commits**: Unlike the provided reference
commits which were mostly cleanups or minor features (all marked NO
for backport), this addresses a clear functional bug affecting real-
world hardware configurations.
This commit follows the stable tree rules perfectly: it's an important
bugfix with minimal risk that affects users with multi-mux Type-C
hardware configurations.
drivers/usb/typec/mux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 49926d6e72c71..182c902c42f61 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -214,7 +214,7 @@ int typec_switch_set(struct typec_switch *sw,
sw_dev = sw->sw_devs[i];
ret = sw_dev->set(sw_dev, orientation);
- if (ret)
+ if (ret && ret != -EOPNOTSUPP)
return ret;
}
@@ -378,7 +378,7 @@ int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
mux_dev = mux->mux_devs[i];
ret = mux_dev->set(mux_dev, state);
- if (ret)
+ if (ret && ret != -EOPNOTSUPP)
return ret;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread