Revert "usb: typec: tcpm: clear pd_event queue in PORT_RESET"
PATCH 1/1 Revert "usb: typec: tcpm: clear pd_event queue in PORT_RESET"
This reverts commit bf20c69cf3cf9c6445c4925dd9a8a6ca1b78bfdf.
During tcpm_init() stage, if the VBUS is still present after tcpm_reset_port(), then we assume that VBUS will off and goto safe0v after a specific discharge time. Following a TCPM_VBUS_EVENT event if VBUS reach to off state. TCPM_VBUS_EVENT event may be set during PORT_RESET handling stage. If pd_events reset to 0 after TCPM_VBUS_EVENT set, we will lost this VBUS event. Then the port state machine may stuck at one state.
Before:
[ 2.570172] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS] [ 2.570179] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms] [ 2.570182] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS] [ 3.490213] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [delayed 920 ms] [ 3.490220] Start toggling [ 3.546050] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected] [ 3.546057] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
After revert this patch, we can see VBUS off event and the port will goto expected state.
[ 2.441992] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS] [ 2.441999] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms] [ 2.442002] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS] [ 2.442122] VBUS off [ 2.442125] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev1 NONE_AMS] [ 2.442127] VBUS VSAFE0V [ 2.442351] CC1: 0 -> 0, CC2: 0 -> 0 [state SNK_UNATTACHED, polarity 0, disconnected] [ 2.442357] Start toggling [ 2.491850] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected] [ 2.491858] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS] [ 2.491863] pending state change SRC_ATTACH_WAIT -> SNK_TRY @ 200 ms [rev1 NONE_AMS] [ 2.691905] state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms]
--- drivers/usb/typec/tcpm/tcpm.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +0 -1
@@ -5655,7 +5655,6 @@ 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
Signature · 1 line
2.34.1
Quoted 36 lines · Xu Yang
This reverts commit
bf20c69cf3cf9c6445c4925dd9a8a6ca1b78bfdf.During
tcpm_init()stage, if the VBUS is still present aftertcpm_reset_port(), then we assume that VBUS will off and goto safe0v after a specific discharge time. Following aTCPM_VBUS_EVENTevent if VBUS reach to off state.TCPM_VBUS_EVENTevent may be set duringPORT_RESEThandling stage. Ifpd_eventsreset to 0 afterTCPM_VBUS_EVENTset, we will lost this VBUS event. Then the port state machine may stuck at one state.Before:
[ 2.570172] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS] [ 2.570179] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms] [ 2.570182] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS] [ 3.490213] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [delayed 920 ms] [ 3.490220] Start toggling [ 3.546050] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected] [ 3.546057] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]After revert this patch, we can see VBUS off event and the port will goto expected state.
[ 2.441992] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS] [ 2.441999] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms] [ 2.442002] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS] [ 2.442122] VBUS off [ 2.442125] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev1 NONE_AMS] [ 2.442127] VBUS VSAFE0V [ 2.442351] CC1: 0 -> 0, CC2: 0 -> 0 [state SNK_UNATTACHED, polarity 0, disconnected] [ 2.442357] Start toggling [ 2.491850] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected] [ 2.491858] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS] [ 2.491863] pending state change SRC_ATTACH_WAIT -> SNK_TRY @ 200 ms [rev1 NONE_AMS] [ 2.691905] state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms]
Quoted 3 lines
Fixes bf20c69cf3cf ("usb: typec: tcpm: clear pd_event queue in PORT_RESET")Signed-off-by Xu Yang <[email protected]>
Quoted 18 lines
--- drivers/usb/typec/tcpm/tcpm.c | 1 - 1 file changed, 1 deletion(-)drivers/usb/typec/tcpm/tcpm.c +0
-1@@ -5655,7 +5655,6 @@ 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 Signature · 1 line
2.34.1
Signature · 1 line
heikki