public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset
@ 2023-08-15  0:13 Alfred Lee
  2023-08-15  1:16 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alfred Lee @ 2023-08-15  0:13 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, sgarzare,
	AVKrasnov, Alfred Lee

If the switch is reset during active EEPROM transactions, as in
just after an SoC reset after power up, the I2C bus transaction
may be cut short leaving the EEPROM internal I2C state machine
in the wrong state.  When the switch is reset again, the bad
state machine state may result in data being read from the wrong
memory location causing the switch to enter unexpected mode
rendering it inoperational.

Fixes: a3dcb3e7e70c ("net: dsa: mv88e6xxx: Wait for EEPROM done after HW reset")
Signed-off-by: Alfred Lee <l00g33k@gmail.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index c7d51a539451..7af2f08a62f1 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3034,6 +3034,14 @@ static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
 
 	/* If there is a GPIO connected to the reset pin, toggle it */
 	if (gpiod) {
+		/* If the switch has just been reset and not yet completed
+		 * loading EEPROM, the reset may interrupt the I2C transaction
+		 * mid-byte, causing the first EEPROM read after the reset
+		 * from the wrong location resulting in the switch booting
+		 * to wrong mode and inoperable.
+		 */
+		mv88e6xxx_g1_wait_eeprom_done(chip);
+
 		gpiod_set_value_cansleep(gpiod, 1);
 		usleep_range(10000, 20000);
 		gpiod_set_value_cansleep(gpiod, 0);
-- 
2.41.0


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

* Re: [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset
  2023-08-15  0:13 [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset Alfred Lee
@ 2023-08-15  1:16 ` Andrew Lunn
  2023-08-17  3:18 ` Jakub Kicinski
  2023-08-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2023-08-15  1:16 UTC (permalink / raw)
  To: Alfred Lee
  Cc: netdev, linux-kernel, olteanv, davem, edumazet, kuba, pabeni,
	sgarzare, AVKrasnov

On Mon, Aug 14, 2023 at 05:13:23PM -0700, Alfred Lee wrote:
> If the switch is reset during active EEPROM transactions, as in
> just after an SoC reset after power up, the I2C bus transaction
> may be cut short leaving the EEPROM internal I2C state machine
> in the wrong state.  When the switch is reset again, the bad
> state machine state may result in data being read from the wrong
> memory location causing the switch to enter unexpected mode
> rendering it inoperational.

Hi Alfred

It is normal to place a history after the --- of what changed between
each version.

> Fixes: a3dcb3e7e70c ("net: dsa: mv88e6xxx: Wait for EEPROM done after HW reset")
> Signed-off-by: Alfred Lee <l00g33k@gmail.com>

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

    Andrew

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

* Re: [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset
  2023-08-15  0:13 [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset Alfred Lee
  2023-08-15  1:16 ` Andrew Lunn
@ 2023-08-17  3:18 ` Jakub Kicinski
  2023-08-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2023-08-17  3:18 UTC (permalink / raw)
  To: Alfred Lee
  Cc: netdev, linux-kernel, andrew, olteanv, davem, edumazet, pabeni,
	sgarzare, AVKrasnov

On Mon, 14 Aug 2023 17:13:23 -0700 Alfred Lee wrote:
> If the switch is reset during active EEPROM transactions, as in
> just after an SoC reset after power up, the I2C bus transaction
> may be cut short leaving the EEPROM internal I2C state machine
> in the wrong state.  When the switch is reset again, the bad
> state machine state may result in data being read from the wrong
> memory location causing the switch to enter unexpected mode
> rendering it inoperational.

I'll apply this instead of the v4:

https://lore.kernel.org/all/20230815220453.32035-1-l00g33k@gmail.com/

since you dropped Andrew's tag :( Please make sure you keep the tags
you were given.

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

* Re: [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset
  2023-08-15  0:13 [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset Alfred Lee
  2023-08-15  1:16 ` Andrew Lunn
  2023-08-17  3:18 ` Jakub Kicinski
@ 2023-08-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-17  3:20 UTC (permalink / raw)
  To: Alfred Lee
  Cc: netdev, linux-kernel, andrew, olteanv, davem, edumazet, kuba,
	pabeni, sgarzare, AVKrasnov

Hello:

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

On Mon, 14 Aug 2023 17:13:23 -0700 you wrote:
> If the switch is reset during active EEPROM transactions, as in
> just after an SoC reset after power up, the I2C bus transaction
> may be cut short leaving the EEPROM internal I2C state machine
> in the wrong state.  When the switch is reset again, the bad
> state machine state may result in data being read from the wrong
> memory location causing the switch to enter unexpected mode
> rendering it inoperational.
> 
> [...]

Here is the summary with links:
  - [net,v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset
    https://git.kernel.org/netdev/net/c/23d775f12dcd

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

end of thread, other threads:[~2023-08-17  3:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-15  0:13 [PATCH net v3] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset Alfred Lee
2023-08-15  1:16 ` Andrew Lunn
2023-08-17  3:18 ` Jakub Kicinski
2023-08-17  3:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox