Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1398935rwb; Fri, 28 Jul 2023 08:53:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlF39+TZXmUhasi44qkBIHkVuQZPS1eUXDIn/M+fohr+7yclPz+VEckN8ANWnYClM02kjjjZ X-Received: by 2002:a17:902:b945:b0:1bb:8a8f:53cb with SMTP id h5-20020a170902b94500b001bb8a8f53cbmr1823789pls.35.1690559619904; Fri, 28 Jul 2023 08:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690559619; cv=none; d=google.com; s=arc-20160816; b=0uIiavWVKrQzUbVoRShbb0I1Twwt4DKjEW67FDKFkDHszbduujALz+Elv4VK6fCWmz 6y95wSjv4ylDB16SXR1nAGKkZXdlSmGOHX5yw461FHVuVG22QsKO2DGRQhI6/ZkTpr+G WE5jc6O8H//qZ0KBYtwiWR7/FlXbjix6BRyGahQMQDitQQkR5nGdVHbuWO55wARqLqDz 8nT4Q4kvu5pG7ByIlvTa4QsnOumSADUyFFKwGSBtpDRyM52cQdtXSbLO/fPr/7YkGxhw FUdpTqpW59D4HqYucWDMxrO2RSQz3nJqCAW0sWSj2L6fFUiY/RzXv5YbJf3ps7l5C1ZI 51dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zFaTvjva0ryo1dGvlmwD9YwRXLb5KCK4M2vuVLGCmtY=; fh=kdg64DkJB5gKPvLZJdGcR9HILboYMZvZc8WpmzXDt4c=; b=sCGunrBfSw9tVInKClSE1LLMu0oGTNXXT5jMxZNqq+jJTHSfQ8LyO+918QsKS3Vh5j l8D56vrz+/BW4/5Fgsm91lH/PQJl0nuamOoNQxyCpiWWCttGsQRNNLm1pobagt7sKhn9 QPdNRR55S38n0Dd6tMZGkOg1OvCxychQ0T5sj2Y3qOa11cF0L6ACD7DtoS4xCS5i+Uly AzPK3RAuTTlrhIKYc2k5AXOc45nRp+MKh1cNrPy/e0rvfHn4hOmz4Y8l1IIySG9cqAxB iuoeCRwjvFQgjpWHiMXMmLNcGCzIdgr8rUl4v8Q2UuxpBCWLdXEr0kaGmcr7ss6S/ek8 1LoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=R648ApYv; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a170902c7cb00b001bb9e2c38ecsi3063165pla.264.2023.07.28.08.53.26; Fri, 28 Jul 2023 08:53:39 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=R648ApYv; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237330AbjG1PXL (ORCPT + 99 others); Fri, 28 Jul 2023 11:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236522AbjG1PXK (ORCPT ); Fri, 28 Jul 2023 11:23:10 -0400 Received: from pandora.armlinux.org.uk (unknown [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B58F35B0; Fri, 28 Jul 2023 08:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zFaTvjva0ryo1dGvlmwD9YwRXLb5KCK4M2vuVLGCmtY=; b=R648ApYvuLp9TRmpig3RK00k45 iwo/6SoqI2MGew0WOsD/C0Pmrd8pPKAp71PCdAHyf3DtaYQsTPecUkOn3Ka5apKAjNYX6GLNVerk9 FFE1jTiLl2rSU5G3jkLo1oh6P7XcoETkQj9jfhD9f6wgdOzCB8UBP3/wJV0846kRjE/XAE2JhyHZH 17FIB6eRR571XIYccm02B92tb7uFK5y7rI/XX8k2I4Kqoh8AAR60xEZyV2pvw8TPmoHWD372yIBE8 vccayBxsZXU4StXzIKMWl3/WmbHP3Z2Iz5Jy/oCU3DexPI5jEKpOQOtuhgX3I+d6ZmBAypVpilYa/ +TG9D+Kw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:34660) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qPPIQ-0007Qe-2c; Fri, 28 Jul 2023 16:22:26 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qPPIJ-00051L-6E; Fri, 28 Jul 2023 16:22:19 +0100 Date: Fri, 28 Jul 2023 16:22:19 +0100 From: "Russell King (Oracle)" To: Andrew Halaney , Will Deacon Cc: Shenwei Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Shawn Guo , Sascha Hauer , Neil Armstrong , Kevin Hilman , Vinod Koul , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Jerome Brunet , Martin Blumenstingl , Bhupesh Sharma , Nobuhiro Iwamatsu , Simon Horman , Bartosz Golaszewski , Wong Vee Khee , Revanth Kumar Uppala , Jochen Henneberg , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, imx@lists.linux.dev, Frank Li Subject: Re: [PATCH v2 net 2/2] net: stmmac: dwmac-imx: pause the TXC clock in fixed-link Message-ID: References: <20230727152503.2199550-1-shenwei.wang@nxp.com> <20230727152503.2199550-3-shenwei.wang@nxp.com> <4govb566nypifbtqp5lcbsjhvoyble5luww3onaa2liinboguf@4kgihys6vhrg> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4govb566nypifbtqp5lcbsjhvoyble5luww3onaa2liinboguf@4kgihys6vhrg> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 On Thu, Jul 27, 2023 at 01:36:45PM -0500, Andrew Halaney wrote: > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > > index 53ee5a42c071..e7819960128e 100644 > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > > @@ -40,6 +40,9 @@ > > #define DMA_BUS_MODE 0x00001000 > > #define DMA_BUS_MODE_SFT_RESET (0x1 << 0) > > #define RMII_RESET_SPEED (0x3 << 14) > > +#define MII_RESET_SPEED (0x2 << 14) > > +#define RGMII_RESET_SPEED (0x0 << 14) > > +#define CTRL_SPEED_MASK (0x3 << 14) > > GENMASK() would be cleaner, as well as BIT() usage, but I do see > the driver currently does shifts.. so /me shrugs BIT() is only useful for single-bit items, not for use with bitfields, and their use with bitfields just makes the whole thing perverse. #define CTRL_SPEED_MASK GENMASK(15, 14) #define CTRL_SPEED_RGMII_RESET 0 #define CTRL_SPEED_MII_RESET 2 #define CTRL_SPEED_RMII_RESET 3 and then its use: FIELD_PREP(CTRL_SPEED_MASK, CTRL_SPEED_RGMII_RESET) or FIELD_PREP(CTRL_SPEED_MASK, CTRL_SPEED_MII_RESET) or FIELD_PREP(CTRL_SPEED_MASK, CTRL_SPEED_RMII_RESET) alternatively: if (iface == MX93_GPR_ENET_QOS_INTF_SEL_RMII) speed = CTRL_SPEED_RMII_RESET; else (iface == MX93_GPR_ENET_QOS_INTF_SEL_MII) speed = CTRL_SPEED_MII_RESET; else speed = CTRL_SPEED_RGMII_RESET; old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG); ctrl = old_ctrl & ~CTRL_SPEED_MASK; ctrl |= FIELD_PREP(CTRL_SPEED_MASK, speed); writel(ctrl, dwmac->base_addr + MAC_CTRL_REG); > I don't have any documentation for the registers here, and as you can > see I'm an amateur with respect to memory ordering based on my prior > comment. > > But you: > > 1. Read intf_reg_off into variable iface > 2. Write the RESET_SPEED for the appropriate mode to MAC_CTRL_REG > 3. wmb() to ensure that write goes through I wonder about whether that wmb() is required. If the mapping is device-like rather than memory-like, the write should be committed before the read that regmap_update_bits() does according to the ARM memory model. Maybe a bit of information about where this barrier has come from would be good, and maybe getting it reviewed by the arm64 barrier specialist, Will Deacon. :) wmb() is normally required to be paired with a rmb(), but we're not talking about system memory here, so I also wonder whether wmb() is the correct barrier to use. Adding Will. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!