Skip to content

Commit edfa1f2

Browse files
RD Babieragregkh
authored andcommitted
usb: typec: tcpm: properly deliver cable vdms to altmode drivers
commit f34bfcc upstream. tcpm_handle_vdm_request delivers messages to the partner altmode or the cable altmode depending on the SVDM response type, which is incorrect. The partner or cable should be chosen based on the received message type instead. Also add this filter to ADEV_NOTIFY_USB_AND_QUEUE_VDM, which is used when the Enter Mode command is responded to by a NAK on SOP or SOP' and when the Exit Mode command is responded to by an ACK on SOP. Fixes: 7e7877c ("usb: typec: tcpm: add alt mode enter/exit/vdm support for sop'") Cc: stable@vger.kernel.org Signed-off-by: RD Babiera <rdbabiera@google.com> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20250821203759.1720841-2-rdbabiera@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2d10b29 commit edfa1f2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,17 +2375,21 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
23752375
case ADEV_NONE:
23762376
break;
23772377
case ADEV_NOTIFY_USB_AND_QUEUE_VDM:
2378-
WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL));
2379-
typec_altmode_vdm(adev, p[0], &p[1], cnt);
2378+
if (rx_sop_type == TCPC_TX_SOP_PRIME) {
2379+
typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt);
2380+
} else {
2381+
WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL));
2382+
typec_altmode_vdm(adev, p[0], &p[1], cnt);
2383+
}
23802384
break;
23812385
case ADEV_QUEUE_VDM:
2382-
if (response_tx_sop_type == TCPC_TX_SOP_PRIME)
2386+
if (rx_sop_type == TCPC_TX_SOP_PRIME)
23832387
typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt);
23842388
else
23852389
typec_altmode_vdm(adev, p[0], &p[1], cnt);
23862390
break;
23872391
case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL:
2388-
if (response_tx_sop_type == TCPC_TX_SOP_PRIME) {
2392+
if (rx_sop_type == TCPC_TX_SOP_PRIME) {
23892393
if (typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P,
23902394
p[0], &p[1], cnt)) {
23912395
int svdm_version = typec_get_cable_svdm_version(

0 commit comments

Comments
 (0)