From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org,
mfd@lists.linux.dev, lee@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v21 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Date: Sat, 12 Sep 2026 22:55:06 +0000 [thread overview]
Message-ID: <20260912225507.0CF9C1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260911225414.225980-6-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Forward loop over `dsa_r50ohm_table` with duplicate values causes a severe calibration discontinuity for an EFUSE value of 127.
- [Medium] `an8855_set_downshift` silently ignores specific downshift counts, treating any non-zero value as a generic 'enable'.
--
commit 836fad6c28da3b4cc1aa1daa6879476d597247ba
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
This commit adds a new PHY driver for the Airoha AN8855 Internal Switch
Gigabit PHY. It configures and calibrates the PHY for the AN8855 switch
using 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];
> + else
> + *dest = dsa_r50ohm_table[i - 8];
[Severity: High]
Does this loop unintentionally apply the fallback value instead of the correct
resistance mapping when shift_sel is 127?
When the EFUSE calibration data read from NVMEM contains a shift_sel value
of 127, the forward for loop finds the first match at index i = 0. The
subsequent bounds check if (i < 8) evaluates to true, overriding the mapped
value with the fallback dsa_r50ohm_table[25] (which is 94).
Additionally, if intermediate values not explicitly defined in the table
are encountered, the strict equality check fails and i reaches
ARRAY_SIZE(dsa_r50ohm_table), which also falls back to 94 instead of
mapping to the closest index.
> +
> + 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;
> +
> + return phy_modify_paged(phydev, AN8855_PHY_PAGE_EXTENDED_1,
> + AN8855_PHY_EXT_REG_14, AN8855_PHY_EN_DOWN_SHIFT,
> + ds);
> +}
[Severity: Medium]
Does this silently ignore the specific downshift count requested by the user?
If userspace requests a specific downshift count, the driver checks
cnt != DOWNSHIFT_DEV_DISABLE, evaluating to true and setting the hardware
enable bit AN8855_PHY_EN_DOWN_SHIFT. However, it configures the hardware
without actually applying the requested count or returning an error
(such as -EOPNOTSUPP) for unsupported values.
Tools like ethtool will report success, but the hardware will silently use
its default count instead.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911225414.225980-1-ansuelsmth@gmail.com?part=5
next prev parent reply other threads:[~2026-09-12 22:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:53 [PATCH net-next v21 0/9] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-09-11 22:53 ` [PATCH net-next v21 1/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 2/9] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 3/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 4/9] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-09-12 22:55 ` sashiko-bot [this message]
2026-09-11 22:53 ` [PATCH net-next v21 6/9] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 7/9] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-09-11 22:53 ` [PATCH net-next v21 8/9] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-09-12 22:55 ` sashiko-bot
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=20260912225507.0CF9C1F00898@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