From: Badhri Jagan Sridharan <badhri@google.com>
To: Kyle Tso <kyletso@google.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
USB <linux-usb@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: typec: tcpm: Relax disconnect threshold during power negotiation
Date: Tue, 15 Jun 2021 11:05:50 -0700 [thread overview]
Message-ID: <CAPTae5JfhDdCjNh8jxE6XMsvV0cC3McH6Hx4MGoOgrcRrT94Vg@mail.gmail.com> (raw)
In-Reply-To: <20210615080817.1417169-1-kyletso@google.com>
On Tue, Jun 15, 2021 at 1:08 AM Kyle Tso <kyletso@google.com> wrote:
>
> If the voltage is being decreased in power negotiation, the Source will
> set the power supply to operate at the new voltage level before sending
> PS_RDY. For non-PPS negotiation, relax the disconnect threshold on Sink
> after receiving Accept Message to ensure the relaxed setting is enabled
> before the voltage collapse. For PPS, relax the threshold before
> sending Request Message so that it will not race with Source which
> begins to adjust the voltage right after it sends Accept Message.
>
> The real threshold will be set after Sink receives PS_RDY Message.
>
> Fixes: f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support")
> Cc: Badhri Jagan Sridharan <badhri@google.com>
> Signed-off-by: Kyle Tso <kyletso@google.com>
> ---
> Changes since v1:
> - move the timing of setting threshold up to "before sending Request"
> for PPS power negotiation so that it won't race with the Source.
> - PPS: if it fails to send the Request, fallback to previous threshold
> - PPS: if the Source doesn't respond Accept, fallback to previous
> threshold
> - update the commit message for above changes
>
> drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 0db685d5d9c0..00f3fd7c05d6 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2599,6 +2599,11 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
> port->send_discover)
> port->vdm_sm_running = true;
>
> + /* Threshold was relaxed before sending Request. Restore it back. */
> + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD,
> + port->pps_data.active,
> + port->supply_voltage);
> +
> tcpm_set_state(port, SNK_READY, 0);
> break;
> case DR_SWAP_SEND:
> @@ -2646,6 +2651,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
> switch (port->state) {
> case SNK_NEGOTIATE_CAPABILITIES:
> port->pps_data.active = false;
> + /* Voltage is going to be at new level. Relax the threshold here. */
> + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0);
> tcpm_set_state(port, SNK_TRANSITION_SINK, 0);
> break;
> case SNK_NEGOTIATE_PPS_CAPABILITIES:
> @@ -3423,6 +3430,9 @@ static int tcpm_pd_send_pps_request(struct tcpm_port *port)
> if (ret < 0)
> return ret;
>
> + /* Relax the threshold as voltage will be adjusted right after Accept Message. */
This makes sense. Shouldn't we have the same approach for
tcpm_pd_send_request as it's equally applicable for fixed RDO as well
?
> + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0);
> +
> memset(&msg, 0, sizeof(msg));
> msg.header = PD_HEADER_LE(PD_DATA_REQUEST,
> port->pwr_role,
> @@ -4196,6 +4206,10 @@ static void run_state_machine(struct tcpm_port *port)
> case SNK_NEGOTIATE_PPS_CAPABILITIES:
> ret = tcpm_pd_send_pps_request(port);
> if (ret < 0) {
> + /* Restore back to the original state */
> + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD,
> + port->pps_data.active,
> + port->supply_voltage);
> port->pps_status = ret;
> /*
> * If this was called due to updates to sink
> --
> 2.32.0.272.g935e593368-goog
>
next prev parent reply other threads:[~2021-06-15 18:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 8:08 [PATCH v2] usb: typec: tcpm: Relax disconnect threshold during power negotiation Kyle Tso
2021-06-15 18:05 ` Badhri Jagan Sridharan [this message]
2021-06-16 1:16 ` Kyle Tso
2021-06-16 2:10 ` Kyle Tso
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=CAPTae5JfhDdCjNh8jxE6XMsvV0cC3McH6Hx4MGoOgrcRrT94Vg@mail.gmail.com \
--to=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 \
/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;
as well as URLs for NNTP newsgroup(s).