All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: lan9303: fix reset on probe
@ 2022-02-09 14:54 Mans Rullgard
  2022-02-09 16:01 ` Andrew Lunn
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Mans Rullgard @ 2022-02-09 14:54 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller
  Cc: Vladimir Oltean, Jakub Kicinski, Juergen Borleis, netdev, linux-kernel

The reset input to the LAN9303 chip is active low, and devicetree
gpio handles reflect this.  Therefore, the gpio should be requested
with an initial state of high in order for the reset signal to be
asserted.  Other uses of the gpio already use the correct polarity.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/net/dsa/lan9303-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index aa1142d6a9f5..2de67708bbd2 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -1301,7 +1301,7 @@ static int lan9303_probe_reset_gpio(struct lan9303 *chip,
 				     struct device_node *np)
 {
 	chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
-						   GPIOD_OUT_LOW);
+						   GPIOD_OUT_HIGH);
 	if (IS_ERR(chip->reset_gpio))
 		return PTR_ERR(chip->reset_gpio);
 
-- 
2.35.1


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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
@ 2022-02-09 16:01 ` Andrew Lunn
  2022-02-09 16:34   ` Måns Rullgård
  2022-02-10  2:36 ` Jakub Kicinski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2022-02-09 16:01 UTC (permalink / raw)
  To: Mans Rullgard
  Cc: Vivien Didelot, Florian Fainelli, David S. Miller,
	Vladimir Oltean, Jakub Kicinski, Juergen Borleis, netdev,
	linux-kernel

On Wed, Feb 09, 2022 at 02:54:54PM +0000, Mans Rullgard wrote:
> The reset input to the LAN9303 chip is active low, and devicetree
> gpio handles reflect this.  Therefore, the gpio should be requested
> with an initial state of high in order for the reset signal to be
> asserted.  Other uses of the gpio already use the correct polarity.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  drivers/net/dsa/lan9303-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index aa1142d6a9f5..2de67708bbd2 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -1301,7 +1301,7 @@ static int lan9303_probe_reset_gpio(struct lan9303 *chip,
>  				     struct device_node *np)
>  {
>  	chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
> -						   GPIOD_OUT_LOW);
> +						   GPIOD_OUT_HIGH);
>  	if (IS_ERR(chip->reset_gpio))
>  		return PTR_ERR(chip->reset_gpio);

lan9303_handle_reset() does a sleep and then releases the reset. I
don't see anywhere in the driver which asserts the reset first. So is
it actually asserted as part of this getting the GPIO? And if so, does
not this change actually break the reset?

    Andrew

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 16:01 ` Andrew Lunn
@ 2022-02-09 16:34   ` Måns Rullgård
  2022-02-11 19:28     ` Andrew Lunn
  0 siblings, 1 reply; 8+ messages in thread
From: Måns Rullgård @ 2022-02-09 16:34 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Vivien Didelot, Florian Fainelli, David S. Miller,
	Vladimir Oltean, Jakub Kicinski, Juergen Borleis, netdev,
	linux-kernel

Andrew Lunn <andrew@lunn.ch> writes:

> On Wed, Feb 09, 2022 at 02:54:54PM +0000, Mans Rullgard wrote:
>> The reset input to the LAN9303 chip is active low, and devicetree
>> gpio handles reflect this.  Therefore, the gpio should be requested
>> with an initial state of high in order for the reset signal to be
>> asserted.  Other uses of the gpio already use the correct polarity.
>> 
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>> ---
>>  drivers/net/dsa/lan9303-core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
>> index aa1142d6a9f5..2de67708bbd2 100644
>> --- a/drivers/net/dsa/lan9303-core.c
>> +++ b/drivers/net/dsa/lan9303-core.c
>> @@ -1301,7 +1301,7 @@ static int lan9303_probe_reset_gpio(struct lan9303 *chip,
>>  				     struct device_node *np)
>>  {
>>  	chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
>> -						   GPIOD_OUT_LOW);
>> +						   GPIOD_OUT_HIGH);
>>  	if (IS_ERR(chip->reset_gpio))
>>  		return PTR_ERR(chip->reset_gpio);
>
> lan9303_handle_reset() does a sleep and then releases the reset. I
> don't see anywhere in the driver which asserts the reset first. So is
> it actually asserted as part of this getting the GPIO? And if so, does
> not this change actually break the reset?

The GPIOD_OUT_xxx flags to gpiod_get() request that the pin be
configured as output and set to high/low initially.  The GPIOD_OUT_LOW
currently used by the lan9303 driver together with GPIO_ACTIVE_LOW in
the devicetrees results in the actual voltage being set high.  The
driver then sleeps for a bit before setting the gpio value to zero,
again translated to a high output voltage.  That is, the value set after
the sleep is the same as it was initially.  This is obviously not the
intent.

With the patch applied, I can measure the reset signal pulse low for the
configured duration when the device is probed.  Without the patch, the
reset signal remains high and no reset of the device occurs.

-- 
Måns Rullgård

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
  2022-02-09 16:01 ` Andrew Lunn
