Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp840336lfb; Fri, 13 May 2022 21:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHol98svsQuE4uWRxmo5ncojjm+KaodwRGDwYiFr7S3W/f9UnvDC7KKvlaSjQdoLWyixa6 X-Received: by 2002:a7b:cbc2:0:b0:388:faec:2036 with SMTP id n2-20020a7bcbc2000000b00388faec2036mr7425652wmi.190.1652502435051; Fri, 13 May 2022 21:27:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652502435; cv=pass; d=google.com; s=arc-20160816; b=CVMneBem0VSYj/EnDk7E8I0knDRzppa9xMPzOTv0wbVZX+yo4mYOgUfK2UlC8sJZrz UcJ9CWskGKTo28JZfK4IeC13+ixUAR29JRJRcQTNgH2iwQIv3U//N+I8ehaIY/I4Bd4Q EU30DhO5QkHtsI8/hy4sibmMMgG3ErCx4CpZxzPmCbkKSFOYfEsSKbd12wgReqMb0Bkj jHkUvoIS10GhORDIhf17wqSZdTDXG6xjNqKWwMS2jGw0Mt0F6vBmX1223RTaWnmNVJ4I llozo56ZJyOpd8wzT6CaAQssOwpBMET9Y/MFoPre/E9OEPkrgmctq742f/dGBQkZXRcA IpQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tJnvsok4/O5C43WNG34rhSOKBJdmEiD4Y+CyjcACWKM=; b=cPghLdNK2QhkgZIwJd1mx2PaKay3ziSjNVymVGoXxbcxbxiUW0N7V4Q51NLhYdIIGZ IbBVV+5L865vuw2lyOaSUOugIHu5tRkpPZpqNDCxE07d6BORjY8//wZhtbdYMHyM/2ds Mhz1goK0gWD3+HMQ5O4K7nllA2D/TlicJuKf3oRTsX8GXE5lKjokAOfiH48RPqBfxVaj K36jblGqu39elBw/raTeIo3SwprKphMePiUq0Wg00HaiKFLljV/uA+q8cNnyaRH7JfBF 2SFT7NW1JBwNadGWbEY83mlx15zJljC9loQQq36RyCZaqiaJe2S4Rp+JSnn5YAMeYlGa 6zcw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=J5RS7rF8; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id az30-20020adfe19e000000b0020ad8314da3si4117351wrb.262.2022.05.13.21.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 21:27:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=J5RS7rF8; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BABD8394A5B; Fri, 13 May 2022 18:30:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiENBaW (ORCPT + 99 others); Fri, 13 May 2022 21:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbiENBaU (ORCPT ); Fri, 13 May 2022 21:30:20 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50079.outbound.protection.outlook.com [40.107.5.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9878E373C6C; Fri, 13 May 2022 16:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QGKNT66ie6usLRrfXRfLbvdaBzBuSPlyiqigHCOt+2I2nrJ3bJQOfNKajFVRN5eQtsrWvM7pXhhOXe2OlCAUmv3qbtfuU4kS7RumnVyhar7kC/YEF/foszLTouJ0gSoWMZmtK2pPasekULxKlsFomypgMRlRKFkPnV7T7To6pxcmu5egdV0AsAGdaegV+PgZ90Yz3gUF93dWK1VwxICudCttgZA9lyy1eo+snNFd7RBpFNygHJ39aP95bt2wNpZjpzyzPMRJjSqE8iyKJGRiDiRpXpeT7PtjSpM0TUtS6c3CbJ2YwqWAy3+FO1KAKFGgIrcqNCPZ/ZX/rsw7kw5ErA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tJnvsok4/O5C43WNG34rhSOKBJdmEiD4Y+CyjcACWKM=; b=P2AHxhGJjqjn9w2nolDp3PYPav9J2XUcv56T1H8+wmnhb6ttWPhbMsrxobGJDhD6KjxVxDHAl1Mh6BnbVAWyy1gmvRCT+24qmbWllbpdCv2TLPnmNXPNT7f7sry7YsCQCJHv+xNeOOJ6ZQjKseOy4sUw9D8oHepQs5cgoB/sISwFDO1/lnSw/+mcks+DddKgfQDrYaCECXF5oFL0ax4B1fniae6H+lV98RpRZ5Ndbgqm3/W1M2w5U4+WKavHuh27UXylQMFlgkUZ4ujW+2eKrJNQIUe5b2Pvdi3d4/aoB1a674w9oI2tkOjA+cyjVGtjTfDjfGJNkHZ3CTgHKg2GGA== 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=tJnvsok4/O5C43WNG34rhSOKBJdmEiD4Y+CyjcACWKM=; b=J5RS7rF8SrqgHyF4F4daH2RcRtNw7p9dveW563vIFNX6cFmG+UestUUUkJh3J1m7TGxGjJsxcDtD8PCnS/vDjyYNzvYUm47gO2Tb7q/U10mcHN7peSga9/c4BRvxJTeMbW8LPTNndjK7VYUtPED8SJRdOXDxSi8rYJZvKUf30ow= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB7PR04MB4972.eurprd04.prod.outlook.com (2603:10a6:10:1c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.17; Fri, 13 May 2022 23:36:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Fri, 13 May 2022 23:36:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Saravana Kannan , Greg Kroah-Hartman , "Rafael J. Wysocki" , Robin Murphy , Geert Uytterhoeven , Rob Herring , Frank Rowand , John Stultz , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Russell King , Heiner Kallweit Subject: [RFC PATCH net 2/2] net: dsa: wait for PHY to defer probe Date: Sat, 14 May 2022 02:36:40 +0300 Message-Id: <20220513233640.2518337-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513233640.2518337-1-vladimir.oltean@nxp.com> References: <20220513233640.2518337-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AM6PR08CA0027.eurprd08.prod.outlook.com (2603:10a6:20b:c0::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 132ca0b2-9473-4f6f-5e84-08da35397953 X-MS-TrafficTypeDiagnostic: DB7PR04MB4972:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ExITxyUAVxaqYIx6yab7WMcZC1eggdOhpeZAiU4zZF2OwVWCfwQFPg+cJAd2pSy/1PkX86tvH0yrftgT67itLgpmKpPvq9TMx/qhf4DXFEjqUCf8kuNhX/1eN3BPwBKtTDyJY655lMZN9P4gOCCRzHI3EX8gYObn6nU0o8h9578iWrfXxwUBqvBuKbdx6glHpImtHqJQozdMXmRjV18wFg84kqAB+1Q+2XaJ1aCr427+0ltkn9+3RJrwHuH7qFOZcwGxRtatEhEeknqdmbp5Q9y/SE2MNi46ovUO9JjOf+uDn1tTQABBcmmnTcEmTt0Vrv54x8gMjpy4GRr1Cr8er/Bgw1UTfDTvlijfpW01EzmfoEvtHSVHgHQUuxigRn7s5hs47MQepbEEpLHfWY8dQj3Doly/GbPcW5JYjahwM+MUw6fSLva9y019qUEKyDemG2ykAQ5fRWTt802onc9+dcbz+0Dr02YvWW/5XIdz7E2Ri9/IHRu5up/K1hnrQbQuZHWbZMsoqQOROBbE997/rUUteyJAlFES4oQ4nzU1RECcImHrnsPhXQIVe8GhhBwJq1OkXHDMen319Gsmq4JZnyYdWGqiTmhjdgPyp0XbQouA4wBzCyZnoEJNPevbjtuXjWq14lPB3X66hmKDh8dhWKTAi6lBNT+/+soNlreucZKyOHmEIAly/LvN5CczqK0nb8T97VOfZLHZybppinzncQ== 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:(13230001)(4636009)(366004)(66476007)(508600001)(38100700002)(38350700002)(6486002)(66556008)(8676002)(66946007)(4326008)(6916009)(83380400001)(54906003)(86362001)(186003)(316002)(1076003)(2616005)(6666004)(6506007)(52116002)(26005)(6512007)(36756003)(2906002)(5660300002)(7416002)(44832011)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Du5F/45MFvWvDB/+tWI5kyFPb4of/sUIUGBGEyMo06GLKD23dbgWpEnIc0Wc?= =?us-ascii?Q?TeHCxm7x/idjh4ikN9keO5k+pbXOMJ1zAF+fhjgrP2oeA3JiePZ3zQFx2W/w?= =?us-ascii?Q?j4Jtvl7Sb55+h/xhj3/W5ccdZzOsjNhgyaBx6uIXGUUW/3vJCBmZu+tl96Hk?= =?us-ascii?Q?PjQ5o+ArhfWeCMxUbpeLMMQfWYfjyFrHP/WhpgzDn0iMoNQgyiMCAYNpbyeY?= =?us-ascii?Q?+Ov2CG9Xm+wmRUH6Qk1/gXHO4jmRnWAV7Pxhy+w9E82W7QS5QKBumoMSa+ZL?= =?us-ascii?Q?AhOptXnbRccPqn2TvEL0E6xyIosfbDyFnfl3Z9sIaz3dWnRAxymaT6+a5K7o?= =?us-ascii?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/Q4uy0eo4c7s3FzL4XRwCoJXQf4?= =?us-ascii?Q?ctvggglpwoaT3IAxcK582mBUQ0Pa7mtVlkdu+DsFsR/rb+eE5M5bn66FYLH5?= =?us-ascii?Q?/0SBd/zP7aHKI2MEows7Ju6DfrFZVB+rvMO3Kz2d/LT4kEfX8QaY0Fn+e5N/?= =?us-ascii?Q?KBMNN1cwh9Lke29gJRj/Prnwqa8HlSnErgVOjQHegcyhOCzovG6nFJNS2Wi6?= =?us-ascii?Q?If5Lab6X5a92uUgI/7Ywe1Huh50OYbPvlUGTOWDMLoLOjCCVH7MqOOuUNAt5?= =?us-ascii?Q?sUeioncQk0wKCDegFaIBqX/uNr+ft0s5iOVuwCx7L2Hugso0mL6VX1za71iB?= =?us-ascii?Q?KjV0duTE8yN/36/GNUHB/MtvV5iv20ulf4OqcIXWpjc7wvMLsrBSvnM1zHaT?= =?us-ascii?Q?pZxLylSGL1c/d73yUdcRVCw79KQs49EHLkMOXMwZCISTZRlTxrkFU5ECPaLR?= =?us-ascii?Q?BjQUiEX4mrsebRTJC5t+g9am3Kk4wzVrVYTFyZZmXLujjPpnAkJ4o8eeOd6g?= =?us-ascii?Q?CvOWlj8+SONCFDA3STBwQr7iPa3zsas=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 132ca0b2-9473-4f6f-5e84-08da35397953 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 23:36:59.4857 (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: V80YeT44aY3cJ3QePlENJgftsoymZkTajWdCd4me7BAwbxss90GFIqVN+Z1DgaMFZsrKjo6ET7JJXmmetNl48Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4972 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DSA is among the 3 drivers which call phylink.*phy_connect() during probe time (vs 11 doing so during ndo_open). So there is no guarantee that the PHY driver will have finished probing by the time we connect to it. Use the newly introduced phylink_of_phy_connect_probe() to wait for this to happen, and propagate the error code all the way to dsa_register_switch(), which switch drivers call from their own probe function. Notably, in dsa_tree_setup_ports() we treat errors on slave interface registration as "soft" and continue probing the ports that didn't fail. This is useful on systems which have riser cards with PHYs, and some of these cards can be missing. But this logic needs to be adapted, since -EPROBE_DEFER is an error we want to propagate regardless. Fixes: 25396f680dd6 ("net: phylink: introduce phylink_fwnode_phy_connect()") Signed-off-by: Vladimir Oltean --- net/dsa/dsa2.c | 2 ++ net/dsa/port.c | 6 ++++-- net/dsa/slave.c | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index cf933225df32..3a2983a1a7dd 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1011,6 +1011,8 @@ static int dsa_tree_setup_ports(struct dsa_switch_tree *dst) list_for_each_entry(dp, &dst->ports, list) { if (dsa_port_is_user(dp) || dsa_port_is_unused(dp)) { err = dsa_port_setup(dp); + if (err == -EPROBE_DEFER) + goto teardown; if (err) { err = dsa_port_reinit_as_unused(dp); if (err) diff --git a/net/dsa/port.c b/net/dsa/port.c index 075a8db536c6..8a2fc99ca0ad 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1628,9 +1628,11 @@ static int dsa_port_phylink_register(struct dsa_port *dp) if (err) return err; - err = phylink_of_phy_connect(dp->pl, port_dn, 0); + err = phylink_of_phy_connect_probe(dp->pl, port_dn, 0); if (err && err != -ENODEV) { - pr_err("could not attach to PHY: %d\n", err); + dev_err_probe(ds->dev, err, + "DSA/CPU port %d could not attach to PHY: %pe\n", + dp->index, ERR_PTR(err)); goto err_phy_connect; } diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 5ee0aced9410..a5407e717c68 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2252,18 +2252,18 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) if (ds->ops->get_phy_flags) phy_flags = ds->ops->get_phy_flags(ds, dp->index); - ret = phylink_of_phy_connect(dp->pl, port_dn, phy_flags); + ret = phylink_of_phy_connect_probe(dp->pl, port_dn, phy_flags); if (ret == -ENODEV && ds->slave_mii_bus) { /* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead */ ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags); } - if (ret) { + if (ret && ret != -EPROBE_DEFER) netdev_err(slave_dev, "failed to connect to PHY: %pe\n", ERR_PTR(ret)); + if (ret) phylink_destroy(dp->pl); - } return ret; } @@ -2386,12 +2386,12 @@ int dsa_slave_create(struct dsa_port *port) netif_carrier_off(slave_dev); ret = dsa_slave_phy_setup(slave_dev); - if (ret) { + if (ret && ret != -EPROBE_DEFER) netdev_err(slave_dev, "error %d setting up PHY for tree %d, switch %d, port %d\n", ret, ds->dst->index, ds->index, port->index); + if (ret) goto out_gcells; - } rtnl_lock(); -- 2.25.1