Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp539281pxf; Wed, 31 Mar 2021 09:31:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWaqXLtyXojppny+WvQb+J9v14M7elvVso7KKJZlDh/2JQ3r42ULlQfDPbz9M8Htu89AJk X-Received: by 2002:aa7:c5d0:: with SMTP id h16mr4795117eds.380.1617208310839; Wed, 31 Mar 2021 09:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617208310; cv=none; d=google.com; s=arc-20160816; b=CJOhh0QH99gZA+zjtCKmKPQvHVyZYysHRueVx8V9yCzf8mmCntTNSA8FN5hapUWL0v WSefADCj+C8JlrFHFnYEBvt7K9IrSPrQkYYhsgqmsYcbrs1pj8i4Eaojyl25FYs1Xzpj kAdfCHWPkUy00+fSscG0L+zedXOaz/8I6YT47CbcqaIj+qcDbygWufBBRUxhnHjRw8AX Hc0y/n/KAjvteCTlsOUyI+Yw6dfngn43q3J3fzqOp9kOdFJXeNw7Nu1Fbv3uYQTCLvRO B4R42m+RuxpuGuvxyaJfKNNCjyMSfZ77ldiaK10Y2pM6dRCill4nuQ8oRfX23LFJRlpf F1ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=+Jm2xpL1bT21fmpaCKc4IEOJlp5/eUlsUKWVf9Vsuf0=; b=n/5pAvRhOdW8NnuzPKGST0JHFJNpEeOho5xkB0EUz82XrfC32WzD5LS/N9CEQbisan 2ZqfwPcyMQh/sMgF/FI5Dgg5DeausWyBhIvcSy7X2sLdyGpoDr283XYL+B2xiEQFLQC1 ykjrH4W2NN/FrbMOqFqt7LR1SEuZswahodRj5LRR95kJsSwNBdmUtKR6442AuD+Tv313 IQjl4qNjpNjzfBDZ1B8yP4G89D8wVj6J0AFibqd0J4J+DNmuobl56cHX0Y0HYCgWFzzu Psrl3HG0eX2F5vBQVFfODTxS4T8NJ/CN5MOkMuZPc3vAn/mbHvPo5jOpKETVDNKWe8nt pXGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si1954880ejf.359.2021.03.31.09.31.24; Wed, 31 Mar 2021 09:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233891AbhCaQ2D (ORCPT + 99 others); Wed, 31 Mar 2021 12:28:03 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:56500 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232319AbhCaQ1t (ORCPT ); Wed, 31 Mar 2021 12:27:49 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lRdgv-00ECMX-OU; Wed, 31 Mar 2021 18:27:37 +0200 Date: Wed, 31 Mar 2021 18:27:37 +0200 From: Andrew Lunn To: Danilo Krummrich Cc: linux@armlinux.org.uk, davem@davemloft.net, hkallweit1@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com Subject: Re: [PATCH 2/2] net: mdio: support c45 peripherals on c22 busses Message-ID: References: <20210331141755.126178-1-danilokrummrich@dk-develop.de> <20210331141755.126178-3-danilokrummrich@dk-develop.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331141755.126178-3-danilokrummrich@dk-develop.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -670,19 +670,21 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) > struct phy_device *phydev = ERR_PTR(-ENODEV); > int err; > > + /* In case of NO_CAP and C22 only, we still can try to scan for C45 > + * devices, since indirect access will be used for busses that are not > + * capable of C45 frame format. > + */ > switch (bus->capabilities) { > case MDIOBUS_NO_CAP: > case MDIOBUS_C22: > - phydev = get_phy_device(bus, addr, false); > - break; > - case MDIOBUS_C45: > - phydev = get_phy_device(bus, addr, true); > - break; > case MDIOBUS_C22_C45: > phydev = get_phy_device(bus, addr, false); > if (IS_ERR(phydev)) > phydev = get_phy_device(bus, addr, true); > break; > + case MDIOBUS_C45: > + phydev = get_phy_device(bus, addr, true); > + break; > } I think this is going to cause problems. commit 0231b1a074c672f8c00da00a57144072890d816b Author: Kevin Hao Date: Tue Mar 20 09:44:53 2018 +0800 net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b The Ethernet on mpc8315erdb is broken since commit b6b5e8a69118 ("gianfar: Disable EEE autoneg by default"). The reason is that even though the rtl8211b doesn't support the MMD extended registers access, it does return some random values if we trying to access the MMD register via indirect method. This makes it seem that the EEE is supported by this phy device. And the subsequent writing to the MMD registers does cause the phy malfunction. So use the dummy stubs for the MMD register access to fix this issue. Indirect access to C45 via C22 is not a guaranteed part of C22. So there are C22 only PHYs which return random junk when you try to use this access method. I'm also a bit confused why this is actually needed. PHY drivers which make use of C45 use the functions phy_read_mmd(), phy_write_mmd(). int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) { int val; if (regnum > (u16)~0 || devad > 32) return -EINVAL; if (phydev->drv && phydev->drv->read_mmd) { val = phydev->drv->read_mmd(phydev, devad, regnum); } else if (phydev->is_c45) { val = __mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr, devad, regnum); } else { struct mii_bus *bus = phydev->mdio.bus; int phy_addr = phydev->mdio.addr; mmd_phy_indirect(bus, phy_addr, devad, regnum); /* Read the content of the MMD's selected register */ val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA); } return val; } So if the device is a c45 device, C45 transfers are used, otherwise it falls back to mmd_phy_indirect(), which is C45 over C22. Why does this not work for you? Andrew