Skip to contentSkip to conversation

usb: typec: tcpm: clear pd_event queue in PORT_RESET

PATCH In review RD Babiera 2 participants 2 messages Apr 23, 2024 – Apr 25, 2024

Subsystems (4)
lore
Share & tools
lore

RD Babiera

author
#0 lore raw

PATCH 1/1 usb: typec: tcpm: clear pd_event queue in PORT_RESET

When a Fast Role Swap control message attempt results in a transition to ERROR_RECOVERY, the TCPC can still queue a TCPM_SOURCING_VBUS event.

If the event is queued but processed after the tcpm_reset_port() call in the PORT_RESET state, then the following occurs:
1. tcpm_reset_port() calls tcpm_init_vbus() to reset the vbus sourcing and sinking state
2. tcpm_pd_event_handler() turns VBUS on before the port is in the default state.
3. The port resolves as a sink. In the SNK_DISCOVERY state, tcpm_set_charge() cannot set vbus to charge.

Clear pd events within PORT_RESET to get rid of non-applicable events.

Fixes b17dd57118fe ("staging: typec: tcpm: Improve role swap with non PD capable partners")
---
 drivers/usb/typec/tcpm/tcpm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpm.c +1 -0
index c26fb70c3ec6..6dcafbaf10a2 100644
@@ -5605,6 +5605,7 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 	case PORT_RESET:
 		tcpm_reset_port(port);
+		port->pd_events = 0;
 		if (port->self_powered)
 			tcpm_set_cc(port, TYPEC_CC_OPEN);
 		else

base-commit: 684e9f5f97eb4b7831298ffad140d5c1d426ff27

Signature · 1 line
2.44.0.769.g3c40516874-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · RD Babiera

When a Fast Role Swap control message attempt results in a transition to ERROR_RECOVERY, the TCPC can still queue a TCPM_SOURCING_VBUS event.

If the event is queued but processed after the tcpm_reset_port() call in the PORT_RESET state, then the following occurs:
1. tcpm_reset_port() calls tcpm_init_vbus() to reset the vbus sourcing and sinking state
2. tcpm_pd_event_handler() turns VBUS on before the port is in the default state.
3. The port resolves as a sink. In the SNK_DISCOVERY state, tcpm_set_charge() cannot set vbus to charge.

Quoted 5 lines

Clear pd events within PORT_RESET to get rid of non-applicable events.

Fixes b17dd57118fe ("staging: typec: tcpm: Improve role swap with non PD capable partners")
Quoted 20 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpm.c +1 -0
index c26fb70c3ec6..6dcafbaf10a2 100644
@@ -5605,6 +5605,7 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 	case PORT_RESET:
 		tcpm_reset_port(port);
+		port->pd_events = 0;
 		if (port->self_powered)
 			tcpm_set_cc(port, TYPEC_CC_OPEN);
 		else

base-commit: 684e9f5f97eb4b7831298ffad140d5c1d426ff27

Signature · 1 line
2.44.0.769.g3c40516874-goog
Signature · 1 line
heikki