From mboxrd@z Thu Jan 1 00:00:00 1970 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 8164EC4338F for ; Tue, 24 Aug 2021 12:02:40 +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 0CB0B61262 for ; Tue, 24 Aug 2021 12:02:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0CB0B61262 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4396182F1A; Tue, 24 Aug 2021 14:02:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="Gdaq/ihx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 262A281E3D; Tue, 24 Aug 2021 14:01:16 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0609.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::609]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 02C1F82E08 for ; Tue, 24 Aug 2021 14:01:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vladimir.oltean@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nhQ8iNRQQZHEqGYserXH9vZ+iPw65W/AnkOFH226/y/QxlWaGxlvKFSNX65OHUr6eJa5MBqM33Ro1DriOYlNI/gkzhu6/WX/MQBlee2eu/IoMgt++24BBhHNgcY5a2lTfP9tsKax0jv954HoWWciohtQ+l9L5rQFhRFqUnoXYX7A6hx4Hfg8nNSUfoNmztHJPzVnsCGDYOWiDSXBAxUuxAA8KUgxLiMS44FCIecZp3jKeoaDgBNYsD0/a+bX70OEx0OPanWpaz+nJDJPcmupjf5H6xyAfCYAQ/IERiwxlGeBvCGpc34ozjwYqh2+FtKXoqtCzrd+CJuQ1ImEsydZZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m817TV3WyUq4D2R0zm/m8iEdLe88NGFju0D5c3ewkwE=; b=maFExKwJT456kuJ5ub2aH1J6MkmdNK2HJBstghuECJxSPycQrDAFl1oxDFJXB5NLW0X0ehaXOd0zIF4OL2zwkGr0xU33dduwSN5Uh1LI1YLFxbgT+jrEjXmqyYH88uJmfl3g7GFEfQbc8NcsfZlJGoe7UJUFSyyeIngNKZvMlJuAcocMVXUlKxnzNUuqJbc3+ah0eVZWqloayZW89n9CesXLy7Q/v+jobNmdy00/KkAmN11DpfGUKRNdwEnPU93pOf1QdcwaY0ESWnXgw7fK8BL9D+ANeVZDFmSpwYQ/rciPJxhJLe8PY3m4vtp8U5X2vIOQ+PaR4wTMHe8Q9k45bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m817TV3WyUq4D2R0zm/m8iEdLe88NGFju0D5c3ewkwE=; b=Gdaq/ihxiL3ERadJblOALCn6Eb6xjC4L/RoGjsszKWHrPX0CpzP+HBkxv/hglQhyKUIwBWeqYUlPXO6ebiRuDDVGnhiTBld0oJXmOTNwOkixJ2w99/b8nitQGJF6MGd6IOvvWJzBzXGrPjWI4x/NHT6GOLVJjXSRpHiT9jyBEhk= Authentication-Results: ni.com; dkim=none (message not signed) header.d=none;ni.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0401MB2510.eurprd04.prod.outlook.com (2603:10a6:800:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Tue, 24 Aug 2021 12:01:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4436.025; Tue, 24 Aug 2021 12:01:02 +0000 From: Vladimir Oltean To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de Cc: Claudiu Manoil , Michael Walle , Priyanka Jain Subject: [PATCH v2 5/6] net: dsa: felix: call phy_config at .port_probe() time Date: Tue, 24 Aug 2021 15:00:42 +0300 Message-Id: <20210824120043.3823931-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824120043.3823931-1-vladimir.oltean@nxp.com> References: <20210824120043.3823931-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: PR3P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by PR3P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 24 Aug 2021 12:01:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e932f7a-babe-46b4-bf57-08d966f6d833 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2510: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eNcHWa1w8kPieoC84x35tO3tLwtVia7Il+xgENLtq/Fp4qrL0b8CKcKNdRcnpfMTwAxus0xe/UXRgriUF2W+0xDPCyM+oWLSxxCx6EvheAHI0OzIW568jVik39qG4+ZxjcrfJ8uHW5k05a2lJ5UhYJ+MgJ4k+Tlpv4DIpz8Y2f4tj448ecVege248b+hXyQ9pzKfqfnVjifNzKfDWJ1h/DTLdpZU85T+JPZDUXNWu+f87sD6FtYb0khAUD4qlhjumZXlvyZn1DlUlO3VWujeg7/Ulf0WMH9I9k8cFOBiGTygBZa8s8Nc4WnNyT7lAmkdMwL+uo65YSx7qDFds/bzvlk5hKDSSw5odOQYsnKuKzJ4zFlk0hoFpJfoRge7taZytVczRthaL6xom2HC0tzMbojEY96wM3CVMU5ZUOfJXM+bQq3St5MRl0GaweL/g2lYB9xie4k1kYiCmn7O3YfaJog7eUovnqUv1KD7JKiUw6s40n5DO/jaDGz1/Zoqba+d6/1rLaGlUVZhpd6pStl+ZZKkp04+6XbKhEWhhH6MD/nYSWV0AhAcbpdyYhQ7oZ2RoYdyOBzScQhFmx0P865Ib1NO4OqbRx1YAIjL+2Od9lZUFjblsY7SKklYM/ciyYrcvlmJsZa99WxBEjYu5HnnQkSGL9d37BW2GXh5zcBWcnk33dlvbqVk3WbDVQAT0baSTdWpfc3I0Nqw28QP5xW7HOdBqZ7Kn+O6r1Y8kc7jAxgEefpzdjQb5g5C5BM6fHK03Vw/t8SO6rOQ4tQqUjW9J/J+FHtdKScQG0zzZPkeO/4GKi5NthdpyPhay4q7XG1V X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(39860400002)(396003)(136003)(36756003)(186003)(26005)(83380400001)(8676002)(66946007)(66476007)(6666004)(66556008)(86362001)(4326008)(316002)(966005)(5660300002)(478600001)(6486002)(8936002)(54906003)(38100700002)(38350700002)(2906002)(1076003)(6506007)(110136005)(6512007)(956004)(2616005)(52116002)(44832011)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?NCJt0wr/ptu9zCM2+rVEHUpTofaTtILsNjr9RfI4ZlxiPVL6aSCF19uoO11/?= =?us-ascii?Q?uHSgOliASicggDdCbB7kSREAXkBDxiV2fiyGpRbalxf2MqXPt/9IgRLfBGjP?= =?us-ascii?Q?u9omViCHnIWQ6i799F+D5bhyeYaNcohfEd/xiJcLa2dvhmiyVdcCHlkgsAs7?= =?us-ascii?Q?f25BegW5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PHN56R?= =?us-ascii?Q?svKL1H+hj8Yo4j0cbggZncYBtGPRqxWFJFa9/+pI5cZfNG4hybk4buevsiTA?= =?us-ascii?Q?Lu8EnB425HUoFJD0fTG2P+1skxwtm3qhPvFR7owwVK+Ly/p2nYNGu/DFJHts?= =?us-ascii?Q?SWN62yMc8VYJdTrKWffA+PzVbu/UECPbTgSyonNpNuTdvO3WjPxXy1Cno1DW?= =?us-ascii?Q?L6ruWOGZFd2jd3whAZOXf0VHdhkgyISf4Qr6bemGEBr1nsThAy1NssozA9MF?= =?us-ascii?Q?RxB8Y5szuBg2urcXzxn9z7AR?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e932f7a-babe-46b4-bf57-08d966f6d833 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 12:01:02.6352 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nB1HzgqWaKo4H0XdkQl1CjnWiq7oaHCFEpbWxeP8Dg0nWO4Zy/vb2Ecmg9TfsD30ezWl3OKm4sutIupzq7bB6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2510 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 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 Reviewed-by: Ramon Fried Tested-by: Michael Walle --- 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