Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5781575rwp; Mon, 17 Jul 2023 09:18:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7pa1PldHSrZYBOR3s5VDCgbSkk3pZMrDQrmXnJcFwiP7p96tL91DygTd12L7ePJusO6vo X-Received: by 2002:a17:906:f191:b0:992:462d:e2af with SMTP id gs17-20020a170906f19100b00992462de2afmr10202174ejb.75.1689610724776; Mon, 17 Jul 2023 09:18:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689610724; cv=pass; d=google.com; s=arc-20160816; b=dVKn2rVxPiHt0VkPtW08n+xPwrhXOwj5+3sAI9XRWnSGKvJDhl2xDRVqKRQQ612g0B Yv8+uShcJN5K1I9zaAG5CQLQrf/zYCAoTJpFJ+LVNAPGOSukF3EvgS9mzZ7ZUO9KDNF2 HWnFof7OGkbu5NebsBaZCDMv4AGspZdRbW4ZAahdGyHKgWbO+ciCX1JTgG2yhtc8yjkj CeeHjCYHpW5vBbvNkGrvdthf1+jYcglAnlS25kyzC/AYFMOItiXJG2k++PhI+iy2Kbwj d2jCwoa8/PNB+ilZCHldqPuweS+N/INydWX1DJuUhaMO/xM/DwMCg8cZMURKSucoJpLE dsXg== 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=zzc7E6CfYK2zrLX0w9MQWTufyjGs6lAs5lxehq134N0=; fh=pB1u9kFmKl/f5bcTUEifHJQa7ZXugffegv3ITfVESik=; b=va6NnZ6dGl+/nVAqLvBz1ZvBInNH6miVLRCMd2MCwl0h9frVI49R47LkQlOBa9nz2K s4T26GYOEGFt+Qv4LLZiU81u3RlxzNc1te7V86zxp7VclJAtWOrRFC8tiaDnfmCKgat4 R+z67JHZhMFNC4me91mwxjYjq/OQB4+BK/d3IlH5n/rS3802R+UV8P3jFrvaP5yKfnuI hygrJNWo2Oa/z1GVATPfQi0DfgRmop1iDc0uNngoRFqyDuENr9bYyrcqyzWlyzaNd68C 8uEHPJV+pltkhHXWJfxwq6YDsoS/ctImQVCWfDh8Sriggv9B+V00hpPnpGEALGQL8neJ PBDA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QzdivViP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc9-20020a170906f90900b0098678728b52si12990673ejb.123.2023.07.17.09.18.19; Mon, 17 Jul 2023 09:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QzdivViP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbjGQP3K (ORCPT + 99 others); Mon, 17 Jul 2023 11:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232449AbjGQP2T (ORCPT ); Mon, 17 Jul 2023 11:28:19 -0400 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=20Maincent?= , 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> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: VE1PR03CA0035.eurprd03.prod.outlook.com (2603:10a6:803:118::24) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) 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: =?us-ascii?Q?TTLYsPvzgDE5o6bMJ7XgVJ3gLxbb3r0eOCCqrdPqvqHZLTwsCBC4S/f8VCgF?= =?us-ascii?Q?GCGQKqnNeF2LaWxepyFtgbCfJ7Me6azBrhP4iO+39ErTU1NmmwD5WXCLD5Xb?= =?us-ascii?Q?1qgVryqzELmeixO4x5h/gas0GSpgGJuajpY+UOvRDnveJIgBIlWJh0auBtpH?= =?us-ascii?Q?0JPnvf2pIUtbAyKjoruXcbQkr3bivRYmVXUjjpf6ZdB/LTEW8rcokVijtc51?= =?us-ascii?Q?uYprnEPRhpWcwTfYtPqOCOdgs+rT3KbVA+zLTSjxM7SVUC4h6gMYIslLGoPq?= =?us-ascii?Q?FdEBAEmU4UbjjfL8fV8QfbH1ZTp6NyghOgVEPZ9DlpIBiRXxnVj9tYr3KaWy?= =?us-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9l+h82h1iSRN7JSzJR6Q4c/?= =?us-ascii?Q?OvPG3OO/nloPlIO4blX776Yh3odo6xMM03Buf5wTKXuzhVGi/m6bz82RNT0t?= =?us-ascii?Q?OplgWIVlS98nQxMskr1SS120mIkZfxp9NWXp0oG62Rl4zVgVZGokMm2sychs?= =?us-ascii?Q?CK4WnX9LG3SO9D14sLBTBw+952yqZPgbC7ugbDz/TruLUJnAc2eZFU7qWxfs?= =?us-ascii?Q?GuiIn0QjAHHNo39F79xLbowIQlEQnKhaQk52QUCSvOHxgltR5aLMnJemsLSJ?= =?us-ascii?Q?o1s0opE5gHddzpqBcvv4Z7ffX1DFzzE/DWqETipYCdnPY8xMLIEMp1w+Mnya?= =?us-ascii?Q?C9gJa6Md/dLL9hPkhn3tLKnE5q4XbNP1hlXRw3c7kr0AmLmOOBkeVVSkAW5x?= =?us-ascii?Q?dA=3D=3D?= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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); -- 2.34.1