From patchwork Mon Jul 17 15:27:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13315958 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26E4EC141 for ; Mon, 17 Jul 2023 15:28:10 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015BF10F1; Mon, 17 Jul 2023 08:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vr2WcPMui2vtcw0Iyuijimks+bAvVGLqJVFPckQaHvUmZjkQ5Qbud1djkxR374AgPM9laY/PpjvI02pSsA7/NuXom6MTNO11PGDzPKa7R2YhlAJh63lmvyLsBiAqO2iu0kC/3pT6aIQBd7Ywkg1Zj+RbKzwnXp/q7yBYKomBCdll0RFoVOVsL7G1kca4/XGonqxy79c6CuX5WYUPZib18WrH/BwsA90RZdnWEVHRxAdwtmrdWxzlZjBcURthAyj2uTCGa5Jk7O/a+bDe4627kVdVXSPW+9n/BFkBidH/SXsIEzJHMPRDtC2ZPiT6818RlPZnsq4ISaWy1BNXGOHoQA== 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=zzc7E6CfYK2zrLX0w9MQWTufyjGs6lAs5lxehq134N0=; b=ZgyQdC7JMwEVUcR39tlyJLZ7M+VCRUN343Ay6N5Af8lzz6dazwk/rSKU5Zz8BDZawUxsDtqg4vN1B/amWKfzSy4JR/dP/z7Df4oz9Skf+Rc2DEvjwCVIcAoWuzDzbvbIXOTvqVyvNR3J9pstnlW7A+z3SB1Op5UXXtSCcZPN1u5ReN1AMdP6Qecm9O4HRZuTqdNctg8gl0HAmKfCJisdzeBYlFWKrrP1wKSh261lwuUssliJ8RN5utuA9J+dsOEYd9rl1fGI04JtfuC4pOxBQrRrKYwMeI4MEW+wSy5rNUt8+dip/SHo5CcuuLg1lrE3jvkAt+6o5pto6enfGeibMg== 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=zzc7E6CfYK2zrLX0w9MQWTufyjGs6lAs5lxehq134N0=; b=QzdivViPK9znGAsSR9Tdb3vgdeT9KGZJZJvi6jWGo6N/E1tah4TUUpetex6pAlZdiyUBoR/ncJvU+s1nv08yE0b0WMln5zDAl0CfZk/DZlVfKVgmstNj15TJRDR/iFjBIc1faGrJa7MDY6kZnhAqUQqP8lpOc+ra/9XwkDzNq7o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by VE1PR04MB7245.eurprd04.prod.outlook.com (2603:10a6:800:1b1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Mon, 17 Jul 2023 15:27:43 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c680:1128:9d53:24ae]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c680:1128:9d53:24ae%4]) with mapi id 15.20.6588.031; Mon, 17 Jul 2023 15:27:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?utf-8?q?K=C3=B6ry_Maincent?= , Maxime Chevallier , Richard Cochran , Vadim Fedorenko , Gerhard Engleder , Hangbin Liu , Russell King , Heiner Kallweit , Jacob Keller , Jay Vosburgh , Andy Gospodarek , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Lars Povlsen , Steen Hegelund , Daniel Machon , Simon Horman , Casper Andersson , Sergey Organov , Michal Kubecek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 net-next 10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller Date: Mon, 17 Jul 2023 18:27:07 +0300 Message-Id: <20230717152709.574773-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717152709.574773-1-vladimir.oltean@nxp.com> References: <20230717152709.574773-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VE1PR03CA0035.eurprd03.prod.outlook.com (2603:10a6:803:118::24) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VE1PR04MB7245:EE_ X-MS-Office365-Filtering-Correlation-Id: ab8b09c6-9f9d-4860-f33b-08db86da5da2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hNKNeyk3KvtwhfV1WFaF/8uhAGxov6c6Xy0IqoMc8j8qEObksh+mdZKHWEuHKRp83W7EcUg7tmUS1NDdR/siQ4gsXWuz6JI62SoUnBMRoH3qfeqrn9Ni6m6qte7JUtWvPQ4octiyG7QozMHDkdw09MKdUoqpTytlI10AM3xeQ2u4L26yhhX6sAvm2bE6jAnNvBlKr+LMvI7sqO6mVfbf6FlC0mh4MSdbLtY3lWrLAVE3lsECjcDNGhEhPH/rCCBUS0CN02r2uUuOMUhso/ehdt+EwOvHhZRL6WrZ3a5XGrtUgKjCxw7+L/NhyxBl+NgyujSceXZHObSuKKMQ8NO2+FF0QV/ilXQ4gg9BQLtMqeF2Ao4DXNBGJvRljwmFMMdCcESY4vIshiRDvBNvm4jGThdY1OXikFjTwDGlS4VAt/l0YLiE80VqzHkR7xGvWQp5aJSgghVpavEhlNRLNbyWWgQikZ9Sr1bVdwrG4itozTXwdgNjFnyxMoAeeE+Wj8mp0AttWoccXNFnH+Mz1hLsxNd2qMMt80RlpW5zSXLOuSCtiyrGDTxXncrIuQHCPCJRvUiqjxYqZ4a8r22cEdxTH932mlTmzypfa9NJ+ZjOgxlG1xQi//X1Kuh4FkTBJC96 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(136003)(39860400002)(346002)(396003)(451199021)(2906002)(38100700002)(86362001)(6512007)(83380400001)(2616005)(1076003)(186003)(26005)(6506007)(38350700002)(5660300002)(36756003)(8676002)(8936002)(7416002)(44832011)(7406005)(66556008)(478600001)(6486002)(54906003)(52116002)(6666004)(316002)(41300700001)(66476007)(6916009)(4326008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TTLYsPvzgDE5o6bMJ7XgVJ3gLxbb3r0eOCCqrdPqvqHZLTwsCBC4S/f8VCgFGCGQKqnNeF2LaWxepyFtgbCfJ7Me6azBrhP4i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oA8plwccKY8ic7dSTAr8DHIEaznB659yvZyfJInRFOQo68+RjQgv7OPcY2uxkNL9l+h82h1iSRN7JSzJR6Q4c/OvPG3OO/nloPlIO4blX776Yh3odo6xMM03Buf5wTKXuzhVGi/m6bz82RNT0tOplgWIVlS98nQxMskr1SS120mIkZfxp9NWXp0oG62Rl4zVgVZGokMm2sychsCK4WnX9LG3SO9D14sLBTBw+952yqZPgbC7ugbDz/TruLUJnAc2eZFU7qWxfsGuiIn0QjAHHNo39F79xLbowIQlEQnKhaQk52QUCSvOHxgltR5aLMnJemsLSJo1s0opE5gHddzpqBcvv4Z7ffX1DFzzE/DWqETipYCdnPY8xMLIEMp1w+MnyaC9gJa6Md/dLL9hPkhn3tLKnE5q4XbNP1hlXRw3c7kr0AmLmOOBkeVVSkAW5xdA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab8b09c6-9f9d-4860-f33b-08db86da5da2 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2023 15:27:43.6584 (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: 5R5jCZdD8wkPjSWjau3Pjmh3FisCrNXLD1yx4ySLZEwG/gWy4NDIFu59y2pRmBnTNQFTDBeZEFxUJJ83H4J4gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7245 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org phy_init() and phy_exit() will have to do more stuff under rtnl_lock() in a future change. Since rtnl_unlock() -> netdev_run_todo() does a lot of stuff under the hood, it's a pity to lock and unlock the rtnetlink mutex twice in a row. Change the calling convention such that the only caller of ethtool_set_ethtool_phy_ops(), phy_device.c, provides a context where the rtnl_mutex is already acquired. Note that phy_exit() wasn't performing the opposite teardown of phy_init(). Reverse mdio_bus_init() with ethtool_set_ethtool_phy_ops(), so that this is now the case. Signed-off-by: Vladimir Oltean --- Changes in v8: - Patch is new drivers/net/phy/phy_device.c | 8 +++++++- net/ethtool/common.c | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0c2014accba7..ab53d10f1844 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -3451,11 +3452,14 @@ static int __init phy_init(void) { int rc; + rtnl_lock(); + ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); + rtnl_unlock(); + rc = mdio_bus_init(); if (rc) return rc; - ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); features_init(); rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE); @@ -3477,7 +3481,9 @@ static void __exit phy_exit(void) phy_driver_unregister(&genphy_c45_driver); phy_driver_unregister(&genphy_driver); mdio_bus_exit(); + rtnl_lock(); ethtool_set_ethtool_phy_ops(NULL); + rtnl_unlock(); } subsys_initcall(phy_init); diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 5fb19050991e..f5598c5f50de 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -665,9 +665,8 @@ const struct ethtool_phy_ops *ethtool_phy_ops; void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) { - rtnl_lock(); + ASSERT_RTNL(); ethtool_phy_ops = ops; - rtnl_unlock(); } EXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops);