From patchwork Wed Oct 19 12:36:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 13011689 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 EB173C43217 for ; Wed, 19 Oct 2022 12:38:14 +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=19FrEnUc3v0z3Qqb5I3b2bVlpFnOcdMmq3rbWzORrIo=; b=dVrNwIvV9jTE5B 8oSn2pOKp5yeQM2y8hKgfFc4LvgFxKEilU8WEde60iNC+4g8xgQ7n+IUn58etdQyXxF6enkRPFj/8 rtdX2/B+LHN9xVLKocji78xP0+knRGcJU9eUwCO1ExMCyYr5WdGnnpjPXMdfN3sFVFC45S/eMrzjK zFl+ssXzdwqxUOsqosyf+hn4DnwR0v3Lx7fSLcrLxAD4eiEQhV7UTwAm6iDs6u5plbUe9+zDcSOb3 yHReFNQh46GiLPhRFQInLrH4RuqEDLWYTrrF7fv3JCOPj9tT5CkgT8VPkxqhuHqO4MjZrcrkXR5S7 QzS5l/QvL/x138VJmaCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8Jn-001XOA-AY; Wed, 19 Oct 2022 12:37:07 +0000 Received: from mail-eopbgr60066.outbound.protection.outlook.com ([40.107.6.66] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8Jk-001XMe-HL for linux-arm-kernel@lists.infradead.org; Wed, 19 Oct 2022 12:37:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lPxHIoryL3FTlEpoi+3HqRhmEVJ2CiYIH3mCEgVei2qgoaZy9KQGxhKWB7XF7M19ZKBfmKYPXXELbNWuIhl2lSszGvZkQoUR9yzjreWConZtcgREIC5KHyI3mBnYyBLYVxdXBOEbEb5dT/0uDvZgATilUbL7cL0iSkYL5ojuzBXjBRo9IJvCSOw5fZhqcqqx7EEcM7BIPJlwIkwq+dQp+eOJ7tMx8il8CRTDsSWZsn7piEuU89+MdukQIgX0ZJ03541+66XEub9oCix3g5cZ0gHVtFoTlM4T8K2KWFBvEhn11G2yleS8PQc+q5NF2/glj97iwwsFNfFr/FfY4Ugp5Q== 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=lM0ygeiEGam8Rt1aKmv4rqJtqfGRJlCd4+fCBAvcrC0=; b=LhxOS19bRW8ntwl3yINFTjobhlBoIAvuC8CvGMCEBYrG0ZNXayO1lWPEnspJkZfcvnRONqHdzzhK9IiGFCv+8tO7eKSQiEFVCKZ90HAYlBeH6LNg0N9v0eHQHGPkOYGYRXK7aTKgkvshmqffRB0C7DJ4zZ/SNSWjJdEjO9IHipDRoODUivccwIeI2NNu3AxwcnXlOmEbOdqUemPjMjJVz4IpMlUPGdQdEfbS+X0mpWN2KGCGXahXh0DWY6qisq8BgO37MyU2OfkhfkMzSOxqRDFRYk1Kxe8fvKFyACN5J5o7NrsDWTLul3Ufb9s0OJKYLIjd4nbtW9e0MDD/TlVE5A== 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=lM0ygeiEGam8Rt1aKmv4rqJtqfGRJlCd4+fCBAvcrC0=; b=aVWoGOsNV+1mLaijF8SW6GINsXs01ZUWEkcU4K67PpvsHbL0Scdye+W4urBGIxVMdgNWk/PnJ4dZ1CcCXI+NWyib6D3OHXV2Ke7s5qMoZDzZchEqgSG9HIEHh7alvspfyFoLITBPubq2y7ADW3Z5AFzdJcnRE1Ya3c7VMOtHKPk= 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 AM0PR04MB6819.eurprd04.prod.outlook.com (2603:10a6:208:17f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Wed, 19 Oct 2022 12:36:58 +0000 Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::d8b1:a777:e29:7a5a]) by HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::d8b1:a777:e29:7a5a%10]) with mapi id 15.20.5723.034; Wed, 19 Oct 2022 12:36:58 +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 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: stmmac: linkup phy after enabled mac when system resume Date: Wed, 19 Oct 2022 20:36:43 +0800 Message-Id: <20221019123643.1937889-1-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0041.apcprd02.prod.outlook.com (2603:1096:4:196::20) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|AM0PR04MB6819:EE_ X-MS-Office365-Filtering-Correlation-Id: 49527828-924d-4810-d575-08dab1ce9d34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9szagNAqYm1JYs5/tjNwbOwQB6BRNhfiKvIGkO0alAtsXoxUfUqFX5v6Ach8p+V2QrR0CvRy5Gi8VkLnwqm9H7SVmMdd9yanMPcW7dUlNpHMFQpQn282bCGbSKNQyHC2F9+dkufSa0xd608pWE27HBDwfuf15uQ5bykq0pwjmNHlZotcFw6SDNMO86jauo24p+s743ChfBKqgxjxj+AeyUrJyDQ1/PACE6TXHRd9s35y2UIe0Y3XNySLqTUHboxqGuJw9sgG5oqyoOJQiQdrOgjdck2gQTWGcMzY0yFGYiaHi0zPZkepU7shBDjO2vz4QGh/cup0XTkFQOTD0hyzofQoKfcjeZ70oW5S5yMOMcw9WRo/TB/LRF79lY1cKfQ4U1an9XQY7sCnggZH5S+wbWec4iXVU3FgTvNrnLKghOmDNa6w/vTp5FWd1+MyVyLpVp5W5gcnKq0zyG/QCA1fE0CbRJKnT8LLaijmZzA2qqzCgI93QrSMPWLfEJVPq5s6I+PQ0m4NUjxSvgZm3wthviiGt2GDY19JcSSrK1pnkwCp3+1kfK3248Rr2knZ3CZWoljxqDJA0zsuSoPRt3UGjdb/wUh4V+c4DV3rNpwAEixoGo/RjeY9oeHgkKTRDOtwN2f6kmay98qZQqtGoGRFRAenTFtzrYH6Hy3zH7KPpWzbUvnSxOnDbHjFtOmsupu9AFnVAC0oggp5UWxQtgZm+r1dvBvQgmz6280XW6ZuG/4EgTo/8Edaums3TunhW40h4N/SE9HMqrOuxIADJIW+5A== 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:(13230022)(4636009)(136003)(346002)(396003)(376002)(39860400002)(366004)(451199015)(36756003)(7416002)(86362001)(2906002)(38350700002)(5660300002)(38100700002)(2616005)(6486002)(186003)(1076003)(83380400001)(316002)(66946007)(52116002)(66556008)(6512007)(66476007)(6506007)(478600001)(8676002)(26005)(4326008)(41300700001)(8936002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ghS86wO7Wn9N13jEjSSLhefuCCMS7Q64HFD4hEkTbw18HCy9Dvz9RTsiSqAYKSBFfH43FxX5H+cIDA2bFGgcUJrRcSuy+S7X0I+GrwjkWqMX2fz7n20IGS7rvkJatsCKE7C8Mj4lc28e60+LfhFQdg5Un8rkupbzEp3InxIHGvEj1XqPOi6/sKpqQfWZl4Mm9RnddTbbAWI6KbyLsuXdaIPIbvjvTJzkii2vi8vaMf/p2uGNnel/ON3x6t1Ec8O2MKUD51wSsvw469cxZQuH+5sbakpLdVgP2niYREw42aOTJxgRoYvzr/1b8HBYWIkKqah9bm0qSpjaciMso5Yp5LD5xmo6tQfjl1ahoHgbG1HxYDmhjpZMhjkLqQtfobezU4m2dW6WMM6Rf4nJsRjFJwlTJg05E9rsB2F0Icr8RNHH6sGPrf2DILYeVTHOSvpXPbpQ2DcDaHWjCHGJnRtAa7sCthP4HSQuhpXWxTew5MKMuKqewf7PsjZeSD7g3vY5zYEhtYvurQduJ33Ce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nt2nfZ7BoZrJFQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49527828-924d-4810-d575-08dab1ce9d34 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:36:58.7711 (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: 8L632FfXNSLvaydnFtvsL5+xnlBACVNBdPeJHg1ShQDIf15m6ef/S17S0eBmPeBcYiyrUZMH0J19UQl4258iEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6819 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_053704_637057_0D770B39 X-CRM114-Status: GOOD ( 13.69 ) 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 Here is an issue: after enabled the WoL function, EQoS cannot send and receive data after resumed because of the wrong setting of MAC_CONFIGURATION register. When enable the WoL function, stmmac_resume will call stmmac_hw_setup and phylink_resume. - When do stmmac_hw_setup, it will reset the stmmac, and re-config the register GMAC_CONFIG with a fixed default value GMAC_CORE_INIT. - When do phylink_resume in stmmac_resume, it will call stmmac_mac_link_up in a workqueue. stmmac_mac_link_up will set the correct speed/duplex states provided by phy to the CONFIG register. So when resume the stmmac, the workqueue of phylink_resume must be run after the stmmac_hw_setup to ensure that the configuration of the CONFIG register is correct. In order to ensure this, put the place of phylink_resume consistent with stmmac_open. Make sure that stmmac_mac_link_up is called after stmmac_hw_setup even the workqueue of phylink_resume is run immediately. Signed-off-by: Clark Wang --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 65c96773c6d2..79c9ea451a81 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7515,16 +7515,6 @@ int stmmac_resume(struct device *dev) return ret; } - 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(); mutex_lock(&priv->lock); @@ -7539,6 +7529,16 @@ int stmmac_resume(struct device *dev) stmmac_restore_hw_vlan_rx_fltr(priv, ndev, priv->hw); + mutex_unlock(&priv->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); + } + mutex_lock(&priv->lock); + stmmac_enable_all_queues(priv); stmmac_enable_all_dma_irq(priv);