Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp4009455rdb; Wed, 30 Aug 2023 12:30:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8pmX5CkIR/j3Qe/sIcFNnOSECC/hozvsLEhNveJeHQ7zsNt3enLA9zvypTstznrzKXSCD X-Received: by 2002:a17:90b:4c8c:b0:262:e6d2:2d6 with SMTP id my12-20020a17090b4c8c00b00262e6d202d6mr3074856pjb.47.1693423823598; Wed, 30 Aug 2023 12:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693423823; cv=none; d=google.com; s=arc-20160816; b=rSWpk4cZL6LrubpcRDgMHk9g2eYsX+mXp2+QhoLIH6WbbqftkFbibiRMlKJ353q7q2 4/8vdh/LxjMGfh0sXAClQhmGHfDWiX+5Pv+GChFXSwFRJQhZ9fnHtavLi4LSLgNeKtKr qrs0MddlFxTiQw+lK3s2aGNz5ADTWUHzup4uzoBXY0EtkHj0CPWOiJu1MI4LXWxnpHBs FcxXTi+cbu45GqKJEwEqyNqx8S1ChtlNGYRgocZzeskEHn7iD8HZSy9bg8I1eaRThEhY ocqOM8TsgU5pM5ALuAod8x9AKgO8YfNOZ6rQ+qRZjG7TXxLHvHXkMrCBzF1Kl1gIc8d8 f3uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=CYYHYLRbC9+AnCrIpCtM9OnKjd6pf5DpqMMCpc8VjTI=; fh=ZSF+dJomy5gdkStQYTUKUyPldFHD+XYmY5qwakySEVk=; b=dyGUyeR9QiZY9m1N+1V8zznJ16daRJMV6BRksIs/L5wxAOafAcuAmXX+L/hOM8i794 drQ1+m3E4iUhOfhLhL0FfFwNHmcTIhWn6+YdcsUsaYAsublqNyrQt2bdTG2xjH0aCRic gkceCE6Oqsznj8eA8M9n3zlw9J7tvW8cyEba2rKaO6ClVDzH3bbdFcX3/Vmh4E57AjP2 oi9jG88dTO2DQ548FQRgkL45vEJo3zobIfLEQ3kQd5IXoyke5vOnk6wk8/LF61NwYQCw GVLQxSKI2nGBhnqFiZ4CiT/yDAyB95A9urXdp+0PbUb3EmgT1xamTef/J5k5rdvEze2Y 9VXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce20-20020a17090aff1400b0025c238650d1si2356055pjb.174.2023.08.30.12.30.05; Wed, 30 Aug 2023 12:30:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242283AbjH3TYw (ORCPT + 99 others); Wed, 30 Aug 2023 15:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245098AbjH3O1X (ORCPT ); Wed, 30 Aug 2023 10:27:23 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9149D124 for ; Wed, 30 Aug 2023 07:27:19 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qbM9l-0005o1-43; Wed, 30 Aug 2023 16:26:53 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qbM9i-0006uX-Ue; Wed, 30 Aug 2023 16:26:50 +0200 Date: Wed, 30 Aug 2023 16:26:50 +0200 From: Oleksij Rempel To: "Russell King (Oracle)" Cc: Lukasz Majewski , Eric Dumazet , Andrew Lunn , davem@davemloft.net, Woojung Huh , Vladimir Oltean , Tristram.Ha@microchip.com, Florian Fainelli , Jakub Kicinski , Paolo Abeni , UNGLinuxDriver@microchip.com, Heiner Kallweit , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C) Message-ID: <20230830142650.GL31399@pengutronix.de> References: <20230830092119.458330-1-lukma@denx.de> <20230830092119.458330-2-lukma@denx.de> <20230830101813.GG31399@pengutronix.de> <20230830125224.1012459f@wsk> <20230830105941.GH31399@pengutronix.de> <20230830135151.683303db@wsk> <20230830121738.GJ31399@pengutronix.de> <20230830130649.GK31399@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Wed, Aug 30, 2023 at 02:30:55PM +0100, Russell King (Oracle) wrote: > On Wed, Aug 30, 2023 at 03:06:49PM +0200, Oleksij Rempel wrote: > > On Wed, Aug 30, 2023 at 01:35:18PM +0100, Russell King (Oracle) wrote: > > > On Wed, Aug 30, 2023 at 02:17:38PM +0200, Oleksij Rempel wrote: > > > > On Wed, Aug 30, 2023 at 01:51:51PM +0200, Lukasz Majewski wrote: > > > > > Hi Oleksij, > > > > > > > > > It looks like the most optimal solution would be the one proposed by > > > > > Tristam: > > > > > https://www.spinics.net/lists/netdev/msg932044.html > > > > > > > > In this case, please add the reason why it would work on this HW and > > > > will not break by any changes in PHYlib or micrel.c driver. > > > > > > > > If I remember it correctly, in KSZ9477 variants, if you write to EEE > > > > advertisement register, it will affect the state of a EEE capability > > > > register. Which break IEEE 802.3 specification and the reason why > > > > ksz9477_get_features() actually exist. But can be used as workaround if > > > > it is written early enough before PHYlib tried to read EEE capability > > > > register. > > > > > > > > Please confirm my assumption by applying your workaround and testing it > > > > with ethtool --show-eee lanX. > > > > > > > > It should be commented in the code with all kind of warnings: > > > > Don't move!!! We use one bug to workaround another bug!!! If PHYlib > > > > start scanning PHYs before this code is executed, then thing may break!! > > > > > > Why would phylib's scanning cause breakage? > > > > > > phylib's scanning for PHYs is about reading the ID registers etc. It > > > doesn't do anything until the PHY has been found, and then the first > > > thing that happens when the phy_device structure is created is an > > > appropriate driver is located, and the driver's ->probe function > > > is called. > > > > > > If that is successful, then the fewatures are read. If the PHY > > > driver's ->features member is set, then that initialises the > > > "supported" mask and we read the EEE abilities. > > > > > > If ->features is not set, then we look to see whether the driver > > > provides a ->get_features method, and call that. > > > > > > Otherwise we use the generic genphy_c45_pma_read_abilities() or > > > genphy_read_abilities() depending whether the PHY's is_c45 is set > > > or not. > > > > > > So, if you want to do something very early before features are read, > > > then either don't set .features, and do it early in .get_features > > > before calling anything else, or do it in the ->probe function. > > > > Let me summarize my view on the problem, so may be you can suggest a better > > way to solve it. > > - KSZ9477, KSZ8565, KSZ9893, KSZ9563, seems to have different quirks by > > the same PHYid. micrel.c driver do now know what exact HW is actually > > in use. > > - A set of PHY workarounds was moved from dsa/microchip/ksz9477.c to > > micrel.c, one of this workaround was clearing EEE advertisement > > register, which by accident was clearing EEE capability register. > > Since EEE cap was cleared by the dsa/microchip/ksz9477.c code before > > micrel.c was probed, PHYlib was assuming that his PHY do not supports > > EEE and dint tried to use it. > > After moving this code to micrel.c, it is now trying to change EEE > > advertisement state without letting PHYlib to know about it and PHYlib > > re enables it as actually excepted. > > - so far, only KSZ9477 seems to be broken beyond repair, so it is better > > to disable EEE without giving it as a choice for user configuration. > > We do have support in phylib for "broken EEE modes" which DT could set > for the broken PHYs, and as it is possible to describe the DSA PHYs in > DT. This sets phydev->eee_broken_modes. > > phydev->eee_broken_modes gets looked at when genphy_config_aneg() or > genphy_c45_an_config_aneg() gets called - which will happen when the > PHY is being "started". > > So, you could add the DT properties as appropriate to disable all the > EEE modes. > > Alternatively, in your .config_init function, you could detect your > flag and force eee_broken_modes to all-ones. @Lukasz, can you please try to set eee_broken_modes to all-ones. Somewhat like this: ksz9477_config_init() ... ...quirks... if (phydev->dev_flages & .. NO_EEE...) phydev->eee_broken_modes = -1; err = genphy_restart_aneg(phydev); ... @Russell, thx! Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |