All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out
@ 2023-07-12 22:34 Linus Walleij
  2023-07-12 23:17 ` Andrew Lunn
  2023-07-14  3:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2023-07-12 22:34 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S . Miller, Jakub Kicinski
  Cc: netdev, Linus Walleij, Tobias Waldekranz

I get sporadic timeouts from the driver when using the
MV88E6352. Reading the status again after the loop fixes the
problem: the operation is successful but goes undetected.

Some added prints show things like this:

[   58.356209] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
    for switch, addr 1b reg 0b, mask 8000, val 0000, data c000
[   58.367487] mv88e6085 mdio_mux-0.1:00: Timeout waiting for
    ATU op 4000, fid 0001
(...)
[   61.826293] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
    for switch, addr 1c reg 18, mask 8000, val 0000, data 9860
[   61.837560] mv88e6085 mdio_mux-0.1:00: Timeout waiting
    for PHY command 1860 to complete

The reason is probably not the commands: I think those are
mostly fine with the 50+50ms timeout, but the problem
appears when OpenWrt brings up several interfaces in
parallel on a system with 7 populated ports: if one of
them take more than 50 ms and waits one or more of the
others can get stuck on the mutex for the switch and then
this can easily multiply.

As we sleep and wait, the function loop needs a final
check after exiting the loop if we were successful.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Cc: Tobias Waldekranz <tobias@waldekranz.com>
Fixes: 35da1dfd9484 ("net: dsa: mv88e6xxx: Improve performance of busy bit polling")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Instead of reading 10 times, read an extra time after the
  loop and check if the value is fine.
---
 drivers/net/dsa/mv88e6xxx/chip.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 08a46ffd53af..642e93e8623e 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -109,6 +109,13 @@ int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
 			usleep_range(1000, 2000);
 	}
 
+	err = mv88e6xxx_read(chip, addr, reg, &data);
+	if (err)
+		return err;
+
+	if ((data & mask) == val)
+		return 0;
+
 	dev_err(chip->dev, "Timeout while waiting for switch\n");
 	return -ETIMEDOUT;
 }
-- 
2.34.1


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

* Re: [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out
  2023-07-12 22:34 [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out Linus Walleij
@ 2023-07-12 23:17 ` Andrew Lunn
  2023-07-14  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2023-07-12 23:17 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S . Miller, Jakub Kicinski, netdev, Tobias Waldekranz

On Thu, Jul 13, 2023 at 12:34:05AM +0200, Linus Walleij wrote:
> I get sporadic timeouts from the driver when using the
> MV88E6352. Reading the status again after the loop fixes the
> problem: the operation is successful but goes undetected.
> 
> Some added prints show things like this:
> 
> [   58.356209] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
>     for switch, addr 1b reg 0b, mask 8000, val 0000, data c000
> [   58.367487] mv88e6085 mdio_mux-0.1:00: Timeout waiting for
>     ATU op 4000, fid 0001
> (...)
> [   61.826293] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
>     for switch, addr 1c reg 18, mask 8000, val 0000, data 9860
> [   61.837560] mv88e6085 mdio_mux-0.1:00: Timeout waiting
>     for PHY command 1860 to complete
> 
> The reason is probably not the commands: I think those are
> mostly fine with the 50+50ms timeout, but the problem
> appears when OpenWrt brings up several interfaces in
> parallel on a system with 7 populated ports: if one of
> them take more than 50 ms and waits one or more of the
> others can get stuck on the mutex for the switch and then
> this can easily multiply.
> 
> As we sleep and wait, the function loop needs a final
> check after exiting the loop if we were successful.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Cc: Tobias Waldekranz <tobias@waldekranz.com>
> Fixes: 35da1dfd9484 ("net: dsa: mv88e6xxx: Improve performance of busy bit polling")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Hi Linus

Thanks for the new version.

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

    Andrew

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

* Re: [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out
  2023-07-12 22:34 [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out Linus Walleij
  2023-07-12 23:17 ` Andrew Lunn
@ 2023-07-14  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-07-14  3:40 UTC (permalink / raw)
  To: Linus Walleij
  Cc: andrew, vivien.didelot, f.fainelli, olteanv, davem, kuba, netdev, tobias

Hello:

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

On Thu, 13 Jul 2023 00:34:05 +0200 you wrote:
> I get sporadic timeouts from the driver when using the
> MV88E6352. Reading the status again after the loop fixes the
> problem: the operation is successful but goes undetected.
> 
> Some added prints show things like this:
> 
> [   58.356209] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
>     for switch, addr 1b reg 0b, mask 8000, val 0000, data c000
> [   58.367487] mv88e6085 mdio_mux-0.1:00: Timeout waiting for
>     ATU op 4000, fid 0001
> (...)
> [   61.826293] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
>     for switch, addr 1c reg 18, mask 8000, val 0000, data 9860
> [   61.837560] mv88e6085 mdio_mux-0.1:00: Timeout waiting
>     for PHY command 1860 to complete
> 
> [...]

Here is the summary with links:
  - [net,v2] dsa: mv88e6xxx: Do a final check before timing out
    https://git.kernel.org/netdev/net/c/95ce158b6c93

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] 3+ messages in thread

end of thread, other threads:[~2023-07-14  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 22:34 [PATCH net v2] dsa: mv88e6xxx: Do a final check before timing out Linus Walleij
2023-07-12 23:17 ` Andrew Lunn
2023-07-14  3:40 ` 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.