Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4116623ybl; Mon, 3 Feb 2020 12:56:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwgID4D5aympHJxAVsmS7ogu1gUlhXaMZ9taEDkZplKTuqguwayn+JWzhR8Xb0A5LpjPa1p X-Received: by 2002:aca:db56:: with SMTP id s83mr656111oig.171.1580763375647; Mon, 03 Feb 2020 12:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580763375; cv=none; d=google.com; s=arc-20160816; b=xfBMFKRnpdX4lS++TVUiEcKf/cNOvpatfisg8BaZaY+xeghhSoJtUfQnDiaHG223nl 2YUHSHTvJnomvhCFrJnroXLwPLR73TbL9TnQkDDmXoe2Q2qBimzTDmy+fMEeR1apnq4P qjOinc5aBU8DE2a0NmEFAH3oGiv4CLUp5bB1LIQL+pYzPXbwWOYt/2sfPHDvyGd0NuC/ n0UDwPPRf28nSy9bpABhf/YxZAEXk5R9LYXFVtxsD6uLJX4We69bYD8Ih8Qpym+RwJFI XYW22EWgToviCePc5DgbfzwnwapWJvuY7g+7egCjzw0hwS0GieOHptsBlg1KjMSfkxWe mrag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=4PvKV2c7fablf5zGnZXIOwVJkpsf6Vl3plbqg7cF5bE=; b=jJlwm0wQCz0ZluyjsLFDU68H04s8TSrVaGqXx5GvD+08OIyFzUsWPb6C1Qr7XuVv8H 49+lquAv8xjWz8uII00vVJNOlkV+KOqIe79o9eBBXbIX0rKOChAc+YNhCQDheA3j438m hgilaS46eiuCnpjFACoqg4LcMdCSaC1dbDzUT/QFFKjdp1nX65YngxZAPkITtT1K8i70 t/bGc/M4SOFSsvZuMO2lA471z7UELZ0wn/IB7Ht2nOBW1anzSHHpMYg+uR77QVkTtjhy 30QhxAmt6ccj4TakJSFoSQOuU3PwO/JSpfvnvtNaOk+mcF73n/i+bGaiNncXTf7/B5Bv tjSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PxLMg1t7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si11113915otg.66.2020.02.03.12.56.03; Mon, 03 Feb 2020 12:56:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PxLMg1t7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727105AbgBCUzH (ORCPT + 99 others); Mon, 3 Feb 2020 15:55:07 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:34969 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbgBCUzG (ORCPT ); Mon, 3 Feb 2020 15:55:06 -0500 Received: by mail-pj1-f65.google.com with SMTP id q39so298311pjc.0; Mon, 03 Feb 2020 12:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4PvKV2c7fablf5zGnZXIOwVJkpsf6Vl3plbqg7cF5bE=; b=PxLMg1t72Gtqwy+YXBBPokAcQB9gkEBde90LY1JZzrtuv7iZGmhBlF6FICvPtWGVgO jpAnI+Lon4V/BWjiSeTs6tgb8ke5sEhkjRTL5H43lyNWDyNFrULWTFcm3623Cniwpbsx Zzm0ZIcf2W5E+NAtLb1AHLAiKNGiAT73mQ+k27iw9+5Lk7cL+x5Nls0ljp7P2onmpOdR i9HxOJ7t8GoTEVtbJxhwrzm1N16trAP5lUApPNwKmnQ/22AMK9Bj6i0JN4mKfaE+Xe4z MW0E4mcDekSWTYNV9dChLM7LiwgEt//V9azt1txLuAmWWbcotpnfxNOJLWU+Vt4OD2eI GZww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=4PvKV2c7fablf5zGnZXIOwVJkpsf6Vl3plbqg7cF5bE=; b=LGOGwrpKvArp+3tBjPVSN/NgjigsYeKzNpd88M9EQ6o3nllVnzEbHeKb1Hd0rcCXgU 5HwxdXqdYBIVPNdnOsr76Y+Aob8pnqR1qA2A7j+LUdFLuq3v4M2AQeE0X6eydTrVsNpv F3IHtCdT9nbSwtec2vaGSVkAUe9zoqGdZfFihDAONux9dxlyhdw4WPE55bQBID6YJMX+ v4dIxebzwUJ5W7aqOHeH7/Nw3jK+J8IE15OKRINmzBaXPhNok7ET28ioLiIxyI+skbMV s0l+9URsWaJjtioF3RSUF89d4mWisnq5m6hrz+U2MItAHOBqvE5cTAOOUJeiQZVOgWBF vT0g== X-Gm-Message-State: APjAAAVLjOx5uSHRkh+ZEEufqxYhFgQgVr1buA0cyeaMCbO7gZv+nLVM 9sz85uO2PxVo5sH1iKqVgL4= X-Received: by 2002:a17:902:8341:: with SMTP id z1mr24660047pln.178.1580763305427; Mon, 03 Feb 2020 12:55:05 -0800 (PST) Received: from [10.67.50.115] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id i3sm21394759pfg.94.2020.02.03.12.55.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Feb 2020 12:55:04 -0800 (PST) Subject: Re: [PATCH 3/6] net: bcmgenet: enable automatic phy discovery To: Jeremy Linton , Andrew Lunn Cc: netdev@vger.kernel.org, opendmb@gmail.com, davem@davemloft.net, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, wahrenst@gmx.net, hkallweit1@gmail.com References: <20200201074625.8698-1-jeremy.linton@arm.com> <20200201074625.8698-4-jeremy.linton@arm.com> <20200201152518.GI9639@lunn.ch> <608e7fab-69a3-700d-bfcf-88e5711ce58f@arm.com> From: Florian Fainelli Autocrypt: addr=f.fainelli@gmail.com; prefer-encrypt=mutual; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz80nRmxvcmlhbiBG YWluZWxsaSA8Zi5mYWluZWxsaUBnbWFpbC5jb20+wmYEExECACYCGyMGCwkIBwMCBBU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ent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <608e7fab-69a3-700d-bfcf-88e5711ce58f@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/1/20 11:07 AM, Jeremy Linton wrote: > Hi, > > First thanks for looking at this! > > On 2/1/20 9:25 AM, Andrew Lunn wrote: >> On Sat, Feb 01, 2020 at 01:46:22AM -0600, Jeremy Linton wrote: >>> The unimac mdio driver falls back to scanning the >>> entire bus if its given an appropriate mask. In ACPI >>> mode we expect that the system is well behaved and >>> conforms to recent versions of the specification. >>> >>> We then utilize phy_find_first(), and >>> phy_connect_direct() to find and attach to the >>> discovered phy during net_device open. >>> >>> Signed-off-by: Jeremy Linton >>> --- >>>   drivers/net/ethernet/broadcom/genet/bcmmii.c | 40 +++++++++++++++++--- >>>   1 file changed, 34 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c >>> b/drivers/net/ethernet/broadcom/genet/bcmmii.c >>> index 2049f8218589..f3271975b375 100644 >>> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c >>> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c >>> @@ -5,7 +5,7 @@ >>>    * Copyright (c) 2014-2017 Broadcom >>>    */ >>>   - >>> +#include >>>   #include >>>   #include >>>   #include >>> @@ -311,7 +311,9 @@ int bcmgenet_mii_config(struct net_device *dev, >>> bool init) >>>   int bcmgenet_mii_probe(struct net_device *dev) >>>   { >>>       struct bcmgenet_priv *priv = netdev_priv(dev); >>> -    struct device_node *dn = priv->pdev->dev.of_node; >>> +    struct device *kdev = &priv->pdev->dev; >>> +    struct device_node *dn = kdev->of_node; >>> + >>>       struct phy_device *phydev; >>>       u32 phy_flags = 0; >>>       int ret; >>> @@ -334,7 +336,27 @@ int bcmgenet_mii_probe(struct net_device *dev) >>>               return -ENODEV; >>>           } >>>       } else { >>> -        phydev = dev->phydev; >>> +        if (has_acpi_companion(kdev)) { >>> +            char mdio_bus_id[MII_BUS_ID_SIZE]; >>> +            struct mii_bus *unimacbus; >>> + >>> +            snprintf(mdio_bus_id, MII_BUS_ID_SIZE, "%s-%d", >>> +                 UNIMAC_MDIO_DRV_NAME, priv->pdev->id); >>> + >>> +            unimacbus = mdio_find_bus(mdio_bus_id); >>> +            if (!unimacbus) { >>> +                pr_err("Unable to find mii\n"); >>> +                return -ENODEV; >>> +            } >>> +            phydev = phy_find_first(unimacbus); >>> +            put_device(&unimacbus->dev); >>> +            if (!phydev) { >>> +                pr_err("Unable to find PHY\n"); >>> +                return -ENODEV; >> >> Hi Jeremy >> >> phy_find_first() is not recommended. Only use it if you have no other >> option. If the hardware is more complex, two PHYs on one bus, you are >> going to have a problem. So i suggest this is used only for PCI cards >> where the hardware is very fixed, and there is only ever one MAC and >> PHY on the PCI card. When you do have this split between MAC and MDIO >> bus, each being independent devices, it is more likely that you do >> have multiple PHYs on one shared MDIO bus. > > Understood. > >> >> In the DT world, you use a phy-handle to point to the PHY node in the >> device tree. Does ACPI have the same concept, a pointer to some other >> device in ACPI? > > There aren't a lot of good options here. ACPI is mostly a power mgmt > abstraction and is directly silent on this topic. So while it can be > quite descriptive like DT, frequently choosing to use a bunch of DT > properties in ACPI _DSD methods is a mistake. Both for cross OS booting > as well as long term support. Similar silence from SBSA, which attempts > to setup some guide rails for situations like this. I think that is > because there aren't any non-obsolete industry standards for NICs. I suppose you have two options from here: - try to set a good example and provide a representation of the devices that is as comprehensive as possible and paves the way for others to draw as a good (or not bad at least) example - continue to do an ad-hoc solution since there is little to no interest in any standardization (more likely, no need). > > So, in an attempt to fall back on the idea that the hardware should be > self describing, and it shouldn't be involving the system firmware in > basic device specific introspection I've been trying to avoid the use of > any DSD properties. In the majority of cases (including DT) these > properties aren't being auto-detected by the firmware either, they are > just being hard-coded into DT or DSDT tables. > > Part of the arm standardization effort has been to clamp down on all the > creative ways that these machines can be built. It seems a guide rail > that says for this adapter it must have a MDIO bus per MAC for ACPI > support as though it were on PCI isn't unreasonable. Another easily > understood one, might be to assign the PHY's the the same order as the > MAC's UIDs if there were a shared bus (less ideal without example > hardware). > > I'm not really sure what the right answer here is, but I like to avoid > hardcoding DT properties in DSD unless there simply isn't an alternative. I do not think we are asking to get properties hard coded, we are asking to get a proper representation of these MDIO devices, including their supserset that PHY devices are into ACPI, in a way that is usable by the core MDIO layer without drivers cutting corners. -- Florian