Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp476rwl; Thu, 13 Apr 2023 19:33:19 -0700 (PDT) X-Google-Smtp-Source: AKy350at7Kv/r9Oo80+7yK5HsMdB7eyqoRgJyuam8T2bjUMwouDeBjeJdM/vuMcAEIFldnq4qazQ X-Received: by 2002:a05:6a20:1b1e:b0:ec:2021:f42a with SMTP id ch30-20020a056a201b1e00b000ec2021f42amr4118049pzb.14.1681439598941; Thu, 13 Apr 2023 19:33:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681439598; cv=pass; d=google.com; s=arc-20160816; b=f4NJ0rMuFTgVMdV6x7pMqQuZ3YuFSY0imqNA44h/227FHyOoi9ZmRk6x635LuQ02tO emN0JfRDFy622AjqHkqMwNwrO96/YhdNEShKeWBaAcoWWb4JIcdVhMWEuUQOG+7KuXQP Ccy5xr4ZGkmO3mQ25TW50bD6sFb3bI2g0PzxuaBjSXT6fp0+KxtZJDDReZY/P3++4Rnh nzFppcFOzy5Q/LR8f4o2QPxMheoo7QIyO8Uo5wHDiGiJ7z1wuCfe0FxPQJyB2Q+OjPuB 5nDjHQuydSQIS4zU5P3dOiBph9gP4k7IiBq7fnFvbf/EkMG6iGp05vnU1EhDyVFnHjHX kN0Q== 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=qBDbvD3JZkVSBPlod6bdoB90wzu9+p4AQQEdai6b+04=; b=o5RZq4plx4j98Kmb3Eue6KmXItC8BGsnCnNN1imwW8eV4lO2hCxa7mkLlT8dGcMf8b K9oqT6umhZcLz4Il0/DgOF692L0+koR7uG6+s9wCTeNjhZ6hJ84iv80GBRmdhkjhYq5L zsCmIBxDuhsYUNcbGclAkAXF3iiNtZKB+mqkvz6BWp6//N/K3UgSx6Lmt5bttUDh7Jl1 TKv3n9LAzrDws1G0F9UJCyHWGNMIcnGp2VybvEVhknnEeGZMomjGblHH7bzu2fqEG0w3 1fpa3Cm8s83nUHsJfLV2fWUJLLCW3q+pL45X+ElJYkb0XtTgTqrPFRg0mOVodZXgJVSm GhBw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=TWDB+QJi; 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 v191-20020a6389c8000000b00503059b8b2fsi3485288pgd.220.2023.04.13.19.33.01; Thu, 13 Apr 2023 19:33:18 -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=TWDB+QJi; 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 S229720AbjDNCYL (ORCPT + 99 others); Thu, 13 Apr 2023 22:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjDNCYK (ORCPT ); Thu, 13 Apr 2023 22:24:10 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2060.outbound.protection.outlook.com [40.92.53.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F7330D5; Thu, 13 Apr 2023 19:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VotyPCJVFMIhfTrCoRucowbjF2VAOOSHEQKEUth0eG9kxv6oaqaaq0Qtn5ttWG5mjBEOiqAqAY0sf2qz0tktz09KuqcF9tn0aEQjBswKg1Voks/T1YKFaLOiEG9xXqSUg9B+rFout6Ls4y1oDThwR+TD9Pvl8w2R9eoW4Sa3kViMbAgWNtf5M87pu7G4qBkn1nt8uEmn/o2njjBmWIyGAuZJvv5B/r9uElzu7YddcRawSicqfJBaZep4uNdsUkxEOIOTjej1qVG2v0jgasqByJlKsgpHo8GbFovr7G590qeJrnZ77Jm9auu4n8XXByAC0zHnoULyuSKUuOvDwlVHOA== 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=qBDbvD3JZkVSBPlod6bdoB90wzu9+p4AQQEdai6b+04=; b=Mf08bS4Uk5QmjdjjCIf8/DrkfWX1zgBAhoPpocel7yqw12HPw5M8BZcnQOCdOVhhXU4sqp3LSXMzQbiPh4xdeefSUDRdVZvdC2np9I9HLhhjk+omGM+nXkC1Ik3CT2K8N5lusPU6jb8DNEuyKvHeS1R0XYCPO1bqbeU0pAFn2tk4DXxyOltDK99PXxG+3MZQCf7ab9kfKZKu7i5K7nDPqmEMkSMr3qP+tYP00a6e8zgHo5GR8nqcNZdxjQm0S7UJflmtS7YtI6NmTSdvQioqi5qLYJYo5w7d7Q4W19f2DYGyh9fmVHVR01dh+blPQK8xJCzBkMEbQxwTsrENYhYO7g== 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=qBDbvD3JZkVSBPlod6bdoB90wzu9+p4AQQEdai6b+04=; b=TWDB+QJi7mg8PVi6bMD85NJ5++mZFQgO8q3Cl4Lj6PUZ0u6N/ZeJxJMpYzs87r7t3PrZsJtRLxjpu3Mf1rMLbz/l7WIBLYDB0PUnS+5fAFHARboASv7R3zcMDt7o9GecQGC67bmEYem5Re6HOszbdAZog/tqhQWFyMPX0EygoPBkTvGCVRKr/dalYAfNwQO+oM5pGa/1wYJ7+Lbg53YFn4v6ItdmMrKVgU9+eZQaXwJkIHCilsHQYKAkMm41DxKMbHii1U9G70PcEwLrr6YFU11+TYF/bWkdO/AlJt737l1GUIaDkU3Lz64eGKQ66syFDudXX4Zew2dHkT+Z8Bk06A== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by SEZPR01MB5342.apcprd01.prod.exchangelabs.com (2603:1096:101:e5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.4; Fri, 14 Apr 2023 02:24:01 +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.6319.007; Fri, 14 Apr 2023 02:24:01 +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-next v2] net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports Date: Fri, 14 Apr 2023 10:23:41 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [iutxibE7g/AJa0EZGWrBA8JcKp1NSYu2Ve8NNNXbiLE=] X-ClientProxiedBy: SG2PR01CA0111.apcprd01.prod.exchangelabs.com (2603:1096:4:40::15) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230414022341.18095-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|SEZPR01MB5342:EE_ X-MS-Office365-Filtering-Correlation-Id: 157a1ed4-ba50-4fc4-4700-08db3c8f4f71 X-MS-Exchange-SLBlob-MailProps: ScCmN3RHayHCvCmR7Mrip+46pMXVmOzprsLuyh2I67nGh5nZ7zZbEY0KUuutlMqqtHCXkPobdCGgHNhfJS+upb0wirypm/N7aVOfjvdbQhVoUvlduaM9or71uiMQbb2TZclrArSjcKMcnTjAo0cciFggy1rLkM/HP0DPfuTy/BYmN1433IYYHRp22hMaXeH45Uox2UISjxKyBOhHepyg86tv36jYUtbbgupny3H2o977FmjyWxMmzO6LICfXqZjAAu280PKYn6ZTzm4ch2+3wXvJaBiLaIhF1cvznv5v0fVlkf0nm3PQ6pa96GP+rPgNVGv9nUF/XzAa4Zvwybw7lhWRpC2sn5tqCplDb7PguPolnGMu3AQiUHg5lHAHCLvc/vTo5mfAeOjAze0kTVTF4oVHQ5onSeq37lbvNaKi8Mta+Y8m9H+0wIvm9j2M/1rkxeea3bGYmw+snfOECsW+Ja1GJpSJUj6J+arEU2anLVNxCmSnR4vUZeagnZdehwGdxLgRzQUMUwzdELo6uJf/lQHeHeR+CmGaHqg14bzF2mj7ChxxauaH3F+1jfIZc5D8/p1E5vlU3TUgWWdm0BtGH2gogfQqrwvPzNAfskrVCkQEHl6pnomgJwzjvvd6q0u34CWyFDwqno5NDsovgzc0h64n3/xRpvNa97YvXN3SkS0j7rV/8X/OvyRvB2wwoAPIBQgO5nbb0P7nUW06lNcl2VaZTmVa5zyefRLPLb3JHus= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qzHaPCFYOQcEQL7nliogwm1wpVh2SlFe84bjb59amplC1Tt7nLAg2fFnhpx1gb7vJ3G0+dibHjjIw8U+AB1pP0DnTHYgaNjnJclwmlpK4MWsJPfb3CurIlJUhwNOKyYjErosYzxNitGG2jzRHSV8Gvh+BWbHSLYZ2i3yCm6LZTibVAPQ8ocALgHeatheRjVMvcP5Tw6c9Rbsiyt8UlAKMIliDgEanGztDphUFL3CwUTFbd0pTUoHi/4BLT2/lGat0ovKNAHIqpm8+Sk8CtvmBXOdJtntvJbOIkRlIG2+mWruOXzKTiWnHRwN5cXfu+NB3+E6ozbGF2ewyG0oIaLWAmRcwoHJMobGGGSUVpByGwaDe7gfy2HwJUrZU7nU8JTwEb54AOhuq4YV45U5k3UQI+mqBXlzBvdFTsmspSS6pkfHvqhdBLJ6pwbQR+H89Qt9OHogz2K0ve+u6iNk+awHGUTkNtmch9sz2S5h1HFEO15AYiPDt0rhznmwQlAD2qz+N101G6BFPxPIgup9eHL8wy0sXWrf7JMA0IAzhfoSjQZbl6xGRO1EZdUmrjSqPxbMe3Gixi6Xn2rXYFXnThPtw618frRDNaixDjnAhl+35YOK4eMaR9RC4e7sYI5yIkrf X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?d8sHqUsVdDFEtfLgYcpvcd1FGuirujX/G/8IAErtjA+gg5a8DdrR0aolK4Fn?= =?us-ascii?Q?nkG8xOdGev0kVF1rblcK0upEWevtcOv5Aa7dpoLc1U8Fu74j+4mJ1pb60bF4?= =?us-ascii?Q?2h2wtLEIHk27PCqkYS0M7QingCO1NTlqbYg/kmkjBDM2rU642ZludhV4NaUz?= =?us-ascii?Q?5G3yjqWv5tJjk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8UcFMlO?= =?us-ascii?Q?oKMIsM7CRBvwcqJ5IJG2W5na0hHlOlZYOg0hrJX8n8OjV9hnFlD3fbbgs0mN?= =?us-ascii?Q?zc09JTMNfcO9Wf3y1Z1W6IUb2cwMOu/Vqdtq/f8XaSGFqN63+bhBSAL7zVS5?= =?us-ascii?Q?wcdgfdnuPYDe16hcyMc8fh6n/5ociAhDZoUn/g=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 157a1ed4-ba50-4fc4-4700-08db3c8f4f71 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 02:24:01.5841 (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: SEZPR01MB5342 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, 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 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. Fixes: 804ff4120f67 ("net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports") 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