From nobody Mon Sep 15 00:30:05 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE556C63797 for ; Tue, 17 Jan 2023 05:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235220AbjAQFyh (ORCPT ); Tue, 17 Jan 2023 00:54:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235534AbjAQFy3 (ORCPT ); Tue, 17 Jan 2023 00:54:29 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2044.outbound.protection.outlook.com [40.107.21.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8633C227BF; Mon, 16 Jan 2023 21:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7TBgdCQEuvEjPKI6tHxWnsU6ftDC4dDPVw5HRR6Y/4Uj7Fm/GdtdL1YyjW9XLRk80jue8B2/eS3jKqw6LtkORzqSO3VrunblvOL59B+yZ3i9QgnFh3GWlOwioPzsyMdWTtW+U9czkBGmmoIJy2SzKu6I+iWgXr+EsH1wEc1/HkOWX4MAsi6b9LzH2KvHWyoKLIlI9LuVbVW5VW7QlK7iXO6z8cvxl5LKR5b9ZM3Rvo5Y9ytAAeu5lUOQ7rtNy8PFqUqLmAk0dvOnw29WrAmHeZvTA4xYqeWWH5a33nEwxhWUY8WDpNPO63/mxUI2G3MzQo8KlbWrMUDRn/a2kbq+w== 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=ciz1Mc2uFU7oVfNkfpFtCRQ5Ud3p1cvgW4JT1b9CSdA=; b=QvG957nUUL764DnN/LMu2V2+l95K8FZZ5hjMaFCsrmwIzeC6M9WTIy5jcyMLqhF4/g1m2Mhq+hFLq6J6Gdtgtm97lRldQ5NW5MW4CHGFU0r1hNm+dPKVafAjy0x9E9b8rleG+08l6yFw+N3G20AERPI4hcDYsk3STOzGlOaSAAE9gaeSqMtaIOjLrieGZlArk4n1NmseaQlNAiA80F+PYehzqI3CTNmeBMRUQpWZtKBPEt208OVmQ8mKHSpdJyeFrM2Akt1NT8pdX6szuDqYrb/gqzEf23vyCaBlWPDRgYIbb9Y/BY2gWADjBARixigHwmFsWFeha1jzNZi/PfEQUg== 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=ciz1Mc2uFU7oVfNkfpFtCRQ5Ud3p1cvgW4JT1b9CSdA=; b=TqDPCIxL7Tji/KMwzuKNaNza7gyi5uJDrQf9/Uv2sXYZvoSTHWCYP8CGcpqEwfnhOqgBN8ZkFZnX3U5kqP8pYny0eaYc+PGGeJ190jxULAeAj+5TT5tKGNdu5dT3PF1wD+9Yl4KcRq2ASBBvlFSOyLzLT5OhmySse0++iWHlW80= Received: from DB9PR04MB8106.eurprd04.prod.outlook.com (2603:10a6:10:24b::13) by PAXPR04MB8428.eurprd04.prod.outlook.com (2603:10a6:102:1ce::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 05:54:21 +0000 Received: from DB9PR04MB8106.eurprd04.prod.outlook.com ([fe80::5b45:16d:5b45:769f]) by DB9PR04MB8106.eurprd04.prod.outlook.com ([fe80::5b45:16d:5b45:769f%5]) with mapi id 15.20.5986.023; Tue, 17 Jan 2023 05:54:21 +0000 From: Wei Fang To: Pierluigi Passaro , Andrew Lunn CC: Pierluigi Passaro , Shenwei Wang , Clark Wang , dl-linux-imx , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "eran.m@variscite.com" , Nate Drude , Francesco Ferraro Subject: RE: [PATCH v2] net: fec: manage corner deferred probe condition Thread-Topic: [PATCH v2] net: fec: manage corner deferred probe condition Thread-Index: AQHZKSmth/GaxUjULU+HlYnwAPdOW66gBiKAgAAHoYCAABs7gIAAlDMAgABv7oCAAFFXgIAAkZzw Date: Tue, 17 Jan 2023 05:54:21 +0000 Message-ID: References: <20230115213804.26650-1-pierluigi.p@variscite.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DB9PR04MB8106:EE_|PAXPR04MB8428:EE_ x-ms-office365-filtering-correlation-id: 588659aa-7e4c-4bdd-068d-08daf84f47a1 x-ld-processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: F4YFxkfq6d64VKwmURHMyi88F1QY5FYtI1U4/ACOx9YjZ15M2wI+udM6PcbxnaIqtFMNBrvRkzJhygp9ynarnSIq8X0jFfhuhWdBIbasHKvElxsGmcfTsRenxAn2diZke4U7BrCV6UiSyj18FSBw8vLqRMGUz9nJV47/jGe4FtvmK0k8Byv3pKqqRvNjaO240CGp8CcgK/Tpr86nOOhKzhfheIRTRU8IhK6TOBheAZI2wC+zI29MnC37W+q6EEiN8vvieKoWV0Vw1pH0VAApaj94nh068ucQbSheO+m8mFWA+pGOd8PsKZWKcB/s3AQLzLDB/sKp8613XUDte36KPeej861ULOuf1gfSymKy1IDwBk95Yzh0mZdwJ0RhikVIKuRa4j448Uj35eFNznI/udP4EpiiJ9qBbwFW5PXD2JL6ol3oEYBDnM/E9FbXXBBx3HdHvBQwTtB9DvjjfvSP+3hIxZlLAqqMAhTQ8rFGTvmM4z7IXWBiM1az6858HjHIOXNhFNMMXeSuYostyqFfmFiMEjx84L0xixAR2iaLK9TwWdr5+O04Vo1XgsHHGPyipng72Gw7dOmwvW7o1gTyow4YyP6CRO/Kups7FE14sZ6iCRPlQyYBEmhmAuPVq/MxiDdo7TYibMAjPIo9Rz/wH8kbRNlHa5ROn86kxq8YqOyNQZqIYt/YQtbUcmfHviqP7zVXFFK61bXTz4/ueG6UwA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8106.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(346002)(136003)(396003)(451199015)(8676002)(38100700002)(86362001)(38070700005)(64756008)(8936002)(44832011)(66556008)(66476007)(66446008)(66946007)(76116006)(52536014)(55016003)(5660300002)(2906002)(7416002)(4326008)(83380400001)(122000001)(33656002)(478600001)(7696005)(110136005)(54906003)(71200400001)(316002)(41300700001)(53546011)(9686003)(26005)(186003)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?Tmk1bVdvcE5OaTNuTFo5WnRjd2xueHM0WmI0WFM3dy9DUVVNZHdsakRvYlNJ?= =?utf-8?B?WGkxSzdZYTRsZ05mU29GL3JoKzU4UTFWMjFzdFhZenJWakdHckdaYkt3WnBw?= =?utf-8?B?VTF0MnJwaDloTnFqZFlw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jF0WGVuVjN0?= =?utf-8?B?SGtpTndXNTZFNmRJR1JRZmpmRVF3WkRURkxtTmVjT25yRnpnUWg5VHBpbWQ1?= =?utf-8?B?ZlhaU1grMS91VEhwS1VMZlF6dFR3NCtOektLR1dVL0V1RHNPSXJ5dzVhMTVH?= =?utf-8?B?YUYrd0V5WGc0M0Q4M1JrN0NaNlZGdy9pQ0FqanNzc01QQmY5QVlBUmUzOGx5?= =?utf-8?Q?tnyc=3D?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8106.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 588659aa-7e4c-4bdd-068d-08daf84f47a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2023 05:54:21.3717 (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: MO0kIbIKOvx49heTv3PQZwFMTWtRvd7vHiQyyrID791xR5UzT43WyuKX0z7OgsSvizYK+TgVDR8Aj2E945cDNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8428 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Pierluigi Passaro > Sent: 2023=E5=B9=B41=E6=9C=8817=E6=97=A5 4:23 > To: Andrew Lunn > Cc: Pierluigi Passaro ; Wei Fang > ; Shenwei Wang ; Clark Wang > ; dl-linux-imx ; > davem@davemloft.net; edumazet@google.com; kuba@kernel.org; > pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; > eran.m@variscite.com; Nate Drude ; Francesco > Ferraro > Subject: Re: [PATCH v2] net: fec: manage corner deferred probe condition >=20 > On Mon, Jan 16, 2023 at 4:32 PM Andrew Lunn wrote: > > > This is the setup of the corner case: > > > - FEC0 is the owner of MDIO bus, but its own PHY rely on a "delayed" > > > GPIO > > > - FEC1 rely on FEC0 for MDIO communications The sequence is > > > something like this > > > - FEC0 probe start, but being the reset GPIO "delayed" it return > > > EPROBE_DEFERRED > > > - FEC1 is successfully probed: being the MDIO bus still not owned, > > > the driver assume > > > =C2=A0 that the ownership must be assigned to the 1st one successfully > > > probed, but no > > > =C2=A0 MDIO node is actually present and no communication takes place. > > > > So semantics of a phandle is that you expect what it points to, to > > exists. So if phy-handle points to a PHY, when you follow that pointer > > and find it missing, you should defer the probe. So this step should > > not succeed. > > > I agree with you: the check is present, but the current logic is not cons= istent. > Whenever the node owning the MDIO fails the probe due to > EPROBE_DEFERRED, also the second node must defer the probe, otherwise no > MDIO communication is possible. > That's why the patch set the static variable wait_for_mdio_bus=C2=A0to tr= ack the > status. > > > - FEC0 is successfully probed, but MDIO bus is now assigned to FEC1 > > > =C2=A0 and cannot =C2=A0and no communication takes place > > Have you tested that this issue also exists on the net tree? According to y= our description, I simulated your situation on the net tree and tested it with = imx6ul, but the problem you mentioned does not exist. Below is is my test patch. diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethern= et/freescale/fec_main.c index 644f3c963730..e4f6937cdc3e 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2284,6 +2284,7 @@ static int fec_enet_mii_init(struct platform_device *= pdev) int err =3D -ENXIO; u32 mii_speed, holdtime; u32 bus_freq; + static bool test_flag; /* * The i.MX28 dual fec interfaces are not equal. @@ -2388,7 +2389,12 @@ static int fec_enet_mii_init(struct platform_device = *pdev) fep->mii_bus->priv =3D fep; fep->mii_bus->parent =3D &pdev->dev; - err =3D of_mdiobus_register(fep->mii_bus, node); + if (node && !test_flag) { + err =3D -EPROBE_DEFER; + test_flag =3D true; + } else { + err =3D of_mdiobus_register(fep->mii_bus, node); + } if (err) goto err_out_free_mdiobus; of_node_put(node); @@ -4349,8 +4355,9 @@ fec_probe(struct platform_device *pdev) /* Decide which interrupt line is wakeup capable */ fec_enet_get_wakeup_irq(pdev); - + dev_info(&pdev->dev, "[FEC Debug] >> Start registering mii bus!\n"); ret =3D fec_enet_mii_init(pdev); + dev_info(&pdev->dev, "[FEC Debug] >> Finish registering mii bus! re= t:%d\n", ret); if (ret) goto failed_mii_init; On the imx6ul platform, fec1 (ethernet@2188000) and fec2 (fec2: ethernet@20= b4000) share the same MDIO bus and external PHYs can only be configured by fec2. After a= pplying the test patch, the fec2 will be delayed to probe, the debug log shows as follows. [ 7.101569] fec 20b4000.ethernet: [FEC Debug] >> Start registering mii b= us! [ 7.109386] fec 20b4000.ethernet: [FEC Debug] >> Finish registering mii = bus! ret:-517 [ 7.153045] fec 2188000.ethernet: [FEC Debug] >> Start registering mii b= us! [ 7.343374] fec 2188000.ethernet: [FEC Debug] >> Finish registering mii = bus! ret:0 [ 8.742909] fec 20b4000.ethernet: [FEC Debug] >> Start registering mii b= us! [ 8.769657] fec 20b4000.ethernet: [FEC Debug] >> Finish registering mii = bus! ret:0 And the MDIO bus also can be accessed, please refer to the following log. root@imx6ul7d:~# ./mdio eth0 1 read phy addr: 0x2 reg: 0x1 value : 0x786d root@imx6ul7d:~# ./mdio eth1 1 read phy addr: 0x1 reg: 0x1 value : 0x786d The only change is that after applying the test patch, the fec1 and fec2 ex= change the ethernet port names (before fec1: eth1 fec2: eth0, after fec1: eth0, fec2: eth1) bec= ause of the sequence of probe. Of course, this is just a simulated situation on my side, maybe t= he actual situation on your side is different from this which leads to different behaviors. BTW, you'd better use the ./script/checkpatch.pl to check the patch before = sending the patch. There were some warnings and errors in the patch as follows. WARNING: 'succesfully' may be misspelled - perhaps 'successfully'? #14: succesfully. ^^^^^^^^^^^ ERROR: do not initialise statics to false #29: FILE: drivers/net/ethernet/freescale/fec_main.c:2287: + static bool wait_for_mdio_bus =3D false; total: 1 errors, 1 warnings, 0 checks, 40 lines checked