From patchwork Wed Sep 1 22:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12470479 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 5C685C4320A for ; Wed, 1 Sep 2021 22:51:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B33D610E7 for ; Wed, 1 Sep 2021 22:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244239AbhIAWwM (ORCPT ); Wed, 1 Sep 2021 18:52:12 -0400 Received: from mail-eopbgr00087.outbound.protection.outlook.com ([40.107.0.87]:32899 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236906AbhIAWwJ (ORCPT ); Wed, 1 Sep 2021 18:52:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j1s5M7gCpJbRHyLo/wJsRfiIZu0bPNBgnZnR1ka0ja1eFxGhudiW9Zbf0TqrPYSsQGipxjBjuWCHL4IsObbiPsVMwQxY+RuWQZmIlUrPlccJRF4xf9OUtzUCRKsRc03wmwGddfxXE9I7frFoh4QWiTD3hhmO5/Ln6B8lhU8CN2/+5yXA7Fr7uqLOu5zz2al1Xa9+QjYOxoMjBZ49z/wXtf3CY6I7DB7xWvXVrwCgnQsmWUHZOjdKHZcob1AskLzDU97z7LntSG1HBazsSbS3AfJ+7gpLXmuykATLDRoytie57HbTpDkmhIdOU+sBXRWk6bAMX/qcI/jhlnG+nyv8dw== 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; bh=pWiPOuEmFZyrTxtIUVeN4fyc4bTX3yYc0vTDGglDUzo=; b=XaNCbXi/wlfTNT73R8Pn3kJWOi+/+35VHotBxSUXz0HW2gyqZhL6u2/De061v7G018Mx20lzdyRYvn/ItUp3210xrVQqKpgo0YrDxRms246i3tOX3MbYtgPcKAf8mkRhw0mJxnz81CLwzhbayhISfujdEOi7uqC7hAU6EJeFHx+Kc7LEsOdYAlrjqMzaUNrh2yXMlKhErd64WHGcAeIxmWBW40ccw2RAU42kyjvBucWRxdnXH+7PHWvv3xKkPl/WkKRDngnx1a5JITyLPkkkZcFaL30/qN26HTv/C6xSrewg2jFKDzmZOrC11C3PuePctgJckCG5hCWTmpRw7uaEDg== 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=pWiPOuEmFZyrTxtIUVeN4fyc4bTX3yYc0vTDGglDUzo=; b=MnYpuEtCCuJws4xigf3E1XlDu3PSY0Ec7eizZdcWhtCwkKw/xUFlVPefaSo9KsbEFl8ZIjx4pXELmcRwfA0KPuMkzYM2isK0ZMSOF8KQD2+nNFnQB5DwYj/xbf977y17nLiceWwSDy+gauK9OwLASTpL2Ws80+9FiyJIK5t5WVQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB6015.eurprd04.prod.outlook.com (2603:10a6:803:d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Wed, 1 Sep 2021 22:51:06 +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.4457.026; Wed, 1 Sep 2021 22:51:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown Subject: [RFC PATCH net-next 1/3] net: phy: don't bind genphy in phy_attach_direct if the specific driver defers probe Date: Thu, 2 Sep 2021 01:50:51 +0300 Message-Id: <20210901225053.1205571-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901225053.1205571-1-vladimir.oltean@nxp.com> References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.78.148.104) by AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 1 Sep 2021 22:51:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d5d4052-366b-422b-a641-08d96d9afbc8 X-MS-TrafficTypeDiagnostic: VI1PR04MB6015: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /1kGNySXgg76QpPjveAl3o01fWS8SysvXRT2y7I3kdrnHuJiKZid5wIIIKgg5O9ihqXg2Vib5eck9fbTg/eoY4aEaX27RbIFUm4reisI2XCCuz/J6TKaEoUx/dVz6fz7ZvGUk56yYgKMph4CWyKrTm+sYbNK1JXbdVBGbjf7+M+KiMq5E1Nzr9OUC3r3aep0rbjXY4tUWh/SAEnvNChJ8NpGqjJRPy+oh177l45ZbHxzx/6sISvPll5kl02rtco5JEpAo9viFOLdLps+NgR+sbkHLEdmRszTHT0/msf0JNLwfMUrGDf3UN4+ZJ1Z8iyvv02/7aQM6nY3/8drsHI9OJhgEIuxCTiU3lSl/zIUEBW7aZ77jmgFhnkyO1BOerlazPNxG8Y1DJ9bPHF5ioj1x03AvQPa7KteQkSpQ/GP0JoN8dsqk3TCZMYAiEcxNMOWq1ElCI/BAMSO5cmk2ExG2UsgLI9kCHxKVZc512QkamCtnahHA3Kg0CYMe+fpj8Jj9vG2VtJvkY7y0ElKBsU+njGpcCYAT0lo+ZuRfzQ/MhuCaWpiMSQH4ovFk/oY61az3eNPHUuLDxBiLsYICTW+7adw+rZNQvnf//jlwVCAPH5dkOMsfX30J3uUeg48Kdim0E44V0hkQVqe4KaYpUqcSoAEmG3PlcOesy8exHSsw30TqYOp6aLoUa/M5bBDZsLie434f0X60BxmIPJWPFHn3w== 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)(366004)(136003)(396003)(39860400002)(376002)(346002)(66556008)(66476007)(83380400001)(186003)(8936002)(66946007)(26005)(6506007)(52116002)(316002)(36756003)(478600001)(5660300002)(6916009)(2906002)(7416002)(4326008)(6666004)(956004)(86362001)(2616005)(6486002)(6512007)(44832011)(1076003)(38100700002)(54906003)(8676002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: muemRvmZsER8ennsqke+yIxR0DgheQjxSCC8AkIrB1LEl18AZFgMn71AKM+qnuceJW2pgieoIhSH+oBX0O78l+3LG6zKJcKgA8T6oF59eTL2eNEplkuy3HKq5AwHHDaOs5wLtFdqO99ciXfVk5OggfNGN8htVkMgUPjYgh44RdqL/d6+wv/LJNC1EddKXGRi73xHGP0DJtBNwdzWDH9GwCEj2xNtXY0EhJhobhuiNsO8rsvMOEe85w9mhX218G/eeHdR7TzcwmRVxFW6bu0KFsgKSRBCkRRQ7e1Bu5689v5TmLPPE1BIhxL8hroxEUFK6umFH7IU43kWnatcqiz/pKpOg6ptDjz+eygeDtp/QMhOBNzXgPN0ICmsT38PBqWsTNCsjCUj2TkR5H3X82LGDTLJqBEEdnTHcOMB/wGaU9JErQdtLRLYD3KLXrUqvwCtTuMvae/GKrHNrMwCUuD/GAnri2ErePwh5LfWVuVhSZuTCfMLaw9sLRla13Wo3qKeDYKQURqKOLZnZEB7VBFRG4cAQpVoP6u8/gzeroNmf/MXcekJ1Pzj+UTmMlDfo6Iz1qS6Wk+kV5pS2jOZInnLHIKlY6/E4kzp3OtqCSKA1Hcgg34/OMVLw2lz7UUArOYBeda29+B1EAuODUMGxHGzKRzOe3vq8f07SJCCrYnAWx/Rbz3JEpagLQ3s+MzBeGqgo4gC/RStXUb4S+3ffwX2tDGrjZdoeJWEMWU4Yl9sFjOD3SQW9M0KxkuSfQIBxfzhkji6Upk3AxPyHtTNX2x5dudDdun47M95irOXB+l3iu80RUMUJyjfqrMSGpwe4mY11ad1BsTaeuEf//zy4Oi1vFF09VnrNHSd5sTXD3Qe4tSfwF5Vj8k3sgLNokl7rB9MwGnsABqDRrvmlBaZQ2UEkTfolOMxSii6fPOpfrl7S/Huiu0dhm5b4tCJR3NBTKoS+R9x9BOukFpeOa/QMEaA2ru9tfUutCpyM9bRnlRfNL0lExWjih7qYxL+1q+SkZ7tMrrP9wbJX70nKV/sRLQ9OEeGr3WGg0VrTDHVLRNXBVV6Gr1qCaWiOO5hVhreqZ9hpi9fcFQJ1+AFTx/wBROmUZ0bdEPTbaRdfDb0z+Os4EGCprrhPwmlndYIm15yqIPGNYC1D/fxTnNLc5VKHLg79fDr+Bk+mrV4MgFiR3YU6Rq/L/uHssTpQOwLeQ2dE/fDA8lVxf+q/z0xjd8huKkVzVtvUsopzULvmqLH5ycclMd5kpFbdZ5WNTk3vwhOA+H1nNp9Sre0k9ktWj4/XArP4CeGiGgfKrVdKa3NTBlOlansEr+1nP7YIdAjGAJunhjG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d5d4052-366b-422b-a641-08d96d9afbc8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 22:51:06.7887 (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: czQ8cnPbkwtV+PbLI4RAaFR5LAuQkgyyceVswUgAr1jj5E6oox8M98ezYmvnPh+IfM1K02Un01PrvMfXIGuRBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6015 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org There are systems where the PHY driver might get its probe deferred due to a missing supplier, like an interrupt-parent, gpio, clock or whatever. If the phy_attach_direct call happens right in between probe attempts, the PHY library is greedy and assumes that a specific driver will never appear, so it just binds the generic PHY driver. In certain cases this is the wrong choice, because some PHYs simply need the specific driver. The specific PHY driver was going to probe, given enough time, but this doesn't seem to matter to phy_attach_direct. To solve this, make phy_attach_direct check whether a specific PHY driver is pending or not, and if it is, just defer the probing of the MAC that's connecting to us a bit more too. Signed-off-by: Vladimir Oltean --- drivers/base/dd.c | 21 +++++++++++++++++++-- drivers/net/phy/phy_device.c | 8 ++++++++ include/linux/device.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 1c379d20812a..b22073b0acd2 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -128,13 +128,30 @@ static void deferred_probe_work_func(struct work_struct *work) } static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func); +static bool __device_pending_probe(struct device *dev) +{ + return !list_empty(&dev->p->deferred_probe); +} + +bool device_pending_probe(struct device *dev) +{ + bool pending; + + mutex_lock(&deferred_probe_mutex); + pending = __device_pending_probe(dev); + mutex_unlock(&deferred_probe_mutex); + + return pending; +} +EXPORT_SYMBOL_GPL(device_pending_probe); + void driver_deferred_probe_add(struct device *dev) { if (!dev->can_match) return; mutex_lock(&deferred_probe_mutex); - if (list_empty(&dev->p->deferred_probe)) { + if (!__device_pending_probe(dev)) { dev_dbg(dev, "Added to deferred list\n"); list_add_tail(&dev->p->deferred_probe, &deferred_probe_pending_list); } @@ -144,7 +161,7 @@ void driver_deferred_probe_add(struct device *dev) void driver_deferred_probe_del(struct device *dev) { mutex_lock(&deferred_probe_mutex); - if (!list_empty(&dev->p->deferred_probe)) { + if (__device_pending_probe(dev)) { dev_dbg(dev, "Removed from deferred list\n"); list_del_init(&dev->p->deferred_probe); __device_set_deferred_probe_reason(dev, NULL); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 52310df121de..2c22a32f0a1c 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1386,8 +1386,16 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, /* Assume that if there is no driver, that it doesn't * exist, and we should use the genphy driver. + * The exception is during probing, when the PHY driver might have + * attempted a probe but has requested deferral. Since there might be + * MAC drivers which also attach to the PHY during probe time, try + * harder to bind the specific PHY driver, and defer the MAC driver's + * probing until then. */ if (!d->driver) { + if (device_pending_probe(d)) + return -EPROBE_DEFER; + if (phydev->is_c45) d->driver = &genphy_c45_driver.mdiodrv.driver; else diff --git a/include/linux/device.h b/include/linux/device.h index e270cb740b9e..505e77715789 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -889,6 +889,7 @@ int __must_check driver_attach(struct device_driver *drv); void device_initial_probe(struct device *dev); int __must_check device_reprobe(struct device *dev); +bool device_pending_probe(struct device *dev); bool device_is_bound(struct device *dev); /* From patchwork Wed Sep 1 22:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12470481 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 45F3BC4320E for ; Wed, 1 Sep 2021 22:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23C7D60525 for ; Wed, 1 Sep 2021 22:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343901AbhIAWw0 (ORCPT ); Wed, 1 Sep 2021 18:52:26 -0400 Received: from mail-eopbgr00087.outbound.protection.outlook.com ([40.107.0.87]:32899 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243383AbhIAWwM (ORCPT ); Wed, 1 Sep 2021 18:52:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QWKL7dsEvX6Zp0M10hrOz8tMNWtDcZL+Bdgemh+j+X6vSUFVEOnYtuWxs9Y8r40UIU/35qt8w275z52JkeIao0tZyAkqmCX5ClQ8onqdIdPZDE2DM8p2AN1ssVmQ9s0vkaMLiop01VcDiveYoNHQ9Mdha1E94kTvOMhixfsM4280RHokqGSJCFlq3e1eIMqKDostGSzEq1P7ZiAep8QLrtGW3r/RobzOqx7JnrdN6CLLYga/CCnVIrapqFdfwp6MCDvxQM0bH5DZDALENK8/62kJmDNJGUhSQDuJxiM/rXUS/r5UobVulXrmAx+6/eYO0G9qwBQKH14iMku+CyDeIg== 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; bh=rQPJ05F5JebNF2FJ90pWZCThDfbAb9Db0DUCkr+NfEE=; b=YjxF78oXhVjot6uo/ApV/SySkrPHDFNvREE2BcyUNYANm8+3Sn3o6k+Np1+aCG9cL6zeg0EnPNICjb038s9HD8ZSmLFiRUWltfg8a04BbEdn/jeI+eoecS6Zp+XwK/OyZuZ1xJJPU9VPjD0p5xpXoPn2H9UwTlbR2flRw0peyfMPm6CjUz8a3TP+HcJotLxEzV9bBIjSIbfXP0prHhK0+xQ7uOpS7tma640+1oHivdRHJ5Dn7j3gAUkPBv4am6pyzJm1j+e6jYPH0gxYMPqJxZXTz775WJRpaZmhnHLjVzm1XDh2xKIOJRf8YEOMq8H2rIcUs6QyPHnYuj/siAYS+w== 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=rQPJ05F5JebNF2FJ90pWZCThDfbAb9Db0DUCkr+NfEE=; b=MgsGqnQ7fYjWbkc1UMDVUHuUe4zdB6glvhdL5ifXKfF9cptjN5yK87lYLa6IC0rR/Fw0OMl9yBlR1ueWcYPoVBmRqUVYg98wN66pApetREcQJWhw5YVC+ochoSngdvVboy5JgVwkh+cxBNuaoCe6+QxS+Fl2JpzAkYRGOqLEj5U= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB6015.eurprd04.prod.outlook.com (2603:10a6:803:d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Wed, 1 Sep 2021 22:51:08 +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.4457.026; Wed, 1 Sep 2021 22:51:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown Subject: [RFC PATCH net-next 2/3] net: dsa: destroy the phylink instance on any error in dsa_slave_phy_setup Date: Thu, 2 Sep 2021 01:50:52 +0300 Message-Id: <20210901225053.1205571-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901225053.1205571-1-vladimir.oltean@nxp.com> References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.78.148.104) by AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 1 Sep 2021 22:51:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a11dfae5-39f6-409a-532d-08d96d9afcc7 X-MS-TrafficTypeDiagnostic: VI1PR04MB6015: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ya59+eQTQFNz35vpDQOiEIf69UH6vtcvoqd+F2xM2wlfsijjpQ+CuTw5iK5LHuFXP6smEwSZgNh7xTquZMdAPKicHfEWCrKuK/voTLfm3Cc0YobNDBmc9tt7FqLTKYmaBSbju9YiqZae2z14qr0mEuLCsykEpsrMk3JOp69MB8QYSrjVbqwu7H69c+jYB+QkN4DWNUE0MmZAOitUErz9eYG2k37j+9VPNChF05tGEqXaWiENVfAHSc3YSuLkU1AhH1dlv7hjpMokJHBLG2N8GEvS9aKvnArF157A2lRopP5Bazss+RzX+GhPGW9rV0SmD2Y932aKMJSExggLo6N5Dt+R9IwLDMwETBhdwATlIMQ22hUNfSIxDYjdKdfqvH0ocbB+0Wm/x90qvi5+8KVW/GGk97KzVK4ytTFMUvLwkuMN5EJcBBceLMKpvbmIs8tatw4C8ha5Sir2EMgtR44o5DvrgrIiIn0u3PuIlGHS2EZImsUb+ERokP9r2/j0JlDj+ugccBirOQYfFjfvJwuuBBp1M9a8BUz/3xcsFWSyqHEEuszBR6k+0Y91wUcYcZJuWitpnuI2uqqsJrrcz8f3gsQ0ftP5VI1R0GRtNdvvwT/YTDxbRplVSCOlqEORiPcINEMvQ47rplhyCcf5X/1inlJ5qN3RRAijuSijrxTqSkorV1rLRP7rsADsmD84huwbHYwnaI5AhS+YtpW6w98jMw== 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)(366004)(136003)(396003)(39860400002)(376002)(346002)(66556008)(66476007)(83380400001)(186003)(8936002)(66946007)(26005)(6506007)(52116002)(316002)(36756003)(478600001)(5660300002)(6916009)(2906002)(7416002)(4326008)(6666004)(956004)(86362001)(2616005)(6486002)(6512007)(44832011)(1076003)(38100700002)(54906003)(8676002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jk+3qOdtAEXLgWCrqGPlMhnJb0X1yoxbl0aXqUDOJI2QT4F4CZf4S5Bq9vdQK7y2Be3XPmkySx1kYAncb6R/dxO74iyEOYVL4U3JCKNw41Sz2p0gQW5IvoxvkUOqHxRFO90JE6Wy69NV8DtzZmdRPjXjWh4YPrk7xwWAEdPkUyupxEyUiYA+1rTg8Y8WhThCu2deqmc+5k9pjlrI9CYnZVoUf4NTNXO9iLUzMEiGDvaX/fE5x2JENUTo9KQJ7Q7377PZscfe0kzB9P6QY8LYhRfNyMdfT2oWr7+mYXA1kmx42ZNkMJU7Bi/dvJF77oerxFdz4HpavWeXKgODrMrJZTUpFXfHOkjNLSqonZO4yyUNfRdDeJAhn2LIgBl/mhLpFeWwX3+LuIAHk4wZVMqYK39CFo25jxXKDNtyMqrpa7OXkNvqUdAwgriOghlN+RkNFDd0UK9C1NhIqS+qLcatlc4890lc6NtOnEHR/Ki07sVaT5T4JLSu7V3ZMkuW+ZEn4PJByT2Wlk+GTleUjTuCHZoagPrOPOuOH/H2TE2Ydjv1MzoZM+fESHDXuZpPQAlVernloEQ0GixJDqsY30+nYiZPnr0JHkc7mjVjflNx71MK+z43/0/eoGnZqyaJzsg9TmHoaGmzhYC+d2Jxt/cbQf5Xf13RlT1wHGR2EkSDuZK3HJsrik4Z/xMxYomQWxpIk3ZNo8IZOgEBNV/Z5KUUXkuNsimbB0gZrITtKMZzKwCAYo9BX+sbQWjfLnqRlo1dtXNE1WBsx0f97m4Y7yduiRl0HSAuGM08CpEDIagOC73XIJlQRmlzg0FoxGTti9oRM526NQfPKb/XGZhaEd9XlyPfHS5Iy+y0sN04+dUIQ0HFZ/wQq7XtkxFxyzB7CUkZPWpJyeu5HnIGJClF5rSrq3sEi5SWpVoLJCRbuwV5Dv/Iv3YNIceR5/Yu8PJNR6UNaK9cxhpLgv+5qdZx7I675MwvDXvbNSyVxuIpvNuWeVl2kWNUFSkyx7LrUfFPuIuJHzV3GeLM6is/y/ImtRtnTnQ2yHk0pyZFHc6FLzv3Z/Zu8DUG+ZfW5fJATFLjtnzDQPJ17oHXkBGyeSqjCsI7tjVwfb0K5fHoy52lcC6xOdU3FPXfUzfNyNSQLsjb2HFA6nVwet0JxxjJE+Qkj+rvGt+k4LYGjcUpLA3KQja3Ew6ldoccAraFXz3Rfty2HTzl9gVkRtCcIilAldUGU2l07OG4bqiIG9ur6HiJFAjYhrPrPLitNu9hlFpqIAw9o/qXBiYXVw6m6/2lOGVcgoLBOveEUPMuKiMwOXniD4feo6OCOWIdPsgxXznP98DT/hVC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a11dfae5-39f6-409a-532d-08d96d9afcc7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 22:51:08.4637 (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: Fx4m0dAXCAAVqG6t/qRr/uQUkCwjU3BpgqBUmIsEchETGsteqQ1yeRFGTZHkdMZ0NDmP2lU4Rbn8wEAk1LeGjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6015 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org DSA supports connecting to a phy-handle, and has a fallback to a non-OF based method of connecting to an internal PHY on the switch's own MDIO bus, if no phy-handle and no fixed-link nodes were present. The -ENODEV error code from the first attempt (phylink_of_phy_connect) is what triggers the second attempt (phylink_connect_phy). However, when the first attempt returns a different error code than -ENODEV, this results in an unbalance of calls to phylink_create and phylink_destroy by the time we exit the function. The phylink instance has leaked. There are many other error codes that can be returned by phylink_of_phy_connect. For example, phylink_validate returns -EINVAL. So this is a practical issue too. Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support") Signed-off-by: Vladimir Oltean Reviewed-by: Russell King (Oracle) Reviewed-by: Florian Fainelli --- I know, I will send this bug fix to "net" too, this is provided just for testing purposes, and for the completeness of the patch set. net/dsa/slave.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a7a114b9cb77..8a395290267c 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1856,13 +1856,11 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) * use the switch internal MDIO bus instead */ ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags); - if (ret) { - netdev_err(slave_dev, - "failed to connect to port %d: %d\n", - dp->index, ret); - phylink_destroy(dp->pl); - return ret; - } + } + if (ret) { + netdev_err(slave_dev, "failed to connect to PHY: %pe\n", + ERR_PTR(ret)); + phylink_destroy(dp->pl); } return ret; From patchwork Wed Sep 1 22:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12470483 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 5B525C43214 for ; Wed, 1 Sep 2021 22:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4197361075 for ; Wed, 1 Sep 2021 22:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239507AbhIAWw2 (ORCPT ); Wed, 1 Sep 2021 18:52:28 -0400 Received: from mail-eopbgr00087.outbound.protection.outlook.com ([40.107.0.87]:32899 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S245624AbhIAWw0 (ORCPT ); Wed, 1 Sep 2021 18:52:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDbjaI1z8+0pfwGdTUpu0ELtpX4psesNSJdF7AdMfbFrA5+Ej1DasRxg6JNGLPi+PCcpVcKWWGBwN7HdWFWmYPrkJLwSbTOwBNXjGwCKL2swpGHaOQjtuaCs4R1sWVvI4WCywu6DyudM4t5+9Wl1jlwZsIdZzQ2VQekvgJL+1Ynh24mYLfyg6jOxiax5p7s437VOrqtOu4tPWjTrQeVH6cMnOlzkFhiKhR1jidwrleNS+gcRSKa73ef6GYruHzaRSafP0YqVr5P1tjqeSFL/3V6Lq9q/dkTyh5zUXIKaaUSuyEQUxjJPkCsL1uD0FG73clxQJjp5q1miMz2iQqFRQQ== 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; bh=+HgTtnB8nMO1RfbJjwju+iPYZi9GWPjMwGFOVRbuIkk=; b=n7BRowV+oyHmEecu7qlBBQl2/bc2Ol3HefMJdNSIpeWAJ3nGrgdxFxF4jlBKfU71vRlUO752gRK6gIR9Go2LFjTA3MTy+XYnDPRiElA7p21g2BKQsy7iTADPk06CKUMD8qAbXk5ZJDmSW0j4wcKeWYQ9veR5dSYZwB3biql+dcQqe/CSk2VpwKQVfBG5vDeS6Cm4nosGGhuJBsPsx+PFpl43bMOHn5XQsm/xAHdLwOXyLe03R6K5FlsFzFPZlw3Lpsa3gyWYcp4OXBelPdBGw1S6r9ccLAE8uUPq3fI9xgIytvPdF+aCM1QhgOvTRueRLh5DdqIFWPO9qY3wYJb/xQ== 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=+HgTtnB8nMO1RfbJjwju+iPYZi9GWPjMwGFOVRbuIkk=; b=cIhA0QVnh7bkz3+boFOF70Djc/iDaFe0Y/i5R0Qg4Fs8ZGPXv9zVTJBjxUa4bv6ckrwOjA+bl9l7qBOjxlMZXpx6jCYDb1W1AwZ0f4ZDkkrDvWx630Jy8veD2jNEhJ1K2O7ByswQ2yWrDiFjuRbDI0weaB5YozGU+ZK9ohRR30Y= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB6015.eurprd04.prod.outlook.com (2603:10a6:803:d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Wed, 1 Sep 2021 22:51:10 +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.4457.026; Wed, 1 Sep 2021 22:51:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown Subject: [RFC PATCH net-next 3/3] net: dsa: allow the phy_connect() call to return -EPROBE_DEFER Date: Thu, 2 Sep 2021 01:50:53 +0300 Message-Id: <20210901225053.1205571-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901225053.1205571-1-vladimir.oltean@nxp.com> References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.78.148.104) by AM3PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:207::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 1 Sep 2021 22:51:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70d707b9-24c7-4346-867a-08d96d9afdc7 X-MS-TrafficTypeDiagnostic: VI1PR04MB6015: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZkwuLHjB1kzK/2ZbDKGNhrRvquzw6rXOw5INPIT8UEyhMaU6U/rBpzPuwlQPligjHVa0TBiH3L7KHlfinmGOhNoPF2JH6BN0DjT+N6UB8RRQ1rIO7uAGUMpGsz4ARdpfV8scs/W6bK4C68eCPlke+RN5jHxnYupmZLDh3qfD5hTcf/76ELiFILF5rh1quO/zZOZ327o8tyQ9x3bSOjplnOw6XfRd86gUNEcm4/P30lkvKzviNaf2pyubsjcL5RXFrK0A2nOMbI+GEcW5fl2aSyObXN7TMGmFE7g++8d2aUsL3e7cNCzM6tZ7SDssHaBoiv/JdxpvtiKULrHoQnlDWXVDtTxS1B2iEED/Hr9wft69y8c0Fh1okoR00HYhGA2i0AyH5ypw2cCuL+aN5MO/oAaPRPGY27SImS4MNhjwmwb0KJECa9DYLY61U4rRrtlgT8tB+nejho5CzvoV3qshoaaqKgkVT+a0JXbyNF1U2JHSNvbn15K/eDQg5i17Uzi9LOly/PlsLZ+Z6A1NtiODrhnuwSTSjpDPPFGn9cicxm+yDwCOOq88dRVLYB0HVjbdNzYuC5HKw2KviOKzVmDwtRM8QDmq3FJv6C2XquVi+kGzTwqjLuozFPaO2kRHrV9ax7sI35bKTaNB3tcd3AO6002arrAozjE0QY3M5mv2hwh8/90cip9HDyHTXlanwjYSxsSTXOozbbOAGoU0lsP9g== 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)(366004)(136003)(396003)(39860400002)(376002)(346002)(66556008)(66476007)(186003)(8936002)(66946007)(26005)(6506007)(52116002)(316002)(36756003)(478600001)(5660300002)(6916009)(2906002)(7416002)(4326008)(6666004)(956004)(86362001)(2616005)(6486002)(6512007)(44832011)(1076003)(38100700002)(54906003)(8676002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KkOoPhiEIntsG9fdVBkZE1/o9kylCb+0AxCniwYl2ZlduGWJS0Tq91MTtzi2uWy4eMHTyUDoKW8DIoQhFopSoAAcgJ0/agTruDvDCumgpiRsXu3iTDSjADQRANq2gVMiUWl+P2kZZXStWPMOLUT1k7ScgTzqwesx1pp2GcEOx8Yceo5308nKelSJA6/FaIwXMiU9wPKBt3ZFiPxPhQZ+XLW+utBjw+OrqDTNBtznC/r6xEGdAC5PSx47AKhXEvQiwMV06HA7qD5FCABKzatvX8MHzXLAJ4/vWAUR4XLw/pQU3accBrZjFsVqmv9NbIOtU6NlxPzHWKhnY59FZ/ZvCUXA1HezSLMuvVk3sIke9ltKElsr8rxqgnznJWFH6vUqO7NxaCdxesKFG3Ult6vE11gGZ3EC82MAidMNWTvuZBfB2CFlcIEdFEUa/QZsFADXxOPozHGMCI3lSd+L/YECxcLPDf+LkJSTsn9uVTH3fHsi42mez9rm+P4OzvfX8QJWIZsoCpSU94GO/TSb7P1B/RAypw+f5aDkERoANOAQdUoIN4HSMEA4vwjWWdYTMFuWKf+ZNuRA3r6lpTRjKHAVYhePKVp2s/0DCnY0sD7zq3i6YSx5xHNDw4q/LZPXM31BzodtHu+Y2c/fnKjdw7XV04sSbWBROBcK97CHy/JQoWJ3aMcMeaYXjkdOpIrCWIQ/HPRXi3cE6Je7Nv1FbGS/gQzp7sglens0FAxnnQxL4jj9VQ7i0/MKWJywGeO174w6ekw9Wy4duw4PajPTVAcS7E4wtKe3X3DLdNRYwn3IGfIVi72xY8ZKfyz3kc3row2fiZq2xrl8pNMM1fV5e1+h+BJwb+4g/1kSZlfxx4LflR7CM7bHeDPi7pFtsuG+Insw0U8q/PMMVc7lCbvdOkW7EuoWahioNucVz0xTwTAIBXhAllKwntsUcvIilBUmbZQr1fawrNmvxD+1K1XwHJIQwbBvFgQ8Mfbpvh7gZGazRZ/Dh+HruGQR0NvmDjw475Z0wmRH3/NjDl7tMgxK4fX9ujxc2kruGVIpl7TSyT1F1zVfpUXDVHoqC/kH1xCqgnWJtvAmTap9jCOsELGkzbhNElSY8wcgzvFQflaZz0Cw9krb016udnt3RJoxSESckQobdjo9z5yV8MFMeD1AXoq6KdG1ezB3dkew11kBD6t4YliCYHFi7QTaTshuJO7RMxYH6eHudq2GaYVk0wyWgxnE3M7E1v7nGd0bR5ia/Tgj8513neHuDM62jMP9hXHkqgAwYe/TSdmaQnVeFg2e+2NkgyMkTzRemtIN1Mvo+YQvikwGEgjSQvpU2H0GoVQtGNgG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70d707b9-24c7-4346-867a-08d96d9afdc7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 22:51:10.1067 (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: ksqwgnxC2LLGMWJABNAqVvqVVtRfNd5nDFWpgoAefGms7aILFNg9CKRGqRM7eWEY5hBmrl7sDCK9yw/Hcv73bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6015 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently DSA ignores any errors coming from dsa_port_setup(), and this includes: dsa_port_setup -> dsa_slave_create -> dsa_slave_phy_setup -> phylink_of_phy_connect -> ... -> phy_attach_direct This is done such that PHYs present on optional riser cards which are missing do not cause the entire switch probing to fail. Now that phy_attach_direct tries harder to probe the specific PHY driver instead of genphy, it can actually return -EPROBE_DEFER. It makes sense to treat this error separately, and not just give up. Trigger the normal error path, unwind the setup done so far, and come back later. Signed-off-by: Vladimir Oltean --- net/dsa/dsa2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index e78901d33a10..282bdebac835 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -912,6 +912,8 @@ static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) list_for_each_entry(dp, &dst->ports, list) { err = dsa_port_setup(dp); + if (err == -EPROBE_DEFER) + goto teardown; if (err) { dsa_port_devlink_teardown(dp); dp->type = DSA_PORT_TYPE_UNUSED;