@@ -1445,10 +1445,18 @@ static int tcpm_ams_start(struct tcpm_port *port, enum tcpm_ams ams)
1445
1445
static void tcpm_queue_vdm (struct tcpm_port * port , const u32 header ,
1446
1446
const u32 * data , int cnt )
1447
1447
{
1448
+ u32 vdo_hdr = port -> vdo_data [0 ];
1449
+
1448
1450
WARN_ON (!mutex_is_locked (& port -> lock ));
1449
1451
1450
- /* Make sure we are not still processing a previous VDM packet */
1451
- WARN_ON (port -> vdm_state > VDM_STATE_DONE );
1452
+ /* If is sending discover_identity, handle received message first */
1453
+ if (PD_VDO_SVDM (vdo_hdr ) && PD_VDO_CMD (vdo_hdr ) == CMD_DISCOVER_IDENT ) {
1454
+ port -> send_discover = true;
1455
+ mod_send_discover_delayed_work (port , SEND_DISCOVER_RETRY_MS );
1456
+ } else {
1457
+ /* Make sure we are not still processing a previous VDM packet */
1458
+ WARN_ON (port -> vdm_state > VDM_STATE_DONE );
1459
+ }
1452
1460
1453
1461
port -> vdo_count = cnt + 1 ;
1454
1462
port -> vdo_data [0 ] = header ;
@@ -1948,11 +1956,13 @@ static void vdm_run_state_machine(struct tcpm_port *port)
1948
1956
switch (PD_VDO_CMD (vdo_hdr )) {
1949
1957
case CMD_DISCOVER_IDENT :
1950
1958
res = tcpm_ams_start (port , DISCOVER_IDENTITY );
1951
- if (res == 0 )
1959
+ if (res == 0 ) {
1952
1960
port -> send_discover = false;
1953
- else if (res == - EAGAIN )
1961
+ } else if (res == - EAGAIN ) {
1962
+ port -> vdo_data [0 ] = 0 ;
1954
1963
mod_send_discover_delayed_work (port ,
1955
1964
SEND_DISCOVER_RETRY_MS );
1965
+ }
1956
1966
break ;
1957
1967
case CMD_DISCOVER_SVID :
1958
1968
res = tcpm_ams_start (port , DISCOVER_SVIDS );
@@ -2035,6 +2045,7 @@ static void vdm_run_state_machine(struct tcpm_port *port)
2035
2045
unsigned long timeout ;
2036
2046
2037
2047
port -> vdm_retries = 0 ;
2048
+ port -> vdo_data [0 ] = 0 ;
2038
2049
port -> vdm_state = VDM_STATE_BUSY ;
2039
2050
timeout = vdm_ready_timeout (vdo_hdr );
2040
2051
mod_vdm_delayed_work (port , timeout );
0 commit comments