Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: namiltd@yahoo.com
Cc: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com,
	maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 8/9] net: dsa: realtek: rtl8365mb: re-latch the family D SerDes
Date: Tue, 13 Oct 2026 01:08:33 +0000	[thread overview]
Message-ID: <179185371389.434549.2909566722698284726@kernel.org> (raw)
In-Reply-To: <98dbdca5-77c0-4027-aacc-4f97de5f3bb7@yahoo.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] rtl8365mb_sds_relatch_work() relies on a lockless `if
  (!dev_get_drvdata(priv->dev)) return;` check at entry (line 1812), not…
- [Low] The comment on RTL8365MB_D_SDS_RESTORE_TRIES (lines 315-318) says
  a failed restore write "is retried this many times" (3).

--

net: dsa: realtek: rtl8365mb: re-latch the family D SerDes

On family D switches, this patch adds a delayed work item that keeps
re-driving the DISABLE -> HSGMII edge in SDS_MISC until the SerDes
receiver latches, then health-checks the link every 10 s. pcs_config()
starts the work for 2500base-x. pcs_config(), pcs_disable(), teardown()
and a devres action cancel it. A new sds_lock serializes the SDS_INDACS
indirect access sequences.

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index d23e80f1d745d..bef95f91eea50 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c

[ ... ]

> @@ -299,6 +300,28 @@
>  #define   RTL8365MB_SDS_MISC_SGMII_SPD_MASK		GENMASK(8, 7)
>  #define   RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK	BIT(6)
>  

[ ... ]

> +/* The SerDes stays parked until the restore write succeeds, so a failed
> + * write is retried this many times before giving up until the next run.
> + */
> +#define RTL8365MB_D_SDS_RESTORE_TRIES		3

[Severity: Low]
This isn't a bug, but does this comment match how the macro is used?
rtl8365mb_sds_relatch_restore() uses it as the total number of writes,
counting the first one:

	for (i = 0; i < RTL8365MB_D_SDS_RESTORE_TRIES; i++) {
		ret = regmap_update_bits(...);
		if (!ret)
			return 0;
		usleep_range(1000, 2000);
	}

So a failed first write gets two retries, not three. The loop also sleeps
1-2 ms after the last failed write before it gives up.

[ ... ]

> @@ -1669,8 +1725,192 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,

[ ... ]

> +static void rtl8365mb_sds_relatch_work(struct work_struct *work)
> +{
> +	struct rtl8365mb *mb = container_of(to_delayed_work(work),
> +					    struct rtl8365mb, sds_relatch);
> +	struct realtek_priv *priv = mb->priv;

[ ... ]

> +	/* rtl83xx_shutdown() clears the driver data and nothing stops the PCS
> +	 * then: do not touch the hardware or rearm after that.
> +	 */
> +	if (!dev_get_drvdata(priv->dev))
> +		return;

[Severity: Medium]
Is this check enough to keep the work away from the hardware after
shutdown?

rtl83xx_shutdown() clears the driver data with a plain store and never
cancels sds_relatch:

drivers/net/dsa/realtek/rtl83xx.c:rtl83xx_shutdown() {
	dsa_switch_shutdown(ds);

	dev_set_drvdata(priv->dev, NULL);
}

dsa_switch_shutdown() does not tear down the CPU port's phylink, so neither
rtl8365mb_pcs_disable() nor rtl8365mb_teardown() runs on this path.

Suppose a run passes the dev_get_drvdata() test just before the store. It
then reads SDS_MISC, runs the SDS_INDACS sequence under sds_lock, parks
SDS_MISC, sleeps 20 ms in usleep_range(), restores, and calls
schedule_delayed_work() again. All of that can happen after
rtl83xx_shutdown() has returned, while device_shutdown() moves on to the
parent MDIO/SMI bus device.

Closing the conduit in dsa_switch_shutdown() drops the trunk, so the work
is likely to take the park path at about that moment. If the reboot or
kexec lands in the middle of a park, could the SerDes stay in DISABLE
mode?

The commit message says:

  rtl83xx_shutdown() clears the driver data and nothing stops the PCS
  then, so the work does nothing once the driver data is gone

That seems true only for runs that start after the store. Would a
cancel_delayed_work_sync() of sds_relatch on the shutdown path be more
reliable than this lockless drvdata check?

[ ... ]

> +	usleep_range(20000, 21000);
> +
> +	if (rtl8365mb_sds_relatch_restore(mb)) {

[ ... ]

> +rearm:
> +	schedule_delayed_work(&mb->sds_relatch, delay);
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/38872e6f-1264-4a93-9f81-8212173e909d%40yahoo.com

  reply	other threads:[~2026-10-13  1:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <38872e6f-1264-4a93-9f81-8212173e909d.ref@yahoo.com>
2026-10-12  0:08 ` [PATCH net-next v4 0/9] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-10-12  0:09   ` [PATCH net-next v4 1/9] dt-bindings: net: dsa: realtek: add RTL8367S-V Mieczyslaw Nalewaj
2026-10-12  9:31     ` Linus Walleij
2026-10-12 14:15     ` Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko
2026-10-12  0:10   ` [PATCH net-next v4 2/9] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-10-12  0:11   ` [PATCH net-next v4 3/9] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-10-12  0:12   ` [PATCH net-next v4 4/9] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko
2026-10-12  0:12   ` [PATCH net-next v4 5/9] net: dsa: realtek: rtl8365mb: set and get vlan 4k " Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko
2026-10-12  0:13   ` [PATCH net-next v4 6/9] net: dsa: realtek: rtl8365mb: use raw VID for PVID on " Mieczyslaw Nalewaj
2026-10-12  0:14   ` [PATCH net-next v4 7/9] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko
2026-10-12  0:15   ` [PATCH net-next v4 8/9] net: dsa: realtek: rtl8365mb: re-latch the family D SerDes Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko [this message]
2026-10-12  0:16   ` [PATCH net-next v4 9/9] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-10-13  1:08     ` netdev-bot+sashiko
2026-10-13  8:49     ` Mieczyslaw Nalewaj

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=179185371389.434549.2909566722698284726@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luizluca@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=namiltd@yahoo.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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