patch "usb: typec: tcpm: fix create duplicate source-capabilities file" added to usb-linus
Subsystems (4)
This is a note to let you know that I've just added the patch titled
usb: typec: tcpm: fix create duplicate source-capabilities file
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From a826492fc9dfe32afd70fff93955ae8174bbf14b Mon Sep 17 00:00:00 2001
From: Xu Yang <[email protected]>
Date: Wed, 15 Feb 2023 13:49:51 +0800
Subject: usb: typec: tcpm: fix create duplicate source-capabilities file
The kernel will dump in the below cases:
sysfs: cannot create duplicate filename '/devices/virtual/usb_power_delivery/pd1/source-capabilities'
1. After soft reset has completed, an Explicit Contract negotiation occurs. The sink device will receive source capabilitys again. This will cause a duplicate source-capabilities file be created.
2. Power swap twice on a device that is initailly sink role.
This will unregister existing capabilities when above cases occurs.
--- drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +9 -0
@@ -4570,6 +4570,9 @@ static void run_state_machine(struct tcpm_port *port)case SOFT_RESET : port->message_id =0 ; port->rx_msgid =-1 ; +/* remove existing capabilities */ +usb_power_delivery_unregister_capabilities (port->partner_source_caps); + port->partner_source_caps =NULL ;tcpm_pd_send_control (port,PD_CTRL_ACCEPT );tcpm_ams_finish (port);if (port->pwr_role ==TYPEC_SOURCE ) {
@@ -4589,6 +4592,9 @@ static void run_state_machine(struct tcpm_port *port)case SOFT_RESET_SEND : port->message_id =0 ; port->rx_msgid =-1 ; +/* remove existing capabilities */ +usb_power_delivery_unregister_capabilities (port->partner_source_caps); + port->partner_source_caps =NULL ;if (tcpm_pd_send_control (port,PD_CTRL_SOFT_RESET ))tcpm_set_state_cond (port,hard_reset_state (port),0 );else
@@ -4718,6 +4724,9 @@ static void run_state_machine(struct tcpm_port *port)tcpm_set_state (port,SNK_STARTUP ,0 );break ;case PR_SWAP_SNK_SRC_SINK_OFF : +/* will be source, remove existing capabilities */ +usb_power_delivery_unregister_capabilities (port->partner_source_caps); + port->partner_source_caps =NULL ;/* * Prevent vbus discharge circuit from turning on during PR_SWAP * as this is not a disconnect.
Signature · 1 line
2.39.2