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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64087C636D4 for ; Fri, 17 Feb 2023 13:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbjBQNNV (ORCPT ); Fri, 17 Feb 2023 08:13:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjBQNNU (ORCPT ); Fri, 17 Feb 2023 08:13:20 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711792FCDD for ; Fri, 17 Feb 2023 05:13:18 -0800 (PST) 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=CzALCF+eGK1up4l2u58xXS8JzSTTDyQcSQ5QWvIqkMs=; b=P+7w7sCOi1lGEhKoZdstGoj3CP lA+CHEKKxL98zzIJn3JrRrZZOo49JLMZHuOwC9PZ8im5cLB1+9GwhhC5J05wEOczahJNrdNtCt/IG JvxBymqbPP0F+rA+Obf5NWunWMYgB/gE/tgz5AwLT7cteaEo36dM7XcoZVJjOeisPIu1vohvUXy/o 074you4rX2vJrCyH6fWLVlkOi0SaF8vdZ127tioBPq8XwVRAWCx1QdCNGFxsHBDIiHhe8i240jXJI wnhI/JLEUJZQ5/RfmCkgVJCmWo1GjPAxLgcaojLvAdFkxPwSC0Q/9vttb+un3qvggZNOUN4dEuebW 7rl/e1cg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:37684) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pT0Y2-0000ye-Bo; Fri, 17 Feb 2023 13:13:10 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pT0Xv-0006pk-IU; Fri, 17 Feb 2023 13:13:03 +0000 Date: Fri, 17 Feb 2023 13:13:03 +0000 From: "Russell King (Oracle)" To: Andrew Lunn Cc: netdev , Florian Fainelli , Vladimir Oltean , Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , AngeloGioacchino Del Regno , Doug Berger , Broadcom internal kernel review list , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Byungho An , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Woojung Huh , Oleksij Rempel Subject: Re: [PATCH RFC 03/18] net: marvell: mvneta: Simplify EEE configuration Message-ID: References: <20230217034230.1249661-1-andrew@lunn.ch> <20230217034230.1249661-4-andrew@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Feb 17, 2023 at 11:59:39AM +0000, Russell King (Oracle) wrote: > On Fri, Feb 17, 2023 at 04:42:15AM +0100, Andrew Lunn wrote: > > @@ -4221,10 +4218,8 @@ static void mvneta_mac_link_up(struct phylink_config *config, > > > > mvneta_port_up(pp); > > > > - if (phy && pp->eee_enabled) { > > - pp->eee_active = phy_init_eee(phy, false) >= 0; > > - mvneta_set_eee(pp, pp->eee_active && pp->tx_lpi_enabled); > > - } > > + if (phy) > > + mvneta_set_eee(pp, phy->eee_active && pp->tx_lpi_enabled); > > Thinking about this a bit more, I'm not convinced this is properly safe. > What protects phy->eee_active from changing here? The phydev mutex won't > be held at this point. > > As I mentioned in my reply to the cover letter about passing a flag to > mac_link_up() for EEE status, this would mean phylink could save the > EEE active status just like it does with the other phydev parameters > in phylink_phy_change() (which is called under the phydev mutex). I suppose another option would be to add a new method to phylink_mac_ops: int (*mac_set_eee)(struct phylink_config *config, bool eee, u32 tx_lpi_timer); and phylink calls this just before mac_link_up() or after phylink_ethtool_set_eee(). The eee flag would be the effective result of phydev->eee_active && tx_lpi_enabled, possibly also && tx_lpi_timer != 0, since a zero tx_lpi_timer is rather meaningless, unless we explicitly have phylink_ethtool_set_eee() reject it is invalid. All that mac_set_eee() implementations should then need to do is to program the LPI timer in the MAC hardware, and enable or disable it according to the "eee" flag. The down-side to another mac_ops method is having to add a wrapper in net/dsa/port.c for it. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!