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 1612CC77B61 for ; Fri, 7 Apr 2023 16:36:43 +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: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:In-Reply-To:References: List-Owner; bh=AojZd4gKVhX+/Z7Wg6uz4iFh1bz/gCk181/GkhEhCU8=; b=n0MGTfkYH994sZ Ob1FtnrCrgltk70ZtA2gcTAEBZ/pU6UvJ1eIuNYzDjgRD5hJNNMODqUBdH72yC4U3TvfQ72yGt2I6 whTNo6mEOozzoa2X1Cqtz9qAc72EmljJxTn3U7JwidwwgaO8QWvYs7lnNZzzUGJL2ZEumSFY4kGNh x+MN5YVLQ47j5FfcCr1743WX1zAkpOrS0zCVnelUttGJtefROcfolNyEyLLu0QJUYaPcbcd1AdAEs KCCXEsM+xU0Fi4VynBOwz/1WufvBXrb6pPFT547qIhwArjwbfFAfOec4CardasTAt7GHhnQL7Tf6D 2j1Fn/s5USiHEtymTP5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pkp49-00AjqQ-0m; Fri, 07 Apr 2023 16:35:57 +0000 Received: from mail115-24.sinamail.sina.com.cn ([218.30.115.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkp43-00Ajmz-2z for linux-arm-kernel@lists.infradead.org; Fri, 07 Apr 2023 16:35:55 +0000 X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([180.168.184.106]) by sina.com (10.75.12.45) with ESMTP id 6430419E00004168; Fri, 8 Apr 2023 00:15:31 +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: 60537331457789 From: louts To: davem@davemloft.net Cc: alexandre.torgue@foss.st.com, peppe.cavallaro@st.com, joabreu@synopsys.com, edumazet@google.com, kuba@kernel.org, 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, louts Subject: [PATCH] net: stmmac: fix system hang when setting up standalone tag_8021q VLAN for DSA ports Date: Sat, 8 Apr 2023 00:15:12 +0800 Message-Id: <20230407161512.20109-1-rocklouts@sina.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230407_093552_148467_6ED17E81 X-CRM114-Status: GOOD ( 10.16 ) 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: louts --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++--- 1 file changed, 10 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..91d719ebdd97 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,19 @@ 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 update_vlan_error; } if (priv->hw->num_vlan) { ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); if (ret) - return ret; + goto add_vlan_error; } +update_vlan_error: +add_vlan_error: + 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