Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] net: dsa: motorcomm: Resync SMI slave before register access
Date: Wed, 18 Nov 2026 03:16:43 +0000	[thread overview]
Message-ID: <179497180399.3136.7097991469555509523@kernel.org> (raw)
In-Reply-To: <20261116162303.1368472-1-mmyangfl@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · 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).

- [High] The resync sequence in yt921x_reg_mdio_reset()
  (drivers/net/dsa/motorcomm/chip.c) cannot bring the SMI slave out of…
- [Low] The patch adds a new way for probe to fail, and the commit
  message does not mention it.

--

net: dsa: motorcomm: Resync SMI slave before register access

This patch adds yt921x_reg_mdio_reset(). It sends a fixed sequence of SMI
address and data frames to realign the slave's 4-frame state machine. The
function is called from yt921x_chip_reset() before yt921x_chip_detect(),
and it ends with a read that is expected to return the 0xdead sentinel.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 35e70b3226089..5d6390abd7cb5 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -98,6 +98,103 @@ struct yt921x_reg_mdio {

[ ... ]

> + * State Input Next Comment
> + * ----- ----- ---- -------
> + * AH    aw?   AL?  step #1
> + * AL?   aw?   DH?  step #2
> + * DH?   d?    DL?  step #3
> + * DL?   d?    AH   step #4
> + * A?    dr    A?   `0xdead` sentinel
> + * ALw   awr   ALw  ignored
> + * D?r   awr   AH   abort, frame discarded
> + * DHw   awr   AH   abort, frame discarded
> + * DHw   dr    DHw  `0xdead` sentinel
> + * DLr   dw    ?    `0xdead` on following drs; next state undetermined
> + * DLw   awr   ALr  abort, frame consumed as next access's addr-hi
> + * DLw   dr    ?    `0xdead` sentinel; next state undetermined
> + *
> + * Any other REGAD/op combination is not characterized and never sent.
> + *
> + * The reset sequence is awr, dr, dr, awr, awr, dr, dr, plus one more dr
> + * as a heuristic sanity check. The `0xdead` sentinel cannot distinguish between
> + * AH, AL, or D?w, but when this happens, it should be classified as a model or
> + * hardware error - in either case, there is no use to do more check.

[ ... ]

> +	reg_addr = YT921X_SMI_SWITCHID(mdio->switchid) | YT921X_SMI_ADDR |
> +		   YT921X_SMI_READ;
> +	reg_data = YT921X_SMI_SWITCHID(mdio->switchid) | YT921X_SMI_DATA |
> +		   YT921X_SMI_READ;

[ ... ]

> +	/* Heuristic sanity check: expect AH + dr -> AH `0xdead` sentinel. */
> +	res = __mdiobus_read(bus, addr, reg_data);
> +	if (res < 0)
> +		goto end;
> +	res = res != 0xdead ? -EIO : 0;

[Severity: High]
Can this sequence get the slave out of the ALw state?

The table above gives these transitions for ALw:

  A?    dr    A?   0xdead sentinel
  ALw   awr   ALw  ignored

The only characterized way out of ALw is "AL? aw? DH?" with an aww frame.
yt921x_reg_mdio_reset() only builds read-flag address and data REGADs.
So by the table, every awr and dr it sends is a no-op in ALw.

I stepped through the table for the other states. AH, ALr, DHr, DHw, DLr
and DLw all end up back in AH, so ALw looks like the only state that
does not converge.

The final check does not catch this either. ALw answers dr with 0xdead
just like AH does, so yt921x_reg_mdio_reset() returns 0 while the slave
is still out of phase.

The slave can end up in ALw through yt921x_reg_mdio_write(). Its first
address frame is aww, because YT921X_SMI_ADDR | YT921X_SMI_WRITE is 0:

	reg_addr = YT921X_SMI_SWITCHID(mdio->switchid) | YT921X_SMI_ADDR |
		   YT921X_SMI_WRITE;
	res = __mdiobus_write(bus, addr, reg_addr, (u16)(reg >> 16));
	if (res)
		goto end;
	res = __mdiobus_write(bus, addr, reg_addr, (u16)reg);

If the second frame never reaches the slave, the slave stays in ALw.
That can happen on an MDIO bus error or a host reset between frames, and
firmware could also leave the slave in that state. This is the "access
interrupted between frames, e.g. on an MDIO bus error" case from the
commit message.

On the next probe, yt921x_dsa_setup()->yt921x_chip_reset()->
yt921x_reg_mdio_reset() reports success. Then yt921x_chip_detect() reads
CHIP_ID. Both awr frames are ignored and both dr frames return 0xdead, so
chipid is 0xdeaddead.

That matches neither YT9215_MAJOR nor YT9218_MAJOR. Probe fails with
"Unexpected chipid" and -ENODEV before the YT921X_RST_HW write is
reached.

Every re-probe repeats the same no-op sequence. Wouldn't the switch stay
unusable until a power cycle? That looks like the chicken-and-egg problem
this patch is meant to remove.

The comment also says an ambiguous 0xdead result "should be classified
as a model or hardware error". The model in the same comment predicts
ALw -> ALw for this sequence, so the two seem to disagree.

Would this need a characterized aww step? Another option might be to
check the real CHIP_ID read result and then send aww followed by awr.

[ ... ]

> @@ -2225,6 +2322,10 @@ static int yt921x_chip_reset(struct yt921x_priv *priv)
>  	u32 val;
>  	int res;
>  
> +	res = yt921x_reg_mdio_reset(priv->reg_ctx);
> +	if (res)
> +		return res;
> +
>  	res = yt921x_chip_detect(priv);

[Severity: Low]
This adds a new probe failure path, and the commit message does not
mention it.

yt921x_reg_mdio_reset() returns -EIO whenever the final read is not
0xdead. It runs before yt921x_chip_detect(), so the check applies to
every entry in yt921x_infos[] before the driver knows which chip it is
talking to.

Has the 0xdead sentinel behaviour been confirmed on both the
YT9215_MAJOR and YT9218_MAJOR parts?

The -EIO is also passed up through yt921x_chip_reset() and
yt921x_dsa_setup() without a dev_err(). The other early failures in
yt921x_chip_detect() print "Unexpected chipid" or "Unsupported chipid".
If the heuristic misfires, the user only sees a generic probe error -5.

Could this path print a message that points at the SMI resync?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116162303.1368472-1-mmyangfl%40gmail.com

      parent reply	other threads:[~2026-11-18  3:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:23 [PATCH net-next v2] net: dsa: motorcomm: Resync SMI slave before register access David Yang
2026-11-17  2:10 ` Andrew Lunn
2026-11-18  3:16 ` netdev-bot+sashiko [this message]

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=179497180399.3136.7097991469555509523@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmyangfl@gmail.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