Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Zhao Li
Fri, 20 Nov 2026 06:20
[PATCH net-next v2] net: phy: air_en8811h: check PBUS register read errors
Author: Zhao Li
Date: Fri, 20 Nov 2026 06:20
Date: Fri, 20 Nov 2026 06:20
124 lines
14830 bytes
14830 bytes
an8811hb_check_crc() ignores the return value of its PBUS reads. When
the status read fails, the loop tests a stale or uninitialized
pbus_value and can stop waiting before the check has finished. When the
result read fails, the PASS or FAIL message tests the status value.
en8811h_print_fw_version() also ignores a failed read, which leaves
priv->firmware_version at 0 on the first firmware load, or when the
bootloader's running firmware is kept. en8811h_read_status() then
handles it as firmware older than 24011202 and guesses the link
partner's 2.5GBASE-T ability from the link speed.
Return the error from each of these reads. A failed version read now
fails the firmware load or the probe, as the other PBUS errors there
do.
Found by an AI code review agent; not triggered. Compile-tested with W=1.
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
v2:
- retarget to net-next, drop the Fixes: and Cc: stable tags (Andrew Lunn)
- also check the version read in en8811h_use_running_fw(), added in
net-next by 89f0fb60afdb
v1: https://lore.kernel.org/netdev/20261118182436.32455-1-enderaoelyther@gmail.com/
No new W=1, sparse or smatch warnings.
drivers/net/phy/air_en8811h.c | 36 ++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/net/phy/air_en8811h.c b/drivers/net/phy/air_en8811h.c
index ef20b41ed5cb..c48ada43ab6b 100644
--- a/drivers/net/phy/air_en8811h.c
+++ b/drivers/net/phy/air_en8811h.c
@@ -378,18 +378,25 @@ static int an8811hb_check_crc(struct phy_device *phydev, u32 set1,
AN8811HB_CRC_RD_EN);
if (ret < 0)
return ret;
- air_phy_buckpbus_reg_read(phydev, set1, &pbus_value);
+ ret = air_phy_buckpbus_reg_read(phydev, set1, &pbus_value);
+ if (ret < 0)
+ return ret;
do {
msleep(300);
- air_phy_buckpbus_reg_read(phydev, mon2, &pbus_value);
+ ret = air_phy_buckpbus_reg_read(phydev, mon2, &pbus_value);
+ if (ret < 0)
+ return ret;
/* We do not know what errors this check is supposed
* catch or what to do about a failure. So print the
* result and continue like the vendor driver does.
*/
if (pbus_value & AN8811HB_CRC_ST) {
- air_phy_buckpbus_reg_read(phydev, mon3, &pbus_value);
+ ret = air_phy_buckpbus_reg_read(phydev, mon3,
+ &pbus_value);
+ if (ret < 0)
+ return ret;
phydev_dbg(phydev, "CRC Check %s!\n",
pbus_value & AN8811HB_CRC_CHECK_PASS ?
"PASS" : "FAIL");
@@ -403,14 +410,20 @@ static int an8811hb_check_crc(struct phy_device *phydev, u32 set1,
return -ENODEV;
}
-static void en8811h_print_fw_version(struct phy_device *phydev)
+static int en8811h_print_fw_version(struct phy_device *phydev)
{
struct en8811h_priv *priv = phydev->priv;
+ int ret;
+
+ ret = air_phy_buckpbus_reg_read(phydev, EN8811H_FW_VERSION,
+ &priv->firmware_version);
+ if (ret < 0)
+ return ret;
- air_phy_buckpbus_reg_read(phydev, EN8811H_FW_VERSION,
- &priv->firmware_version);
phydev_info(phydev, "MD32 firmware version: %08x\n",
priv->firmware_version);
+
+ return 0;
}
static int an8811hb_load_file(struct phy_device *phydev, const char *name,
@@ -527,7 +540,10 @@ static int en8811h_use_running_fw(struct phy_device *phydev, int err)
if (status != EN8811H_PHY_READY)
return err;
- en8811h_print_fw_version(phydev);
+ status = en8811h_print_fw_version(phydev);
+ if (status < 0)
+ return status;
+
return 1;
}
@@ -575,7 +591,7 @@ static int en8811h_load_firmware(struct phy_device *phydev)
if (ret < 0)
goto en8811h_load_firmware_out;
- en8811h_print_fw_version(phydev);
+ ret = en8811h_print_fw_version(phydev);
en8811h_load_firmware_out:
release_firmware(fw2);
@@ -1179,7 +1195,9 @@ static int an8811hb_probe(struct phy_device *phydev)
goto err_dev_create;
}
- en8811h_print_fw_version(phydev);
+ ret = en8811h_print_fw_version(phydev);
+ if (ret < 0)
+ goto err_dev_create;
/* mcu has just restarted after firmware load */
priv->mcu_needs_restart = false;
base-commit: 0742ef27cd72f155e6d355d13c49133116f19c89
--
2.56.1
Re: [PATCH net-next v2] net: phy: air_en8811h: check PBUS register read errors
Author: Andrew Lunn
Date: Fri, 20 Nov 2026 13:15
Date: Fri, 20 Nov 2026 13:15
16 lines
8881 bytes
8881 bytes
> /* We do not know what errors this check is supposed
> * catch or what to do about a failure. So print the
> * result and continue like the vendor driver does.
> */
> if (pbus_value & AN8811HB_CRC_ST) {
> - air_phy_buckpbus_reg_read(phydev, mon3, &pbus_value);
> + ret = air_phy_buckpbus_reg_read(phydev, mon3,
> + &pbus_value);
> + if (ret < 0)
> + return ret;
Please could you explain your understanding how this change and the
comment go together? You did read the comment didn't you?
Andrew
Re: [PATCH net-next v2] net: phy: air_en8811h: check PBUS register read errors
Author: Zhao Li
Date: Sat, 21 Nov 2026 12:27
Date: Sat, 21 Nov 2026 12:27
39 lines
12709 bytes
12709 bytes
On Fri, Nov 20, 2026 at 02:15:00PM +0100, Andrew Lunn wrote:
> > /* We do not know what errors this check is supposed
> > * catch or what to do about a failure. So print the
> > * result and continue like the vendor driver does.
> > */
> > if (pbus_value & AN8811HB_CRC_ST) {
> > - air_phy_buckpbus_reg_read(phydev, mon3, &pbus_value);
> > + ret = air_phy_buckpbus_reg_read(phydev, mon3,
> > + &pbus_value);
> > + if (ret < 0)
> > + return ret;
>
> Please could you explain your understanding how this change and the
> comment go together? You did read the comment didn't you?
Yes, I did.
The failure mentioned in the comment is a firmware CRC mismatch
(AN8811HB_CRC_CHECK_PASS clear in mon3 once AN8811HB_CRC_ST is set in
mon2). That behavior is unchanged: when reading mon3 succeeds, a CRC
FAIL is only logged via phydev_dbg(), AN8811HB_CRC_RD_EN is cleared,
and firmware loading continues.
The added check handles a PBUS/MDIO register read failure instead. If
air_phy_buckpbus_reg_read() returns an error, pbus_value is not updated
and still holds the mon2 status word, so phydev_dbg() would report PASS
or FAIL decoded from the wrong register.
an8811hb_check_crc() already propagates PBUS errors from the
air_phy_buckpbus_reg_modify() calls at the start and end of the check
(and returns -ENODEV on timeout), so propagating errors from the three
PBUS reads in between keeps bus-error handling consistent.
If the comment now looks misleading right above the mon3 read check, I
can move it down above phydev_dbg() in a v3.
Thanks,
Zhao
Re: [PATCH net-next v2] net: phy: air_en8811h: check PBUS register read errors
Author: Andrew Lunn
Date: Sat, 21 Nov 2026 17:08
Date: Sat, 21 Nov 2026 17:08
10 lines
8605 bytes
8605 bytes
> If the comment now looks misleading right above the mon3 read check, I
> can move it down above phydev_dbg() in a v3.
That would be good. Thanks
Andrew
---
pw-bot: cr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads