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 E66ACC6379F for ; Fri, 17 Feb 2023 13:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbjBQN6m (ORCPT ); Fri, 17 Feb 2023 08:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbjBQN6f (ORCPT ); Fri, 17 Feb 2023 08:58:35 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0569367835 for ; Fri, 17 Feb 2023 05:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=2FV3q1oXqatB0Gs2fOcFn6Hx201yub5XR9SozRzOx4U=; b=hvlPin2fL5k6lxicBuWBOi5Gx+ Dz1V2lIVP+GZgS0T2fTzpYrcUXLmJmmALxB5/DY0sI6HpQOkDaWrEM44obOaRJ5yPEaYIZPgTrx4Z jOIsQ0VdCjhQ7JzBvJ8SHN7xnTp7lcWZOgV85HbxV2kF8619xZ791nifpH/nQHoUKCKg=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pT0tF-005HoG-Uw; Fri, 17 Feb 2023 14:35:05 +0100 Date: Fri, 17 Feb 2023 14:35:05 +0100 From: Andrew Lunn To: Oleksij Rempel 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 , Russell King , Woojung Huh , Oleksij Rempel Subject: Re: [PATCH RFC 01/18] net: phy: Add phydev->eee_active to simplify adjust link callbacks Message-ID: References: <20230217034230.1249661-1-andrew@lunn.ch> <20230217034230.1249661-2-andrew@lunn.ch> <20230217090919.GB9065@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230217090919.GB9065@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Feb 17, 2023 at 10:09:19AM +0100, Oleksij Rempel wrote: > On Fri, Feb 17, 2023 at 04:42:13AM +0100, Andrew Lunn wrote: > > MAC drivers which support EEE need to know the results of the EEE > > auto-neg in order to program the hardware to perform EEE or not. The > > oddly named phy_init_eee() can be used to determine this, it returns 0 > > if EEE should be used, or a negative error code, > > e.g. -EOPPROTONOTSUPPORT if the PHY does not support EEE or negotiate > > resulted in it not being used. > > > > However, many MAC drivers get this wrong. Add phydev->eee_active which > > indicates the result of the autoneg for EEE, including if EEE is > > administratively disabled with ethtool. The MAC driver can then access > > this in the same way as link speed and duplex in the adjust link > > callback. > > > > Signed-off-by: Andrew Lunn > > --- > > drivers/net/phy/phy.c | 3 +++ > > include/linux/phy.h | 2 ++ > > 2 files changed, 5 insertions(+) > > > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > > index b33e55a7364e..1e6df250d0d0 100644 > > --- a/drivers/net/phy/phy.c > > +++ b/drivers/net/phy/phy.c > > @@ -916,9 +916,12 @@ static int phy_check_link_status(struct phy_device *phydev) > > if (phydev->link && phydev->state != PHY_RUNNING) { > > phy_check_downshift(phydev); > > phydev->state = PHY_RUNNING; > > + phydev->eee_active = genphy_c45_eee_is_active(phydev, > > + NULL, NULL, NULL); > > genphy_c45_eee_is_active() may return an error. Yep. So we want eee_active false on error. Thanks Andrew