lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ojegz5rmcjavsi7rnpkhunyu2mgikibugaffvj24vomvan3jqx@5v6fyz32wqoz>
Date: Sat, 7 Dec 2024 08:53:38 +0100
From: Jörg Sommer <joerg@...so.de>
To: netdev@...r.kernel.org
Cc: Christian Eggers <ceggers@...i.de>
Subject: KSZ8795 not detected at start to boot from NFS

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@...i.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@...i.de>
    Signed-off-by: Jakub Kicinski <kuba@...nel.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)

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