.. | .. |
---|
1447 | 1447 | static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, |
---|
1448 | 1448 | const u32 *data, int cnt) |
---|
1449 | 1449 | { |
---|
| 1450 | + u32 vdo_hdr = port->vdo_data[0]; |
---|
| 1451 | + |
---|
1450 | 1452 | WARN_ON(!mutex_is_locked(&port->lock)); |
---|
1451 | 1453 | |
---|
1452 | | - /* Make sure we are not still processing a previous VDM packet */ |
---|
1453 | | - WARN_ON(port->vdm_state > VDM_STATE_DONE); |
---|
| 1454 | + /* If is sending discover_identity, handle received message first */ |
---|
| 1455 | + if (PD_VDO_SVDM(vdo_hdr) && PD_VDO_CMD(vdo_hdr) == CMD_DISCOVER_IDENT) { |
---|
| 1456 | + port->send_discover = true; |
---|
| 1457 | + mod_send_discover_delayed_work(port, SEND_DISCOVER_RETRY_MS); |
---|
| 1458 | + } else { |
---|
| 1459 | + /* Make sure we are not still processing a previous VDM packet */ |
---|
| 1460 | + WARN_ON(port->vdm_state > VDM_STATE_DONE); |
---|
| 1461 | + } |
---|
1454 | 1462 | |
---|
1455 | 1463 | port->vdo_count = cnt + 1; |
---|
1456 | 1464 | port->vdo_data[0] = header; |
---|
.. | .. |
---|
1540 | 1548 | * 0x0000 in the last VDO, so we need to break the Discover SVIDs |
---|
1541 | 1549 | * request and return false here. |
---|
1542 | 1550 | */ |
---|
1543 | | - return cnt == 7 ? true : false; |
---|
| 1551 | + return cnt == 7; |
---|
1544 | 1552 | abort: |
---|
1545 | 1553 | tcpm_log(port, "SVID_DISCOVERY_MAX(%d) too low!", SVID_DISCOVERY_MAX); |
---|
1546 | 1554 | return false; |
---|
.. | .. |
---|
1901 | 1909 | } |
---|
1902 | 1910 | break; |
---|
1903 | 1911 | case ADEV_ATTENTION: |
---|
1904 | | - typec_altmode_attention(adev, p[1]); |
---|
| 1912 | + if (typec_altmode_attention(adev, p[1])) |
---|
| 1913 | + tcpm_log(port, "typec_altmode_attention no port partner altmode"); |
---|
1905 | 1914 | break; |
---|
1906 | 1915 | } |
---|
1907 | 1916 | } |
---|
.. | .. |
---|
1994 | 2003 | switch (PD_VDO_CMD(vdo_hdr)) { |
---|
1995 | 2004 | case CMD_DISCOVER_IDENT: |
---|
1996 | 2005 | res = tcpm_ams_start(port, DISCOVER_IDENTITY); |
---|
1997 | | - if (res == 0) |
---|
| 2006 | + if (res == 0) { |
---|
1998 | 2007 | port->send_discover = false; |
---|
1999 | | - else if (res == -EAGAIN) |
---|
| 2008 | + } else if (res == -EAGAIN) { |
---|
| 2009 | + port->vdo_data[0] = 0; |
---|
2000 | 2010 | mod_send_discover_delayed_work(port, |
---|
2001 | 2011 | SEND_DISCOVER_RETRY_MS); |
---|
| 2012 | + } |
---|
2002 | 2013 | break; |
---|
2003 | 2014 | case CMD_DISCOVER_SVID: |
---|
2004 | 2015 | res = tcpm_ams_start(port, DISCOVER_SVIDS); |
---|
.. | .. |
---|
2081 | 2092 | unsigned long timeout; |
---|
2082 | 2093 | |
---|
2083 | 2094 | port->vdm_retries = 0; |
---|
| 2095 | + port->vdo_data[0] = 0; |
---|
2084 | 2096 | port->vdm_state = VDM_STATE_BUSY; |
---|
2085 | 2097 | timeout = vdm_ready_timeout(vdo_hdr); |
---|
2086 | 2098 | mod_vdm_delayed_work(port, timeout); |
---|