* patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing
@ 2023-02-14 13:43 gregkh
2023-02-15 5:45 ` [EXT] " Xu Yang
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2023-02-14 13:43 UTC (permalink / raw)
To: xu.yang_2, gregkh, heikki.krogerus, linux, stable
This is a note to let you know that I've just added the patch titled
usb: typec: tcpm: fix create duplicate source/sink-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-testing 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 be merged to the usb-next branch sometime soon,
after it passes testing, and the merge window is open.
If you have any questions about this process, please let me know.
From f430e60b78c6359ba4cb4e521d7df7f9a0484e03 Mon Sep 17 00:00:00 2001
From: Xu Yang <xu.yang_2@nxp.com>
Date: Tue, 14 Feb 2023 14:56:35 +0800
Subject: usb: typec: tcpm: fix create duplicate source/sink-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.
Fixes: 8203d26905ee ("usb: typec: tcpm: Register USB Power Delivery Capabilities")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230214065635.972698-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/typec/tcpm/tcpm.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index a0d943d78580..7d8c53d96c3b 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4570,6 +4570,8 @@ 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);
tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
tcpm_ams_finish(port);
if (port->pwr_role == TYPEC_SOURCE) {
@@ -4589,6 +4591,8 @@ 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);
if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
tcpm_set_state_cond(port, hard_reset_state(port), 0);
else
@@ -4718,6 +4722,8 @@ 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);
/*
* Prevent vbus discharge circuit from turning on during PR_SWAP
* as this is not a disconnect.
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [EXT] patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing
2023-02-14 13:43 patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing gregkh
@ 2023-02-15 5:45 ` Xu Yang
2023-02-15 6:52 ` gregkh
0 siblings, 1 reply; 3+ messages in thread
From: Xu Yang @ 2023-02-15 5:45 UTC (permalink / raw)
To: gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com,
linux@roeck-us.net
Cc: stable@vger.kernel.org
Just noticed that port->partner_source_caps should also be reset to NULL.
I'll send a V4 for this soon.
Best Regards,
Xu Yang
> -----Original Message-----
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: Tuesday, February 14, 2023 9:44 PM
> To: Xu Yang <xu.yang_2@nxp.com>; gregkh@linuxfoundation.org; heikki.krogerus@linux.intel.com; linux@roeck-us.net;
> stable@vger.kernel.org
> Subject: [EXT] patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing
>
> Caution: EXT Email
>
> This is a note to let you know that I've just added the patch titled
>
> usb: typec: tcpm: fix create duplicate source/sink-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-testing 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 be merged to the usb-next branch sometime soon,
> after it passes testing, and the merge window is open.
>
> If you have any questions about this process, please let me know.
>
>
> From f430e60b78c6359ba4cb4e521d7df7f9a0484e03 Mon Sep 17 00:00:00 2001
> From: Xu Yang <xu.yang_2@nxp.com>
> Date: Tue, 14 Feb 2023 14:56:35 +0800
> Subject: usb: typec: tcpm: fix create duplicate source/sink-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.
>
> Fixes: 8203d26905ee ("usb: typec: tcpm: Register USB Power Delivery Capabilities")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Link:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fr%2F20230214065635.972698-1-
> xu.yang_2%40nxp.com&data=05%7C01%7Cxu.yang_2%40nxp.com%7C0a677a0f0f744fdba90608db0e918880%7C686ea1d3b
> c2b4c6fa92cd99c5c301635%7C0%7C0%7C638119790442766596%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LBwdwkjQxcH1NSRUEstHtYDDTCacXUg8p
> bQ%2B1b6nQKY%3D&reserved=0
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index a0d943d78580..7d8c53d96c3b 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4570,6 +4570,8 @@ 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);
> tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
> tcpm_ams_finish(port);
> if (port->pwr_role == TYPEC_SOURCE) {
> @@ -4589,6 +4591,8 @@ 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);
> if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
> tcpm_set_state_cond(port, hard_reset_state(port), 0);
> else
> @@ -4718,6 +4722,8 @@ 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);
> /*
> * Prevent vbus discharge circuit from turning on during PR_SWAP
> * as this is not a disconnect.
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [EXT] patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing
2023-02-15 5:45 ` [EXT] " Xu Yang
@ 2023-02-15 6:52 ` gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2023-02-15 6:52 UTC (permalink / raw)
To: Xu Yang
Cc: heikki.krogerus@linux.intel.com, linux@roeck-us.net,
stable@vger.kernel.org
On Wed, Feb 15, 2023 at 05:45:25AM +0000, Xu Yang wrote:
> Just noticed that port->partner_source_caps should also be reset to NULL.
>
> I'll send a V4 for this soon.
Ick, let me go revert this then :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-15 6:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-14 13:43 patch "usb: typec: tcpm: fix create duplicate source/sink-capabilities file" added to usb-testing gregkh
2023-02-15 5:45 ` [EXT] " Xu Yang
2023-02-15 6:52 ` gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).