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 2B373C77B6C for ; Sat, 8 Apr 2023 16:00:24 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: 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: List-Owner; bh=TsSDQEC5dubCPwXXEe3SsolIan+EL1GWY4hT7G7/Xao=; b=awt2xP3Q7+kJ5k Hgfum/W09UTOUgIN53I9KUf14dwXAtQWxsZRdE5Rat9WdXH0WqfNfd8FZ/8nJ8mkOiR9CqHVXtfbU 5gD5RbQCxv3DsDNdEebjwuzj+jYVM3H1jsGpGvUxKJQwrRj5YokYcsfAB3oFyMA1AwwZzsBaSRoAp Lf6xD1C0y43LX1wAVrjPM7WjCKnjYxfKX2rRMJfycra94Jx0HR2palOxG6joPlJChuZYRfwVGLZRm ASqUFvORp3sMKq3tbIJubwdTLwNQt8AaAY+/XP9x0jpiT8MeyHfbefkcL/izp3IsNVXDALpYcWY1b JoYACzqzPM/KGheEJEXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1plAy7-00CX9F-0q; Sat, 08 Apr 2023 15:59:11 +0000 Received: from mail114-240.sinamail.sina.com.cn ([218.30.114.240]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1plAxz-00CX7j-1o for linux-arm-kernel@lists.infradead.org; Sat, 08 Apr 2023 15:59:08 +0000 X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([116.233.90.202]) by sina.com (172.16.235.24) with ESMTP id 64318F2E00006490; Sat, 8 Apr 2023 23:58:46 +0800 (CST) X-Sender: rocklouts@sina.com X-Auth-ID: rocklouts@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=rocklouts@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=rocklouts@sina.com X-SMAIL-MID: 14674445089172 From: Yan Wang To: kuba@kernel.org, davem@davemloft.net Cc: alexandre.torgue@foss.st.com, peppe.cavallaro@st.com, joabreu@synopsys.com, edumazet@google.com, pabeni@redhat.com, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yan Wang Subject: [PATCH] net: stmmac:fix system hang when setting up standalone tag_8021q VLAN for DSA ports Date: Sat, 8 Apr 2023 23:58:23 +0800 Message-Id: <20230408155823.12834-1-rocklouts@sina.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230407195730.298867dd@kernel.org> References: <20230407195730.298867dd@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230408_085903_785217_D7347A39 X-CRM114-Status: GOOD ( 10.74 ) 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The system hang because of dsa_tag_8021q_port_setup() callbcak stmmac_vlan_rx_add_vid().I found in stmmac_drv_probe() that cailing pm_runtime_put() disabled the clock when check the stmmac dirver. 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 d1a7cf4567bc..1bfbd05497b8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6191,6 +6191,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; @@ -6198,16 +6202,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel