From: netdev-bot+sashiko@kernel.org
To: parthiban.veerasooran@microchip.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, hkallweit1@gmail.com,
linux@armlinux.org.uk, netdev@vger.kernel.org,
UNGLinuxDriver@microchip.com
Subject: Re: [PATCH net-next RESEND v4 1/4] net: phy: microchip_t1s: fix collision detection on PLCA status change
Date: Wed, 25 Nov 2026 13:05:25 +0000 [thread overview]
Message-ID: <179561192599.3135.16135249584970983112@kernel.org> (raw)
In-Reply-To: <20261124124930.485323-2-parthiban.veerasooran@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] lan86xx_update_cden() in drivers/net/phy/microchip_t1s.c
decides CDEN from the software copy priv->plca_enabled, not from the…
- [Low] lan86xx_config_intr() changes only the PLCA_STS_CHANGED (PSTC)
bit of IMSK1, via phy_clear_bits_mmd()/phy_set_bits_mmd() in…
--
net: phy: microchip_t1s: fix collision detection on PLCA status change
This patch adds PSTC interrupt handling and a resync in read_status() so
that CDEN in COL_DET_CTRL0 follows the actual PLCA or CSMA/CD operating
mode. The PRSCTL1 fallback bit is taken into account. The patch also stops
treating plca_cfg->enabled as a boolean, so that -1 ("don't change") no
longer touches CDEN.
> diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c
> index 73c23d311d72a..5ce0304bf0952 100644
> --- a/drivers/net/phy/microchip_t1s.c
> +++ b/drivers/net/phy/microchip_t1s.c
[ ... ]
> +static int lan86xx_update_cden(struct phy_device *phydev)
> +{
> + struct lan86xx_priv *priv = phydev->priv;
> + struct phy_plca_status plca_st;
> + int fallback, ret;
> + u16 cden;
> +
> + fallback = lan86xx_fallback_to_csmacd(phydev);
> + if (fallback < 0)
> + return fallback;
> +
> + ret = genphy_c45_plca_get_status(phydev, &plca_st);
> + if (ret < 0)
> + return ret;
> +
> + /* PLCA disabled -> CDEN enabled
> + * PLCA enabled + BEACON -> CDEN disabled
> + * PLCA enabled + no BEACON + fallback -> CDEN enabled
> + * PLCA enabled + no BEACON + no fallback -> CDEN disabled
> + */
> + if (!priv->plca_enabled)
> + cden = COL_DET_ENABLE;
> + else if (plca_st.pst)
> + cden = COL_DET_DISABLE;
> + else if (fallback)
> + cden = COL_DET_ENABLE;
> + else
> + cden = COL_DET_DISABLE;
[Severity: Medium]
Can priv->plca_enabled get out of sync with the hardware PLCA enable bit
(MDIO_OATC14_PLCA_CTRL0.EN) here? lan86xx_read_status() now calls this on
every phylib poll. A stale cached value would therefore keep re-applying
the wrong CDEN setting for as long as the mismatch lasts.
The cached value seems able to diverge in a few ways.
First, lan86xx_plca_set_cfg() only stores priv->plca_enabled after
genphy_c45_plca_set_cfg() returns 0. With enabled == 0, that helper clears
PLCA_EN first and then does more MDIO accesses that can fail:
drivers/net/phy/phy-c45.c:genphy_c45_plca_set_cfg() {
...
// first of all, disable PLCA if required
if (plca_cfg->enabled == 0) {
ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
MDIO_OATC14_PLCA_CTRL0,
MDIO_OATC14_PLCA_EN);
...
if (plca_cfg->to_tmr >= 0) {
ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
MDIO_OATC14_PLCA_TOTMR,
plca_cfg->to_tmr);
if (ret < 0)
return ret;
}
...
}
If one of the later writes fails, PLCA is off in hardware but
priv->plca_enabled is still 1.
Second, phy_detach() asserts the PHY reset line through
phy_device_reset(phydev, 1), and phy_attach()->phy_init_hw() releases it
on the next attach. That clears PLCA_CTRL0.EN. However, priv belongs to the
driver binding, so plca_enabled stays 1. Nothing in config_init reads the
hardware value back.
Third, the opposite case: an unbind and rebind without a reset GPIO leaves
PLCA enabled in hardware. lan86xx_probe() then allocates a zeroed priv
with plca_enabled == 0.
In the first two cases, assume the PRSCTL1 fallback bit is clear. This
function then sees plca_enabled == 1 and pst == 0, and writes
COL_DET_DISABLE while the PHY is actually running plain CSMA/CD. Isn't that
the "CDEN stayed disabled, leaving CSMA/CD running unprotected" situation
the commit message describes?
In the rebind case, every poll forces COL_DET_ENABLE while the PHY runs
PLCA with BEACONs. Meanwhile genphy_c45_plca_get_cfg() reports PLCA as
enabled to userspace.
The Rev.D0 follow-on patch also passes priv->plca_enabled into its
link-selection logic. Would reading PLCA_CTRL0.EN directly inside
lan86xx_update_cden() remove the need for the cached copy?
> +
> + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_COL_DET_CTRL0,
> + COL_DET_CTRL0_ENABLE_BIT_MASK, cden);
> +}
[ ... ]
> +/* Mask (mask bit = 1) or unmask (mask bit = 0) the given STS1 bits in
> + * IMSK1.
> + */
> +static int lan86xx_set_intr_mask(struct phy_device *phydev, u16 mask,
> + bool enable)
> +{
> + if (enable)
> + /* A mask bit of 0 enables the corresponding interrupt. */
> + return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
> + LAN86XX_REG_IMSK1, mask);
> +
> + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_IMSK1,
> + mask);
> +}
[ ... ]
> +static irqreturn_t lan86xx_handle_interrupt(struct phy_device *phydev)
> +{
> + struct lan86xx_priv *priv = phydev->priv;
> + irqreturn_t ret_irq = IRQ_NONE;
> + int sts1, ret;
> +
> + /* Reading the status register clears the latched event bits. */
> + sts1 = lan86xx_read_clear_sts1(phydev);
> + if (sts1 < 0) {
> + phy_error(phydev);
> + return IRQ_NONE;
> + }
> +
> + if (sts1 & LAN86XX_STS1_PLCA_STS_CHANGED) {
[ ... ]
> + ret_irq = IRQ_HANDLED;
> + }
> +
> + return ret_irq;
> +}
[Severity: Low]
lan86xx_config_intr() only changes the PSTC bit in IMSK1 through
lan86xx_set_intr_mask(). The other IMSK1 bits keep whatever state the
reset default or a bootloader left them in. What happens if another STS1
source is unmasked?
lan86xx_handle_interrupt() reads STS1, which acks every latched bit. It
returns IRQ_NONE unless PSTC is set, so each such event would be reported
as an unhandled PHY interrupt.
phylib doesn't poll read_status() in interrupt mode. If the spurious IRQ
detector ends up disabling the line, PSTC-based CDEN tracking would stop
entirely.
On the disable path, those other sources would also stay armed while
phylib considers interrupts off.
I couldn't confirm the IMSK1 reset default. If it masks every source, this
has no visible effect. Would it be more robust to program the whole IMSK1
register, with everything masked except PSTC when enabling and everything
masked when disabling?
The Rev.D0 config_intr added later in the series uses the same
read-modify-write helper.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124124930.485323-1-parthiban.veerasooran%40microchip.com
next prev parent reply other threads:[~2026-11-25 13:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 12:49 [PATCH net-next RESEND v4 0/4] net: microchip_t1s: fix collision detection on PLCA status change Parthiban Veerasooran
2026-11-24 12:49 ` [PATCH net-next RESEND v4 1/4] net: phy: " Parthiban Veerasooran
2026-11-25 13:05 ` netdev-bot+sashiko [this message]
2026-11-24 12:49 ` [PATCH net-next RESEND v4 2/4] net: ethernet: oa_tc6: deliver the PHY interrupt to phylib Parthiban Veerasooran
2026-11-25 13:05 ` netdev-bot+sashiko
2026-11-24 12:49 ` [PATCH net-next RESEND v4 3/4] microchip: lan865x: enable PHY interrupt via virtual IRQ Parthiban Veerasooran
2026-11-25 13:05 ` netdev-bot+sashiko
2026-11-24 12:49 ` [PATCH net-next RESEND v4 4/4] net: phy: microchip_t1s: fix collision detection for LAN867X Rev.D0 Parthiban Veerasooran
2026-11-25 13:05 ` netdev-bot+sashiko
2026-11-24 12:52 ` [PATCH net-next RESEND v4 0/4] net: microchip_t1s: fix collision detection on PLCA status change netdev-bot+sinfo
2026-11-25 3:28 ` Parthiban.Veerasooran
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=179561192599.3135.16135249584970983112@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parthiban.veerasooran@microchip.com \
/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