@ 2022-02-10  2:36 ` Jakub Kicinski
  2022-02-10 13:48   ` Måns Rullgård
  2022-02-11 20:00 ` Florian Fainelli
  2022-02-11 22:30 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2022-02-10  2:36 UTC (permalink / raw)
  To: Mans Rullgard
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Vladimir Oltean, Juergen Borleis, netdev, linux-kernel

On Wed,  9 Feb 2022 14:54:54 +0000 Mans Rullgard wrote:
> The reset input to the LAN9303 chip is active low, and devicetree
> gpio handles reflect this.  Therefore, the gpio should be requested
> with an initial state of high in order for the reset signal to be
> asserted.  Other uses of the gpio already use the correct polarity.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>

Pending Andrew's review, this is the correct fixes tag, right?

Fixes: a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-10  2:36 ` Jakub Kicinski
@ 2022-02-10 13:48   ` Måns Rullgård
  0 siblings, 0 replies; 8+ messages in thread
From: Måns Rullgård @ 2022-02-10 13:48 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Vladimir Oltean, Juergen Borleis, netdev, linux-kernel

Jakub Kicinski <kuba@kernel.org> writes:

> On Wed,  9 Feb 2022 14:54:54 +0000 Mans Rullgard wrote:
>> The reset input to the LAN9303 chip is active low, and devicetree
>> gpio handles reflect this.  Therefore, the gpio should be requested
>> with an initial state of high in order for the reset signal to be
>> asserted.  Other uses of the gpio already use the correct polarity.
>> 
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>
> Pending Andrew's review, this is the correct fixes tag, right?
>
> Fixes: a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")

Yes, the error has been there since the driver was first added.

-- 
Måns Rullgård

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 16:34   ` Måns Rullgård
@ 2022-02-11 19:28     ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2022-02-11 19:28 UTC (permalink / raw)
  To: Måns Rullgård
  Cc: Vivien Didelot, Florian Fainelli, David S. Miller,
	Vladimir Oltean, Jakub Kicinski, Juergen Borleis, netdev,
	linux-kernel

