Netdev List
 help / color / mirror / Atom feed
* KSZ8795 not detected at start to boot from NFS
@ 2024-12-07  7:53 Jörg Sommer
  2024-12-07 20:47 ` Andrew Lunn
  0 siblings, 1 reply; 18+ messages in thread
From: Jörg Sommer @ 2024-12-07  7:53 UTC (permalink / raw)
  To: netdev; +Cc: Christian Eggers

[-- Attachment #1: Type: text/plain, Size: 4534 bytes --]

Hi,

I'm trying to load the root filesystem via NFS with a
NET_DSA_MICROCHIP_KSZ8795_SPI attached to an TI_DAVINCI_EMAC. With 5.10 it
works, but with later versions the kernel fails to detect the switch. It is
since

commit 8c4599f49841dd663402ec52325dc2233add1d32
Author: Christian Eggers <ceggers@arri.de>
Date:   Fri Nov 20 12:21:07 2020 +0100

    net: dsa: microchip: ksz8795: setup SPI mode

    This should be done in the device driver instead of the device tree.

    Signed-off-by: Christian Eggers <ceggers@arri.de>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

diff --git drivers/net/dsa/microchip/ksz8795_spi.c drivers/net/dsa/microchip/ksz8795_spi.c
index 8b00f8e6c02f..f98432a3e2b5 100644
--- drivers/net/dsa/microchip/ksz8795_spi.c
+++ drivers/net/dsa/microchip/ksz8795_spi.c
@@ -49,6 +49,12 @@ static int ksz8795_spi_probe(struct spi_device *spi)
        if (spi->dev.platform_data)
                dev->pdata = spi->dev.platform_data;

+       /* setup spi */
+       spi->mode = SPI_MODE_3;
+       ret = spi_setup(spi);
+       if (ret)
+               return ret;
+
        ret = ksz8795_switch_register(dev);

        /* Main DSA driver may not be started yet. */

The kernel reports

[    1.912756] ksz8795-switch: probe of spi0.1 failed with error -22
…
[    2.048054] davinci_emac 1e20000.ethernet: incompatible machine/device type for reading mac address
[    2.062352] davinci_emac davinci_emac.1: failed to get EMAC clock
[    2.068632] davinci_emac: probe of davinci_emac.1 failed with error -16

It tries to initialize the switch before the ethernet of the SoC is ready.

Before this commit the kernel returned EPROBE_DEFER instead of EINVAL (or
ENODEV) as a quick

```
dev_err(&spi->dev, "ksz8795_spi_probe:%d: ret of ksz8795_switch_register=%d\n", __LINE__, ret);
```

reveals.

Without 8c4599f49841dd663402ec52325dc2233add1d32:

```
[    1.809914] ksz8795-switch spi0.1: ksz8795_spi_probe:60: ret of ksz8795_switch_register=-517
…
[    2.069770] ksz8795-switch spi0.1: ksz8795_spi_probe:60: ret of ksz8795_switch_register=-517
[    2.209715] ksz8795-switch spi0.1: ksz8795_spi_probe:60: ret of ksz8795_switch_register=-517
[    2.223625] davinci_emac 1e20000.ethernet: incompatible machine/device type for reading mac address
[    3.110937] ksz8795-switch spi0.1 lan-x1 (uninitialized): PHY [dsa-0.0:00] driver [Generic PHY] (irq=POLL)
[    3.125766] ksz8795-switch spi0.1 lan-x2 (uninitialized): PHY [dsa-0.0:01] driver [Generic PHY] (irq=POLL)
[    3.140779] ksz8795-switch spi0.1 lan-x3 (uninitialized): PHY [dsa-0.0:02] driver [Generic PHY] (irq=POLL)
[    3.155026] ksz8795-switch spi0.1 lan-bp (uninitialized): PHY [dsa-0.0:03] driver [Generic PHY] (irq=POLL)
[    3.168579] ksz8795-switch spi0.1: configuring for fixed/rmii link mode
[    3.175324] eth0: mtu greater than device maximum
[    3.180273] davinci_emac 1e20000.ethernet eth0: error -22 setting MTU to include DSA overhead
[    3.189075] DSA: tree 0 setup
[    3.192155] ksz8795-switch spi0.1: ksz8795_spi_probe:60: ret of ksz8795_switch_register=0
[    3.204819] device eth0 entered promiscuous mode
[    3.209962] ksz8795-switch spi0.1: Link is Up - 100Mbps/Full - flow control rx/tx
[    3.221219] davinci_emac 1e20000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
[    3.232894] ksz8795-switch spi0.1 lan-x1: configuring for phy/gmii link mode
[    6.409818] ksz8795-switch spi0.1 lan-x1: Link is Up - 100Mbps/Full - flow control rx/tx
```

With 8c4599f49841dd663402ec52325dc2233add1d32:

```
[    1.808910] ksz8795-switch spi0.1: ksz8795_spi_probe:60: ret of ksz8795_switch_register=-22
[    1.817612] ksz8795-switch: probe of spi0.1 failed with error -22
[    1.823992] spi_davinci 1f0e000.spi: Controller at 0x(ptrval)
…
[    1.952350] davinci_emac 1e20000.ethernet: incompatible machine/device type for reading mac address
```

So, I inserted these lines and it works.

```
        ret = ksz8_switch_register(dev);
+        if (ret == -EINVAL || ret == -ENODEV)
+            ret = -EPROBE_DEFER;
```

Is this the correct solution or should it be done something different?
Something like this is still missing in ksz_spi.c:88-100.


Thanks in advance.

Kind regards, Jörg

-- 
Manchmal denke ich, das sicherste Indiz dafür, daß anderswo im Universum
intelligentes Leben existiert, ist, daß niemand versucht hat, mit uns
Kontakt aufzunehmen.                           (Calvin und Hobbes)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2025-01-08  0:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-07  7:53 KSZ8795 not detected at start to boot from NFS Jörg Sommer
2024-12-07 20:47 ` Andrew Lunn
2024-12-07 21:07   ` Jörg Sommer
2024-12-07 22:44     ` Christian Eggers
2024-12-08 16:44       ` Jörg Sommer
2024-12-10 16:43         ` Jörg Sommer
2024-12-10 17:41           ` Andrew Lunn
2024-12-10 21:21             ` Jörg Sommer
2024-12-11 10:18           ` Christian Eggers
2024-12-11 12:23             ` Jörg Sommer
2024-12-11 13:04               ` Christian Eggers
2024-12-11 14:46                 ` Jörg Sommer
2025-01-05 16:33                   ` Jörg Sommer
2025-01-05 17:08                     ` Andrew Lunn
2025-01-06 13:38                       ` Pieter Van Trappen
2025-01-07 22:14                         ` Jörg Sommer
2025-01-08  0:07                           ` Tristram.Ha
2024-12-11 13:24             ` Andrew Lunn

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