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 a2a1baabca933..35d7a4d40d9a4 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -288,6 +288,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);