From mboxrd@z Thu Jan 1 00:00:00 1970 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 ECF56C87FDA for ; Fri, 8 Aug 2025 23:42:03 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jqi5bdgNs2AX9eoY1oTYfwwxfE0BgwmbLz8d7dSIuLc=; b=ULAVv4Y4cOj71y +3d//SIfuKBxzZRo9UbvkADEdymVVH+EtIGFCVNWVA0S6sYHiFecBLcIs3uxjYUOqpxRz7M8TzJxj NSd2QbOIudeTgsjYBTPho8VajmJa3tARjtQAAAZRkILajhwpC8sppAd65ka61GShdSJoYc42vJlS/ Dn51pALt/Tgd+3v4QMldo5Ji8Y+GSwozeYlWjXU8iP+8Hx8t0kG3yr3UTfG22FkoB1+dHdMSBWwsp HVQjvIPlFuJWE/eDS83SygkiXwkRGai06fgSauyv3U9fnB4WLjiuyDaAOmifdmprOT10q5DOF8nMN iw312ClZN9iVCAVgiv9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1ukWie-00000003svn-0MOE; Fri, 08 Aug 2025 23:41:52 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1ukVn3-00000003nmC-1z4q for linux-riscv@lists.infradead.org; Fri, 08 Aug 2025 22:42:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 541D2A56AEE; Fri, 8 Aug 2025 22:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5B58C4CEF1; Fri, 8 Aug 2025 22:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754692940; bh=rLZBj+I02MJoP2e/2GvebvvCShxDWxP7isVZ958jGIQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=egzCnQltzQI4eH2ac1xfMp6bl4YDwg8TXYPhGh3XBShjOXHzkgVs04NeR+H+B4Yyy PWMyRAw2yEDAtUxSXyr22tWISRoJquWCQ3NhwdOsfsqR2KD5wbj5wdd44bvmbixNCc R3F7hu4zpJjEjb9swk1tbOH1jiu00afLtLVelssrkxLwlM7M5HY8nUD8qmc8ECbLKP lvi4Ml/nTabT/U934nBBPQtdeZ+C8HwOZhIHS3ofZYMPB+nCnolUXAAWa3g7jHdFIl 06DLY2RrMv+gsYiapzFkFfQac/FiqnlKoopi87aLq6TM8BkluxTsmeXdFrw6vdb8hJ KKuHLTsFYoWtg== Date: Fri, 8 Aug 2025 15:42:18 -0700 From: Drew Fustini To: Yao Zi Cc: Guo Ren , Fu Wei , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Emil Renner Berthing , Jisheng Zhang , linux-riscv@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net v3 2/3] net: stmmac: thead: Get and enable APB clock on initialization Message-ID: References: <20250808093655.48074-2-ziyao@disroot.org> <20250808093655.48074-4-ziyao@disroot.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250808093655.48074-4-ziyao@disroot.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250808_154221_636567_7FAD95E1 X-CRM114-Status: GOOD ( 24.23 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Aug 08, 2025 at 09:36:55AM +0000, Yao Zi wrote: > It's necessary to adjust the MAC TX clock when the linkspeed changes, > but it's noted such adjustment always fails on TH1520 SoC, and reading > back from APB glue registers that control clock generation results in > garbage, causing broken link. > > With some testing, it's found a clock must be ungated for access to APB > glue registers. Without any consumer, the clock is automatically > disabled during late kernel startup. Let's get and enable it if it's > described in devicetree. > > For backward compatibility with older devicetrees, probing won't fail if > the APB clock isn't found. In this case, we emit a warning since the > link will break if the speed changes. > > Fixes: 33a1a01e3afa ("net: stmmac: Add glue layer for T-HEAD TH1520 SoC") > Signed-off-by: Yao Zi > Tested-by: Drew Fustini > --- > drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c > index c72ee759aae5..f2946bea0bc2 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c > @@ -211,6 +211,7 @@ static int thead_dwmac_probe(struct platform_device *pdev) > struct stmmac_resources stmmac_res; > struct plat_stmmacenet_data *plat; > struct thead_dwmac *dwmac; > + struct clk *apb_clk; > void __iomem *apb; > int ret; > > @@ -224,6 +225,19 @@ static int thead_dwmac_probe(struct platform_device *pdev) > return dev_err_probe(&pdev->dev, PTR_ERR(plat), > "dt configuration failed\n"); > > + /* > + * The APB clock is essential for accessing glue registers. However, > + * old devicetrees don't describe it correctly. We continue to probe > + * and emit a warning if it isn't present. > + */ > + apb_clk = devm_clk_get_enabled(&pdev->dev, "apb"); > + if (PTR_ERR(apb_clk) == -ENOENT) > + dev_warn(&pdev->dev, > + "cannot get apb clock, link may break after speed changes\n"); > + else if (IS_ERR(apb_clk)) > + return dev_err_probe(&pdev->dev, PTR_ERR(apb_clk), > + "failed to get apb clock\n"); > + > dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); > if (!dwmac) > return -ENOMEM; > -- > 2.50.1 > Reviewed-by: Drew Fustini Thanks for improving the commit description and adding the warning. Drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv