Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 953CDC11F67 for ; Tue, 29 Jun 2021 17:10:06 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1368661DE2 for ; Tue, 29 Jun 2021 17:10:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1368661DE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4CD4831CA; Tue, 29 Jun 2021 19:09:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TEu4Qoys"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCE31831BC; Tue, 29 Jun 2021 19:09:17 +0200 (CEST) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6DD4182DF5 for ; Tue, 29 Jun 2021 19:09:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=olteanv@gmail.com Received: by mail-ed1-x533.google.com with SMTP id w13so26297763edc.0 for ; Tue, 29 Jun 2021 10:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sgZN0YDMWJnuYPlSjYY4A+qG7WiZRC4V7GfTOdmOthI=; b=TEu4Qoysy0hGpBKhikcX90gRlXunGBPZhYBjk8qCAEVjG6t3Lc0VIp3uqF8spXXyR8 AGEHqRR7qPHFqjW2ZpZwkXaDlMpU/dghv8HG/Qm4ZVoTvpjqMcffPQGyak6kFE7NWTlU IMZOniDqZ/y5suqFbb5Zx6EbOHFHmkB4HkK2wCLIptVkaD9edtrv3534Dxhsb67ofQyy PDKvdzqEA4MCDMGrg3T7KWH+BhIkwdJv9/A33yEPMYhG7HLV4M2XL9yAq60lXra0XQVH FMpwtgcJQ3oPb1YeoOeW+M/ftFJ4krJrXsULcbQCmJGCw66AEQd+11OhmiG9nj/dd5H+ TCaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sgZN0YDMWJnuYPlSjYY4A+qG7WiZRC4V7GfTOdmOthI=; b=R5TuhbtGglAUCFfmVSgxgsyYy3S6MQ8UXVAciP6tzs2yi3poa9SH3HamAvxW5G/cFa EcfeiVxzf+uF4hhk/PMquMWz+W4Omb+N4JYBoijd9NFEfuLmN5u0htuPOYWqLyE2eal6 9jp2sEZNYfZYvVuL7WSwWmIK8Tk2Oro/0pODfmpdlgHoql4AasLDZZ63xSBRx0mZzFr6 iP8Kq7y1RbmbBWsjMkFgxooaT+BtOMOJOlxE7IAqVTOpruWy94hBTmomLQ0U00QP5Xud sSxWVh0PBDJTwlEvtIfS7U5MRdaizJzntfP9xKVPuOfzUU+9ZjvmGlNEkp9kjRuInxoe fZLA== X-Gm-Message-State: AOAM531RPMfxkeW4OdlopaGT/q855YBDM1epGcepa1FBv/opDysCL1zI /9FlqXU81tg1S+cITJGVA4s= X-Google-Smtp-Source: ABdhPJyrDXa6hqNpo7MNntrhjMErpTx8O4wD4FdSsYa55WA1qouL7q2ZSAzsqwZOAASc/YYnfsY52Q== X-Received: by 2002:a05:6402:17d3:: with SMTP id s19mr42192391edy.222.1624986554136; Tue, 29 Jun 2021 10:09:14 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id h19sm9928525edt.87.2021.06.29.10.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 10:09:13 -0700 (PDT) From: Vladimir Oltean To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de Cc: Claudiu Manoil , Bin Meng , Alex Marginean , Michael Walle , Tim Harvey , Vladimir Oltean Subject: [PATCH 5/6] net: dsa: felix: call phy_config at .port_probe() time Date: Tue, 29 Jun 2021 20:08:38 +0300 Message-Id: <20210629170839.2583797-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210629170839.2583797-1-olteanv@gmail.com> References: <20210629170839.2583797-1-olteanv@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Vladimir Oltean It is an unfortunate reality that some PHY settings done by U-Boot persist even after the PHY is reset and taken over by Linux, and even more unfortunate that Linux has come to depend on things being set in a certain way. For example, on the NXP LS1028A-RDB, the felix switch ports are connected to a VSC8514 QSGMII PHY. Between the switch port PCS and the PHY, the U-Boot drivers enable in-band auto-negotiation which makes the copper-side negotiated speed and duplex be transmitted from the PHY to the MAC automatically. The PHY driver portion that does this is in vsc8514_config(): /* Enable Serdes Auto-negotiation */ phy_write(phydev, MDIO_DEVAD_NONE, PHY_EXT_PAGE_ACCESS, PHY_EXT_PAGE_ACCESS_EXTENDED3); val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_MAC_SERDES_CON); val = val | MIIM_VSC8574_MAC_SERDES_ANEG; phy_write(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_MAC_SERDES_CON, val); The point is that in-band autoneg should be turned on in both the PHY and the MAC, or off in both the PHY and the MAC, otherwise the QSGMII link will be broken. And because phy_config() is currently called at .port_enable() time, the result is that ports on which traffic has been sent in U-Boot will have in-band autoneg enabled, and the rest won't. It can be argued that the Linux kernel should not assume one way or another and just reinitialize everything according to what it expects, and that is completely fair. In fact, I've already started an attempt to remove this dependency, although admittedly I am making slow progress at it: https://patchwork.kernel.org/project/netdevbpf/cover/20210212172341.3489046-1-olteanv@gmail.com/ Nonetheless, the sad reality is that NXP also has, apart from kernel drivers, some user space networking (DPDK), and for some reason, the expectation there is that somebody else initializes the PHYs. The kernel can't do it because the device ownership doesn't belong to the kernel, so what remains is for the bootloader to do it (especially since other drivers generally call phy_config() at probe time). This is a really weak guarantee that might break at any time, but apparently that is enough for some. Since initializing the ports and PHYs at probe time does not break anything, we can just do that. Signed-off-by: Vladimir Oltean --- drivers/net/mscc_eswitch/felix_switch.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/mscc_eswitch/felix_switch.c b/drivers/net/mscc_eswitch/felix_switch.c index 75073880cf87..c8ecf4f19442 100644 --- a/drivers/net/mscc_eswitch/felix_switch.c +++ b/drivers/net/mscc_eswitch/felix_switch.c @@ -317,10 +317,23 @@ static int felix_probe(struct udevice *dev) return 0; } +static int felix_port_probe(struct udevice *dev, int port, + struct phy_device *phy) +{ + int supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full; + struct felix_priv *priv = dev_get_priv(dev); + + phy->supported &= supported; + phy->advertising &= supported; + + felix_start_pcs(dev, port, phy, &priv->imdio); + + return phy_config(phy); +} + static int felix_port_enable(struct udevice *dev, int port, struct phy_device *phy) { - int supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full; struct felix_priv *priv = dev_get_priv(dev); void *base = priv->regs_base; @@ -339,12 +352,6 @@ static int felix_port_enable(struct udevice *dev, int port, FELIX_QSYS_SYSTEM_SW_PORT_LOSSY | FELIX_QSYS_SYSTEM_SW_PORT_SCH(1)); - felix_start_pcs(dev, port, phy, &priv->imdio); - - phy->supported &= supported; - phy->advertising &= supported; - phy_config(phy); - phy_startup(phy); return 0; @@ -392,6 +399,7 @@ static int felix_rcv(struct udevice *dev, int *pidx, void *packet, int length) } static const struct dsa_ops felix_dsa_ops = { + .port_probe = felix_port_probe, .port_enable = felix_port_enable, .port_disable = felix_port_disable, .xmit = felix_xmit, -- 2.25.1