Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2460193rwl; Thu, 13 Apr 2023 06:50:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YrkhsgOgG6gNmBHlf+/LBNhkggq26YoOm1lJ/PuV/JpCpf0QeFqI7VBq2mmajL6mTbFyzn X-Received: by 2002:a17:906:d18e:b0:94e:1764:b09b with SMTP id c14-20020a170906d18e00b0094e1764b09bmr2807540ejz.45.1681393832935; Thu, 13 Apr 2023 06:50:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681393832; cv=pass; d=google.com; s=arc-20160816; b=EHQAqdJBoD6NAhVUC6ULlNyQR7zR3WA50yT4R8/XTuDFHr23lUeHkgdK8dW8H5V5tS r+lXkq45X3p+5bZJfaPqQ05dKE4eYw4wvPY81zuK1I1s/+N06dc3j27u3ovp3G4y8xM1 UsI1PVoV6k4+2HawvX0t8Wo+CBmzRAcs74vY5DUJ2X7Z3TkaucyVcykJn/sLuVmHAAdR DccbkManFMHeUFBQ6EfAyt+fBtILjQknuRA9ryJe2p+5lTgTsSPBsjFSVyTkdGEDJ4s4 nkPTgw74/SI9Q83QPmbOusrmHTiWYSslRRR5ltHuV7z88Baa0Rv4cFCS9oLNanUk4tgn Cixw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=mm54x0ZpfEPUTyp717dSMXaBikmpwNkOoQc7/DEi4Rs=; b=vWLDQ+LsPR9reSNNAYWoG5DjN3L00fIyMmHgOZKgu+4/E3K3o4lPI7/yQOITzk6SbQ p6WjWpd+MdVANRFa4qrpkCXrvgoG9ZIjxFJ17Z8y6LhQk7HEsslKEMN+WGLRh/zdbIXT zI27l0HX7vGQZUH91T3yeZQNXebMgZh0CgvUJaFKxWI30DaeJDD3Nwr7mGK02yN1pC1B lGxPH27v4IWZPEV35yjbSW2eWe8HV2zUkWUSKnW9LGRif9JtDIAhTaI2zTY6fNi69NKh DnTIhHwLPwwKxwBxBtclAwycsDmhBKlCCg4REk4S4r4Dldk1yLMxJz/ndjEcW+MJbRbR i4SA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Sl+A1Nvh; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mf20-20020a1709071a5400b0094a819713e7si1626978ejc.603.2023.04.13.06.50.07; Thu, 13 Apr 2023 06:50:32 -0700 (PDT) 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=@outlook.com header.s=selector1 header.b=Sl+A1Nvh; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbjDMNmG (ORCPT + 99 others); Thu, 13 Apr 2023 09:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbjDMNls (ORCPT ); Thu, 13 Apr 2023 09:41:48 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2081d.outbound.protection.outlook.com [IPv6:2a01:111:f403:704b::81d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5DBAD17; Thu, 13 Apr 2023 06:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9xrADIMYJrEhvYmgnulJUAskHYAcS8tJ6UScpyRNlTS7SRwbunfBhXFsUZFKZo2tHLKZTDSHfqdWQAZ4PkEON0cTzsnFiD5Q083VWWyMvAUoMG9kBKSidV2eRbdaAEF87LDujAknmC2POdts2KD123wKfbpP/IUtOs93njmbZFNeUuzDxLGC+umEg8xrpi4EGZcVhWzC1gvx2QJPFbFYf9LCQEqYR7TM3pX//u1lelHwoc3UYfw+zDt4/HTG0KQxzkV9bytHHXFDeZwjfwdyucljSM7GQxXhU5/EiZQ5L8gjHxqlLo0VmBzRjkmuC8yMjD7B085EVL9Q5FeCKDnfw== 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=mm54x0ZpfEPUTyp717dSMXaBikmpwNkOoQc7/DEi4Rs=; b=f8rxgxlaDbVbwK3HoL+FjrgVdF7OrCgwbap7MJV8FO6YkBzilDenBjVNFT7Op/o4I/Jn4yoeXMhaJXnX+//2TTIRAYyh7Uk4KBP4D71YycuxuM2SiZQ7fPjvNupyfboxc5Lp/RMwRqVngBO1xqyLn9mAoHfjt1F7b5ZYYcDCrIInDzgjHWN//p51q+M30crY3hRp0oZCGuQT9Q4bD7ANbqaH1p0WUgSxqushGZOyLYftSq9ml5jh4OMmTPvzsQImWIqHbjIyqL26KcS8duKopSPzwjN4VGxzVCoxy38vtPa2HpA0XHQDDj2u1jk30sA9fgMnPiF2rYTpstsBqiKBfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mm54x0ZpfEPUTyp717dSMXaBikmpwNkOoQc7/DEi4Rs=; b=Sl+A1NvhqYsnMRTg2SL7sD8WVJTQqoNNStf+KvqKJnPalM7MeC/b6RlJsJhnz4mZnzekVDAvgMzsLHCGs8yDlUdXPRcXLhwdyFGD+9QNC9LUZjp/KIRtzcWGWYHDsR4CqMsE4CSxQIPOh296MWy5jSiG8gHb6wNcy9LfEqhGn5XiIZ6D0VaZOaRum37VXrUEwmUfbXdRX58+tOU0uowtRpAq4C2zLzgodGa2FbMuA+s6tKHI62k5tSADv0Wbh1/wsjZ6NGIlVwxIabUYg+dOK6YDf4UrJ7tkwZyKtyGX254nXGxyd6IKW5A7Y4FRp9Aww73DxeF1C+klEr8Afzhqrg== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by TY0PR01MB5412.apcprd01.prod.exchangelabs.com (2603:1096:400:279::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.4; Thu, 13 Apr 2023 13:38:57 +0000 Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::5bff:fd7e:ec7c:e9d3]) by KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::5bff:fd7e:ec7c:e9d3%7]) with mapi id 15.20.6298.030; Thu, 13 Apr 2023 13:38:57 +0000 From: Yan Wang To: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, kuba@kernel.org, mcoquelin.stm32@gmail.com Cc: Yan Wang , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , netdev@vger.kernel.org (open list:STMMAC ETHERNET DRIVER), linux-stm32@st-md-mailman.stormreply.com (moderated list:ARM/STM32 ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32 ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports Date: Thu, 13 Apr 2023 21:38:32 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [FBE36qCL9osDQYswg1W5k2d0z5bBysbfamTzsZgSih8=] X-ClientProxiedBy: SG2PR02CA0012.apcprd02.prod.outlook.com (2603:1096:3:17::24) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230413133832.7838-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|TY0PR01MB5412:EE_ X-MS-Office365-Filtering-Correlation-Id: eec0b1c0-148c-4afb-327a-08db3c246e63 X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKx/5wRYKwbtF7hqq2E99L18DXqaHAPjZVBBA9B1MIywpG4LTy0MxrqpW+U88FnyYC79tmKNQR7a8GxOvPldwlTMKqBrU2bn+EX8lEHDTh7UXI2TZkoxz4EFTRdfOY14tKDG7IiqfJ0E1p9Nrnul31xvP1xDhiAaY1N59lP75OVSeuAGQYnNHvG9ti7F8S2NBtB78mkmAC5IYWL0gmSvNOw3+Ey70NFRNbrvwJ291SJiLNo6hz4EPuTgFlC7nVYX0CwyMoARwnnJZXXb56j0gBXZwJEZAMG4zQGiYpRSfa0zcB3y8ONVwhbVbH5QOAP3dlkH4eqndtUqhd3P2R+hdMAP/gXspbsUgQL9lF1xaRQvp58Yqeu8sxeoNaW/VRCYgzTDNK+TUvj2S/8R9LeK5XCu9uxKD5vlfpOkwAx7y2I5TmTW3Pe2r6WVjL9xpv83WOKT4iqfwOcrDMe1yX26GHVpPpH4nEG1s/gwZlqRdWX2kd4/Oj19QaIe5nEkhnUmMbH1DvpxMgJueOhXYNXT9oHqxzk7z6ZJA7ple24XDr0aJgS0VEiudnuWH3+wSRRHZoZfjP5z2C+zxcgNs5YduKg07ssFcH0qyxaL9f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ascii?Q?NX4cY+nAFuuudUxO0q+zMP+eCPbb6pibit9zD4Z1VP5M29+txokaZCmOAD4v?= =?us-ascii?Q?dW05E2iUivXGixp0SXBssLZZRC5P+9gnblpY2t1ebVD4QrOCu3vkdmKGu3+5?= =?us-ascii?Q?3u7dPlEgADMUByb609YHHkyYKUkHlHvAmIhn2V6e9aRb8Y/dZUVK/+oYfAKG?= =?us-ascii?Q?VDWJg/+d1I28bWoSc25a2VEKlpQbY+sZvc02hw=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eec0b1c0-148c-4afb-327a-08db3c246e63 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 13:38:57.3416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR01MB5412 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 The system hang because of dsa_tag_8021q_port_setup()-> stmmac_vlan_rx_add_vid(). I found in stmmac_drv_probe() that cailing pm_runtime_put() disabled the clock. First, when the kernel is compiled with CONFIG_PM=y,The stmmac's resume/suspend is active. Secondly,stmmac as DSA master,the dsa_tag_8021q_port_setup() function will callback stmmac_vlan_rx_add_vid when DSA dirver starts. However, The system is hanged for the stmmac_vlan_rx_add_vid() accesses its registers after stmmac's clock is closed. I would suggest adding the pm_runtime_resume_and_get() to the stmmac_vlan_rx_add_vid().This guarantees that resuming clock output while in use. Signed-off-by: Yan Wang --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d7fcab057032..f9cd063f1fe3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6350,6 +6350,10 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid bool is_double = false; int ret; + ret = pm_runtime_resume_and_get(priv->device); + if (ret < 0) + return ret; + if (be16_to_cpu(proto) == ETH_P_8021AD) is_double = true; @@ -6357,16 +6361,18 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid ret = stmmac_vlan_update(priv, is_double); if (ret) { clear_bit(vid, priv->active_vlans); - return ret; + goto err_pm_put; } if (priv->hw->num_vlan) { ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); if (ret) - return ret; + goto err_pm_put; } +err_pm_put: + pm_runtime_put(priv->device); - return 0; + return ret; } static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid) -- 2.17.1