Skip to content

Commit f1fbd95

Browse files
kyletsoadlgregkh
authored andcommitted
usb: typec: tcpm: Fix wrong handling for Not_Supported in VDM AMS
Not_Supported Message is acceptable in VDM AMS. Redirect the VDM state machine to VDM_STATE_DONE when receiving Not_Supported and finish the VDM AMS. Also, after the loop in vdm_state_machine_work, add more conditions of VDM states to clear the vdm_sm_running flag because those are all stopping states when leaving the loop. In addition, finish the VDM AMS if the port partner responds BUSY. Fixes: 8dea75e ("usb: typec: tcpm: Protocol Error handling") Fixes: 8d3a057 ("usb: typec: tcpm: Respond Wait if VDM state machine is running") Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Kyle Tso <kyletso@google.com> Link: https://lore.kernel.org/r/20210507062300.1945009-3-kyletso@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c34e85f commit f1fbd95

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,6 @@ static void vdm_run_state_machine(struct tcpm_port *port)
18971897

18981898
if (res < 0) {
18991899
port->vdm_state = VDM_STATE_ERR_BUSY;
1900-
port->vdm_sm_running = false;
19011900
return;
19021901
}
19031902
}
@@ -1913,6 +1912,7 @@ static void vdm_run_state_machine(struct tcpm_port *port)
19131912
port->vdo_data[0] = port->vdo_retry;
19141913
port->vdo_count = 1;
19151914
port->vdm_state = VDM_STATE_READY;
1915+
tcpm_ams_finish(port);
19161916
break;
19171917
case VDM_STATE_BUSY:
19181918
port->vdm_state = VDM_STATE_ERR_TMOUT;
@@ -1978,7 +1978,7 @@ static void vdm_state_machine_work(struct kthread_work *work)
19781978
port->vdm_state != VDM_STATE_BUSY &&
19791979
port->vdm_state != VDM_STATE_SEND_MESSAGE);
19801980

1981-
if (port->vdm_state == VDM_STATE_ERR_TMOUT)
1981+
if (port->vdm_state < VDM_STATE_READY)
19821982
port->vdm_sm_running = false;
19831983

19841984
mutex_unlock(&port->lock);
@@ -2569,6 +2569,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
25692569
port->sink_cap_done = true;
25702570
tcpm_set_state(port, ready_state(port), 0);
25712571
break;
2572+
case SRC_READY:
2573+
case SNK_READY:
2574+
if (port->vdm_state > VDM_STATE_READY) {
2575+
port->vdm_state = VDM_STATE_DONE;
2576+
if (tcpm_vdm_ams(port))
2577+
tcpm_ams_finish(port);
2578+
mod_vdm_delayed_work(port, 0);
2579+
break;
2580+
}
2581+
fallthrough;
25722582
default:
25732583
tcpm_pd_handle_state(port,
25742584
port->pwr_role == TYPEC_SOURCE ?

0 commit comments

Comments
 (0)