From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: conor+dt@kernel.org, lee@kernel.org, mfd@lists.linux.dev,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v23 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Date: Sat, 26 Sep 2026 18:25:18 +0000 [thread overview]
Message-ID: <20260926182519.1F4431F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260925182435.21207-6-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] net: phy: air_an8855: incorrect r50ohm calibration for 127 due to forward search
- [Medium] net: phy: air_an8855: register clobbering in AN8855_PHY_RXADC_REV registers
- [Low] net: phy: air_an8855: an8855_set_downshift ignores specific count values
--
commit c9b4d007095aa6a972d5abbc505cecf057eb353e
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Add support for Airoha AN8855 Internal Switch Gigabit PHY. This is a
simple PHY driver to configure and calibrate the PHY for the AN8855 Switch
with the use of NVMEM cells.
> diff --git a/drivers/net/phy/air_an8855.c b/drivers/net/phy/air_an8855.c
> new file mode 100644
> index 0000000000000..bc22256fd5f95
> --- /dev/null
> +++ b/drivers/net/phy/air_an8855.c
> @@ -0,0 +1,275 @@
[ ... ]
> +static int an8855_get_r50ohm_val(struct device *dev, const char *calib_name,
> + u8 *dest)
> +{
> + u32 shift_sel, val;
> + int ret;
> + int i;
> +
> + ret = nvmem_cell_read_u32(dev, calib_name, &val);
> + if (ret)
> + return ret;
> +
> + shift_sel = FIELD_GET(AN8855_SWITCH_EFUSE_R50O, val);
> + for (i = 0; i < ARRAY_SIZE(dsa_r50ohm_table); i++)
> + if (dsa_r50ohm_table[i] == shift_sel)
> + break;
> +
> + if (i < 8 || i >= ARRAY_SIZE(dsa_r50ohm_table))
> + *dest = dsa_r50ohm_table[25];
[Severity: Medium]
Will this mapping produce the wrong value for 127?
Since dsa_r50ohm_table starts with multiple 127s, the forward loop finds
the first match at index 0. Then the subsequent check sees i < 8 and assigns
94 (table index 25) instead of 127.
Should this use a reverse search (or find the last match) to map 127 to 127
at index 16 (where 16 - 8 = 8)?
> + else
> + *dest = dsa_r50ohm_table[i - 8];
> +
> + return 0;
> +}
[ ... ]
> +static int an8855_set_downshift(struct phy_device *phydev, u8 cnt)
> +{
> + u16 ds = cnt != DOWNSHIFT_DEV_DISABLE ? AN8855_PHY_EN_DOWN_SHIFT : 0;
[Severity: Low]
Does this code incorrectly ignore unsupported downshift counts?
If a user sets an unsupported downshift retry count via ethtool that isn't
DOWNSHIFT_DEV_DISABLE or DOWNSHIFT_DEV_DEFAULT_COUNT, this simply applies
AN8855_PHY_EN_DOWN_SHIFT and returns 0 (success).
Should it return -EOPNOTSUPP for unknown values to maintain consistency
between requested and actual hardware state?
> +
> + return phy_modify_paged(phydev, AN8855_PHY_PAGE_EXTENDED_1,
> + AN8855_PHY_EXT_REG_14, AN8855_PHY_EN_DOWN_SHIFT,
> + ds);
> +}
[ ... ]
> +static int an8855_config_init(struct phy_device *phydev)
> +{
[ ... ]
> + ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, AN8855_PHY_RXADC_CTRL,
> + AN8855_PHY_RG_AD_SAMPLE_PHSEL_A |
> + AN8855_PHY_RG_AD_SAMPLE_PHSEL_C);
> + if (ret)
> + return ret;
> + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AN8855_PHY_RXADC_REV_0,
> + FIELD_PREP(AN8855_PHY_RG_AD_RESERVE0_A, 0x1));
> + if (ret)
> + return ret;
> + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AN8855_PHY_RXADC_REV_1,
> + FIELD_PREP(AN8855_PHY_RG_AD_RESERVE0_C, 0x1));
[Severity: Medium]
Can this clobber the adjacent fields in the RXADC_REV registers?
phy_write_mmd() overwrites the entire 16-bit register. By preparing only
AN8855_PHY_RG_AD_RESERVE0_A and AN8855_PHY_RG_AD_RESERVE0_C, the lower
8 bits (RESERVE0_B and RESERVE0_D) will be unintentionally zeroed out.
Should phy_modify_mmd() be used here instead to preserve undocumented
hardware defaults?
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260925182435.21207-1-ansuelsmth@gmail.com?part=5
next prev parent reply other threads:[~2026-09-26 18:25 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 18:24 [PATCH net-next v23 0/9] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-09-25 18:24 ` [PATCH net-next v23 1/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-25 18:24 ` [PATCH net-next v23 2/9] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-29 20:34 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 3/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-29 20:35 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 4/9] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-29 20:35 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-09-26 18:25 ` sashiko-bot [this message]
2026-09-27 18:45 ` Andrew Lunn
2026-09-29 20:35 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 6/9] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-27 18:49 ` Andrew Lunn
2026-09-29 20:35 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 7/9] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-09-27 18:51 ` Andrew Lunn
2026-09-25 18:24 ` [PATCH net-next v23 8/9] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-27 19:02 ` Andrew Lunn
2026-09-27 20:28 ` Christian Marangi
2026-09-27 21:48 ` Andrew Lunn
2026-09-29 20:35 ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-09-26 18:25 ` sashiko-bot
2026-09-27 19:15 ` Andrew Lunn
2026-09-29 20:35 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260926182519.1F4431F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox