Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Coia Prant" <coiaprant@gmail.com>
Cc: olteanv@gmail.com, neil.armstrong@linaro.org, vkoul@kernel.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org,
	linux-phy@lists.infradead.org, robh@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH net-next v3 06/10] net: pcs: xpcs: add ANRESTART support for SGMII link recovery
Date: Wed, 02 Sep 2026 15:04:38 +0000	[thread overview]
Message-ID: <20260902150438.6F9C91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901150111.141037-7-coiaprant@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] State getter `xpcs_get_state_c37_sgmii` mutates hardware state (restarting autonegotiation) and applies a hardware-specific workaround universally to all platforms.
--

commit 71d0b44c6ef52210f70310761abecf6962cd887a
Author: Coia Prant <coiaprant@gmail.com>

net: pcs: xpcs: add ANRESTART support for SGMII link recovery

This commit introduces support for restarting autonegotiation on the DesignWare
XPCS IP to handle link recovery on platforms like the RK3568 MAC side SGMII.

> diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
> index 0337e2bcc0125..50b9cdf94fdaa 100644
> --- a/drivers/net/pcs/pcs-xpcs.c
> +++ b/drivers/net/pcs/pcs-xpcs.c
[ ... ]
> @@ -1093,10 +1098,15 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
>  		return 0;
>  	}
>  
> -	/* Clear AN complete status or interrupt */
> -	if (state->an_complete)
> +	if (state->an_complete) {
> +		/* Clear AN complete status or interrupt */
>  		xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);
>  
> +		/* Initiate the next round of AN */
> +		xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART,
> +			    BMCR_ANRESTART);
> +	}
> +

[Severity: High]
Does this mutation inside xpcs_get_state_c37_sgmii violate the phylink API
semantics, which typically require state getters to be side-effect free?

Because the phylink_resolve workqueue polls the state periodically when the
link is down, won't this cause the getter to constantly restart the
autonegotiation state machine and generate continuous MDIO traffic?

For instance, when the SGMII PHY drops the copper link, it sends an SGMII
config word with link=0. The MAC completes autonegotiation based on this word,
meaning state->an_complete is true but state->link is false, which triggers
this exact path.

Additionally, does this apply an RK3568-specific workaround unconditionally to
all Generic DW XPCS controllers? Standard MAC-side SGMII automatically handles
link state updates via the SGMII config word without needing manual AN
restarts. Could this override that conformant behavior on other platforms?

>  	return 0;
>  }
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901150111.141037-1-coiaprant@gmail.com?part=6

  reply	other threads:[~2026-09-02 15:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 15:01 [PATCH net-next v3 00/10] net: pcs: add basic support for RK3568 XPCS Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 01/10] net: stmmac: move XPCS lifetime management to platform drivers Coia Prant
2026-09-02 22:23   ` Maxime Chevallier
2026-09-03  8:32   ` Maxime Chevallier
2026-09-03  8:51     ` Coia Prant
2026-09-03  8:58       ` Maxime Chevallier
2026-09-01 15:01 ` [PATCH net-next v3 02/10] dt-bindings: phy: rockchip: naneng-combphy: add rockchip,sgmii-mac-sel property Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 03/10] phy: rockchip: naneng-combphy: add SGMII MAC selection for RK3568 Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 04/10] dt-bindings: net: pcs: add rockchip,rk3568-xpcs support Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 05/10] arm64: dts: rockchip: rk3568: add XPCS and fixed-clock nodes Coia Prant
2026-09-02 15:04   ` sashiko-bot
2026-09-01 15:01 ` [PATCH net-next v3 06/10] net: pcs: xpcs: add ANRESTART support for SGMII link recovery Coia Prant
2026-09-02 15:04   ` sashiko-bot [this message]
2026-09-01 15:01 ` [PATCH net-next v3 07/10] net: pcs: xpcs: add Rockchip RK3568 platform glue driver Coia Prant
2026-09-02 15:04   ` sashiko-bot
2026-09-03 10:15     ` Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 08/10] net: stmmac: dwmac-rk: add SGMII support for RK3568 Coia Prant
2026-09-02 15:04   ` sashiko-bot
2026-09-03  8:34   ` Maxime Chevallier
2026-09-03  8:38     ` Coia Prant
2026-09-03  8:44       ` Maxime Chevallier
2026-09-03  8:59   ` Maxime Chevallier
2026-09-01 15:01 ` [PATCH net-next v3 09/10] arm64: dts: rockchip: rk3568-photonicat: enable SGMII LAN port Coia Prant
2026-09-01 15:01 ` [PATCH net-next v3 10/10] MAINTAINERS: add entry for Rockchip XPCS driver Coia Prant

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=20260902150438.6F9C91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=coiaprant@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=wsa+renesas@sang-engineering.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