From patchwork Thu Aug 17 15:06:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13356695 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 0239114F79 for ; Thu, 17 Aug 2023 15:07:06 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 226FB2711; Thu, 17 Aug 2023 08:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YF3MjuW3rRsmiVFfwjLKIUupHeVZjhzS+QnRi29fYfh/zihOFeT0fq9abLyXlRZ50lZEJN1x/MmbshOy+VHU9GyeH0mXQoiMO1V3XbU3ur0UzqXM3CiQDbZelLjRSOf2V6/lY516BWnsdmpvfEDLQJ09KRTBzvBd9JKAMMKwZ3Povt8ArzYLbvLyen8SpxSfbDk/ssJL8xL8bwD8QLVcOYWE27pcc+Jy/MrvEVCbEsGUV6Sl5/iHlxvRxwXlKw3U+4T8NuIMrC1TkhistrVteFrSvTY6jeWbdWXdkoNt/hLJlCdZdFp4lJjOavekrDBRwKaOInrp71m5nNvU7xVNhg== 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=p7ImfiEnvrOdShACecPKky6yj2SGCUD0V+OnjaenyPM=; b=kyR39mBvHZjCQ6l5mQxI9YxqHelIl5R098IwwLVdbs4xOzRvs6thgsPxsySRNnD8R3xE3i576fy4tBjGR/4Umem6olCB9GW6XvPBj3jKhBf8ssHrggvQXv4LR5H92rA4fgvFmTkTkbCZtteF7/k30alIcOTS3kqaCJcXChO4HbbyoqagOVM/Yp5wpwatgr12nX1YYPuMqgrkCO+2u/l6iKHCQclHsP7VD5E8j8kNldRKVbf0wMTM6+G+kpEJpMtkJ03EMdyQsFjA7y/qvq04t1u7gsi6uGO8pPs9CEIkWNvVH+nzcIVMyEfA2so7GBMwBYtJSdvOYvQiZKLk+LQhDQ== 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=p7ImfiEnvrOdShACecPKky6yj2SGCUD0V+OnjaenyPM=; b=ZnJ8f+aHNdPZn2OcGrTqtVyyz+F8w1g7BS9qoqldVSjifYGv3edGGmmZ3OlYGXTuUGQn9FmUSP6L6g5inl67iWPB1BvNpSKuwAeGvG1I85yNGXwbKsPxQbzC3aASSVaMIgzqPNJfhnEArdZ0tof4PIn4AqW1Cy/xadTmKl9V+ms= 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 PAXPR04MB9469.eurprd04.prod.outlook.com (2603:10a6:102:2b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Thu, 17 Aug 2023 15:07:03 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%7]) with mapi id 15.20.6678.031; Thu, 17 Aug 2023 15:07:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH net-next 5/8] net: phy: balance calls to ->suspend() and ->resume() Date: Thu, 17 Aug 2023 18:06:41 +0300 Message-Id: <20230817150644.3605105-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817150644.3605105-1-vladimir.oltean@nxp.com> References: <20230817150644.3605105-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0137.eurprd02.prod.outlook.com (2603:10a6:20b:28c::34) 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_|PAXPR04MB9469:EE_ X-MS-Office365-Filtering-Correlation-Id: 29b0a30f-6ae3-4060-1b46-08db9f339d03 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: F4/WLngJ5kQl9EJWIPzYKIfdzA4YeEXS5vh+KGimr3WRYrSuW4AFYYjySygxSLH9vpXcgQRdDywdtsmT70mM5xJ2e+JYAXSL2ufOR38QaITsBR6eFw7U91YBnHpqNdABqqZpCpKeIfvg5HpnDtbI5Pn57wn7aOHTfZMV/S7bFonoVKwDcHPq8v1ibyzV+1D8q8Y0GGXVAWn4ddnUlEjborRVhSi7JEn0hwDBmDg9yW21dIX0rwLlgt1N/kwGM4m+oYqM4h+jhiopQBET/jOdFxBmiFGOpl4YyemFRpLrVu7TB7ntaYeWVXT46bnLc6TqviYZqgwoJIYgVN4MGfiyktD5BgNaTlCrYdp5e9dvGRvWtP1MpUg9Qf7levuJudXfSRJ2llb3C3AfyEHXrYauew1eLUf9ay9OhlJIcEL0ulPlbk/pcVnkYal3zXqpyQk6lberwzTiyycagrkh7n5ay9t3JnZDLrjEndRaaVOyMhxDBx2qjb5uWNfLiMmCynOckvykbZYSGoDGhVzalC/ZnDdqx9WteornifJCwQPVQGD4AYRlFlf6ORdz9/KQP6VkXFYirbtO1WEVw6rpMsRk207e/F+ifpbiy2azJP1EH0iBdRPlzOUG3SSaKMk9bxwi 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:(13230031)(366004)(376002)(136003)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(15650500001)(2906002)(83380400001)(26005)(86362001)(7416002)(478600001)(6506007)(36756003)(6666004)(2616005)(1076003)(6486002)(6512007)(52116002)(44832011)(5660300002)(41300700001)(316002)(54906003)(66946007)(66476007)(66556008)(4326008)(8676002)(8936002)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I7fHMBh98sjb5aWPTH2XHflAZZC2ANmJ1ZRu34ywESbPya3hyZVvPkdJPob0tHoOvGKR4uNEEC5eWyZ2/2nCOQqFMKcidydBSa1WOd2m4XbsyPzHpMEoRts8KeaUpTTPVq2uxNKHC1iZx9b6d2tozDztEyp+TZ+XZoskv9Ua3PqSdkGvOLARyaJ2TdQadWShcTqDhLnHhCxLpPuqbLVvVA7pUdlxz7ru5k5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jowytS+56XlDEFLUya0gX/iyfi3cRZRi55PX+3v9JP+ZV6Hup6tuo71tm7eIICRY8SU0G0S3/pzQcRLkd4k7tbGEnyTjiqxFSIoRj5SXDNTXsGurNAnzc+Faw/YkJITO/wV56SoWkNmB5cXMCTFGx17zgu7gIQvjEo9aOef0pBEr3oV55zyAy23icCVPJLpz9oufXjbEewV6lPWK346XfWzDNA46s97zjY+uATgzo8w0X7QNshxMd7jg75BrWP3iiKXZIBScuT2LywUw4MRwIaNx9tAGh3Qd5gMfdYSBdaieSfKN+/BCdu1nNw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29b0a30f-6ae3-4060-1b46-08db9f339d03 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2023 15:07:03.1574 (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: Ww0wmgaac0f4dbWMOEZ10UfjgLSYHEzylfLYuzZTAlK+DH2ylIerfhbaziQnG5ZP06+fQY0wktkHQXJPTBN1kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9469 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 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 X-Patchwork-State: RFC Some future PHY drivers will need to do balanced stuff in these methods, like phy_power_off() and phy_power_on(). Currently ->resume() is called twice during initialization, leading to phy_power_off() not actually doing anything during ->suspend() because the refcount in the generic PHY core remains elevated. Signed-off-by: Vladimir Oltean --- drivers/net/phy/phy_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 17cb3e07216a..9cb5aa04b2b5 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1882,7 +1882,7 @@ int __phy_resume(struct phy_device *phydev) lockdep_assert_held(&phydev->lock); - if (!phydrv || !phydrv->resume) + if (!phydrv || !phydrv->resume || !phydev->suspended) return 0; ret = phydrv->resume(phydev); @@ -3275,6 +3275,8 @@ static int phy_probe(struct device *dev) if (phydrv->flags & PHY_IS_INTERNAL) phydev->is_internal = true; + phydev->suspended = true; + /* Deassert the reset signal */ phy_device_reset(phydev, 0);