Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp4010931rdb; Wed, 30 Aug 2023 12:32:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGZUEJFpM9KnAle64cI2nqjMpaYiKVtdZD2pNJ0smr+Eq5ARppMXtxCm+MEf3kRtTtBk+Y X-Received: by 2002:a19:6504:0:b0:500:9a15:9054 with SMTP id z4-20020a196504000000b005009a159054mr879426lfb.20.1693423977198; Wed, 30 Aug 2023 12:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693423977; cv=none; d=google.com; s=arc-20160816; b=P4HGmq4ELVaE/kt38NSR6DrDodLfPDhEqOlqQPWU9maozFnM534rCDFwTtZ/kSdQwY Kfe308rTw93+kwRkq75fUyoIkvJ6m0g3AGf56ztY648SEzrDEOnzhFQmlndX7E8RyVdo XpaR3zhRvcdjuiRp/KgxFHglA8Ng3svGMXIno0LJCkTT3/+DZWZcVwEz6DD7ePvcfhkc dE23aHuHEML/KzSa9fIV0oiIrKLpcBfmJCSg+qJ/VMV1n6ev6qmKH/niItaMm+x3MFAQ rgXO4fq+KH1fjBnPGv+df2rPY9XManCjMhK8oytVjxm4B8xsXL94/SjPoqtM7ttptVqa MsUg== 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=qXDnTENf1cpDwSglV1bKnUnQe/xh9v6pAXIFuXIgylc=; fh=qvjTytidzSG8hLJF3dOXHgkpUlfrtbJfXqvm2mjKzfU=; b=UNLjRaAF5tY77qAekKbHTKV/geBkQKcbZfOV4lZeRE1plRotj5q1EEEqXGTfpXsmzP 4BBz0KX0qBcCa68S96wMPjNCSH/qUpTEAq/9NBCcxqfzJOIhlLha+zVnjpGR79/V32eX 4K5sqJGVRSVHAR4fs0M3CDikvRS1mNL06OXe+S8Gmlc5sH70Ia2NiPossLW9He6S5gL2 4vpnHNDr5RBkBEX+gVLtM9ALS2PEWBZMXf42jZBosAS+YdBMA586KIaWZork9qihO9uR c2Za1Rd/8yvOmFemHcEeI6yG4Sbpr81WlsftLWtya40snILQ2UaHrS9474Xr77OljieD U17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=OG050MqM; 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 k3-20020a1709063e0300b009a1b54e52d2si8135372eji.952.2023.08.30.12.32.22; Wed, 30 Aug 2023 12:32:57 -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=OG050MqM; 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 S1344115AbjH3T0a (ORCPT + 99 others); Wed, 30 Aug 2023 15:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244619AbjH3NbP (ORCPT ); Wed, 30 Aug 2023 09:31:15 -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 706A2198; Wed, 30 Aug 2023 06:31:10 -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=qXDnTENf1cpDwSglV1bKnUnQe/xh9v6pAXIFuXIgylc=; b=OG050MqMB1dVOtvFlGV2rC0qD4 mZmWrfGqn72HGqSt1lahm1QBPQXkMhwzi1s75kucl+kg5N4RcCfbW1WQfpGbDB3cOvdjKWGUvKPR6 jaaarw2cbWpS3ByStjNbdZ4aYR2oCUpNDTwB6PDfV+3JmcenFiuxwBH1AGSp3x9eI+31XqvXfwDWi 7iLvnFqrwVkmiNMgBakVdH4XS4wjQ16Xd99Z0z8AUodi5ej+HWHq2LsjkiVCArfYyhDTlDZ3vqsUf dAl7vAPKw4oXerqXOPi9WCscpSOL8BJLM3pCjUTohwsG7yOYxp68lSm8vsrIN9ljW7xS3U3Wr8jA5 bqPCzRIg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:57212) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qbLHb-0001f6-2h; Wed, 30 Aug 2023 14:30:57 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qbLHb-0005j4-IW; Wed, 30 Aug 2023 14:30:55 +0100 Date: Wed, 30 Aug 2023 14:30:55 +0100 From: "Russell King (Oracle)" To: Oleksij Rempel 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: 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=us-ascii Content-Disposition: inline In-Reply-To: <20230830130649.GK31399@pengutronix.de> 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 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 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. The problem with clearing ->supported_eee is that will stop genphy_c45_write_eee_adv() writing the advertisement register - which means if bits are set in the register, they won't be cleared because phylib thinks the registers aren't supported. So you won't actually be disabling anything by clearing ->supported_eee. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!