🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22503

Re: [PATCH net-next RESEND v4 1/4] net: phy: microchip_t1s: fix collision detection on PLCA status change

#22503
From: netdev-bot+sashiko
Date: Wed, 25 Nov 2026 13:05
195 lines
14655 bytes
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
Technical Details
Message-ID: <179561192599.3135.16135249584970983112@kernel.org>
Path: mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371320-linux-kernel-netdev=dewy.ru
References: <20261124124930.485323-2-parthiban.veerasooran@microchip.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371320-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179561192599.3135.16135249584970983112@kernel.org>
References: <20261124124930.485323-2-parthiban.veerasooran@microchip.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="210276"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ThL2oOPRYmnY5CDcQa0RGXfUpus= sha256:M6U3oZe8ol3FD4ykZu4DjdXYE5T+3bkUwCiBPWdsFck=
	sha1:OrsM6wPRwi7oRBVA2snnef9tlZQ= sha256:zVpXU2ZyAiXWrZzqP8ZL6ZJTlSyyCKN21X/j1S6kMvg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 37AA8125E6A; Wed, 25 Nov 2026 16:05:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Z2WftNPW8urA;
	Wed, 25 Nov 2026 16:05:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371320-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 20982125E68; Wed, 25 Nov 2026 16:05:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 98D8C35B46; Wed, 25 Nov 2026 13:05:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795611928;
	b=GTq+rLyxHk6E+gjWhhHLYTnqLJLZtliGRImawZGAmuxY/utK0SLUT1G7P91+/xEWDgQu
	 sEl3+bs3OYbIRQdde1aRz+YDv3E8hhJYTTUc5sDYAJ77vRsWiubes5mlr85UlZNEYHiCb
	 zRICv3+5TkQYtfNyxglXLtFDoNHihtZ1eW4ukXOj9uEKAgiy3Ibih0I9eb+31EVLXwWm8
	 RTcr4g9z4R+/csZnwwRoAZboZV1lCA7p1vZp3ayMtJrlX9Npe2IH0GDOlEGvjflpZscvN
	 FW3gxtJtGkB+iMJrRv0BLUR+hv6KjETvxGYhvWpziI12ceJ6CQIzVkKZ/74fa0S5n+g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795611928;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=rh7XvE7JeObnSSKRdyHTvlts1tr9f8hO8zi9pra9mvQ=;
	b=J+gVeKqwpJVAAL2TNJE1hdKq69v20IyNxzOGJP4LGW88zjJRZS1f5uLg6sCZJ4oyIC/8
	 /VDx57+s2P9tA/2POq1+ohgDUjKyADzOqAGrXdL9EUq/98QN4hhQk0DruO1vozXlV/1oX
	 +nVypFRQt2ph0dn2i7/3fAV7qBNslpnhCy5wEFudSL7v77qGyaYVAQOYaJ9zhPNqXb73B
	 ZPuMTrBZl9qhrPKyfq2F5JhPGmIELvTKgPVPCAtCJ1faU8sUKICD8ZQVvc2uRFyMdD3br
	 gIYAqjwWuLjXUlRUzGLUvRQtsDqOCL40EbA7TQjdkXSVuDZsDZpUl7bJyVrUvnhdHqg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=INWCZ1eA;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 242A5606A330;
	Wed, 25 Nov 2026 13:05:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=INWCZ1eA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795611927;
	b=OU4WqiKRZT6yI1mD9z9d+kwxSh4iDza7NzMUmpmJKkFT1kUYfc/+zGv00NFDCQ4Q80p4
	 n7J9ih8zqwhHyFzG5vvjRG4XBgUWKQOQuQUClX5gNYb+twHrG3mZzN6/qZ59veVeS7Sy3
	 AC3XwCMzff//r59j7hQWN2k3r8RBrzhY7C/k9sslSOay6THb2cgNN4Yhqc/0IZc0/khR1
	 x29n79ggN+AEpYKz99al6hLP9YuJFzzwT7ct0I6bRitHDr/BQaWfU91tpiPLQLGUPgWj6
	 DP600l1LCdYrjlstYxegBb2mvXCAZZVolzg5fS2n/UBo2naa5sioTABrCpjIuatSGyA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795611927;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=rh7XvE7JeObnSSKRdyHTvlts1tr9f8hO8zi9pra9mvQ=;
	b=2I67btr8mFD+lY78WfWeRrFM+RQZAPZwB/h2IJLnG/bONE+ytLr6tlT37mw1PH+5mzLT
	 Jsf+MXUEu/U4h+jfqB4NeHNe1lwl8MkOzYglk8CFUMv0BxZhNF5p6s0k8WjNnPOYXM29l
	 kXVK672XuD/WWyUi4mKCxOH22nA83WLVYaX/n0jp1t6C0nd76duqKmDLJUdIGyYQD0QGG
	 UvXfly9FHW3dAfjoyFClT4uiu3M+wcQVkABq6AiRlHLKHH8EOsNg5V2B76B3mXvjNOAO2
	 0aZeJyx7py8MCfeRHYZZW5HiJ8m9hb3Uj6fkoRgKwvBuZVqzeU8JplfGEsNkeUi93Ng==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=INWCZ1eA;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 429A4606A327
	for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 13:05:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A0BD1F000CA;
	Wed, 25 Nov 2026 13:05:26 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795611927;
	bh=rh7XvE7JeObnSSKRdyHTvlts1tr9f8hO8zi9pra9mvQ=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=INWCZ1eA1uJbdxa/2BvyWJZDQy4RTETpLdA/dwsOl+Zupn6G3b75FqFyGbiLTHJsH
	 MjfSDNblAGqfOdQibRKvBoHcxKgERqz4xGBaq1+247gaG1Lfpi4vpdltWFvCipxix3
	 Qpi6UFujd1aKAaa56IXnZRE/MctJEydtveQhZ39rmK556+pnqY/BuPOmFwRxFX2amz
	 cJk9d7vJ4tsckvmG7VcAk69otRnGvZkh1NC96b7A+F5OYYstO8CaoFQ329iA4+TunE
	 e5MqaoSRv5FxwxXYoYJmUQ7FKiFizWMWiLfAyiroO1W+cV6IX6DVcp+VN17bPyOuTw
	 yvOo4+tlpVT8g==
X-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
X-In-Reply-To: <20261124124930.485323-2-parthiban.veerasooran@microchip.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list