Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2577352rwl; Thu, 13 Apr 2023 08:12:45 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmphSiNKbiKg1ZXA4i0rsvP3CHJyCHtLSA2hKeBgMOaKzwqo5/KCzcqWSrPRpbmOxIvaTQ X-Received: by 2002:a6b:ce0d:0:b0:760:ac0c:480e with SMTP id p13-20020a6bce0d000000b00760ac0c480emr1401654iob.18.1681398765157; Thu, 13 Apr 2023 08:12:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681398765; cv=pass; d=google.com; s=arc-20160816; b=RSCvZETSUPlA2hN8kPaxVSGysXOj/9tWOdB2EL8O3uTrEsb/lCDtaAxU8u3KQm03q5 39v/nfdXNR7Sf9qNiOdcNy6nEFoUK6nVLJknGQkV67JxucMTqcPncbx4IA7g33CQ0WQH JrpNxMR1T7dnfQPr/h3w2rNeese0howNjklp0DH90vPuNZY/r5fHa0UqwkNhQ8eFpoX9 Cvlp/NGx5SwonwKWhbJSPqoQm3SCqwAmCTkdd/eC/aOrnBPz/2aZpHk43iylwVLVE/O+ kpzFI9H0+bhB3wS09yfqt4qu74ziCBbgmT7mmeCj4uwkJrL+FIJGUvW2/mQe9CGj3b17 YCpw== 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=rEpHz2hoBrlsCJr//M0Nwj/LmRTZHO66rn0IFriPm9/v2GlJUK//RQ8EUJTVLrWEOe +3ZHJ/1R8WWrgllN0hRD5IjVLSuzR17jT2TgZ3JC5ojR458fROZYHRf3XeY4yvVkGR1x jUZRVab0iKiBcb4hkPIF1m4YvSb3ncxb6EsT/f5MiatQuIQPqbkJgStT+FbAdsoxHgEj g6wwJrplvUGLA/faOWo/2E2wK+vs3jSFRq7L+Z6yxxIFSY9534pkKyfXZvEir4Et4KTt Bzwb1qGvY+IE5DwgYODD5K0Z+S+MWoJUJH5vxxJEQB6lYZW8vs5lP7GIeYaftyxau7Qm dc4g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=g3DwqYtv; 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 z2-20020a05663822a200b004061e7b6ad3si1695866jas.121.2023.04.13.08.12.31; Thu, 13 Apr 2023 08:12:45 -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=g3DwqYtv; 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 S230057AbjDMPJd (ORCPT + 99 others); Thu, 13 Apr 2023 11:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbjDMPJJ (ORCPT ); Thu, 13 Apr 2023 11:09:09 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2034.outbound.protection.outlook.com [40.92.53.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CD993CA; Thu, 13 Apr 2023 08:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4aIH6V99QyeiZMEzNb88qf0ZaU2bhclT4rtiV+vaqQP112zPMkDlfb1tiy4Oqj5G6Nig1gQbnbgmkjhB752eDg0phXvAze3G9Jv4pvnsJKsUgECL9DarSAUzlBI3brlg0yO/a2SBwLxIk9WwIsJM7j+2BA4X3N3LqCmmdh0uvdXCGTzc7aWjq6vmpJeEHE+fYRnM3D+LqyWwZBv5xn8h7hHUh1tPmkLwUxsjq/CcmSVd2orXx3/hZv41GuqeMsDFUq6ru3dn93ZkV5cUvwmcDBAy9i0BauxL+pebENQoXo872Ax0o8sDaqRWe4oSgIoFu/NJoNtLpYWRSX1OORvug== 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=fWo5xYV3iNlwN3Ll6iWIMig1J8VSiC/ZE5bHdM8ZdUqvRCte7BcrWNr9xXZlgZKjSPzGyFrI5X6/Hhet7XRtyTzSMbLbZM/ByGN8/M7zaTfiXEH88k3ot2+6KkWS6CVbzqryryqDO4qo6bjcG/oBipETOrPMtYi/pB2iigAnWuW6Qml+wUEU0ds30q09lOV+6AEewHqNluTMb7bRQsM/56+hrBERyLafp3j6N6mGIEi3ffTQfrwGIffTGG4A6IJro5NLpz/V0usrsYXI0gsCgiiLqNDkm1gW+BZlfUpWvQliqjcKoAkFZUSopmHdMXMktVpva7b+k6hNFQMYX/Vo0w== 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=g3DwqYtvou3anKTin3Uoxk0wDXnMqCtiOO6Ajl33aCK+0e+5LdK9QaFNn3DCaKeYc9C19OmX7xSrtvYSJDhdgjlkbSbjrhv27lSRq3x/1l7n/GHOVOv13Os2oIxxH9pgzE10af99sUVI/glu6L5jBw9MdW0ZyUM9OebozUCqOBEY+BH+WL7SWqKRptZTJrt0tNrR52zAvz9xkeWSd03LO0AvTSEOIibuqcNWMIEQgjAtwvz4pWVOxS7Wj8znak0uzhlX0AFi7l7YI6VdiLmr5WqpWkYjnpJ9aGKoJNNpZQRCHoed7bsmP23LLqqxdoio9HEcdb7aYHOQqwrx5PhDkw== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by SEZPR01MB4087.apcprd01.prod.exchangelabs.com (2603:1096:101:4a::10) 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 15:09:02 +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 15:09:02 +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 v4] net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports Date: Thu, 13 Apr 2023 23:06:41 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [VHhC3a7aJWKoe03Q7vxcoqXXRSI+VjgI] X-ClientProxiedBy: SG2PR03CA0088.apcprd03.prod.outlook.com (2603:1096:4:7c::16) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230413150642.17871-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|SEZPR01MB4087:EE_ X-MS-Office365-Filtering-Correlation-Id: b7726d68-79cb-4179-fdc6-08db3c3103db X-MS-Exchange-SLBlob-MailProps: ScCmN3RHayHCvCmR7Mrip+46pMXVmOzprsLuyh2I67kMzgUfXKxcaDCRsLbQS6h+U+rj6I5q0jhTA4VD36DsI00bh6ZfcmAQefRX2a4WK8Y/dTfZmICND861kMNDrjmItKScFMh/LT7hfE3fYo5lbY8MkHDYZroZrDHsNIbyxRJlJXR1xOOkcpUcqi1Zre3amAJy83AMSybCyFCbzQkhh7AUEXGLhS+HunNRey0U0EiuZaRNBZSHfQlG1MOehMIkNSmuWiPwgX3KSfYuEMQxsZOa4SHFXO9szYYnmrCyECGT0tWlzk0jAK5Ch/Gr8IxUDfRaLxX3yntkogqNI/SFXSZCCbC8kIijyBT+vJy2ibtxDtc/eWn19g4luPsy6igsXUkqCZzg71dvXR6G4lbIW6cy5j8mxCNtJTwNA0A674/cXkshqtD7ldakh6gfamvpDfDBStkddExXSTUOka6+r8VB/6TqBRsp0qaPiERu8YWsY4t+GPp7hp2un7UYZPJZ4Nzgiv1Ponu0UXy+DakxRv+HuJZq+kUy37kJ9KDmuT0GDXnm54t8gfGr6zPsEyinoN3igKPP+V+/kR0cK04zuG4I7XZ5SbzqW9s/F1XLjqUSLldSuasvhrp1P15nEMpMkKDfxg6+zVXUjDTNNDd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MX4glw7CoT9CczkkxEDaQ?= =?us-ascii?Q?pBF7Tw/bbGm/x4KaM9TnVQMB3gVx+Ou4f3QnddCgN8OkkTpu+fLAeJP3uZAx?= =?us-ascii?Q?3IbElFUtzgVI9bjuyzi+AeU/X8boGsBwEBnEhi80K/HDsGcaQ+sUdag2sYe/?= =?us-ascii?Q?ZAQRtac6oXzIj+CzIZlmj6WxLzygkJx/xWSgOQ=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7726d68-79cb-4179-fdc6-08db3c3103db X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 15:09:02.0667 (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: SEZPR01MB4087 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. 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