Allocation of MDIO bus numbers when fixed MDIO bus is enabled?
Subsystems (2)
Hello Andy,
An user of the r6040 driver has enabled support for the Fixed MDIO bus, so when the r6040 registers with its first instance, it will also try to register a MDIO bus with id 0, and this fails.
What's the proper solution to fixing this kind of issue? The same user proposed to use the pci slot and function as an id for registering the MDIO bus, which will work for PCI devices, but not for platform_devices for instance.
Thanks.
--
Florian
Hello,
Quoted 8 lines · Florian Fainelli
An user of the r6040 driver has enabled support for the Fixed MDIO bus, so when the r6040 registers with its first instance, it will also try to register a MDIO bus with id 0, and this fails.
What's the proper solution to fixing this kind of issue? The same user proposed to use the pci slot and function as an id for registering the MDIO bus, which will work for PCI devices, but not for
platform_devicesfor instance.
AFAIR, MDIO bus id doesn't have to be numeric, so you can change it to parent's dev_name(). I.e. something like
snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "%s-mdio", dev_name(dev));
So, the resulting PHYs would have IDs something like "dev-mdio:1".
Thanks,
Signature · 2 lines
Anton Vorontsov Email: [email protected]
Quoted 12 lines · Anton Vorontsov
Hello,
Quoted 8 lines · Florian Fainelli
An user of the r6040 driver has enabled support for the Fixed MDIO bus, so when the r6040 registers with its first instance, it will also try to register a MDIO bus with id 0, and this fails.
What's the proper solution to fixing this kind of issue? The same user proposed to use the pci slot and function as an id for registering the MDIO bus, which will work for PCI devices, but not for
platform_devicesfor instance.
Quoted 6 lines
AFAIR, MDIO bus id doesn't have to be numeric, so you can change it to parent's
dev_name(). I.e. something like
snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "%s-mdio", dev_name(dev));So, the resulting PHYs would have IDs something like "dev-mdio:1".
Yeah, there's a long-standing issue from when the "fixed" bus was created. I wasn't really involved in the architecture, and the arbitrary "0" bus stuck around. I think renaming it is not as trivial as it sounds, in that the bus id is hard-coded in a number of places. However, I would eagerly endorse any solution that was less hard-coded. You would have to change all of the fixed-phy clients. At the very least, it should be called "fixed-0", or something.
However, the issue is that the r6040's bus registration is being just as bad a citizen as the fixed bus registration. Please change it to have a sensible bus name. You can craft whatever name you like. Make it something that follows a convention that shouldn't ever conflict with anything else, while also being trivially deducible from available information (so the ethernet driver can find the right bus for the right instance). The names are global for the whole system.
Andy