hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/usb/typec/tcpm/tcpm.c
....@@ -1447,10 +1447,18 @@
14471447 static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header,
14481448 const u32 *data, int cnt)
14491449 {
1450
+ u32 vdo_hdr = port->vdo_data[0];
1451
+
14501452 WARN_ON(!mutex_is_locked(&port->lock));
14511453
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
+ }
14541462
14551463 port->vdo_count = cnt + 1;
14561464 port->vdo_data[0] = header;
....@@ -1540,7 +1548,7 @@
15401548 * 0x0000 in the last VDO, so we need to break the Discover SVIDs
15411549 * request and return false here.
15421550 */
1543
- return cnt == 7 ? true : false;
1551
+ return cnt == 7;
15441552 abort:
15451553 tcpm_log(port, "SVID_DISCOVERY_MAX(%d) too low!", SVID_DISCOVERY_MAX);
15461554 return false;
....@@ -1901,7 +1909,8 @@
19011909 }
19021910 break;
19031911 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");
19051914 break;
19061915 }
19071916 }
....@@ -1994,11 +2003,13 @@
19942003 switch (PD_VDO_CMD(vdo_hdr)) {
19952004 case CMD_DISCOVER_IDENT:
19962005 res = tcpm_ams_start(port, DISCOVER_IDENTITY);
1997
- if (res == 0)
2006
+ if (res == 0) {
19982007 port->send_discover = false;
1999
- else if (res == -EAGAIN)
2008
+ } else if (res == -EAGAIN) {
2009
+ port->vdo_data[0] = 0;
20002010 mod_send_discover_delayed_work(port,
20012011 SEND_DISCOVER_RETRY_MS);
2012
+ }
20022013 break;
20032014 case CMD_DISCOVER_SVID:
20042015 res = tcpm_ams_start(port, DISCOVER_SVIDS);
....@@ -2081,6 +2092,7 @@
20812092 unsigned long timeout;
20822093
20832094 port->vdm_retries = 0;
2095
+ port->vdo_data[0] = 0;
20842096 port->vdm_state = VDM_STATE_BUSY;
20852097 timeout = vdm_ready_timeout(vdo_hdr);
20862098 mod_vdm_delayed_work(port, timeout);