All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation
@ 2021-06-13 15:12 Kyle Tso
  2021-06-14 16:51 ` Badhri Jagan Sridharan
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Tso @ 2021-06-13 15:12 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh; +Cc: badhri, linux-usb, linux-kernel, Kyle Tso

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. Relax the disconnect threshold for Sink after receiving Accept
Message to ensure the relaxed setting is enabled before the voltage
collapse. And 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>
---
 drivers/usb/typec/tcpm/tcpm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 0db685d5d9c0..9f3f37da71b6 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -2646,6 +2646,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:
@@ -2656,6 +2658,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 			port->req_supply_voltage = port->pps_data.req_out_volt;
 			port->req_current_limit = port->pps_data.req_op_curr;
 			power_supply_changed(port->psy);
+			/* 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 SOFT_RESET_SEND:
-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation
  2021-06-13 15:12 [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation Kyle Tso
@ 2021-06-14 16:51 ` Badhri Jagan Sridharan
  2021-06-14 16:55   ` Kyle Tso
  0 siblings, 1 reply; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2021-06-14 16:51 UTC (permalink / raw)
  To: Kyle Tso; +Cc: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman, USB, LKML

Hi Kyle,

The change doesn't seem to handle the cases where the partner does not
accept the request i.e.
       "case PD_CTRL_REJECT:
        case PD_CTRL_WAIT:
        case PD_CTRL_NOT_SUPP:"
We should fall back to the disconnect threshold based on the
previously negotiated voltage levels in those cases.

Regards,
Badhri


On Sun, Jun 13, 2021 at 8:13 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. Relax the disconnect threshold for Sink after receiving Accept
> Message to ensure the relaxed setting is enabled before the voltage
> collapse. And 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>
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 0db685d5d9c0..9f3f37da71b6 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2646,6 +2646,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:
> @@ -2656,6 +2658,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>                         port->req_supply_voltage = port->pps_data.req_out_volt;
>                         port->req_current_limit = port->pps_data.req_op_curr;
>                         power_supply_changed(port->psy);
> +                       /* 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 SOFT_RESET_SEND:
> --
> 2.32.0.272.g935e593368-goog
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation
  2021-06-14 16:51 ` Badhri Jagan Sridharan
@ 2021-06-14 16:55   ` Kyle Tso
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Tso @ 2021-06-14 16:55 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman, USB, LKML

On Tue, Jun 15, 2021 at 12:52 AM Badhri Jagan Sridharan
<badhri@google.com> wrote:
>
> Hi Kyle,
>
> The change doesn't seem to handle the cases where the partner does not
> accept the request i.e.
>        "case PD_CTRL_REJECT:
>         case PD_CTRL_WAIT:
>         case PD_CTRL_NOT_SUPP:"
> We should fall back to the disconnect threshold based on the
> previously negotiated voltage levels in those cases.
>
> Regards,
> Badhri
>
>
> On Sun, Jun 13, 2021 at 8:13 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. Relax the disconnect threshold for Sink after receiving Accept
> > Message to ensure the relaxed setting is enabled before the voltage
> > collapse. And 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>
> > ---
> >  drivers/usb/typec/tcpm/tcpm.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 0db685d5d9c0..9f3f37da71b6 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -2646,6 +2646,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:
> > @@ -2656,6 +2658,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
> >                         port->req_supply_voltage = port->pps_data.req_out_volt;
> >                         port->req_current_limit = port->pps_data.req_op_curr;
> >                         power_supply_changed(port->psy);
> > +                       /* 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;

Yes, Badhri you are right.

And it's still too late for PPS power negotiation. The Source begins
to lower it's Vbus level just after Accept Message.
I will send patch v2 to fix these problems.

thanks,
Kyle

> >                 case SOFT_RESET_SEND:
> > --
> > 2.32.0.272.g935e593368-goog
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-14 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13 15:12 [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation Kyle Tso
2021-06-14 16:51 ` Badhri Jagan Sridharan
2021-06-14 16:55   ` Kyle Tso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.