1 From f2865c6300d75a9f187dd7918d248e010970fd44 Mon Sep 17 00:00:00 2001
2 From: Amit Sunil Dhamne <amitsd@google.com>
3 Date: Mon, 10 Mar 2025 19:19:07 -0700
4 Subject: usb: typec: tcpm: fix state transition for SNK_WAIT_CAPABILITIES state in run_state_machine()
6 From: Amit Sunil Dhamne <amitsd@google.com>
8 commit f2865c6300d75a9f187dd7918d248e010970fd44 upstream.
10 A subtle error got introduced while manually fixing merge conflict in
11 tcpm.c for commit 85c4efbe6088 ("Merge v6.12-rc6 into usb-next"). As a
12 result of this error, the next state is unconditionally set to
13 SNK_WAIT_CAPABILITIES_TIMEOUT while handling SNK_WAIT_CAPABILITIES state
14 in run_state_machine(...).
16 Fix this by setting new state of TCPM state machine to `upcoming_state`
17 (that is set to different values based on conditions).
19 Cc: stable@vger.kernel.org
20 Fixes: 85c4efbe60888 ("Merge v6.12-rc6 into usb-next")
21 Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
22 Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
23 Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
24 Link: https://lore.kernel.org/r/20250310-fix-snk-wait-timeout-v6-14-rc6-v1-1-5db14475798f@google.com
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 drivers/usb/typec/tcpm/tcpm.c | 8 ++++----
28 1 file changed, 4 insertions(+), 4 deletions(-)
30 --- a/drivers/usb/typec/tcpm/tcpm.c
31 +++ b/drivers/usb/typec/tcpm/tcpm.c
32 @@ -5067,16 +5067,16 @@ static void run_state_machine(struct tcp
34 if (port->vbus_never_low) {
35 port->vbus_never_low = false;
36 - tcpm_set_state(port, SNK_SOFT_RESET,
37 - port->timings.sink_wait_cap_time);
38 + upcoming_state = SNK_SOFT_RESET;
40 if (!port->self_powered)
41 upcoming_state = SNK_WAIT_CAPABILITIES_TIMEOUT;
43 upcoming_state = hard_reset_state(port);
44 - tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT,
45 - port->timings.sink_wait_cap_time);
48 + tcpm_set_state(port, upcoming_state,
49 + port->timings.sink_wait_cap_time);
51 case SNK_WAIT_CAPABILITIES_TIMEOUT: