milos-linux/drivers/usb
Xu Yang 9119500436 usb: typec: tcpm: fix debug accessory mode detection for sink ports
commit f6ec9bb4ac upstream.

The port in debug accessory mode can be either a source or sink. The
previous tcpm_port_is_debug() function only checked for source port.

Commit 8db73e6a42 ("usb: typec: tcpm: allow sink (ufp) to toggle into
accessory mode debug") changed the detection logic to support both roles,
but left some logic in _tcpm_cc_change() unchanged, This causes the state
machine to transition to an incorrect state when operating as a sink in
debug accessory mode. Log as below:

[  978.637541] CC1: 0 -> 5, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
[  978.637567] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
[  978.637596] pending state change SRC_ATTACH_WAIT -> DEBUG_ACC_ATTACHED @ 180 ms [rev1 NONE_AMS]
[  978.647098] CC1: 5 -> 0, CC2: 5 -> 5 [state SRC_ATTACH_WAIT, polarity 0, connected]
[  978.647115] state change SRC_ATTACH_WAIT -> SRC_ATTACH_WAIT [rev1 NONE_AMS]

It should go to SNK_ATTACH_WAIT instead of SRC_ATTACH_WAIT state.

To fix this, add tcpm_port_is_debug_source() and tcpm_port_is_debug_sink()
helper to explicitly identify the power mode in debug accessory mode.
Update the state transition logic in _tcpm_cc_change() to ensure the state
machine transitions comply with Type-C specification. Also update the logic
in run_state_machine() to keep consistency.

Fixes: 8db73e6a42 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug")
Cc: stable <stable@kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Amit Sunil Dhamne <amitsd@google.com>
Link: https://patch.msgid.link/20260424074009.2979266-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-05-14 15:31:04 +02:00
..
atm Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
c67x00 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cdns3 usb: cdns3: gadget: fix state inconsistency on gadget init failure 2026-04-02 09:38:00 +02:00
chipidea usb: chipidea: core: allow ci_irq_handler() handle both ID and VBUS change 2026-05-07 06:13:41 +02:00
class usb: usblp: fix uninitialized heap leak via LPGETSTATUS ioctl 2026-05-14 15:31:04 +02:00
common usb: ulpi: fix memory leak on ulpi_register() error paths 2026-05-14 15:31:04 +02:00
core usb: port: add delay after usb_hub_set_port_power() 2026-04-22 13:32:18 +02:00
dwc2 usb: dwc2: gadget: Fix spin_lock/unlock mismatch in dwc2_hsotg_udc_stop() 2026-03-30 17:05:07 +02:00
dwc3 usb: dwc3: Move GUID programming after PHY initialization 2026-05-14 15:31:04 +02:00
early
fotg210 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
gadget USB: omap_udc: DMA: Don't enable burst 4 mode 2026-05-14 15:31:04 +02:00
host usb: xhci: Make usb_host_endpoint.hcpriv survive endpoint_disable() 2026-05-07 06:13:41 +02:00
image usb: image: mdc800: kill download URB on timeout 2026-02-25 10:27:01 -08:00
isp1760 Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
misc usb: misc: usbio: Fix URB memory leak on submit failure 2026-04-02 09:36:36 +02:00
mon Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
mtu3 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
musb Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
phy Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
renesas_usbhs usb: renesas_usbhs: fix use-after-free in ISR during device removal 2026-03-11 16:18:16 +01:00
roles usb: roles: get usb role switch from parent only for usb-b-connector 2026-03-11 16:22:22 +01:00
serial USB: serial: option: add Telit Cinterion LE910Cx compositions 2026-05-14 15:31:04 +02:00
storage usb: storage: Expand range of matched versions for VL817 quirks entry 2026-04-22 13:32:17 +02:00
typec usb: typec: tcpm: fix debug accessory mode detection for sink ports 2026-05-14 15:31:04 +02:00
usbip usbip: validate number_of_packets in usbip_pack_ret_submit() 2026-04-22 13:32:17 +02:00
Kconfig
Makefile
usb-skeleton.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00