From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: linux@roeck-us.net, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com
Subject: Re: [PATCH v3] usb: typec: tcpm: fix create duplicate source/sink-capabilities file
Date: Tue, 14 Feb 2023 13:38:54 +0200 [thread overview]
Message-ID: <Y+tyzhyb+PGhTJpx@kuha.fi.intel.com> (raw)
In-Reply-To: <20230214065635.972698-1-xu.yang_2@nxp.com>
On Tue, Feb 14, 2023 at 02:56:35PM +0800, Xu Yang wrote:
> 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>
> ---
> v2: unregister existing capabilities on specific cases
> v3: add changelog and modify commit message
> ---
> 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.34.1
--
heikki
next prev parent reply other threads:[~2023-02-14 11:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 6:56 [PATCH v3] usb: typec: tcpm: fix create duplicate source/sink-capabilities file Xu Yang
2023-02-14 11:38 ` Heikki Krogerus [this message]
2023-02-14 12:00 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+tyzhyb+PGhTJpx@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jun.li@nxp.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox