Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3987821rdb; Wed, 30 Aug 2023 11:53:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwIkjUaziXxkYB6Wc7tiXRzkX/PEnTqCV6P51ptu3dnRRKzaTZ80G5qeLmpc4YmUdascHQ X-Received: by 2002:a05:6a20:7487:b0:13c:b1a7:7b1 with SMTP id p7-20020a056a20748700b0013cb1a707b1mr3375460pzd.25.1693421591857; Wed, 30 Aug 2023 11:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693421591; cv=none; d=google.com; s=arc-20160816; b=pKEZpjFJJJETltM7zwcwuA3A4zxfMPOwTX+W+V5UD2aRpv7c3gqSQv2KQJIzHA+ULA BV+oKghzc1V1woW/0tVBPtWsZ0J8nwT8nLWeo2XGKf8NX3OFmxE8rxv3RgDmXjLjJurJ J5L3Iys9MOh1h2Yhc80kdgWOr9O7d+d9Xy9bs1+8dYgf6yIoAJpAWyuePmHlHimOzudI oPPFjitxPX3lP4sDpXbnfMVDlkmiGsq4sznNS8LE8tBEPQ3AH4VFiKJe2fBWuQKRVC10 k/1fkk0WFpmIrYA36vHIu5BU86TgGew1Y4BW+GoNCgp0HIozJmfJq3+JaFqb2jEGa+Bj 96Sw== 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=AHHPMHQFrY/OUKsldHd4hhOJgIYuCCi8cba4nanVM7I=; fh=ZSF+dJomy5gdkStQYTUKUyPldFHD+XYmY5qwakySEVk=; b=w2ti5bZ3dDdeu7rzlAC/THLE6YVQUav9hBJmU1pwJKsZavQS1cR++J7OSQk5Qoml7S D4I9GBT7gSMZ7vAhnZrcWaQHAUkHUMzEof9YryZarGBmOBqmAPW1OmAYtiH+Y10waAsJ ae6hUWGwha/wp37yv1RUk7nYB+jtIfSf53KcbYuZaEHI6EnsyuJjigvEQqf4A9pDxJM0 Mj9QHlySyaKTUxNGdOv8VKFEUgvMng/HYOIeJmGzbDTyB+nkgCehbkJgOkifUxYQJjRL D8PS1UfPfudMGkEDQJ/6W3we+5+q0DXZOf5RchMr75Uip7nT7lLasV7+It8U3jsx5CXI 2MYA== 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 s2-20020a056a00178200b0068b4340868bsi13626930pfg.106.2023.08.30.11.52.27; Wed, 30 Aug 2023 11:53:11 -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 S240643AbjH3SoX (ORCPT + 99 others); Wed, 30 Aug 2023 14:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244383AbjH3NHK (ORCPT ); Wed, 30 Aug 2023 09:07:10 -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 81E5A193 for ; Wed, 30 Aug 2023 06:07:07 -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 1qbKuJ-0003ia-1k; Wed, 30 Aug 2023 15:06:51 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qbKuH-0003WT-3v; Wed, 30 Aug 2023 15:06:49 +0200 Date: Wed, 30 Aug 2023 15:06:49 +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: <20230830130649.GK31399@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> 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=unavailable 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 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. -- 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 |