From patchwork Wed Nov 30 11:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 27741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp862906wrr; Wed, 30 Nov 2022 03:18:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DwVBx3wdnnY2viGJFoKCi6rvd7IYwsrjMJHxqQC8RISRqtlhsyQL+ez9QIV/n/3yyzqL5 X-Received: by 2002:a05:6402:1bc4:b0:46a:342d:dcb3 with SMTP id ch4-20020a0564021bc400b0046a342ddcb3mr32601858edb.227.1669807130716; Wed, 30 Nov 2022 03:18:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669807130; cv=pass; d=google.com; s=arc-20160816; b=gSHmF5E1gAqzvuGE01P4K/340YNtzZNEkMxHsy+sMKCmA5rKeeMaDuzgjlpMfn8sCF rYDfgQIX5kX2ksIMKnmV3j2z092Vg8VXtBiS4pzc43mg/yoRQg1Scr0fozggMwwWjwkh v62yAibVPZnm1piyrzVSJDABV4hF8i9dFSsrFBDXZq7e2LyJXMxWtqSqHjk541pYh+lw ry7GxuPYQetVnOoVQWaBkUE5+ugWwoPjqoW5Zj0R0wGlJ9wyo9dzL4lCDtuEVEaEJcc7 l+S550QsyI9es+LufYs6f41HG8tpb5NJhJjZ+KSB9dYkN2S4da+j9s4vMLHGfCNQt+lO NcHg== 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=oOU8PEQY2yDwQEEQ63eF/ws2Gr3p7Lr0IH/5wwxzc0Y=; b=K37ZRAVS8suv9PveYqFSJQJG2MVP9H5tSOaq/Jkg3iAK/75O5r2BiDfB9fzK7fo0hx tjPEax+h9Dn+nwO1k+sRFvwB4UT1xwvL/+kYC9SpO3Ny97bp5LR8ixRBvDtDgJ4/FLMW I30SO3xVsRE21d0csR0wbmaSCR/X58fm4nL0BVSsJr44MTFtLis2MOv+J9emPH8bI2hL jLVBHByL0Lb/UnzrsSlpQMlg1xM2ydcXLAv1oxRzkdI22lbKA59sqbzfK2+OBTWE7sI6 RucU7Kv0z2Nxs5PykdeeAlMFIf6oTHFMEgyzjK+YAOw/M5XmLBPnRenR6UkQaFuLz/v2 iuNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=FnOicuBg; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji11-20020a170907980b00b0073d6c0facdcsi1183432ejc.259.2022.11.30.03.18.26; Wed, 30 Nov 2022 03:18:50 -0800 (PST) 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=FnOicuBg; 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 S233835AbiK3LMw (ORCPT + 99 others); Wed, 30 Nov 2022 06:12:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231919AbiK3LMr (ORCPT ); Wed, 30 Nov 2022 06:12:47 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2047.outbound.protection.outlook.com [40.107.7.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6184E1C918; Wed, 30 Nov 2022 03:12:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MqRrbahmEjd5U7jQ3Li8L+morFvDzn5rc7OQ2+xKVhQ+Jj3Rhk5/yafWGO58/t6o8GbhWsKbu/m6bHNIhxBAEw4RXzy75cPJ5y5cyLw9adzGrpMm8eO6qAlR1EXpZyzbM7OIIiVKPFkADBIdsuykrGjqG8Ae/hdvXS1cWYK/Yd340k9BfqtS5JfCANIZTzTlPNfvTGgWufS9y2J9/Hl52TOw/RXxA5hITpN3Ii51QkotWT7ocZqBVlkHrwzENcwhjC2UetBIHtq2QqVbgkPdKw6leEhpOth0/vvNMg2FOEQVNLXTCraGNAQwphmIar/JSzQ1yho6A3t5oeIYqYPmdw== 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=oOU8PEQY2yDwQEEQ63eF/ws2Gr3p7Lr0IH/5wwxzc0Y=; b=a1mMuuovz2aPMpu2NuvJUyglES2SOq3CDqmQkDO4mkxHZfTQYQ5IdZXSzATqeAi65ggTDYjB331Juz2j+8W/QCwFFYnUN6vhR2SLtH5/kKDKRHrZSFYVw/5mUBTz3DKP5AGa2N1MC13oKQ0Y4SKxJAMfhc1rdC7lRvjjvlPrkMWBKz2txujrPMiLkK4GcmnL0hlHy3f51s0aGMdCQ6TRSCJDLwCPoc4qoWyPzep3zz95A1KT6LHuapAhpLwLclZVuwH582voWhc0l9DEmolU51Qyxrk/aNJiWHlJr+w+XYQa6FEoFp1c1JUmN49LJdoz/sANAo8k6tVwQ2NvX3l3xw== 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=oOU8PEQY2yDwQEEQ63eF/ws2Gr3p7Lr0IH/5wwxzc0Y=; b=FnOicuBg28KcNcVycu1n8jbJlrskmqh1WJcuIiAoSUHt6pAHKKnHJHLnyzYAXky50eFG+d/Hxk6p2eQHrwPCM0EvV5MXfRY99LWNFCg19JTXA3RNxCfs4irtMzKFRjGCkgtGucfBRgvm1YWkClEPF+LD9DNsrOH3J7mMJuMjQPQ= 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 VI1PR04MB6783.eurprd04.prod.outlook.com (2603:10a6:803:130::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.20; Wed, 30 Nov 2022 11:12:40 +0000 Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::7682:a2e6:b891:2f4d]) by HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::7682:a2e6:b891:2f4d%10]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 11:12:39 +0000 From: Clark Wang To: linux@armlinux.org.uk, 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, 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 Subject: [PATCH 1/2] net: phylink: add sync flag mac_ready to fix resume issue with WoL enabled Date: Wed, 30 Nov 2022 19:11:47 +0800 Message-Id: <20221130111148.1064475-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130111148.1064475-1-xiaoning.wang@nxp.com> References: <20221130111148.1064475-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SI1PR02CA0020.apcprd02.prod.outlook.com (2603:1096:4:1f4::9) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|VI1PR04MB6783:EE_ X-MS-Office365-Filtering-Correlation-Id: 69c0892a-3957-4eae-b407-08dad2c3cb37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZZW9cku3yhxTlk5ysohZ+c0h2Xj71qlSsZ1eQKXN1YK/TzDWaDVObVjNg6qvXem5tCDTcUJycaJS+xOaweq6cICFWyqV7dutlZLOiwS8W0NngzoCSpNtEYnd4Nhtswju1LfaQa5TJP293c4IQ95KrDCj3De6MvtkVLcEf9SMBxZOH53Nvmu9fshCYsrfkqWHVFZXjkYECh0+vfuFyzPGX3d+TgEJd484FOWP37t2IdlpozcZhM94kh/16p29tS/+wGq1YZ1oaHjbUBeSHop9Vg001+6ESJrY7gSHQzMYRwIKaiGYTTANrlxvgsVnwfBVIo/ImS7xfoAeO7/gjPAarxn8L1kAdBd4jqYDe05Y/ob5UDT1QHuXbKP3+dMf8r0/kBblhTx4cDOQt/9QSfc7qarpN3Sjxa+9nk0KSZg4rbE5/Jg8ISMIu3L0lsXnBwOQLdTboQ8wIlkXs3HIT/pNeSAZxPYcwFXeONMe+BtTObKLyjxIGxAp+/MnDWWbW7xpfS4zdAUWrnkUtUfW1iGvb9uNHt/Jo29TgyrdeoR43HqLYfAuXCNXvd/px7sJ1zUdmsttqEYWKViP6pgpvgIjIUK6O64LezdZQAUsCM845RxElikkUMN+Kyb51rwbB8+hPMRah6VVkAJgil3H+kFTQXC7O6HM6eFM0BbB6SqBOeipFz96SWoiVWmURqaL9pgCtfkmkw5yuOkQ6mH18yTmaw== 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)(376002)(346002)(396003)(39860400002)(366004)(451199015)(36756003)(921005)(41300700001)(7416002)(2906002)(38350700002)(478600001)(38100700002)(86362001)(83380400001)(66556008)(8676002)(6486002)(316002)(2616005)(66946007)(66476007)(8936002)(5660300002)(6666004)(26005)(186003)(1076003)(52116002)(6512007)(4326008)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FLlFobYSEuJm4rUY8LqTrAj2ihCxLwJ3XyHPH719ZOu5nFaOltiHvXp93YL4PmoEZdy6pTsWNlG+76GmzXojhoDNNu7FL1OEC1lw7HBZXVyQnjnBotEtHpjWyUvE4Kdw5YTGgkxn4wxVUZAlK4Da9UDkODbn/TyIjEh1omYYvo0lIkydzJm9OkYF7GwtSTyakRy8tnq6BvwIWn/C42Eh/F1x7HoGgZRQ69f6Vqr4R+I8XXPyxmMD4mpOlV2p5AMzXUJE+KMQmPYK4JlpHh3mOEWHhaSZkJov0C/F+/KS9IbCemTbZD3eCXtSo3bbvwOwZCuPEb/a2rfUcPPOa9OCzmQSCRgse2NR7tOZTnPKDRfCKuejHCOTA4rA5TP3m2wqXNL4dvq7tUDNxFj9QB3HEuMo9AMbaJLMoLqClO1C0eOx0Fm72hLgijaL9XJ46lq/dR/76f6dGSpGYFZfwb4ihlPgu+EXHEFfW7L0Jep9pSDb2tNTTRaG7VccNmCTiLvunhcC0/xJ2HasM8K6mb/A4yIAUISUX6+a/jbdXxcOO3mDvVIaU0uxW4xlVNKtVvGL7yZ5fIOiow6OrPi4fNZE6WkcCguN1qv3wlXAK5qxBb82/nJIprn+HWCHg3k0nfSvqcFg9ws+ngyYT5BsDQyRyMgcNqYY5ObjZ50H1PZpPxufR0ITM6g5Wnr7LVrF6SSyqmD4oAQ5lL/3QOxXba4Gfu8GYc2Z3H2cg7sUhCKj8uOFCcviw2A7knlt3mglcmmbWT5bF1ZfOiCL2j7UdfP52wZrxQ9W8zVvoS94drxxa720bEQWmtuZXT/YlzbduXFsINI+PGcw03+/wsvXLClevgZLITLDeuHo4Ao0awiEICK4EgU2W27QZS7dWmsCZKKj34bQDENqXGuyiEgOZl0R04Y7nxIh3Zy0MfbcJEwFugWPXePtPxVlgoiavzEwkFY5ldAc4RnEFYwTvpPydM8LbmyMuoRlE4fyPwQIU8JEPtCUri7NGRj47SYmUahS92oa0XXxinfhTT58qrbgbnbjvYHdnSlKL2U8SnOcv+zmY5RXOgn7tZte1ba6DrgHopeWzZ5KBUsmyt4qwel2FR9YAFtMVdca4F/aMnzd6SgFIbF6rnHnEGAwcz8/gHbZwwReaqHHu7DoUusct5NJGJu0rMrFlvz+QvNpqCbIW9biHtFfJj4i5OL1e82J4SlrH0Lja5z2j81m1mY0szv0wviI/iFv0GSstj8bIq6UwawfHEqV4S3cYrG+rxqNUbOGGvtcT58OXP55kTnVMzDVONQrvpEQb+uBCQbXKQDqn8Njni7pjYRG2d4z4v7twBZezTd687S4zG1sZH95w5SRj9+keYGVoldyM0AuYdEWnv/pa2cZn3mzqvZJwpyJ4XyOJdBe3XIrALxjYwzalK0ChXxzrn5pUD/jQ7U4bhVS0NkZnZfkA9bzr+mNB4FbDfsFJtw19B1CnDypk0sGYsn9V5ys5XHzdk9pACdwPNpcBz3tHpu0HWJBJmBsAWqC0ITzxlIeMy/QZLLvG5jBpesA3U3O/V11cTZDM5HYKqb5ZMrvy2fU4QXCLDxx0ZZ8Azd+3XEe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69c0892a-3957-4eae-b407-08dad2c3cb37 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 11:12:39.8727 (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: olX4FSS8GTb7KlUkGZAWZwTUQ6Hkn2/K4uz8tiLcw8yhObgMQh5ONDjlCRiYX3+jyxQ/1JVveahJO0ngbg+2uw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6783 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_NONE, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750919682103895010?= X-GMAIL-MSGID: =?utf-8?q?1750919682103895010?= 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(). 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 solve this problem, the mac_ready flag is added to the phylink structure to synchronize the state of the mac in the phylink_resolve() function. To prevent the correct configuration from being overwritten. By default, mac_ready will be configured as true, that is, it will not affect other drivers that do not use this flag. Signed-off-by: Clark Wang --- drivers/net/phy/phylink.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 09cc65c0da93..312b47fdc12b 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -74,6 +74,7 @@ struct phylink { bool mac_link_dropped; bool using_mac_select_pcs; + bool mac_ready; struct sfp_bus *sfp_bus; bool sfp_may_have_phy; @@ -1276,6 +1277,12 @@ static void phylink_resolve(struct work_struct *w) bool retrigger = false; bool cur_link_state; + /* If mac is not ready, retrigger this work queue to wait it ready*/ + if (!pl->mac_ready) { + queue_work(system_power_efficient_wq, &pl->resolve); + return; + } + mutex_lock(&pl->state_mutex); if (pl->netdev) cur_link_state = netif_carrier_ok(ndev); @@ -1450,6 +1457,34 @@ static int phylink_register_sfp(struct phylink *pl, return ret; } +/** + * phylink_clear_mac_ready() - clear mac_ready flag + * @pl: a pointer to a &struct phylink returned from phylink_create() + * + * set mac_ready to false, which means the mac is not ready, + * if the pl->mac_ops->mac_link_up function in resolve is called at this time, + * the correct speed/duplex and other parameters set in this function will + * be reset to the default values by mac. + */ +void phylink_clear_mac_ready(struct phylink *pl) +{ + pl->mac_ready = false; +} +EXPORT_SYMBOL_GPL(phylink_clear_mac_ready); + +/** + * phylink_set_mac_ready() - set mac_ready flag + * @pl: a pointer to a &struct phylink returned from phylink_create() + * + * set mac_ready to true, which means the mac is ready now, can reslove the + * phylink and set the correct speed/duplex settings for mac. + */ +void phylink_set_mac_ready(struct phylink *pl) +{ + pl->mac_ready = true; +} +EXPORT_SYMBOL_GPL(phylink_set_mac_ready); + /** * phylink_create() - create a phylink instance * @config: a pointer to the target &struct phylink_config @@ -1518,6 +1553,7 @@ struct phylink *phylink_create(struct phylink_config *config, pl->link_config.duplex = DUPLEX_UNKNOWN; pl->link_config.an_enabled = true; pl->mac_ops = mac_ops; + pl->mac_ready = true; __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); timer_setup(&pl->link_poll, phylink_fixed_poll, 0); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..759c8041f3d2 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -570,6 +570,8 @@ void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state); +void phylink_clear_mac_ready(struct phylink *pl); +void phylink_set_mac_ready(struct phylink *pl); struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, phy_interface_t iface, const struct phylink_mac_ops *mac_ops); From patchwork Wed Nov 30 11:11:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 27742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp862955wrr; Wed, 30 Nov 2022 03:19:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Myjmti9aMecCVW+7zXCUplvtzwF7V/7kVRwRPvrx70IJLrrZP3if0jYbfW/dxSGoSh5Uk X-Received: by 2002:a17:906:6a0c:b0:7ad:9f03:aa46 with SMTP id qw12-20020a1709066a0c00b007ad9f03aa46mr36199262ejc.175.1669807140329; Wed, 30 Nov 2022 03:19:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669807140; cv=pass; d=google.com; s=arc-20160816; b=C/paoRJLPkOdSReV6uL+gPnv6sBBAdNhxetxQSen6SBgOYAmlVvnV9XTILWWfiv1x+ sr0mHJE08a0ZJCK5eG08y9VhxB8Tthyl7vUJpYDUhspkV6bbfkG2V5K2y1c9mKmM5JBS QqCTC5kDX10dx9wKidGuqLsnRQmd3YR2axcGinwtShypIIJ5tq7q5sXmYoRvWCfeFx0L SXcD8YypYLkIBRBX+ZqPjOrPSjTD3IuLHFD7ihR+mID/Y4q4GUSC3/Ap/ykY7PIioIyN H3wh8aFTdBnN9NaC70uty98uafc0T1AY1a8vOZofq95RmWzyxPLg20fgW2789hEgkipv e9DQ== 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=keFPfRXhz652HAqSXUZZ6yOs8zHEl/+iFNN9xix71EQ=; b=DgT3WE/rrcxG8+8wMbmJ7fA8+GQxXrg++f52/09NdtHdtH8Wz0P6P3grO3OtXD1hqO Rpk0WdhRYB2r6ndY6qiGVO3NBWTZrlo7kOKwJGqSMUPNo1y54H6cW0DjoDXdzIH143V+ TdcCSWXVow5k/trkcb6r89jLEBYVEhg1Gzn+wqD9TK7T87PZf+yDv5aGszP488P6Qn5w bIThrYS5UKj8vfO2Ccfi787JLngiLSTg4T6OA5G7zZlCfszwVxyEYHsd1YPtkxPdy/yx 14XXA16XnLCu+Q5w9yaHbEEb1vxJwB3OMnsV3DkoxYrZXH71q2JCMkFr6yBOUZixsPDV RqyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="iF/gFgWo"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020aa7d88e000000b004637e16cfa3si1005277edq.598.2022.11.30.03.18.29; Wed, 30 Nov 2022 03:19:00 -0800 (PST) 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="iF/gFgWo"; 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 S233960AbiK3LM6 (ORCPT + 99 others); Wed, 30 Nov 2022 06:12:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233820AbiK3LMt (ORCPT ); Wed, 30 Nov 2022 06:12:49 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2047.outbound.protection.outlook.com [40.107.7.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 865DD23159; Wed, 30 Nov 2022 03:12:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CfNqcpo4O+0r5PXVr64ASeGvHjyFLzdM0Y8GxuwS66kR7s9WMUPO3+RH0iAH3WRAoR9/gdb/U6YTBfIVUzgEl1RRsJpOdYdMfO82tMar0BnM8aBRTBIaJgOh4OmGYUJFz4lZSiItsPgRJkFggbhY23okcNSJ/PRdlpQE6pmC3n8f+bYDlQgAfJF3gBp6pbw6d1yPq2nN0CfkvmO6neVxXdVVMzDj38MP22RpZLbu2p9izYRrxRf+BB9PJtYmCXq3gUcBz3ePjiRANZTv6+sM76j89ZWkxD3kui0ryU9YnV+Ims1gbGbxdH1MeefMIC68Rox/33uFVOIV0WU5FDN+ZA== 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=keFPfRXhz652HAqSXUZZ6yOs8zHEl/+iFNN9xix71EQ=; b=djyosSewk9ksmE2tyQeiKTO2StJq/JbqpiFytx7eSayc3ppGa+gyBmEpR/NSMZDGKykER8W8T3Ey9qMRzlDU1M3ui1Mw8OD1J+CEAQkN7o31bbT3jf7/FRqPYM4uif/kxpNGWE4YI5tQUfhXKK0LG6uyNc8TpjonilgcnmDEBToo1ouqih1pIrkdGYUkp2vRrxVkgqCiOz6+h/bhUjKS5AXB8wFFLCxXwMXXXsv1F/WvfJF09VbUtKKEFxbK1GUUx2fdkZ7QzUeu/QY709bmAzBBr/fo3qkFBCC+4OPyNfYWldMQAV/1LQnjzByxRvF4O2nVSRbUaJfwZPalGWvZAA== 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=keFPfRXhz652HAqSXUZZ6yOs8zHEl/+iFNN9xix71EQ=; b=iF/gFgWoC3UCdfihLQI9r0P50RpAf0HJIGSpI9diXHzpg8aZit9KHMRA1JW2QVs4tlBtsl8RqkVEivMdXZnsN5vthw+PzSHXa8kQv2evnJMJQ92NQLTNHXdq/ScSIZF/Y6dHjMQ8uhXEYYDVNw9kreETTd6jz/bRRXi3RGAUnv8= 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 VI1PR04MB6783.eurprd04.prod.outlook.com (2603:10a6:803:130::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.20; Wed, 30 Nov 2022 11:12:45 +0000 Received: from HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::7682:a2e6:b891:2f4d]) by HE1PR0402MB2939.eurprd04.prod.outlook.com ([fe80::7682:a2e6:b891:2f4d%10]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 11:12:45 +0000 From: Clark Wang To: linux@armlinux.org.uk, 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, 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 Subject: [PATCH 2/2] net: stmmac: synchronize status with phylink via flag during suspend/resume Date: Wed, 30 Nov 2022 19:11:48 +0800 Message-Id: <20221130111148.1064475-3-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130111148.1064475-1-xiaoning.wang@nxp.com> References: <20221130111148.1064475-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SI1PR02CA0020.apcprd02.prod.outlook.com (2603:1096:4:1f4::9) To HE1PR0402MB2939.eurprd04.prod.outlook.com (2603:10a6:3:db::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB2939:EE_|VI1PR04MB6783:EE_ X-MS-Office365-Filtering-Correlation-Id: d66d1edd-d4ef-4123-94aa-08dad2c3ce32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AsmGA6ROotjjhSMzuqFg5tabDXx6W2j9bZub3nbk7s4fhrjR6x5ykA459tix3WiKFZQOkTkTtoaprphsq3fSvVJUaFE0K0WkJ+8Wrf4AtKqMqKLM3r50mAi12QvuBj4WbjYQaRvyiw7RHySzQwJ2RcgOL7MARMNhBjunVDVlb524+Bn5wa9vEjWXy0OmTPBx/PccMcLYpTEfoun6DVnu5Z6hZWi0ISgCI3vIXy/w2ha+AkvvY2rtQZBsTcvjWlupcwPQXQFJ4LK9XXKnSNuu4o+Jg7qoxhUjzvcS2Yrps1KtSd/4l+3eQLXj0snShAYpz7sLvgS/9usLNeIRXQtWcVpAnsQ4qjhmP4zoBqjaPNVqJtu6OdeGar/NYKq5Lu3nDaACoU2OHv0PF5kmmBpE13LVGpstQx9yz0shIKbTHbQs4s+jpHDVzSswiqC43DIw7fUG5SjpJ+c/X47QYDShHfDM1oiFKFbWNb7HP3v8f3U2FJS7zjnwsmKb/3rZ2bxN/TdGJp5uZ4I+5UJlCCbsCDZhR7U/+mhIQkr9jxMTGMX3rdw3NrQ9k46GYkKaG4yZ/BP694BTMgWWADw0BTT3mozZ7XZPllkjFo6mwPFDR+65sBf0KcqVexmNbzOe8p0AmiY/3gGLguuoxGya7VVTtHQN44L/leHvMKyMa2n1KdZ3uy10ew/13opQg4h+GMB3RyrZJADDwsM4tBpd3/jPOg== 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)(376002)(346002)(396003)(39860400002)(366004)(451199015)(36756003)(921005)(41300700001)(7416002)(2906002)(38350700002)(15650500001)(478600001)(38100700002)(86362001)(83380400001)(66556008)(8676002)(6486002)(316002)(2616005)(66946007)(66476007)(8936002)(5660300002)(26005)(186003)(1076003)(52116002)(6512007)(4326008)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8hlefEeRjjOrrPxl3Fy0lXn+440W37x8iEKjwR6TQJ8S9ipa4tmfSTMA/JRPUdIo4E44XA6rSj3z2mcAonJNp2y72zeqfs57KRo9BUlo8VRWrW15YmPjoCFH72ZivFETZJ72GBiztuBArlKoGFR/ZPe8Il6u4UoX8yitL2YZitBJRghT9l0kHAbS/GcWxnn02iyfaKy7edVved6ubIqC3G7ZOTccuN/ijMgRrpPnF5qRrW8zw5F2pmKj3zRB/TPTJC4KRnVhYzTxLNTxI1bFqRumrXP8TzZ/xtlRhcCJKAvRzy7POkvrWWEQZVfGPb0oprwTvvyJXQYKuIOSv5aF2AIqz5d8FV+MFjncnhakjHfsg85hYa4JSqqVWj74+eTXJ7nAJBA2HeZkaDKHEp6EArX9DFSszGxAFKNe8xEV1lbkl18jgfizQ3WUpKLToeItZRPvSqIO8CeJMaPcuJXB6MMMm33386jtRsG1nxunADG8XJ+GpUEPS1PilFa31TmETGSKwMv05+JR9e9K2fT0Wkprs3j9MfSjOxz7RDMD+A2wigTIHnZ8pH7MDOJ8UbuTIZPVgzK8coOsrz6YgbxJu8X5EH/vObmlvRWzIaJ4iHSQVQv0a82MGzlFZDfq8KJ2+UiKoAasLoCojnvkNBfBEU7rjsz2XA4Lbg7mnhFMUb7TbjZ/ecQ3/ToeuYpQnVilb4IeNMP57lFnzignNUfC2K4p8SSnzMkRhMUmsgTzR/IIC5/gdE9fnXFjwt+MjUnSWZ/tmK3Iig5M1c1M+N0nEfpw9uJo4MQfcAVsLAZRpXavVM6rltiIGG4JPQB72g7iNtdbSeNCPgT/xcGJJbZX5dxCzM3/S9D+ebsNtvrE9XApXsiYjV3+5QZEEIDwnLwL+1LhDzP5SRAHXm3K3XxbAn3SfeUyp8x+6Wi7K3oFJfwnMKFL8zmOY7c67XQW/bLxs1uhMCCDIka2UDFlvoI+0yJlNwKP205tg3+6zGUIsJTuTb8rElThVA1KMwfE6ErAQ6IGFkmnE+Of3Cdf3DEC8XVrBRzujE/bHrDYVwznhUUpjCM9xjON9rxlSg5IzblCL6CmWsAkTqqwYpGrGtM+vFnTmW59AXINF4ovT98VGLtkM+ltbSMYYxy480ZXzXf/A2rrqujS6patxNKjbsbKR5FQ+bpNjKvUxWPcs5yLurHAEN62r7FAeWbUk4MXisIYUqDDrfRsn/Gja1JS6RnWS2SgPakpmckW9n8A58uFQzTLlbL0vQu4oku2jdbiuwqKb8/CqlA1+wRfN8L5PC6QaefZWmyHNhqvJovTrk3+LsQZX4x46SJCHy7r1DKpW1Rqqz/RS6hgHTeKKyxRm2whBhLHoMul1Gsb6uz6LXQpPd2I/moWTFp8bcal+rghmlWfUEoidebWVSz7VVPYBtnzmASXdtbXeswHC/ADsOVlVsOf1mEAC3rxYOkbgqQKNSJb6VffXVIlgTtrBf67gB78/MuXTfLnLJw6BF7JEmbngxdavfvV6AuWYz9KPHkCQezDW43lKV6a247DQ5B0QN4YPjirZ4xLirXb3Ri/qj6Lp2ln3i9ZNopjddqtIAIYllS6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d66d1edd-d4ef-4123-94aa-08dad2c3ce32 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB2939.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 11:12:45.0129 (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: B4m9Ztt3IXY+hZ4t/+GCW7FJwl0lII70o9zwkhUcoqtXrA7Lv09cYM/C0rhaEcLdOKrl1fcvT8WlMXrdfnvJZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6783 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_NONE, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750919691811550996?= X-GMAIL-MSGID: =?utf-8?q?1750919691811550996?= 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_resolve(). So use the flag added in phylink to keep phylink_resolve() is executed after the stmmac_hw_setup(). Signed-off-by: Clark Wang --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 18c7ca29da2c..4f89061cc537 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7432,6 +7432,7 @@ int stmmac_suspend(struct device *dev) phylink_speed_down(priv->phylink, false); phylink_suspend(priv->phylink, false); } + phylink_clear_mac_ready(priv->phylink); rtnl_unlock(); if (priv->dma_cap.fpesel) { @@ -7545,6 +7546,7 @@ int stmmac_resume(struct device *dev) stmmac_clear_descriptors(priv, &priv->dma_conf); stmmac_hw_setup(ndev, false); + phylink_set_mac_ready(priv->phylink); stmmac_init_coalesce(priv); stmmac_set_rx_mode(ndev);