Skip to contentSkip to conversation

ftgmac100: use bus name in mdio error messages

PATCH In review Zev Weiss 3 participants 6 messages May 17, 2022 Network drivers

lore
Share & tools
lore

Zev Weiss

author
#0 lore raw

PATCH 1/1 ftgmac100: use bus name in mdio error messages

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
---
 drivers/net/ftgmac100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ftgmac100.c +2 -2
index 999941de14ac..aa1d63880c8c 100644
@@ -117,7 +117,7 @@ static int ftgmac100_mdio_read(struct mii_dev *bus, int phy_addr, int dev_addr,
 				 FTGMAC100_MDIO_TIMEOUT_USEC);
 	if (ret) {
 		pr_err("%s: mdio read failed (phy:%d reg:%x)\n",
-		       priv->phydev->dev->name, phy_addr, reg_addr);
+		       bus->name, phy_addr, reg_addr);
 		return ret;
 	}
 
@@ -149,7 +149,7 @@ static int ftgmac100_mdio_write(struct mii_dev *bus, int phy_addr, int dev_addr,
 				 FTGMAC100_MDIO_TIMEOUT_USEC);
 	if (ret) {
 		pr_err("%s: mdio write failed (phy:%d reg:%x)\n",
-		       priv->phydev->dev->name, phy_addr, reg_addr);
+		       bus->name, phy_addr, reg_addr);
 	}
 
 	return ret;
Signature · 1 line
2.36.1
author
#1 lore raw
Quoted 7 lines · Zev Weiss

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Quoted 6 lines
Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
---
 drivers/net/ftgmac100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Sorry, forgot the subject-prefix tag on this one -- this is for u-boot v2019.04-aspeed-openbmc in case it wasn't clear.

Zev

#2 lore raw
Quoted 16 lines · Zev Weiss
Quoted 7 lines · Zev Weiss

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Quoted 6 lines
Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
---
 drivers/net/ftgmac100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 2 lines

Sorry, forgot the subject-prefix tag on this one -- this is for u-boot v2019.04-aspeed-openbmc in case it wasn't clear.

Thanks, I figured that out :)

How do you reproduce this one?

I didn't realise we had downstream changes for this driver, we should ask aspeed to submit their downstream changes to u-boot mainline.

author
#3 lore raw
Quoted 17 lines · Joel Stanley
Quoted 16 lines · Zev Weiss
Quoted 13 lines · Zev Weiss

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
---
 drivers/net/ftgmac100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 2 lines

Sorry, forgot the subject-prefix tag on this one -- this is for u-boot v2019.04-aspeed-openbmc in case it wasn't clear.

Thanks, I figured that out :)

How do you reproduce this one?

I'm in the process of trying to transition e3c246d4i off of the 2016 branch, and with the 2019 branch I'm finding u-boot spewing a bunch of output like

: mdio read failed (phy:0 reg:2)
: mdio read failed (phy:1 reg:2)
: mdio read failed (phy:2 reg:2)
...

(sometimes with some amount of garbage before the colon at the start of the line, and with "eth1" instead after this patch.)

I'm currently experimenting with various Kconfig settings and dts tweaks (on two different variants of the hardware) to try to narrow down the underlying cause and hopefully eliminate the error spew entirely, but in the meantime I figured we might as well get that error-reporting path smoothed out a bit.

Quoted 2 lines

I didn't realise we had downstream changes for this driver, we should ask aspeed to submit their downstream changes to u-boot mainline.

That sounds appropriate -- though as Cédric pointed out, since the relevant parts for this particular patch are already in mainline u-boot I should probably send this upstream as well.

#4 lore raw
Quoted 31 lines · Zev Weiss
Quoted 17 lines · Joel Stanley
Quoted 16 lines · Zev Weiss
Quoted 13 lines · Zev Weiss

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
---
 drivers/net/ftgmac100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 2 lines

Sorry, forgot the subject-prefix tag on this one -- this is for u-boot v2019.04-aspeed-openbmc in case it wasn't clear.

Thanks, I figured that out :)

How do you reproduce this one?

I'm in the process of trying to transition e3c246d4i off of the 2016 branch, and with the 2019 branch I'm finding u-boot spewing a bunch of output like

Quoted 7 lines

: mdio read failed (phy:0 reg:2)
: mdio read failed (phy:1 reg:2)
: mdio read failed (phy:2 reg:2)
...

(sometimes with some amount of garbage before the colon at the start of the line, and with "eth1" instead after this patch.)

Interesting. Are all of the clocks turned on in the same way as the old branch? Dumping the SCU registers might give you a clue.

Quoted 6 lines

I'm currently experimenting with various Kconfig settings and dts tweaks (on two different variants of the hardware) to try to narrow down the underlying cause and hopefully eliminate the error spew entirely, but in the meantime I figured we might as well get that error-reporting path smoothed out a bit.

Thanks for the explanation.

I'll apply it to our tree now, but also send it to mainline when you get a chance.

Quoted 7 lines
Quoted 3 lines

I didn't realise we had downstream changes for this driver, we should ask aspeed to submit their downstream changes to u-boot mainline.

That sounds appropriate -- though as Cédric pointed out, since the relevant parts for this particular patch are already in mainline u-boot I should probably send this upstream as well.

+1

#5 lore raw
In reply to Zev Weiss

Hello Zev,

Quoted 9 lines · Zev Weiss

Previously we'd been using a device name retrieved via ftgmac100_data->phydev, but the mdio read/write functions may be called before that member is initialized in ftgmac100_phy_init(), leading to a NULL pointer dereference while printing the error message issued if the mdio access fails. We can instead use bus->name, which is already available at that point.

Fixes 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")

You should send upstream.

Thanks,

C.

Quoted 26 lines
---
  drivers/net/ftgmac100.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ftgmac100.c +2 -2
index 999941de14ac..aa1d63880c8c 100644
@@ -117,7 +117,7 @@ static int ftgmac100_mdio_read(struct mii_dev *bus, int phy_addr, int dev_addr,
  				 FTGMAC100_MDIO_TIMEOUT_USEC);
  	if (ret) {
  		pr_err("%s: mdio read failed (phy:%d reg:%x)\n",
-		       priv->phydev->dev->name, phy_addr, reg_addr);
+		       bus->name, phy_addr, reg_addr);
  		return ret;
  	}
 
@@ -149,7 +149,7 @@ static int ftgmac100_mdio_write(struct mii_dev *bus, int phy_addr, int dev_addr,
  				 FTGMAC100_MDIO_TIMEOUT_USEC);
  	if (ret) {
  		pr_err("%s: mdio write failed (phy:%d reg:%x)\n",
-		       priv->phydev->dev->name, phy_addr, reg_addr);
+		       bus->name, phy_addr, reg_addr);
  	}
 
  	return ret;