On Wed, Feb 09, 2022 at 04:34:15PM +0000, Måns Rullgård wrote:
> Andrew Lunn <andrew@lunn.ch> writes:
> 
> > On Wed, Feb 09, 2022 at 02:54:54PM +0000, Mans Rullgard wrote:
> >> The reset input to the LAN9303 chip is active low, and devicetree
> >> gpio handles reflect this.  Therefore, the gpio should be requested
> >> with an initial state of high in order for the reset signal to be
> >> asserted.  Other uses of the gpio already use the correct polarity.
> >> 
> >> Signed-off-by: Mans Rullgard <mans@mansr.com>
> >> ---
> >>  drivers/net/dsa/lan9303-core.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> >> index aa1142d6a9f5..2de67708bbd2 100644
> >> --- a/drivers/net/dsa/lan9303-core.c
> >> +++ b/drivers/net/dsa/lan9303-core.c
> >> @@ -1301,7 +1301,7 @@ static int lan9303_probe_reset_gpio(struct lan9303 *chip,
> >>  				     struct device_node *np)
> >>  {
> >>  	chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
> >> -						   GPIOD_OUT_LOW);
> >> +						   GPIOD_OUT_HIGH);
> >>  	if (IS_ERR(chip->reset_gpio))
> >>  		return PTR_ERR(chip->reset_gpio);
> >
> > lan9303_handle_reset() does a sleep and then releases the reset. I
> > don't see anywhere in the driver which asserts the reset first. So is
> > it actually asserted as part of this getting the GPIO? And if so, does
> > not this change actually break the reset?
> 
> The GPIOD_OUT_xxx flags to gpiod_get() request that the pin be
> configured as output and set to high/low initially.  The GPIOD_OUT_LOW
> currently used by the lan9303 driver together with GPIO_ACTIVE_LOW in
> the devicetrees results in the actual voltage being set high.  The
> driver then sleeps for a bit before setting the gpio value to zero,
> again translated to a high output voltage.  That is, the value set after
> the sleep is the same as it was initially.  This is obviously not the
> intent.

Yes, i agree. I'm just wondering how this worked for whoever
implemented this code. I guess it never actually did a reset, or the
bootloader left the reset already in the asserted state, so that the
gpiod_get() actual deasserted the reset?

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
  2022-02-09 16:01 ` Andrew Lunn
  2022-02-10  2:36 ` Jakub Kicinski
@ 2022-02-11 20:00 ` Florian Fainelli
  2022-02-11 22:30 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2022-02-11 20:00 UTC (permalink / raw)
  To: Mans Rullgard, Andrew Lunn, Vivien Didelot, David S. Miller
  Cc: Vladimir Oltean, Jakub Kicinski, Juergen Borleis, netdev, linux-kernel

On 2/9/22 6:54 AM, Mans Rullgard wrote:
> The reset input to the LAN9303 chip is active low, and devicetree
> gpio handles reflect this.  Therefore, the gpio should be requested
> with an initial state of high in order for the reset signal to be
> asserted.  Other uses of the gpio already use the correct polarity.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>

Reviewed-by: Florian Fianelil <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH] net: dsa: lan9303: fix reset on probe
  2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
                   ` (2 preceding siblings ...)
  2022-02-11 20:00 ` Florian Fainelli
@ 2022-02-11 22:30 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-11 22:30 UTC (permalink / raw)
  To: =?utf-8?b?TcOlbnMgUnVsbGfDpXJkIDxtYW5zQG1hbnNyLmNvbT4=?=
  Cc: andrew, vivien.didelot, f.fainelli, davem, olteanv, kuba, kernel,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  9 Feb 2022 14:54:54 +0000 you wrote:
> The reset input to the LAN9303 chip is active low, and devicetree
> gpio handles reflect this.  Therefore, the gpio should be requested
> with an initial state of high in order for the reset signal to be
> asserted.  Other uses of the gpio already use the correct polarity.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> 
> [...]

Here is the summary with links:
  - net: dsa: lan9303: fix reset on probe
    https://git.kernel.org/netdev/net/c/6bb9681a43f3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-02-11 22:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 14:54 [PATCH] net: dsa: lan9303: fix reset on probe Mans Rullgard
2022-02-09 16:01 ` Andrew Lunn
2022-02-09 16:34   ` Måns Rullgård
2022-02-11 19:28     ` Andrew Lunn
2022-02-10  2:36 ` Jakub Kicinski
2022-02-10 13:48   ` Måns Rullgård
2022-02-11 20:00 ` Florian Fainelli
2022-02-11 22:30 ` patchwork-bot+netdevbpf

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.