usb: typec: tcpm: properly deliver cable vdms to altmode drivers
Subsystems (4)
PATCH 1/1 usb: typec: tcpm: properly deliver cable vdms to altmode drivers
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.
--- drivers/usb/typec/tcpm/tcpm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +8 -4
@@ -2426,17 +2426,21 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,case ADEV_NONE :break ;case ADEV_NOTIFY_USB_AND_QUEUE_VDM : -WARN_ON (typec_altmode_notify (adev,TYPEC_STATE_USB ,NULL )); -typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt); +if (rx_sop_type ==TCPC_TX_SOP_PRIME ) { +typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt); + }else { +WARN_ON (typec_altmode_notify (adev,TYPEC_STATE_USB ,NULL )); +typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt); + }break ;case ADEV_QUEUE_VDM : -if (response_tx_sop_type ==TCPC_TX_SOP_PRIME ) +if (rx_sop_type ==TCPC_TX_SOP_PRIME )typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt);else typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt);break ;case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL : -if (response_tx_sop_type ==TCPC_TX_SOP_PRIME ) { +if (rx_sop_type ==TCPC_TX_SOP_PRIME ) {if (typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt)) { int svdm_version = typec_get_cable_svdm_version(
base-commit: 956606bafb5fc6e5968aadcda86fc0037e1d7548
Signature · 1 line
2.51.0.261.g7ce5a0a67e-goog
Quoted 5 lines · RD Babiera
tcpm_handle_vdm_requestdelivers 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.
Quoted 8 lines
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 7e7877c55eb1 ("usb: typec: tcpm: add alt mode enter/exit/vdm support for sop'")Signed-off-by RD Babiera <[email protected]>Reviewed-by Badhri Jagan Sridharan <[email protected]>
Quoted 38 lines
--- drivers/usb/typec/tcpm/tcpm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/usb/typec/tcpm/tcpm.c +8
-4@@ -2426,17 +2426,21 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,case ADEV_NONE :break ;case ADEV_NOTIFY_USB_AND_QUEUE_VDM : -WARN_ON (typec_altmode_notify (adev,TYPEC_STATE_USB ,NULL )); -typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt); +if (rx_sop_type ==TCPC_TX_SOP_PRIME ) { +typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt); + }else { +WARN_ON (typec_altmode_notify (adev,TYPEC_STATE_USB ,NULL )); +typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt); + }break ;case ADEV_QUEUE_VDM : -if (response_tx_sop_type ==TCPC_TX_SOP_PRIME ) +if (rx_sop_type ==TCPC_TX_SOP_PRIME )typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt);else typec_altmode_vdm (adev, p[0 ], &p[1 ], cnt);break ;case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL : -if (response_tx_sop_type ==TCPC_TX_SOP_PRIME ) { +if (rx_sop_type ==TCPC_TX_SOP_PRIME ) {if (typec_cable_altmode_vdm (adev,TYPEC_PLUG_SOP_P , p[0 ], &p[1 ], cnt)) { int svdm_version = typec_get_cable_svdm_version(base-commit:
956606bafb5fc6e5968aadcda86fc0037e1d7548Signature · 1 line
2.51.0.261.g7ce5a0a67e-goog
Signature · 1 line
heikki