From patchwork Sat Dec 7 07:53:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B6rg_Sommer?= X-Patchwork-Id: 13898196 X-Patchwork-Delegate: kuba@kernel.org Received: from s1.jo-so.de (s1.jo-so.de [37.221.195.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A3DD823DE for ; Sat, 7 Dec 2024 07:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.221.195.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733558027; cv=none; b=aKzKou/oWRHKlGI3IbdqJbdvs3Uc/VJXL7OE/CQ4/OocmNYi0DB2JUr+ByAcgzTRa2G7P4bj+vyTm3GCorGI3XzYMizfjFolhej1zeZjhOdMFyZKXdaHiyvD8mt899l20Ipjg91NgKzsT5K+Dvobn5+cR3Rp0BA1fT5s1l0AsUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733558027; c=relaxed/simple; bh=0crVhjekl/TufH0e58YsLfi54DeRvyDwZuVYybgcy9M=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=o3lwqHA1bHOoj7C1fuCCIVdKWXtIovRve9Ty539jPQfcJ/D2f+Tt25AkA0KyGTixkz+YhzImeeJDNbc+8m6QeHoxlj5qekxyuiEytyPPxwaOXxlMuDndI5mynYCbXXD+hyuBXHChbhQp25QJQ6v0DPyClGUD8+EY4qG2cdST980= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jo-so.de; spf=pass smtp.mailfrom=jo-so.de; arc=none smtp.client-ip=37.221.195.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jo-so.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jo-so.de Received: from mail-relay (helo=jo-so.de) by s1.jo-so.de with local-bsmtp (Exim 4.96) (envelope-from ) id 1tJpdC-000d4H-3A; Sat, 07 Dec 2024 08:53:38 +0100 Received: from joerg by zenbook.jo-so.de with local (Exim 4.98) (envelope-from ) id 1tJpdC-00000000s0R-0QLE; Sat, 07 Dec 2024 08:53:38 +0100 Date: Sat, 7 Dec 2024 08:53:38 +0100 From: =?utf-8?b?SsO2cmc=?= Sommer To: netdev@vger.kernel.org Cc: Christian Eggers Subject: KSZ8795 not detected at start to boot from NFS Message-ID: OpenPGP: id=7D2C9A23D1AEA375; url=https://jo-so.de/pgp-key.txt; preference=signencrypt Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline 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 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 Signed-off-by: Jakub Kicinski 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 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. */