Skip to contentSkip to conversation

FAILED: patch "[PATCH] usb: typec: tcpm: Fix altmode re-registration causes sysfs" failed to apply to 5.10-stable tree

PATCH [email protected] 1 participant 1 message Jan 22, 2023

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Possible dependencies:

36f78477ac2c ("usb: typec: tcpm: Fix altmode re-registration causes sysfs create fail") ef52b4a9fcc2 ("usb: typec: tcpm: Raise vdm_sm_running flag only when VDM SM is running") 5571ea3117ca ("usb: typec: tcpm: Fix VDMs sometimes not being forwarded to alt-mode drivers") 2b537cf877ea ("usb: typec: tcpm: Relax disconnect threshold during power negotiation") c34e85fa69b9 ("usb: typec: tcpm: Send DISCOVER_IDENTITY from dedicated work") e00943e91678 ("usb: typec: tcpm: PD3.0 sinks can send Discover Identity even in device mode") 5e1d4c49fbc8 ("usb: typec: tcpm: Determine common SVDM Version")
31737c27d665 ("usb: pd: Make SVDM Version configurable in VDM header") 8d3a0578ad1a ("usb: typec: tcpm: Respond Wait if VDM state machine is running") 8dea75e11380 ("usb: typec: tcpm: Protocol Error handling")
0908c5aca31e ("usb: typec: tcpm: AMS and Collision Avoidance")
60e998d1c6d9 ("USB: typec: tcpm: Hard Reset after not receiving a Request") 3bac42f02d41 ("usb: typec: tcpm: Clear send_discover in tcpm_check_send_discover") f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support") a30a00e37ceb ("usb: typec: tcpm: frs sourcing vbus callback")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 36f78477ac2c89e9a2eed4a31404a291a3450b5d Mon Sep 17 00:00:00 2001
From: ChiYuan Huang <[email protected]>
Date: Mon, 9 Jan 2023 15:19:50 +0800
Subject: [PATCH] usb: typec: tcpm: Fix altmode re-registration causes sysfs
create fail

There's the altmode re-registeration issue after data role swap (DR_SWAP).

Comparing to USBPD 2.0, in USBPD 3.0, it loose the limit that only DFP can initiate the VDM command to get partner identity information.

For a USBPD 3.0 UFP device, it may already get the identity information from its port partner before DR_SWAP. If DR_SWAP send or receive at the mean time, 'send_discover' flag will be raised again. It causes discover identify action restart while entering ready state. And after all discover actions are done, the 'tcpm_register_altmodes' will be called. If old altmode is not unregistered, this sysfs create fail can be found.

In 'DR_SWAP_CHANGE_DR' state case, only DFP will unregister altmodes. For UFP, the original altmodes keep registered.

This patch fix the logic that after DR_SWAP, 'tcpm_unregister_altmodes' must be called whatever the current data role is.

drivers/usb/typec/tcpm/tcpm.c +3 -4
index 904c7b4ce2f0..59b366b5c614 100644
@@ -4594,14 +4594,13 @@ static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_state(port, ready_state(port), 0);
 		break;
 	case DR_SWAP_CHANGE_DR:
-		if (port->data_role == TYPEC_HOST) {
-			tcpm_unregister_altmodes(port);
+		tcpm_unregister_altmodes(port);
+		if (port->data_role == TYPEC_HOST)
 			tcpm_set_roles(port, true, port->pwr_role,
 				       TYPEC_DEVICE);
-		} else {
+		else
 			tcpm_set_roles(port, true, port->pwr_role,
 				       TYPEC_HOST);
-		}
 		tcpm_ams_finish(port);
 		tcpm_set_state(port, ready_state(port), 0);
 		break;