Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The commit message promises something the code does not deliver:
"The PHY is reset when the driver is unbound, so it reports the…
- [Low] as21xxx_get_features() falls back to the C45-derived modes when
either register lacks the relevant bits: `!(adv & ADVERTISE_ALL) ||…
--
net: phy: as21xxx: Read 10/100/1000 link modes from C22 advertisement
This adds an as21xxx_get_features() callback. It reads the 2.5G, 5G and
10G abilities from the Clause 45 registers, then takes the 10/100/1000
link modes from the C22 ADVERTISE and CTRL1000 registers mapped in the AN
MMD. If those registers do not have the expected bits set, the Clause 45
derived modes are kept.
> diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
> index 1c4a808bf01e9..3423448a0cb1c 100644
> --- a/drivers/net/phy/as21xxx.c
> +++ b/drivers/net/phy/as21xxx.c
> @@ -644,6 +644,61 @@ static int as21xxx_probe(struct phy_device *phydev)
> return aeon_dpc_ra_enable(phydev);
> }
>
> +static int as21xxx_get_features(struct phy_device *phydev)
> +{
> + int ret, adv, ctrl1000;
> +
[ ... ]
> + adv = phy_read_mmd(phydev, MDIO_MMD_AN,
> + AS21XXX_MDIO_AN_C22 + MII_ADVERTISE);
> + if (adv < 0)
> + return adv;
> +
> + ctrl1000 = phy_read_mmd(phydev, MDIO_MMD_AN,
> + AS21XXX_MDIO_AN_C22 + MII_CTRL1000);
> + if (ctrl1000 < 0)
> + return ctrl1000;
[Severity: High]
Does this always sample the firmware defaults? The commit message says:
The PHY is reset when the driver is unbound, so it reports the generic
pre-firmware ID again and the firmware is reloaded from
.match_phy_device() before the next probe.
Hence .get_features() always samples the firmware defaults.
as21xxx has no .remove or .soft_reset callback. The only reset on unbind
is the one in phy_remove():
drivers/net/phy/phy_device.c:phy_remove() {
...
/* Assert the reset signal */
phy_device_reset(phydev, 1);
...
}
That call ends in mdio_device_reset(), which returns immediately when the
board describes no reset line:
drivers/net/phy/mdio_device.c:mdio_device_reset() {
...
if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl)
return;
...
}
On those boards the firmware keeps running across a sysfs unbind/bind or
a module reload. On rebind, as21xxx_match_phy_device() reads the
post-firmware ID and returns early without reloading the firmware:
if (phy_id != PHY_ID_AS21XXX)
return phy_id == phydrv->phy_id;
as21xxx_get_features() then reads ADVERTISE and CTRL1000 in whatever
state the previous session left them. The commit message itself says
these registers mirror the current advertisement.
The later patch in this series, "net: phy: as21xxx: Configure autoneg
advertisement via IPC", changes that advertisement through
aeon_set_top_speed(). Suppose the previous session limited it to 100M,
for example with "ethtool -s ethX advertise 100baseT/Full", which selects
IPC_CU_AN_TOP_SPD_100. CTRL1000 then reads back with no 1000 bits and the
fallback below is taken. That leaves 10baseT/Half and 100baseT/Half set
in phydev->supported again.
Doesn't that bring back the problem this patch is meant to fix? In the
final series, as21xxx_resolve_duplex() uses those Half bits to report
DUPLEX_HALF on parallel detection.
The same thing can happen if a bootloader loaded the firmware and changed
the advertisement before Linux probes.
Boards with a reset line have a separate problem at this commit: match
runs while the PHY is still held in reset, because phy_probe() deasserts
reset only after the bus match. The last patch in the series, "net: phy:
as21xxx: Release reset before reading ID in match", fixes that case. Its
own commit message says the deassert "does nothing when the PHY has no
reset described", though, so the case without a reset line is still open
at the end of the series.
Could the default top speed be restored before these registers are read?
Alternatively, the firmware could be reset or reloaded on unbind, or the
modes could come from a fixed capability source. Either way, the commit
message would need to be corrected.
> +
> + /* If the firmware defaults are not available, keep the C45-derived
> + * modes rather than dropping all 10/100/1000 link modes.
> + */
> + if (!(adv & ADVERTISE_ALL) ||
> + !(ctrl1000 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL))) {
> + phydev_warn(phydev,
> + "Empty C22 advertisement, using C45 abilities\n");
> + return 0;
> + }
[Severity: Low]
This isn't a bug, but the check here ORs the two registers, while the
commit message says the fallback happens only "If the advertisement
reads back empty".
Take the case where ADVERTISE has valid 10/100 bits but CTRL1000 has no
1000 bits, which is the state an advertisement limited to 100M leaves
behind. The advertisement is not empty. Even so, the valid 10/100 data is
thrown away, the C45 modes with both duplexes are kept, and the warning
says "Empty C22 advertisement".
Could the two registers be handled separately, with ADVERTISE used for
10/100 and C45 or CTRL1000 used for 1G? If not, could the commit message
and the warning text describe the condition the code actually checks?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40collabora.com