From patchwork Wed Feb 22 09:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 13148901 X-Patchwork-Delegate: kuba@kernel.org 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 D97B8C6379F for ; Wed, 22 Feb 2023 09:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbjBVJet (ORCPT ); Wed, 22 Feb 2023 04:34:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231895AbjBVJeb (ORCPT ); Wed, 22 Feb 2023 04:34:31 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E6F639B9D; Wed, 22 Feb 2023 01:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WdaXSbt+xbaIRS9D9gsjqAE7Gpqs7UzaNM9jEO2g0kQ54TXoycQ8G//VjlxsGAe3EPeFd8pCd9KkQi1gruLGvUn8/TFG6EFqiNlc5xYDSapN0HHOXkVjsdxyIE0KQn0g97VLQNQovioMJc0bTAFOz92987C369MlxDwwiT76eSSPY3x7cCPc7gRUgwzcwXOS8DAviIU0cg6ianQEgwOh3IrmfVz2ZMKDHmXwavo+yQHgSzwWnoHFJwqkJKtccwiC4aXEA1hA7slpy1CKqWLgCOhQPe1SovShD4pkvm/U4rVxcHE8BS0WaxZ2w/12LeGsSRjZsqu1lr6W/oYWcJxOGA== 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=Y5BEMGpCgypVwzO05HwJfPKZLn/JDJHAsZ62nxCzaE8=; b=jG6OLuU2zfKOsR5uHZoDi9LP1awYw/gUyobPt64IsnmlWuBEdEJ6+WBHE3np7T/2tUPkstypgl8RX/BfzC+Yrh3PztcaKTzS6OHQDoKo/mzW9Z85qWdrQwoKGUMYhLoq8VlzrZHn4URg6jYNku1A0QfBthzy8XOSwHRls53hEx+vK+a9RrBHnIQzbd9pA2aioVY0xvhHDCHwD9AH/0ZBjxNu5Qqm8zWxjGcgGpO6USByhTpbQwCkhED1vR3FvTdftvwtc2wdPeQYKLn9Vt/qvpML8oa+E+YOCeIc33DFhRS1XIPd6hQZTjShCUNIuv1DhE1w9uW9Qx5sAz9ZtByPLQ== 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=Y5BEMGpCgypVwzO05HwJfPKZLn/JDJHAsZ62nxCzaE8=; b=HgdTFZ7jHk8wSlF5BarY0tVfKWn9rAIg9kZgQ7gzNvoHW0mD4vSUhAL080pqEVKDcOtnQhz4fPPzvyg5nmISqe0Ha3duQ0ouUDAlTX5Im/0JUQ9YuuuDlA9Yzr5CG2ShZIi7PxQegV1zSNhQl9N7V67L0LrEIaenz/hnsIvBIXI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) by AS8PR04MB8468.eurprd04.prod.outlook.com (2603:10a6:20b:34b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.18; Wed, 22 Feb 2023 09:28:42 +0000 Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::4980:91ae:a2a8:14e1]) by HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::4980:91ae:a2a8:14e1%4]) with mapi id 15.20.6134.018; Wed, 22 Feb 2023 09:28:42 +0000 From: Clark Wang To: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH net-next V4 1/2] net: phylink: add a function to resume PHY alone to fix resume issue with WoL enabled Date: Wed, 22 Feb 2023 17:26:35 +0800 Message-Id: <20230222092636.1984847-1-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::21) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|AS8PR04MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: 580a852a-76f6-4bcf-7821-08db14b7303c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oEe+7Agp4nq6EQHGi/pjzaLgWNU+8HVHZE321hjAo+IbNDHMPd0+lA+vx1kt7Ry2BKG12uJeqwpZ1w5/g4JGGfYsXzZRPo9XDT9O3NCRWNucnylCZ0ZvTgnig1ta7UwCh2V284kkJilby+xo755A6O8O7Dd9dv9RvG+WE5ZfMJgMKI4jjAZjSbylm07kjeOQZR7GjiXhyVIQMML5ls+4rLeyCHaFlidQKIT/kPHdKQfl5NUb4YPeWi34kSee2LpjNSgBMvW5KzRJuoRfR8HY37+TqtPlmQZH9WKP3VXBb2HWL8ZIEwwAg2F0389+PW61N7efKCFkng7ZFcWBkWIXcL8Lei1CVFpEldGkqCW6yRIuA5b7yGKR9KUU7sc2/iqAdMOldmQTfEBxe50XGEpxQ12TtYvsO5cVsxlDWgTqIGoMDZg2lJZFvpgFRP1d7DCHF5PA675Xd+p5CtTY5r4RoQcVX78k1oaActeEIf7/DhsXQmPLJuaghYakNoXpNcZgJDQzl2fyDI8pEfNUDVnR94Q9owP3TcwdfqWB6dZmIDzOU6Zw8OD/1gTBLOzrRxwY8YjTxdnIfVZnQX/OBylrUiRAdW4QP5Gtwztrxpk/yNjKYlxHi4FW/pP3rk2tEVEthb2YWcycWXXHVXAx0L+tnX/3o4KefMiFqEsB9B8mPYgjGMaJn0CFt9MnexfL1qjMIpDiBmNyLDnOYxEQvtn43X3QzJ1pMInD7r7/sbGPtKk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB2939.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(451199018)(86362001)(36756003)(8676002)(6512007)(6506007)(4326008)(186003)(66946007)(1076003)(66556008)(8936002)(26005)(52116002)(41300700001)(2616005)(6486002)(6666004)(316002)(478600001)(38100700002)(2906002)(921005)(38350700002)(83380400001)(5660300002)(7416002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jpih2v6KDhT7ZlkF0ddcydYpd/VKJ6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NPzRapl76HjRaMZB8aYDE5DgrHQQz0R5EaAevB8ZZf8MKaaOdgH0EQk01THhkwn2tkwYl2qC7BMLxWe9pb9+s2/Q+UVK984EYE6Kb2sa1u8zk9a5/pRJjlyMi3cb31a5pj2ZW0dYi6LGWGxAk6m0FIvUNn3cNoYLI/0KjnuQ+YtY7Q6anW7lVOkg0MD0lOny89tLrH/qj+QNRFuLpliFnokYOyu+1oF8V5sVGJL5PHl8MalXm4ryFbFGtG3KQTBeV3CBzrhTg2bohiS/UGJB8KSjNOmmtilfSHASIqNWr0wKr5nnJsUG7R6Qc1IQ68zC2CMFyI5fdMsL9/W0Q8W0q9rPSeJRaF251KTudqd+S4QFVOLsSASe9DgO/WA++hXngvaZz+19uY6w+Ymc9h8x7ZAixtvkgVT37ZhKh1G2f02cuZW8NX0x0a2SiHZKdIA+tDjhOk/QgjXjiSWcAzkiYAVMuU4INLODty4MO+KDbqdKaVlCoNckk2joBoplHeswe/DWWoQbFqPEq6Lda4w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 580a852a-76f6-4bcf-7821-08db14b7303c X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 09:28:42.6553 (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: ACjK4Xp5cfPJWFQ1B38asbTlZ9mKOIxw7lWSZT5gaD8+WZch1SwGSEWQalNALGimkYRJ4P++tQoweLGMkLXcqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8468 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Issue we met: On some platforms, MAC cannot work after resumed from the suspend with WoL enabled. The cause of the issue: 1. phylink_resolve() is in a workqueue which will not be executed immediately. This is the call sequence: phylink_resolve()->phylink_link_up()->pl->mac_ops->mac_link_up() For stmmac driver, mac_link_up() will set the correct speed/duplex... values which are from link_state. 2. In stmmac_resume(), it will call stmmac_hw_setup() after called the phylink_resume(), because MAC need PHY rx_clk to do the reset. stmmac_core_init() is called in function stmmac_hw_setup(), which will reset the MAC and set the speed/duplex... to default value. Conclusion: Because phylink_resolve() cannot determine when it is called, it cannot be guaranteed to be called after stmmac_core_init(). Once stmmac_core_init() is called after phylink_resolve(), the MAC will be misconfigured and cannot be used. In order to avoid this problem, add a function called phylink_phy_resume() to resume PHY separately. This eliminates the need to call phylink_resume() before stmmac_hw_setup(). Add another judgement before called phy_start() in phylink_start(). This way phy_start() will not be called multiple times when resumes. At the same time, it may not affect other drivers that do not use phylink_phy_resume(). Signed-off-by: Clark Wang --- V2 change: - add mac_resume_phy_separately flag to struct phylink to mark if the MAC driver uses the phylink_phy_resume() first. V3 change: - add brace to avoid ambiguous 'else' Reported-by: kernel test robot V4: Many thanks to Jakub and Russel for their suggestions, here are the changes for V4. - Unify MAC and PHY in comments and subject to uppercase. - Add subject of the sentence. - Move && to the end of the line - Add notice in the comment of function phylink_phy_resume() --- drivers/net/phy/phylink.c | 35 +++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index ea8fcce5b2d9..0be57e9463d9 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -80,6 +80,8 @@ struct phylink { DECLARE_PHY_INTERFACE_MASK(sfp_interfaces); __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support); u8 sfp_port; + + bool mac_resume_phy_separately; }; #define phylink_printk(level, pl, fmt, ...) \ @@ -1509,6 +1511,7 @@ struct phylink *phylink_create(struct phylink_config *config, return ERR_PTR(-EINVAL); } + pl->mac_resume_phy_separately = false; pl->using_mac_select_pcs = using_mac_select_pcs; pl->phy_state.interface = iface; pl->link_interface = iface; @@ -1942,8 +1945,12 @@ void phylink_start(struct phylink *pl) } if (poll) mod_timer(&pl->link_poll, jiffies + HZ); - if (pl->phydev) - phy_start(pl->phydev); + if (pl->phydev) { + if (!pl->mac_resume_phy_separately) + phy_start(pl->phydev); + else + pl->mac_resume_phy_separately = false; + } if (pl->sfp_bus) sfp_upstream_start(pl->sfp_bus); } @@ -2023,6 +2030,30 @@ void phylink_suspend(struct phylink *pl, bool mac_wol) } EXPORT_SYMBOL_GPL(phylink_suspend); +/** + * phylink_phy_resume() - resume PHY alone + * @pl: a pointer to a &struct phylink returned from phylink_create() + * + * In the MAC driver using phylink, if the MAC needs the clock of the PHY + * when it resumes, it can call this function to resume the PHY separately. + * Then proceed to MAC resume operations. + * + * Note: This function MUST ONLY be called before calling phylink_start() + * in the MAC resume function. + */ +void phylink_phy_resume(struct phylink *pl) +{ + ASSERT_RTNL(); + + if (!test_bit(PHYLINK_DISABLE_MAC_WOL, &pl->phylink_disable_state) && + pl->phydev) { + phy_start(pl->phydev); + pl->mac_resume_phy_separately = true; + } + +} +EXPORT_SYMBOL_GPL(phylink_phy_resume); + /** * phylink_resume() - handle a network device resume event * @pl: a pointer to a &struct phylink returned from phylink_create() diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..6edfab5f754c 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -589,6 +589,7 @@ void phylink_stop(struct phylink *); void phylink_suspend(struct phylink *pl, bool mac_wol); void phylink_resume(struct phylink *pl); +void phylink_phy_resume(struct phylink *pl); void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *); int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *); From patchwork Wed Feb 22 09:26:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 13148875 X-Patchwork-Delegate: kuba@kernel.org 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 6B53DC61DA4 for ; Wed, 22 Feb 2023 09:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbjBVJd3 (ORCPT ); Wed, 22 Feb 2023 04:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbjBVJdE (ORCPT ); Wed, 22 Feb 2023 04:33:04 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2088.outbound.protection.outlook.com [40.107.15.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43303929F; Wed, 22 Feb 2023 01:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=igJ00wVpLN8BqUJGRL1kCNLh9aQs5WUHMp5brskLFFJTsEjjOvSJ3jNRuugjHkvGp8CgvIMDcZEeAzzp6LaFVW+lzM40A0R8OVgjlbV0Tqk2sO621zNr+Wl9CxXMb8Ks0BD2IPuVQPbEG4HIp2MaEY+Ymhas9sHUc7etQ4Fq66oYYNtyOskL24vGJCIiTW9aIfgCGoSsHXmLvs5470hqFYn6kRWboKfJQ/mIoj3FwQAJjckZVRHTj+a/s7t3lpRy3NC5wMGeiyXQkl6qhwts6+kejUViam+rgSylcxwRBzAuVfyg6IYHQNtB3cXggFYV4hlRSU0jCT1wArSXIedCYA== 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=CyoynQkskN1O4sEggNgAldSJwdQeO6Tp+Ujrk4hI9pA=; b=VXgf9mH9W9FsLiKwMBvpG5zHJMUCFT18bcVoVHJ6LKQX6pprizSJQ6exd1pK4vh80odEDBXe68nD7UHDgwCdY/eRdAHObLGoYZlO1MgvyRcJB+3zj7tFS4aJn/F849AUqXhB9ZjjAOgIBPfcDSsyD7Zkn7B0BXiTvNOgMrUSHP2ZJy1oOYnMU1V8Sw+V6F0zlEtf4PsPym9CrnvUYPg8CLA+c0eiGbJaofZ06IgHyhJ+/ToXFn+5VCNVNzrkrDTe07mwLiEYJmtCvGTZ5vYwSnFbzJLpu3wG4ioRYv00s5dTC7SYV3n10UsowsfHF6HoJIayvw7/M5EF4RtHU4sYYA== 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=CyoynQkskN1O4sEggNgAldSJwdQeO6Tp+Ujrk4hI9pA=; b=VslS30s9Ao4JrvfbGZutBtyXYnB9DnesP1xiQIX1Chz8C4pm+Y+re1T2VJnRq0xTGmFVej1NcnwD3hiBYGjQVjTPv1QOkFRstVbah2jKqgKOX0Gt3WilvQqLwFM2xykKDEH8GQpD7ZI63MFZ+P1FqtQR5UYzE/mDJVkGVMMI0Pc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) by AS8PR04MB8468.eurprd04.prod.outlook.com (2603:10a6:20b:34b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.18; Wed, 22 Feb 2023 09:28:48 +0000 Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::4980:91ae:a2a8:14e1]) by HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::4980:91ae:a2a8:14e1%4]) with mapi id 15.20.6134.018; Wed, 22 Feb 2023 09:28:47 +0000 From: Clark Wang To: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH net-next V4 2/2] net: stmmac: resume PHY separately before calling stmmac_hw_setup() Date: Wed, 22 Feb 2023 17:26:36 +0800 Message-Id: <20230222092636.1984847-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222092636.1984847-1-xiaoning.wang@nxp.com> References: <20230222092636.1984847-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::21) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|AS8PR04MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: b0d58544-40b2-47d8-7dfe-08db14b7335d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QVk8PgwEhSfq4UT0n2QMA3RJq2qipHuId2OqBYxf2RoJGvvIiOgAfY9K3kmn6hkADYWJaA7KAbqEAykuXJ73eiAelBNwzSJH+g2bP1U3zqlnTemXRVZyBdb9cm2kBHwN17OwLtezZ/BqW6EFDB7pqaG7HSwgV8ul/yinwzlSzVdncRZs2td0SRyBeEB15IzLqAREEAD+8IOYSgi9CYOUcZMhLbFdB+HtklvIS/l/KG+1mF4fvZwVoZjyPEaWCoyDDRwUQ4AAUKvsQijKPPijRY2ZZyXqAyr7acJKp8GFWnwcKYXo51UvV2lByUdjpN1y7R06mZk9s0SJxZmovEd+aBSUFSCqE48k6r06we8uszND42dFc1Z1Cqo8dobia1nd4JBVwvxmlaUWOJv7mDJyMYVRXkI9u4LyG+HoURZNvr22ltxSzqz5QAJLrTR1+RLf7Px5iuT1vfvCZG3JZc1ZbiXt/RAkqmotP272yPzDiULwaskr73fmRJiuWpxXjN9QLX67ANcggHJEIF1gq26a6SbWuAygl2cH96uGfqvaO2Ae2uhtHBgPR2tf57VmkWEvPHJOIio+Dj7FZGb6ikpoUMYCktO1vzEfyYl2uUDICo20HYI0tMnZp25aLyIk95tQ9lFBqkxXRskn/PPOgDE3A9H4svp1Glf2+gBpJba+Egxt9OnWVXASI5myJNjr9LAell7RzVjK3uz5GNYjoWkJ7bGK5SIiJw0RUh79SYewZH8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB2939.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(451199018)(86362001)(36756003)(8676002)(6512007)(6506007)(4326008)(186003)(66946007)(1076003)(66556008)(8936002)(26005)(52116002)(41300700001)(2616005)(6486002)(6666004)(316002)(478600001)(38100700002)(2906002)(921005)(38350700002)(83380400001)(5660300002)(7416002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tFc+Wx/10YtwNqPwdyzahO4huoPjifH/fqId0n/3TUQF7gPm9Sit/MrVVnucPM/uIJByzFUU5wESd3+ZFDlgt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WkptBgtXjDSOejL2WlXJQRw/6dZFvXiz71Pewd4vH6663G2VRR7G2+Uq2lzvA0df351sL6jImJJlE7/Tut3pDWYx0o2hNzhCv8HrT55b229GpNaAEKgvhEciXdwCa8VIsJlhV02HTen6d4eqDtMQx07f0Dj+vvE6V16or9qRt82OgQIBkbaYYrlh0ocUTxLWEB6NN22qNguC3nQCXrfIlSZVsHUze3ihOQI5SFwubkYFBefnQ9peTHjRK+hEbPIWFWWE3TlsnETrC2z6cqGucqdS1/V1J13NULCc02w0eLfV4F80d6yhREG1nrw3ga9XrWgEFd5dyZV94jAoa/U0pBwOIhf43uCPIIjThyKfNtKZq/T/MCsi6Ax7GLuNQpqAPOWhSqkpXacBQmFShJqdx8uzx5NuwR8KL6ADqTxgrfzzdNJe4SYIUXRsSSPTki9Aeog== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0d58544-40b2-47d8-7dfe-08db14b7335d X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 09:28:47.8580 (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: sMl89UcPZE78ujwogS0UCzig8xWSpqFj8aEachDAtJJZmPWe2CE542WCB+bTkS0KNpQ9Jjeeibd6/3XWXWYvLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8468 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org On some platforms, MAC cannot work after resumed from the suspend with WoL enabled. We found the stmmac_hw_setup() when system resumes will called after the stmmac_mac_link_up(). So the correct values set in stmmac_mac_link_up() are overwritten by stmmac_core_init() in phylink_resume(). So call the new added function in phylink to resume PHY firstly. Then can call the stmmac_hw_setup() before calling phy_resume(). Fixes: 90702dcd19c0 ("net: stmmac: fix MAC not working when system resume back with WoL active") Signed-off-by: Clark Wang Reviewed-by: Piotr Raczynski --- V2: - add Fixes tag V3: no change V4: - Unify MAC and PHY in comments and subject to uppercase. --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e4902a7bb61e..75857b85921a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7541,16 +7541,9 @@ int stmmac_resume(struct device *dev) } rtnl_lock(); - if (device_may_wakeup(priv->device) && priv->plat->pmt) { - phylink_resume(priv->phylink); - } else { - phylink_resume(priv->phylink); - if (device_may_wakeup(priv->device)) - phylink_speed_up(priv->phylink); - } - rtnl_unlock(); - rtnl_lock(); + phylink_phy_resume(priv->phylink); + mutex_lock(&priv->lock); stmmac_reset_queues_param(priv); @@ -7568,6 +7561,11 @@ int stmmac_resume(struct device *dev) stmmac_enable_all_dma_irq(priv); mutex_unlock(&priv->lock); + + phylink_resume(priv->phylink); + if (device_may_wakeup(priv->device) && !priv->plat->pmt) + phylink_speed_up(priv->phylink); + rtnl_unlock(); netif_device_attach(ndev);