Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp339713pxb; Thu, 31 Mar 2022 06:43:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiQlLeypjrpXJxcDrZMnvF/Lk9e8uMHjgUuf8m/g42kATDxTCqQvvPh4f5ZPM2nKqDQYx4 X-Received: by 2002:a05:6a00:1a0a:b0:4fc:d6c5:f3f1 with SMTP id g10-20020a056a001a0a00b004fcd6c5f3f1mr5561394pfv.45.1648734207978; Thu, 31 Mar 2022 06:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648734207; cv=none; d=google.com; s=arc-20160816; b=D7Hnpht7mELWfPefeMYb8ivrS21VXHZLqj21uamn9gJtnC/EOJSDokRFkbH/ZK1h8Q OapuljN7n/9f652c4X53AXnVMqIPAvtoJtWwCQTdhiXmcwa54Gg3VKT00gUcJdmK4ZXD jCtt9uMMUGdUK7epB4aP5TUoMclpoMBUMCSYs6ksv7Wyj9MRM246rFnalywj/NzrHRnO U7dZoKGWkk46ndac4JRVJR6Lpr8sFAteJMzg1KIk+nB5NgpaoxoVJqxV/0ZOS55AFbHh 57O6pieEoH2Ua76R9Wuvhg07qf57s8deSbz+aj6WHSb6KuhkrXLmXSbsTyQkb3Fllq3V TIBg== 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=is2hfnm658tQQV/yE96Ye3wvp2HVc9uQBLKKmPWpOMc=; b=zs2AR5y3oDgHGbnSIwVc/E9zaac/icp+tC+YIEDJd4irZgH2ij4b/+KzXaWnE/8Ux/ T87nGvVP2uZnJ6b8p75rTwc0v0aWWfIsGYuxrWkQYMTBrfk8yqNqNcjvAUeJjtuB0VIN ogAZy10KiDz9+ctO/cszqjuyPPXDNKTQCcH9bYuXYJoWH+iI9nqh+cE5YZ36tLtyuqn5 EptURWf2PhVngP3nocFWlM2kV1oJrp5/XomIqAkc7hzJH8eMYwfgW6DfwWs1XWjGGxvD LvnHrIfZzI8TMMiOaFxO4wfEjap4UdO5svNfGbuqIVXEqZIMwvomla8jy8DTZPBLCbD9 Dg4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="dpVa/bTW"; 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 q3-20020a17090311c300b00153b2d1659dsi26951307plh.421.2022.03.31.06.43.11; Thu, 31 Mar 2022 06:43:27 -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="dpVa/bTW"; 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 S235098AbiCaLdu (ORCPT + 99 others); Thu, 31 Mar 2022 07:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232647AbiCaLdt (ORCPT ); Thu, 31 Mar 2022 07:33:49 -0400 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 0D9AB16BCF6; Thu, 31 Mar 2022 04:32:02 -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=is2hfnm658tQQV/yE96Ye3wvp2HVc9uQBLKKmPWpOMc=; b=dpVa/bTWDFWOCs6jBoHfle55D+ KFgmOlVmklNh2Krrqrwi8hqvDEDithDC4lS2WeEOjbS8nTPidVm4/N3HHWt3tuRWSnUBsdwvRxnrt vD4zxHsyvsTPHLPrcIVyESd0xvDjncd2grKUTEtAqIzilhbPMaqbDcqELHWZY+cRhCOgYb08GXvVe kgJzPxauCblhGjHEzWfpH/pnMMUkLYpfxTx3oxr5j4r7WIgAKLECyMUbmeBgTuxKCyMafqJs/MCK4 8Uf1ZMukEph7Z0fmGFwps3MOP86NwMsukf7XnmAoTh2+HzOlbIzvGB88jcoMo+FENK9fj7SRxeuZ/ HkTjIXpQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:58048) 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 1nZt1s-0004iK-6d; Thu, 31 Mar 2022 12:31:51 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nZt1p-0007Zh-Hh; Thu, 31 Mar 2022 12:31:49 +0100 Date: Thu, 31 Mar 2022 12:31:49 +0100 From: "Russell King (Oracle)" To: Andrew Lunn Cc: Michael Walle , Heiner Kallweit , Jakub Kicinski , Paolo Abeni , "David S . Miller" , Xu Liang , Alexandre Belloni , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC net-next 4/5] net: phy: introduce is_c45_over_c22 flag Message-ID: References: <20220323183419.2278676-1-michael@walle.cc> <20220323183419.2278676-5-michael@walle.cc> <8304fb3578ee38525a158af768691e75@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Thu, Mar 24, 2022 at 01:41:44AM +0100, Andrew Lunn wrote: ydev->c45_over_c22 we are currently in a bad shape for. We cannot > reliably say the bus master supports C45. If the bus capabilities say > C22 only, we can set phydev->c45_over_c22. If the bus capabilities > list C45, we can set it false. But that only covers a few busses, most > don't have any capabilities set. We can try a C45 access and see if we > get an -EOPNOTSUPP, in which case we can set phydev->c45_over_c22. But > the bus driver could also do the wrong thing, issue a C22 transfer and > give us back rubbish. Unfortunately, trying a C45 access will be very hit and miss - we need to fix all the MDIO drivers before we do that to check the access type. Many don't, and worse, many assume a C22 formatted access request, and just try throwing the PHY address and register address into the register fields without any masking. The result is that a C45 access will set random bits in the register. For example: drivers/net/mdio/mdio-bcm-iproc.c (no bus capability): /* Prepare the read operation */ cmd = (MII_DATA_TA_VAL << MII_DATA_TA_SHIFT) | (reg << MII_DATA_RA_SHIFT) | (phy_id << MII_DATA_PA_SHIFT) | BIT(MII_DATA_SB_SHIFT) | (MII_DATA_OP_READ << MII_DATA_OP_SHIFT); writel(cmd, priv->base + MII_DATA_OFFSET); Similar is true for: drivers/net/mdio/mdio-bcm-unimac.c (no bus capability) drivers/net/mdio/mdio-hisi-femac.c (no bus capability) drivers/net/mdio/mdio-moxart.c (no bus capability) drivers/net/mdio/mdio-mscc-miim.c (no bus capability) drivers/net/mdio/mdio-mux-bcm6368.c (no bus capability) drivers/net/mdio/mdio-mux-bcm-iproc.c (no bus capability) drivers/net/mdio/mdio-sun4i.c (no bus capability) These truncate the fields, and fwics they don't set the bus type: drivers/net/mdio/mdio-xgene.c (for the "rgmii" only bus and no bus capability) So all of the above need at the very least code added to reject a C45 "dev" or "phy_id" address, or they need to set the bus capability correctly. My feeling is that the introduction of the bus capability hasn't done much to improve this situation; it was introduced to hint at whether a bus is safe for clause 45 accesses, but it hasn't actually solved this problem because we patently still have this same issue today. I think we just need to bite the bullet and audit all the MDIO drivers we currently have, checking what the results would be if they were passed a C45 access request, and make them reject such a request if the register address or phy address obviously overflows into different register fields and also mark them as C22-only. I can't see any other reasonable option. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!