lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 21 Dec 2023 21:34:52 +0300
From: Arınç ÜNAL <arinc.unal@...nc9.com>
To: Vladimir Oltean <olteanv@...il.com>,
 Luiz Angelo Daros de Luca <luizluca@...il.com>
Cc: linus.walleij@...aro.org, alsi@...g-olufsen.dk, andrew@...n.ch,
 f.fainelli@...il.com, davem@...emloft.net, edumazet@...gle.com,
 kuba@...nel.org, pabeni@...hat.com, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 5/7] net: dsa: realtek: Migrate user_mii_bus
 setup to realtek-dsa

On 21.12.2023 20:47, Vladimir Oltean wrote:
> On Wed, Dec 20, 2023 at 01:51:01AM -0300, Luiz Angelo Daros de Luca wrote:
>>> +       priv->user_mii_bus = devm_mdiobus_alloc(priv->dev);
>>> +       if (!priv->user_mii_bus) {
>>> +               ret = -ENOMEM;
>>> +               goto err_put_node;
>>> +       }
>>> +       priv->user_mii_bus->priv = priv;
>>> +       priv->user_mii_bus->name = "Realtek user MII";
>>> +       priv->user_mii_bus->read = realtek_common_user_mdio_read;
>>> +       priv->user_mii_bus->write = realtek_common_user_mdio_write;
>>> +       snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "Realtek-%d",
>>> +                ds->index);
>>> +       priv->user_mii_bus->parent = priv->dev;
>>> +
>>> +       /* When OF describes the MDIO, connecting ports with phy-handle,
>>> +        * ds->user_mii_bus should not be used *
>>> +        */
>>> +       dsa_switch_for_each_user_port(dp, ds) {
>>> +               phy_node = of_parse_phandle(dp->dn, "phy-handle", 0);
>>> +               of_node_put(phy_node);
>>> +               if (phy_node)
>>> +                       continue;
>>> +
>>> +               dev_warn(priv->dev,
>>> +                        "DS user_mii_bus in use as '%s' is missing phy-handle",
>>> +                        dp->name);
>>> +               ds->user_mii_bus = priv->user_mii_bus;
>>> +               break;
>>> +       }
>>
>> Does this check align with how should ds->user_mii_bus be used (in a
>> first step for phasing it out, at least for this driver)?
> 
> No. Thanks for asking.
> 
> What I would like to see is a commit which removes the line assigning
> ds->user_mii_bus completely, with the following justification:
> 
> ds->user_mii_bus helps when
> (1) the switch probes with platform_data (not on OF), or
> (2) the switch probes on OF but its MDIO bus is not described in OF
> 
> Case (1) is eliminated because this driver uses of_device_get_match_data()
> and fails to probe if that returns NULL (which it will, with platform_data).
> So this switch driver only probes on OF.
> 
> Case (2) is also eliminated because realtek_smi_setup_mdio() bails out
> if it cannot find the "mdio" node described in OF. So the ds->user_mii_bus
> assignment is only ever executed when the bus has an OF node, aka when
> it is not useful.
> 
> Having the MDIO bus described in OF, but no phy-handle to its children
> is a semantically broken device tree, we should make no effort whatsoever
> to support it.
> 
> Thus, because the dsa_user_phy_connect() behavior given by the DSA core
> through ds->user_mii_bus does not help in any valid circumstance, let's
> deactivate that possible code path and simplify the interaction between
> the driver and DSA.
> 
> And then go on with the driver cleanup as if ds->user_mii_bus didn't exist.
> 
> Makes sense? Parsing "phy-handle" is just absurdly complicated.

I don't like the fact that the driver bails out if it doesn't find the
"mdio" child node. This basically forces the hardware design to use the
MDIO bus of the switch. Hardware designs which don't use the MDIO bus of
the switch are perfectly valid.

It looks to me that, to make all types of hardware designs work, we must
not use ds->user_mii_bus for switch probes on OF. Case (2) is one of the
cases of the ethernet controller lacking link definitions in OF so we
should enforce link definitions on ethernet controllers. This way, we make
sure all types of hardware designs work and are described in OF properly.

Arınç

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