From patchwork Wed Feb 1 10:38: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: 13124147 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0040C636D3 for ; Wed, 1 Feb 2023 10:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bKALuXFfqg7qWUYBGUwldGVAchDIq3LFnIa2hvnb+Dg=; b=vPPBrjln3l/6he 1hTB//04k8IEW11xGbW0wQYPgQnSsdvAMIP3jqCTqMFekMr+LwwcLv4fsqAXGhQNIWZe48km32jdS +M8sdZSUfGxXym1sEqFRY3Qm97HnVWcsWzn5hEFf9JBgJl9w7KGBUu2OmG3gSoRi9ZaoglmenA00U 5YUNtXUVPsyNPDOOn34jzoVYdgdQal+m/Asvan+5HrFIEvqlVgs9j2YmuDdVkV/hzrqMhGpa4vrO1 C/ZzM1/V0iOzrf8KPhINicXD5/gf7UKZiDDiMd/QAi9zDtuL4QRfoS//Qckb8rIViHrpHZl9Pf4KS 6FFKRpmPS4ui4YPFtHsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAkT-00BLOA-AB; Wed, 01 Feb 2023 10:53:53 +0000 Received: from mail-vi1eur05on2062c.outbound.protection.outlook.com ([2a01:111:f400:7d00::62c] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAkP-00BLMm-Jm for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 10:53:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d8nwaQ6cLvJNzCrM9+G/9jG6ptw6rLVW/gZtahiOd0KykBAih6tgjkmJRMbUDqI0i/wJqp+pflXgLLAtidkj4TuGMSISrA3A/T2D65O4wsIAO2wQhJifuqP/aQMsLLrHSFkdw8jZtUNdMAR4FJ/Mm/kxUqytIMrxLNYRq4nWcoJfDrcMufsmOObgzSf2rRa9fNChAW0hMGsr5j4peTeWzseHaJja7FOFCCCYUMRquSyyMf4pOloKfyYmjfkQOsLflzEs1HbAllFuDakk7gBbmcXcfgl6okVo/UiSB3y8yFzsLBPGyZqSF53lhI53Jk3j0/VAKKEp8TI8rWgt5BPbcQ== 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=664vzMskWXzAS5U3l6IEbrlcnIYgZwaDh9zGQRxj1wI=; b=G3xW92rIcTqnPHxkKoyHXGgn51HI5ZVfK1F+JdXHIAPf/hlrxM2fGC5B0lEDm6YXibuG8KAAca2Bw/PcehUTZF/grOZ0MlHo5mYa5nQEUvN/tDYTae/tPzX61m2PiyN5TwXvJpy/Naa31sHHy+9hBuj430bTjHL9JFKn5gKRDtFD07GQYUtboGI8dpb4Ob6Xca5phWwqvR8YXHURu8Dlhcaoc/kWq5yu85KOmfkgptLwlf+fcI4vbqBliqhVUn6E7sVe7FOPTN+Z534CdoKmrrCtrWlL3WmVV5DxFBxwBgh/fq7CGBmmGJkEcp5TQxzxcak3ZIB4NA8hEEyaE9hfvg== 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=664vzMskWXzAS5U3l6IEbrlcnIYgZwaDh9zGQRxj1wI=; b=SPkIzKb1r8gX0paIT8xZUHl+Pq3ToSUoObtQy1Fkmatm8rt5gKtNEGE9Jx5BX1YrajnXMNfXloQqIQJr78G8MfoKYGkUDST16SoPf692MNdLvbctUIYoO9szGAqKClio21Kmq0C7zTpVLHvosJCJqaaBO7ud0nqRqh2h+jRLI/U= 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 AS8PR04MB8263.eurprd04.prod.outlook.com (2603:10a6:20b:3f9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Wed, 1 Feb 2023 10:39:29 +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.6064.024; Wed, 1 Feb 2023 10:39:28 +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 V2 1/2] net: phylink: add a function to resume phy alone to fix resume issue with WoL enabled Date: Wed, 1 Feb 2023 18:38:36 +0800 Message-Id: <20230201103837.3258752-1-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SGXP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::14) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|AS8PR04MB8263:EE_ X-MS-Office365-Filtering-Correlation-Id: 391e719c-1e5f-4108-5308-08db04409873 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aBYFxDB/nF4SBUz2qlGp52aw89BHPnQ5M+dRJXdt4CRjNf9KFBLw1SHmuOmFf43owv16OenkRtkwx1gqSk7TtZnbUZ7ZzDZX8pj+ya8kexdu4kIo6t7JNy/WQLsv9Klov2C4Jjunb/m2smvHfNUSC8ETZHfg5Iyp1/3WV/wTE3YhUrUoWKiQSImXNNZQEndCf22e7A8KKPvzATsJcFZw9T9tFuv0DRMwqjrW8EDnIIUYfynYLy9L90tLTffgPr2Ho8C4AdVf1+SbWkWfcMBlDIQJ7H55fGi9qYjT5/pReXoc6NnJm1iM7l3bYo3cr1YJ0PTU0VxhvZtd3eguKbJrfwlMAa4FAYARGdg3seM0PwHgG4bazb7Vr6b1lPoK8jWzT73V0uEXHbLtcsX5YuYIS9Qjm5gbXprWMx3nJ7V3mpr1E/enttSmUF4RPjE6I8gpsOvUpIW9d4kB/u4ijdDCA4cxDzImTDYot8uzdiJu0spNSDJfxN7cqHMrr03qBD5EXU4rn71ip43UFIRBdq2bmjYePa89Crzu/CPvZWkRzGtiT8ev9hE4topYMC9iKltYBZAIqEJtIMZKf6FMA62yJJp0nkId9u0bNj1qQGUhga/ZFt1FSocWx6iRAWTndIBPPosnHfOuHjNzupd7FUhX7PH/WjfDrMoxJYCTdqybXnkFCZuCYsQHbBHpFfpN2gEn7/GQu0Cga7FhEVacGsAF82vxfTx4uM52qd3GCtnlrMg= 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)(376002)(366004)(136003)(39860400002)(346002)(451199018)(66476007)(4326008)(66556008)(8676002)(41300700001)(8936002)(316002)(6666004)(66946007)(5660300002)(83380400001)(7416002)(478600001)(1076003)(26005)(2906002)(36756003)(6486002)(6512007)(186003)(6506007)(2616005)(52116002)(86362001)(921005)(38100700002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fiq929B41VrG5vAmApNqWp9NK9xQ8tzW5CR3rm8aSGcWDBrbdxE9zg32nE01wadaQrdPC9FPuj9SU+Mr9P1X3yagEKGKqx8UraKpxPOJKVjv+WqKtMkMa0OmV7G0ZB1b8PHQk45aHhZ9U01lchzCyg5xtd5omra6u5gtqVQW9FfiOk8wl4vYjvi9u2twdkwJ0aewQnHOTlfJvhA76ZMdCYh6oM6uFNTOED1uKsQ1AviVXtTVIIjicSIZ5SW+CItic7As4T6jdAUgCFHCTy6TjsZe7H93Y6JzYG1nhSvV/mr+gQdhX1kMAn/mUBqDmgO9ipDevetBI9Kh4Ws/6b12H8+cmOvPPwZMS+QSlytA7I6AHe0LTbT/A9fmENiyxl/5rCmxCzYO+/njO6bHNHvxNHiD+eBDt2PBaJn5HRoZ/ueRjhjseCHy2cZTvcHeYzdSdaxeLSO8+BUd9SrYYaWggh8/9KdnxwjZOpKMb9RWLf8cqeCsqTl+7W+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M3w+Myr4biHmQRuXvIKjNZo2uYCjk3d2q+Vi0dtgmgn04cbhdpejCUlFCzg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 391e719c-1e5f-4108-5308-08db04409873 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 10:39:28.7825 (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: eZSUWVl2wbPue29oJo7vgFPasAt5rlKUR9Gt3AGhF36TPXBO51dG1pTvjL4RfofRkipAUHzPS1pyVtHvL9D7ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8263 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_025349_675519_61432D9D X-CRM114-Status: GOOD ( 22.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. --- drivers/net/phy/phylink.c | 29 ++++++++++++++++++++++++++++- include/linux/phylink.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 319790221d7f..687562869c33 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; @@ -1944,7 +1947,10 @@ void phylink_start(struct phylink *pl) if (poll) mod_timer(&pl->link_poll, jiffies + HZ); if (pl->phydev) - phy_start(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); } @@ -2024,6 +2030,27 @@ 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, can call this function to resume the phy separately. + * Then proceed to MAC resume operations. + */ +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 1 10:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 13124135 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 406A2C636D3 for ; Wed, 1 Feb 2023 10:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kkFwm3T7hW0RKhiz9L97AwXlrHfTWm5W5XXx0T+sMlM=; b=bxyR7ygTSL7kYE VkYG5yPk4qUjiPFg+PmBUwDre1yMikSJQqLBAIn1Kac8ZxuQuT9NHNYA+vPEbTm7oizV3GqiGZjAM YtF4v8Guudu1+dPn+TuErLMeJNcL66QUaqANO9ZTaF30pHNDWaHIDIkworkLJ4Z8b+D7xl8811j88 /e8YGryVqf/B2qFW4OVfyr87GR6951y+Dc0X7TNwh0O59VaRnjp0hyawvpIwr+22AO5bpfYyFoksh j7WXz6680fRdL4RgOWC3kq1pCfV7/NoHAdnbOuyo60VFyzm89Aw9tqI0SWuD4ee8Wk/Ty1Pyp+UqC QSTLM0drlILyne/ctkVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAWi-00BHug-FS; Wed, 01 Feb 2023 10:39:40 +0000 Received: from mail-am6eur05on2061c.outbound.protection.outlook.com ([2a01:111:f400:7e1b::61c] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAWf-00BHsb-IU for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 10:39:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=StVX7OCccLWMplgA4DyyFXEQzTfhNWQMBRV69ngKJJA2Ng6b0Mf7L6EHNEy3OJNljHUrZ+mHVyApf/grdOniByGjMEE9Zo2J6ZOylRzExIZKQTt78wgjfGXPTnUhQoBzVyDh6otgtESRXGCcIgBIE8qoxLnI2wuCrfMaq3NPaV6rq/4vkTLoaI5rm4hkkcqwQQD1bG5Pd+7EZjuo7VF16WNSQD7F+LLa7G641pPd09/LgPuw1XiWw4vA9GlmojPvabTizgTg60WNzM7cG0IVABaFycl02RZ13AzMcOqlLaYg5GRp6O+1mReFlCDeF7L2Eygejd5sQiUJQT8pNEuzRw== 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=AwwUtue5wCR/qrDcBhsSwW5h2f6WGLFH3hwj2kVLT9c=; b=OQGdQ4j0WrMuXcyavZA+cwvSE1+L+ISW23l4on7vbuWgv2gknYbpfGoLEQNFuo0nejpI/zO2W77E3c7gIa3BxcChczO3D4zTWHYOT3UAitm/n2ZVNdACo+gdNS8bPghyhwW2ISjvK3OGsMd3hTeET3FDrdJMztY63T1kuJOJdrK7suvt55NkAJz6vSGNxS0ruFL6pXS/a3D03Tyun4RUTSsgYjvEOSVVyKWZ4RBkhK4HZuqTZtvyC4JZJkq15ck7LoY4VyS6wCKWJVuAYMKFhKnmRdZByIaALgJQbg/UT0DSkEHcpP1SOUK/Se7EhDbQ84085U4BEBxV0bo6C28UVQ== 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=AwwUtue5wCR/qrDcBhsSwW5h2f6WGLFH3hwj2kVLT9c=; b=lNlap4bT1Vlx8jKZIDckdRxAxzKrPJYAJmBstz7CsPCPqVD2tOJX9Jt/KH9hFaGBrZcybAQSalwOLsQ703Hz2lj+F8U+3Zxwafkj80CaY2OqzFYJcBtJu3KPC28Q5DBsssYx9QgA1V8OmsC8K3OIiRVO3vUDt6RaUn7MmpLaV7g= 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 AM0PR04MB7170.eurprd04.prod.outlook.com (2603:10a6:208:191::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Wed, 1 Feb 2023 10:39:34 +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.6064.024; Wed, 1 Feb 2023 10:39:34 +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 V2 2/2] net: stmmac: resume phy separately before calling stmmac_hw_setup() Date: Wed, 1 Feb 2023 18:38:37 +0800 Message-Id: <20230201103837.3258752-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201103837.3258752-1-xiaoning.wang@nxp.com> References: <20230201103837.3258752-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SGXP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::14) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|AM0PR04MB7170:EE_ X-MS-Office365-Filtering-Correlation-Id: b3656736-c9a7-43c2-b6bd-08db04409bd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NbSxE4ILXDYrQEhdR9CAP56Wlo1KkVuFLJuQ2/lUlr6CQdE1cJqnMIbwR+jokMnz7PNn73EADnOfcuLqolmGYsA/wNZuXJ26wybxvsSzKda+Vj0wlPTP4jySQtKkqcICNVuPHsZmi7Kmw76TvqHdrncrJXwg7z2kFMP+dGvYUHTa3PVkVhRGG5slfewMG40DCyeDJ2HtoWLIkg0ITaMDHAI6cPb9np4CpFFDtVK8YL9F+vYzHzZ++i0HeYSGxp/FCzqs9q3LkpgHWHH+a/p7qbOpWHtMbYR5y/ol85fcwIyJ59KyvwsRV4vWMQgdBJCTwZGnfPZBhiP2A4A1/rbh+CtpK3xu+7PNEXUD9Gs6ekyoMWTysqW4Fe8Sw+RR7Ffc6fdauGQsTEP8flxcTfUT9afViVd1T3Zh1IXETsmMx1n0owL6UrNxHsD6y1QqW6oIFgD5OlaEbXcHkAynfzUquWnZpCoH1G6Z1XJbmRjDwdGYS5n9ZkfM4SWdAsIi0Lu7XOuT7YH/xJOSt6FM/YAMO5Q5DQMk962+En+MvktXnWT4xDVAJb/a82qwVlvfh85v80Ixnv2+3J1AIDANYSqZQeCXwJ7twv6eAsuaVUntBGibKtMzYVkhEw4pNmxuyhYfn4GuJZrGXvrxk0gOMT2ZMgedV8oshS4ERfH8wtlDPjk6Pv7O4zngfd2P6y8qrEELW5ekaPaQxe6w35/3oyhEefiSllicXcCTRswMLvuMX4Y= 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)(39860400002)(346002)(396003)(376002)(366004)(136003)(451199018)(1076003)(6512007)(26005)(6506007)(186003)(478600001)(2616005)(83380400001)(52116002)(6486002)(2906002)(86362001)(316002)(36756003)(8676002)(5660300002)(7416002)(8936002)(921005)(66946007)(38350700002)(38100700002)(66476007)(41300700001)(66556008)(4326008);DIR:OU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hW5ZZl+P/t07pV+7yOCiN8J5WV9mdaxav6GZleA1OQ6G/SXx+vAzpTAsM8RsXxmQeqmHAk7uNWSezVoCCKQUlwB2ENGi1Tn7kH8TalTrR+t4b4VVp45ycFc272+oHn+8dty1YMh/71TQDwvVfq7Hgh62ADB0/p9PW300wZ/M8XaokhrFMocvpsSiK6Nq6teDRD8vMFd16JhP5Jqkt6ZpqRlB9vAzGuXcRxyydemFINP/aSGtd6+A018iN/cL5WzgNiEHKrjmsyY8z7WW3W9tMrskPlMzNEHGGvKgguJ1gNoqD/cHO6eJGPrUnay7BROnt08aMDisPTT/zk0oU4pqu+1HzjRcS2DfXA2SrdOlkJ30xu2VS5nauoE7wDL425hJLJRXmnXJ498qIibvCQMuuvSKgmVQL+LDSRW3JuVd34eMPq8m3jWGGCs78OwgowU9ySr4vJtC6gs7irKy+qVN8l1lhvGLAEPq1JY8vsTDfSGJfidm3T+kWD4spCC/zjdSmYDwmUBknS582LfibpuwoRrmtD5M/YwdI6SzaYc2Emntc5mcJiT7YcxznztPGPG4ZW1wEUbLa7ue1s/t91UOeSfQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3656736-c9a7-43c2-b6bd-08db04409bd4 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 10:39:34.4383 (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: i35yVUcjEAlApECkRXt9W0jdZHSRyH4+1GRViyOhsDL0L23Dm3d+W9n9ug9uIm4OaiFSIaBL7KsVfz3IRetHYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7170 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_023937_631196_1387F624 X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 fristly. 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 --- .../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 1a5b8dab5e9b..38777e408d96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7538,16 +7538,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); @@ -7565,6 +7558,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);