Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1263574rdg; Fri, 11 Aug 2023 15:52:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmxoEqD7azljpqx0soUIkmfAppR/n0yKwv53m0ypkSeLpX5P6D+Bimw9M2hQCwXCZXtXnm X-Received: by 2002:a17:906:5594:b0:992:7295:61c9 with SMTP id y20-20020a170906559400b00992729561c9mr2951756ejp.69.1691794352741; Fri, 11 Aug 2023 15:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691794352; cv=none; d=google.com; s=arc-20160816; b=I0fsoyy9kS7c4ADSkXR6VUYmDZ4nqMd4aP+J8CGpaisOZsaeYjIyHaehSJL6OPhODO rD0YIuq9rTEt1Jg2aYeYiXHGPUb0ycjeOFVHRdExmmLPc+Gjx7VZ3TJGxzlAIy3VTOO4 IU7cDUQaPYBbFcdJKl7pBnI+nHmlPdOEAFGY6d3b0dfHhp+2oL26cgNI9S1x51rAEkUZ rAaIO7joxHnLHOm0czzLdzpL69LPFOqXDtle0NopKkPNZrhfHxxLbIWBbEL47WRfOUlP qF7EhXIo0uNvA/Xi8/+rZeSdsNZtwH9MoehO78n1wijY0rhmkYSlwhM34EB7aGMhVDbJ YLug== 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=bPZ6eb6D+5nlXp0LzoMf2AoIFF7EdtsEvpEfZCHzjiI=; fh=R+lcFH2DoWsh9gznpP12fybDUUNmDt8ibuSNTQ2XLQU=; b=xSGpF0OrAOnn90qF7CGCgkPIAsn/LpCJJkFhNdecqAk5c2TgCL5qbXF5Hz5a1gSQ9n XWQliW9Ku3d9pvHVlhwu2mUlYM30qOVep1tPMVHD9xSiNfJuKwX6m4gsaOkjaDVKyBLD 0WVGf96D6wMqfviJfPc+nVNbVGWmzlD0jlYRMbGF8SK7xihYC3WfTTv+jQL7ZHrV/slX R0601XL2q0Qw59hJ0zjd1Cpt2iRlLHIpSoiR/m5pb3FQPdiwdqEw+5Sywr64akmzQrx+ v90pLu6RzAVEUCbPB28WQz2KD2UVY3JAqQPbO2EROTMlKcYl59FDMulObwTee9D1BWAf M3vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=xfHVd0qa; 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 h4-20020a170906828400b00977e0bdac8asi4209640ejx.583.2023.08.11.15.52.07; Fri, 11 Aug 2023 15:52:32 -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=xfHVd0qa; 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 S233751AbjHKWXO (ORCPT + 99 others); Fri, 11 Aug 2023 18:23:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233713AbjHKWXI (ORCPT ); Fri, 11 Aug 2023 18:23:08 -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 6B6B81703; Fri, 11 Aug 2023 15:22:46 -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=bPZ6eb6D+5nlXp0LzoMf2AoIFF7EdtsEvpEfZCHzjiI=; b=xfHVd0qaUbmZh3B9YRJYOI4nvw IJv4wL6ukw1CyguOkaUYiWVxDWYSQC/CgG1oRhMWnVwlc7gyFC87Z6KYYMDMTHhZpO20hyBUm7L19 zcmmEADFGqXGGUlZIjDbkcNFNQCeBLho7ClZc6pndLDYJevyi1Q+qtk1HKvvMfNpRTKM2mXQHU2xI Br5nZkc0X8l4kKm5Se1QF3fMUDjBOlt/Y47Jxar86NhBIA1aO5/zShjC/mHTCAOxpYbI6td43ZUgj nPQgHP5yDWUcgu1H1oUNhAT+OkXH8aNUfUt9QFYa3Pos3N6WxqvlAt5MgNyx+IjKnA+jq7jrfFXXT 51WU8/Pg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:50692) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qUaWi-00063h-04; Fri, 11 Aug 2023 23:22:36 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qUaWg-0003El-8N; Fri, 11 Aug 2023 23:22:34 +0100 Date: Fri, 11 Aug 2023 23:22:34 +0100 From: "Russell King (Oracle)" To: Giulio Benetti Cc: Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Reinhart , James Autry , Matthew Maron Subject: Re: [PATCH] net: phy: broadcom: add support for BCM5221 phy Message-ID: References: <20230811215322.8679-1-giulio.benetti@benettiengineering.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230811215322.8679-1-giulio.benetti@benettiengineering.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,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 Fri, Aug 11, 2023 at 11:53:22PM +0200, Giulio Benetti wrote: > + reg = phy_read(phydev, MII_BRCM_FET_INTREG); > + if (reg < 0) > + return reg; > + > + /* Unmask events we are interested in and mask interrupts globally. */ > + reg = MII_BRCM_FET_IR_ENABLE | > + MII_BRCM_FET_IR_MASK; > + > + err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); > + if (err < 0) > + return err; Please explain why you read MII_BRCM_FET_INTREG, then discard its value and write a replacement value. > + > + /* Enable auto MDIX */ > + err = phy_clear_bits(phydev, BCM5221_AEGSR, BCM5221_AEGSR_MDIX_DIS); > + if (err < 0) > + return err; > + > + /* Enable shadow register access */ > + brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); > + if (brcmtest < 0) > + return brcmtest; > + > + reg = brcmtest | MII_BRCM_FET_BT_SRE; > + > + err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); > + if (err < 0) > + return err; I think you should consider locking the MDIO bus while the device is switched to the shadow register set, so that other accesses don't happen that may interfere with this. > +static int bcm5221_suspend(struct phy_device *phydev) > +{ > + int reg, err, err2, brcmtest; > + > + /* Enable shadow register access */ > + brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); > + if (brcmtest < 0) > + return brcmtest; > + > + reg = brcmtest | MII_BRCM_FET_BT_SRE; > + > + err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); > + if (err < 0) > + return err; > + > + /* Force Low Power Mode with clock enabled */ > + err = phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXMODE4, > + BCM5221_SHDW_AM4_EN_CLK_LPM | > + BCM5221_SHDW_AM4_FORCE_LPM); > + > + /* Disable shadow register access */ > + err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); > + if (!err) > + err = err2; Same here. > + > + return err; > +} > + > +static int bcm5221_resume(struct phy_device *phydev) > +{ > + int reg, err, err2, brcmtest; > + > + /* Enable shadow register access */ > + brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); > + if (brcmtest < 0) > + return brcmtest; > + > + reg = brcmtest | MII_BRCM_FET_BT_SRE; > + > + err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); > + if (err < 0) > + return err; > + > + /* Exit Low Power Mode with clock enabled */ > + err = phy_clear_bits(phydev, MII_BRCM_FET_SHDW_AUXMODE4, > + BCM5221_SHDW_AM4_FORCE_LPM); > + > + /* Disable shadow register access */ > + err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); > + if (!err) > + err = err2; And, of course, same here. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!