From: Amit Sunil Dhamne <amitsd@google.com>
To: Yanik Fuchs <Yanik.fuchs@mbv.ch>,
"heikki.krogerus@linux.intel.com"
<heikki.krogerus@linux.intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"rdbabiera@google.com" <rdbabiera@google.com>,
"linux@roeck-us.net" <linux@roeck-us.net>,
"kyletso@google.com" <kyletso@google.com>,
"badhri@google.com" <badhri@google.com>,
"xu.yang_2@nxp.com" <xu.yang_2@nxp.com>,
sebastian.reichel@collabora.com
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: typec: tcpm: Prevent Hard_Reset if Vbus was never low
Date: Wed, 23 Oct 2024 20:13:36 -0700 [thread overview]
Message-ID: <d6bbd32a-6de4-492a-8965-c0bc3dbddcff@google.com> (raw)
In-Reply-To: <GVAP278MB0662F98EAAFAD95645E7010A974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
Hi Yanik,
On 10/22/24 10:28 AM, Yanik Fuchs wrote:
> Good Evening
>
> Here is a Patch to resolve an issue with TCPM if Vbus was never low.
> Please consider that this is one of my first kernel pull requests, I may have missunderstood the process.
>
> Freundliche Grüsse
> Best regards
>
>
> Yanik Fuchs
>
> ---
>
> From 604b97b6394b5643394bc63d4ac691c098c99c40 Mon Sep 17 00:00:00 2001
> From: yfu <yanikfuchs@me.com>
> Date: Tue, 22 Oct 2024 18:23:18 +0200
> Subject: [PATCH] usb: typec: tcpm: Prevent Hard_Reset if Vbus was never low
>
> Before this patch, tcpm went into SOFT_RESET state, if Vbus was never low
> resulting in Hard_Reset, if power supply does not support USB_PD Soft_Reset.
>
> In order to prevent this, I remove the Vbus check completely, so that
> we go as well into the SNK_WAIT_CAPABILITIES_TIMEOUT state. There, we send
> PD_CTRL_GET_SOURCE_CAP which many power supply do support.
> (122968f8dda8 usb: typec: tcpm: avoid resets for missing source capability messages)
Please refer to
https://lore.kernel.org/all/20241024022233.3276995-1-amitsd@google.com/ as
122968f8dda8 is causing USB Type-C PD compliance failures.
>
> Additionally, I added SOFT_RESET (instead of Hard_Reset) as Fallback solution
> if we still not have gotten any capabilities. Hard_Reset is now only done,
> if PD_CTRL_GET_SOURCE_CAP and SOFT_RESET fail to get capabilities.
> ---
> drivers/usb/typec/tcpm/tcpm.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index fc619478200f..c7a59c9f78ee 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5038,14 +5038,8 @@ static void run_state_machine(struct tcpm_port *port)
> * were already in a stable contract before this boot.
> * Do this only once.
> */
> - if (port->vbus_never_low) {
> - port->vbus_never_low = false;
> - tcpm_set_state(port, SNK_SOFT_RESET,
> + tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT,
> PD_T_SINK_WAIT_CAP);
> - } else {
> - tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT,
> - PD_T_SINK_WAIT_CAP);
> - }
Instead of deleting code, please restrict this behavior to non self
powered battery case as this most likely break compliance and
may break actual use-cases for other users as a result. If you want you
can move stuff around after
https://lore.kernel.org/all/20241024022233.3276995-1-amitsd@google.com/
gets accepted in the following way:
```
if (!port->self_powered) {
tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT,
PD_T_SINK_WAIT_CAP);
break;
}
if (port->vbus_never_low) {
tcpm_set_state(port, SNK_SOFT_RESET, PD_T_SINK_WAIT_CAP);
} else {
tcpm_set_state(port, hard_reset_state(..), PD_T_SINK_WAIT_CAP);
}
```
This way you don't have to execute the SNK_SOFT_RESET flow for non self
powered use-case.
Thanks,
Amit
> break;
> case SNK_WAIT_CAPABILITIES_TIMEOUT:
> /*
> @@ -5064,7 +5058,7 @@ static void run_state_machine(struct tcpm_port *port)
> * according to the specification.
> */
> if (tcpm_pd_send_control(port, PD_CTRL_GET_SOURCE_CAP, TCPC_TX_SOP))
> - tcpm_set_state_cond(port, hard_reset_state(port), 0);
> + tcpm_set_state_cond(port, SNK_SOFT_RESET, 0);
> else
> tcpm_set_state(port, hard_reset_state(port), PD_T_SINK_WAIT_CAP);
> break;
next prev parent reply other threads:[~2024-10-24 3:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 17:28 Yanik Fuchs
2024-10-23 9:05 ` Heikki Krogerus
2024-10-24 3:13 ` Amit Sunil Dhamne [this message]
2024-10-24 8:54 ` AW: " Yanik Fuchs
2024-10-24 9:20 ` Yanik Fuchs
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=d6bbd32a-6de4-492a-8965-c0bc3dbddcff@google.com \
--to=amitsd@google.com \
--cc=Yanik.fuchs@mbv.ch \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rdbabiera@google.com \
--cc=sebastian.reichel@collabora.com \
--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
all inboxes | Powered by JetHome®