drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
From: Quentin Schulz <quentin.schulz@cherry.de>
bus_id is currently derived from the ethernetX alias. If one is missing
for the device, 0 is used. If ethernet0 points to another stmmac device
or if there are 2+ stmmac devices without an ethernet alias, then bus_id
will be 0 for all of those.
This is an issue because the bus_id is used to generate the mdio bus id
(new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
stmmac_mdio_register) and this needs to be unique.
This allows to avoid needing to define ethernet aliases for devices with
multiple stmmac controllers (such as the Rockchip RK3588) for multiple
stmmac devices to probe properly.
Obviously, the bus_id isn't guaranteed to be stable across reboots if no
alias is set for the device but that is easily fixed by simply adding an
alias if this is desired.
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
Unsure if I should cc stable since people who encountered that issue for
sure had to add an ethernet alias to make things work with their DT so
shouldn't be too much of an actual issue?
---
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index c73eff6a56b87a3783c91b2ffbf5807a27df303f..15205a47cafc276442c3759a36d115d8da1fe51d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -430,6 +430,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat;
struct stmmac_dma_cfg *dma_cfg;
+ static int bus_id = -ENODEV;
int phy_mode;
void *ret;
int rc;
@@ -465,8 +466,14 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
of_property_read_u32(np, "max-speed", &plat->max_speed);
plat->bus_id = of_alias_get_id(np, "ethernet");
- if (plat->bus_id < 0)
- plat->bus_id = 0;
+ if (plat->bus_id < 0) {
+ if (bus_id < 0)
+ bus_id = of_alias_get_highest_id("ethernet");
+ /* No ethernet alias found, init at -1 so first bus_id is 0 */
+ if (bus_id < 0)
+ bus_id = -1;
+ plat->bus_id = ++bus_id;
+ }
/* Default to phy auto-detection */
plat->phy_addr = -1;
---
base-commit: 4a95bc121ccdaee04c4d72f84dbfa6b880a514b6
change-id: 20250521-stmmac-mdio-bus_id-313b74c77933
Best regards,
--
Quentin Schulz <quentin.schulz@cherry.de>
On 5/21/25 5:21 PM, Quentin Schulz wrote: > From: Quentin Schulz <quentin.schulz@cherry.de> > > bus_id is currently derived from the ethernetX alias. If one is missing > for the device, 0 is used. If ethernet0 points to another stmmac device > or if there are 2+ stmmac devices without an ethernet alias, then bus_id > will be 0 for all of those. > > This is an issue because the bus_id is used to generate the mdio bus id > (new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > stmmac_mdio_register) and this needs to be unique. > > This allows to avoid needing to define ethernet aliases for devices with > multiple stmmac controllers (such as the Rockchip RK3588) for multiple > stmmac devices to probe properly. > > Obviously, the bus_id isn't guaranteed to be stable across reboots if no > alias is set for the device but that is easily fixed by simply adding an > alias if this is desired. > > Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> I think no need to CC stable here, but you need to provide a suitable fixes tag, thanks! Paolo
On 5/26/2025 1:26 PM, Paolo Abeni wrote: > On 5/21/25 5:21 PM, Quentin Schulz wrote: >> From: Quentin Schulz <quentin.schulz@cherry.de> >> >> bus_id is currently derived from the ethernetX alias. If one is missing >> for the device, 0 is used. If ethernet0 points to another stmmac device >> or if there are 2+ stmmac devices without an ethernet alias, then bus_id >> will be 0 for all of those. >> >> This is an issue because the bus_id is used to generate the mdio bus id >> (new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c >> stmmac_mdio_register) and this needs to be unique. >> >> This allows to avoid needing to define ethernet aliases for devices with >> multiple stmmac controllers (such as the Rockchip RK3588) for multiple >> stmmac devices to probe properly. >> >> Obviously, the bus_id isn't guaranteed to be stable across reboots if no >> alias is set for the device but that is easily fixed by simply adding an >> alias if this is desired. >> >> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> > > I think no need to CC stable here, but you need to provide a suitable > fixes tag, thanks! > Quentin to make your life easy. It fixes this patch https://lore.kernel.org/lkml/1372930541-19409-1-git-send-email-srinivas.kandagatla@st.com/ dt:net:stmmac: Add support to dwmac version 3.610 and 3.710 It goes back in time to 2013 when this bus_id was introduced through dts > Paolo > >
Hi Abhishek, On 5/30/25 12:16 AM, Abhishek Chauhan (ABC) wrote: > [Some people who received this message don't often get email from quic_abchauha@quicinc.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > On 5/26/2025 1:26 PM, Paolo Abeni wrote: >> On 5/21/25 5:21 PM, Quentin Schulz wrote: >>> From: Quentin Schulz <quentin.schulz@cherry.de> >>> >>> bus_id is currently derived from the ethernetX alias. If one is missing >>> for the device, 0 is used. If ethernet0 points to another stmmac device >>> or if there are 2+ stmmac devices without an ethernet alias, then bus_id >>> will be 0 for all of those. >>> >>> This is an issue because the bus_id is used to generate the mdio bus id >>> (new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c >>> stmmac_mdio_register) and this needs to be unique. >>> >>> This allows to avoid needing to define ethernet aliases for devices with >>> multiple stmmac controllers (such as the Rockchip RK3588) for multiple >>> stmmac devices to probe properly. >>> >>> Obviously, the bus_id isn't guaranteed to be stable across reboots if no >>> alias is set for the device but that is easily fixed by simply adding an >>> alias if this is desired. >>> >>> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> >> >> I think no need to CC stable here, but you need to provide a suitable >> fixes tag, thanks! >> > Quentin to make your life easy. > It fixes this patch > https://lore.kernel.org/lkml/1372930541-19409-1-git-send-email-srinivas.kandagatla@st.com/ > dt:net:stmmac: Add support to dwmac version 3.610 and 3.710 > It goes back in time to 2013 when this bus_id was introduced through dts > Fortunately, we ended up finding the same "culprit" (see v2 of my patch that got merged[1] :) ) [1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=eb7fd7aa35bfcc1e1fda4ecc42ccfcb526cdc780 Thanks! Quentin
On 6/2/2025 2:38 AM, Quentin Schulz wrote: > Hi Abhishek, > > On 5/30/25 12:16 AM, Abhishek Chauhan (ABC) wrote: >> [Some people who received this message don't often get email from quic_abchauha@quicinc.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] >> >> On 5/26/2025 1:26 PM, Paolo Abeni wrote: >>> On 5/21/25 5:21 PM, Quentin Schulz wrote: >>>> From: Quentin Schulz <quentin.schulz@cherry.de> >>>> >>>> bus_id is currently derived from the ethernetX alias. If one is missing >>>> for the device, 0 is used. If ethernet0 points to another stmmac device >>>> or if there are 2+ stmmac devices without an ethernet alias, then bus_id >>>> will be 0 for all of those. >>>> >>>> This is an issue because the bus_id is used to generate the mdio bus id >>>> (new_bus->id in drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c >>>> stmmac_mdio_register) and this needs to be unique. >>>> >>>> This allows to avoid needing to define ethernet aliases for devices with >>>> multiple stmmac controllers (such as the Rockchip RK3588) for multiple >>>> stmmac devices to probe properly. >>>> >>>> Obviously, the bus_id isn't guaranteed to be stable across reboots if no >>>> alias is set for the device but that is easily fixed by simply adding an >>>> alias if this is desired. >>>> >>>> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> >>> >>> I think no need to CC stable here, but you need to provide a suitable >>> fixes tag, thanks! >>> >> Quentin to make your life easy. >> It fixes this patch >> https://lore.kernel.org/lkml/1372930541-19409-1-git-send-email-srinivas.kandagatla@st.com/ >> dt:net:stmmac: Add support to dwmac version 3.610 and 3.710 >> It goes back in time to 2013 when this bus_id was introduced through dts >> > > Fortunately, we ended up finding the same "culprit" (see v2 of my patch that got merged[1] :) ) > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=eb7fd7aa35bfcc1e1fda4ecc42ccfcb526cdc780 > Nice!. Anyway i really like this fix because mdio creates a directory and if there are 2+ macs the directory creation will fail because two emac will have the same mdio directory names provided if someone forgets to mention alias in the dtsi. > Thanks! > Quentin
© 2016 - 2025 Red Hat, Inc.