All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
@ 2021-05-10 21:17 Badhri Jagan Sridharan
  2021-05-10 22:07 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Badhri Jagan Sridharan @ 2021-05-10 21:17 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Kyle Tso, Badhri Jagan Sridharan

This is a regression introduced by
<1373fefc6243cc96b3565f0ffffadfac4ccfb977>
"Allow slow charging loops to comply to pSnkStby".

When Source advertises Rp-default, tcpm would request 500mA when in
SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current
limits when Rp-default is advertised.
[12750.503381] Requesting mux state 1, usb-role 2, orientation 1
[12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
[12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY
[12751.003900] Setting voltage/current limit 5000 mV 500 mA

This patch restores the behavior where the tcpm would request 0mA when
Rp-default is advertised by the source.
[   73.174252] Requesting mux state 1, usb-role 2, orientation 1
[   73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
[   73.674800] state change SNK_STARTUP -> SNK_DISCOVERY
[   73.674808] Setting voltage/current limit 5000 mV 0 mA

During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only
for slow_charger_loop case.

Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index c4fdc00a3bc8..a73299a08ef7 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4055,7 +4055,7 @@ static void run_state_machine(struct tcpm_port *port)
 		if (port->vbus_present) {
 			u32 current_lim = tcpm_get_current_limit(port);
 
-			if (port->slow_charger_loop || (current_lim > PD_P_SNK_STDBY_MW / 5))
+			if (port->slow_charger_loop && (current_lim > PD_P_SNK_STDBY_MW / 5))
 				current_lim = PD_P_SNK_STDBY_MW / 5;
 			tcpm_set_current_limit(port, current_lim, 5000);
 			tcpm_set_charge(port, true);
-- 
2.31.1.607.g51e8a6a459-goog


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

* Re: [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
  2021-05-10 21:17 [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default Badhri Jagan Sridharan
@ 2021-05-10 22:07 ` Guenter Roeck
  2021-05-11  7:20 ` Heikki Krogerus
  2021-05-13 13:01 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-05-10 22:07 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Kyle Tso

On 5/10/21 2:17 PM, Badhri Jagan Sridharan wrote:
> This is a regression introduced by
> <1373fefc6243cc96b3565f0ffffadfac4ccfb977>
> "Allow slow charging loops to comply to pSnkStby".
> 
> When Source advertises Rp-default, tcpm would request 500mA when in
> SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current
> limits when Rp-default is advertised.
> [12750.503381] Requesting mux state 1, usb-role 2, orientation 1
> [12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY
> [12751.003900] Setting voltage/current limit 5000 mV 500 mA
> 
> This patch restores the behavior where the tcpm would request 0mA when
> Rp-default is advertised by the source.
> [   73.174252] Requesting mux state 1, usb-role 2, orientation 1
> [   73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [   73.674800] state change SNK_STARTUP -> SNK_DISCOVERY
> [   73.674808] Setting voltage/current limit 5000 mV 0 mA
> 
> During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only
> for slow_charger_loop case.
> 
> Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/usb/typec/tcpm/tcpm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index c4fdc00a3bc8..a73299a08ef7 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4055,7 +4055,7 @@ static void run_state_machine(struct tcpm_port *port)
>   		if (port->vbus_present) {
>   			u32 current_lim = tcpm_get_current_limit(port);
>   
> -			if (port->slow_charger_loop || (current_lim > PD_P_SNK_STDBY_MW / 5))
> +			if (port->slow_charger_loop && (current_lim > PD_P_SNK_STDBY_MW / 5))
>   				current_lim = PD_P_SNK_STDBY_MW / 5;
>   			tcpm_set_current_limit(port, current_lim, 5000);
>   			tcpm_set_charge(port, true);
> 


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

* Re: [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
  2021-05-10 21:17 [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default Badhri Jagan Sridharan
  2021-05-10 22:07 ` Guenter Roeck
@ 2021-05-11  7:20 ` Heikki Krogerus
  2021-05-13 13:01 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2021-05-11  7:20 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel, Kyle Tso

On Mon, May 10, 2021 at 02:17:56PM -0700, Badhri Jagan Sridharan wrote:
> This is a regression introduced by
> <1373fefc6243cc96b3565f0ffffadfac4ccfb977>
> "Allow slow charging loops to comply to pSnkStby".
> 
> When Source advertises Rp-default, tcpm would request 500mA when in
> SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current
> limits when Rp-default is advertised.
> [12750.503381] Requesting mux state 1, usb-role 2, orientation 1
> [12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY
> [12751.003900] Setting voltage/current limit 5000 mV 500 mA
> 
> This patch restores the behavior where the tcpm would request 0mA when
> Rp-default is advertised by the source.
> [   73.174252] Requesting mux state 1, usb-role 2, orientation 1
> [   73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [   73.674800] state change SNK_STARTUP -> SNK_DISCOVERY
> [   73.674808] Setting voltage/current limit 5000 mV 0 mA
> 
> During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only
> for slow_charger_loop case.
> 
> Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index c4fdc00a3bc8..a73299a08ef7 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4055,7 +4055,7 @@ static void run_state_machine(struct tcpm_port *port)
>  		if (port->vbus_present) {
>  			u32 current_lim = tcpm_get_current_limit(port);
>  
> -			if (port->slow_charger_loop || (current_lim > PD_P_SNK_STDBY_MW / 5))
> +			if (port->slow_charger_loop && (current_lim > PD_P_SNK_STDBY_MW / 5))
>  				current_lim = PD_P_SNK_STDBY_MW / 5;
>  			tcpm_set_current_limit(port, current_lim, 5000);
>  			tcpm_set_charge(port, true);
> -- 
> 2.31.1.607.g51e8a6a459-goog

-- 
heikki

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

* Re: [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
  2021-05-10 21:17 [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default Badhri Jagan Sridharan
  2021-05-10 22:07 ` Guenter Roeck
  2021-05-11  7:20 ` Heikki Krogerus
@ 2021-05-13 13:01 ` Greg Kroah-Hartman
  2021-05-13 17:59   ` Badhri Jagan Sridharan
  2 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-13 13:01 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Heikki Krogerus, linux-usb, linux-kernel, Kyle Tso

On Mon, May 10, 2021 at 02:17:56PM -0700, Badhri Jagan Sridharan wrote:
> This is a regression introduced by
> <1373fefc6243cc96b3565f0ffffadfac4ccfb977>
> "Allow slow charging loops to comply to pSnkStby".
> 
> When Source advertises Rp-default, tcpm would request 500mA when in
> SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current
> limits when Rp-default is advertised.
> [12750.503381] Requesting mux state 1, usb-role 2, orientation 1
> [12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY
> [12751.003900] Setting voltage/current limit 5000 mV 500 mA
> 
> This patch restores the behavior where the tcpm would request 0mA when
> Rp-default is advertised by the source.
> [   73.174252] Requesting mux state 1, usb-role 2, orientation 1
> [   73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [   73.674800] state change SNK_STARTUP -> SNK_DISCOVERY
> [   73.674808] Setting voltage/current limit 5000 mV 0 mA
> 
> During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only
> for slow_charger_loop case.
> 
> Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby")

Your string here was incorrect, I'll fix it up this time, but please be
more careful in the future as it will get caught by our scripts.

thanks,

greg k-h

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

* Re: [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
  2021-05-13 13:01 ` Greg Kroah-Hartman
@ 2021-05-13 17:59   ` Badhri Jagan Sridharan
  0 siblings, 0 replies; 5+ messages in thread
From: Badhri Jagan Sridharan @ 2021-05-13 17:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Guenter Roeck, Heikki Krogerus, USB, LKML, Kyle Tso

Apologies Greg ! Will pay more attention to the "fixes" string next time.

Thanks for fixing it up !
-Badhri


On Thu, May 13, 2021 at 6:01 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, May 10, 2021 at 02:17:56PM -0700, Badhri Jagan Sridharan wrote:
> > This is a regression introduced by
> > <1373fefc6243cc96b3565f0ffffadfac4ccfb977>
> > "Allow slow charging loops to comply to pSnkStby".
> >
> > When Source advertises Rp-default, tcpm would request 500mA when in
> > SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current
> > limits when Rp-default is advertised.
> > [12750.503381] Requesting mux state 1, usb-role 2, orientation 1
> > [12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> > [12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY
> > [12751.003900] Setting voltage/current limit 5000 mV 500 mA
> >
> > This patch restores the behavior where the tcpm would request 0mA when
> > Rp-default is advertised by the source.
> > [   73.174252] Requesting mux state 1, usb-role 2, orientation 1
> > [   73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> > [   73.674800] state change SNK_STARTUP -> SNK_DISCOVERY
> > [   73.674808] Setting voltage/current limit 5000 mV 0 mA
> >
> > During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only
> > for slow_charger_loop case.
> >
> > Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby")
>
> Your string here was incorrect, I'll fix it up this time, but please be
> more careful in the future as it will get caught by our scripts.
>
> thanks,
>
> greg k-h

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

end of thread, other threads:[~2021-05-13 18:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 21:17 [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default Badhri Jagan Sridharan
2021-05-10 22:07 ` Guenter Roeck
2021-05-11  7:20 ` Heikki Krogerus
2021-05-13 13:01 ` Greg Kroah-Hartman
2021-05-13 17:59   ` Badhri Jagan Sridharan

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.