[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <597f2189-b719-41cf-8d2f-eaf26c91622e@solid-run.com>
Date: Thu, 21 Mar 2024 15:54:59 +0000
From: Josua Mayer <josua@...id-run.com>
To: Andrew Lunn <andrew@...n.ch>
CC: Jiri Pirko <jiri@...nulli.us>, Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
Abeni <pabeni@...hat.com>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: dsa: mv88e6xxx: add warning for truncated mdio bus
id
Am 21.03.24 um 16:10 schrieb Andrew Lunn:
> On Thu, Mar 21, 2024 at 10:26:54AM +0000, Josua Mayer wrote:
>> Am 20.03.24 um 19:57 schrieb Andrew Lunn:
>>>> With separators ('!') we have:
>>>> cp0!config-space@...00000!mdio@...200!ethernet-switch@...dio
>>>> cp0!config-space@...00000!mdio@...200!ethernet-switch@...dio-external
>>>> Truncated to MII_BUS_ID_SIZE:
>>>> cp0!config-space@...00000!mdio@...200!ethernet-switch@...di
>>>> cp0!config-space@...00000!mdio@...200!ethernet-switch@...di
>>> This has been made worse by the DT maintainers wanting
>>> ethernet-switch@4, not switch@4. And i guess config-space was also
>>> something shorter in the past.
>>>
>>> I think your idea of cropping from the beginning, not the end, is in
>>> general a good solution. However, is there any danger of
>>>
>>> cp0!config-space@...00000!mdio@...200!ethernet-switch@...dio-external
>>>
>>> and
>>>
>>> cp1!config-space@...00000!mdio@...200!ethernet-switch@...dio-external
>> Since these will appear as links in /sys/bus/mdio_bus/devices,
>> this danger exists.
>> If the prefix is too similar, we can run into duplicates also when
>> cropping from the front.
>>
>> So we could crop at the front and reduce likelihood of this situation,
>> but (imo) should still print a warning since it is not working as intended.
> The problem with a warning is, what do you tell people who ask how to
> fix the warning? Hack your device tree to short the node names?
>
> A warning is best done when there is something which can be done to
> fix the problem. If it is not fixable, it is just noise.
Well, one option is making a future case for increasing MII_BUS_ID_SIZE.
>
>>> Another option would be if the name needs to be truncated, use the
>>> fallback as if there was no np:
>>>
>>> bus->name = "mv88e6xxx SMI";
>>> snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
>>>
>>> That at least gives you unique names.
>> This ensures a unique suffix within a branch of device-tree.
>> It could still collide with same structure on a cp1 or cp2.
> static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
> struct device_node *np,
> bool external)
> {
> static int index;
> struct mv88e6xxx_mdio_bus *mdio_bus;
> struct mii_bus *bus;
> int err;
>
> index is static,
Good point!
> so it is simply a counter. So you should get the
> names mv88e6xxx-0, mv88e6xxx-1, mv88e6xxx-2, mv88e6xxx-3...
This could work as a fall-back within mv88e6xxx driver.
Alternatively - how about having a generic helper somewhere (not sure where)
which can add a marker and use a global counter?
E.g. appending "!...-%d"
Across the tree I found 39 instances of
"snprintf(bus->id, "
Powered by blists - more mailing lists