Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kyle.switch@motor-comm.com
Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	mmyangfl@gmail.com, horms@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	ming.xu@motor-comm.com, xiaolin.xu@motor-comm.com,
	jianmin.wang@motor-comm.com, wei.zhang@gl-inet.com,
	sijia.huang@gl-inet.com
Subject: Re: [PATCH net-next v13 1/5] net: dsa: motorcomm: initialize dsa_switch based on chipid
Date: Mon, 12 Oct 2026 03:01:51 +0000	[thread overview]
Message-ID: <179177411161.434549.11883600135286117076@kernel.org> (raw)
In-Reply-To: <20261011025043.1859940-2-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message does not describe the patch accurately.
- [Low] In yt92xx_register_switch(), `u32 chipid;` has no initializer.

--

net: dsa: motorcomm: initialize dsa_switch based on chipid

This commit moves the dsa_switch field setup out of yt921x_mdio_probe()
and into a new helper, yt92xx_register_switch(). The helper reads
YT921X_CHIP_ID at probe time and takes the per-series parameters from a
new yt92xx_series table. If the major is unknown, probe fails with
-ENODEV.

> Replace the hardcoded chip handling in yt92xx_register_switch() with a
> data-driven loopup based on the chip ID.

[Severity: Low]
Is this description accurate? yt92xx_register_switch() does not exist
before this patch; the patch adds it. The hardcoded ds-> assignments
that get replaced were in yt921x_mdio_probe().

There's also a typo: "loopup" should be "lookup".

yt92xx_series_lookup() is an if-chain on the major, not a table-driven
lookup.

Could the message also mention the behaviour change? yt921x_mdio_probe()
now reads YT921X_CHIP_ID over MDIO before dsa_register_switch(), and it
fails probe with -ENODEV for an unknown major. Before this patch, the chip
was only identified later, in the setup path:

yt921x_dsa_setup()->yt921x_chip_reset()->yt921x_chip_detect()

That path still reads the same register, so every probe now reads the
chip ID twice.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 91cc5647f2b66..d4c20658216a6 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -4078,6 +4078,67 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {

[ ... ]

> +static int yt92xx_register_switch(struct dsa_switch *ds)
> +{
> +	struct yt921x_priv *priv = dsa_to_yt921x_priv(ds);
> +	struct device *dev = yt921x_priv_to_device(priv);
> +	const struct yt92xx_series *series;
> +	u32 chipid;
> +	u32 major;
> +	int res;
> +
> +	mutex_lock(&priv->reg_lock);
> +	res = yt921x_reg_read(priv, YT921X_CHIP_ID, &chipid);
> +	mutex_unlock(&priv->reg_lock);
> +	if (res) {
> +		dev_err(dev, "Unexpected chipid 0x%x\n", chipid);
> +		return res;
> +	}

[Severity: Low]
Can this print an uninitialized chipid? chipid has no initializer.
yt921x_reg_mdio_read() only stores to *valp after all four MDIO
transactions succeed, and every error path jumps past that store:

drivers/net/dsa/motorcomm/chip.c:yt921x_reg_mdio_read() {
    ...
	val = (val << 16) | (u16)res;

	*valp = val;
	res = 0;

end:
	mutex_unlock(&bus->mdio_lock);
	return res;
}

So if the MDIO bus fails during yt921x_mdio_probe(), this message prints
whatever is on the stack as if the switch had returned an unknown ID. It
also never prints the actual error in res.

yt921x_chip_detect() does it the other way round. It returns quietly when
the read fails, and prints "Unexpected chipid" only after a successful
read with an unknown major.

> +
> +	major = FIELD_GET(YT921X_CHIP_ID_MAJOR, chipid);
> +	series = yt92xx_series_lookup(major);
> +	if (!series) {
> +		dev_err(dev, "Undefined series info for the corresponding major\n");
> +		return -ENODEV;
> +	}

The real unknown-chip case here has the opposite gap: it doesn't print
the chipid or major that was read.

The last patch in the series, "net: dsa: motorcomm: Add support for
Motorcomm YT922x", appears to fix both. The read-failure branch becomes a
plain return res, and the unknown-major branch prints chipid. Even so, the
bad message is still there at this commit for anyone bisecting.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261011025043.1859940-1-kyle.switch%40motor-comm.com

  reply	other threads:[~2026-10-12  3:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11  2:50 [PATCH net-next v13 0/5] net: dsa: motorcomm: add support yt922x driver Kyle Switch
2026-10-11  2:50 ` [PATCH net-next v13 1/5] net: dsa: motorcomm: initialize dsa_switch based on chipid Kyle Switch
2026-10-12  3:01   ` netdev-bot+sashiko [this message]
2026-10-11  2:50 ` [PATCH net-next v13 2/5] net: dsa: motorcomm: use max_ports in series for port bounds checking Kyle Switch
2026-10-11  2:50 ` [PATCH net-next v13 3/5] net: dsa: motorcomm: use fixed-width GENMASK_U*() helpers Kyle Switch
2026-10-12  3:01   ` netdev-bot+sashiko
2026-10-11  2:50 ` [PATCH net-next v13 4/5] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags Kyle Switch
2026-10-12  3:01   ` netdev-bot+sashiko
2026-10-11  2:50 ` [PATCH net-next v13 5/5] net: dsa: motorcomm: Add support for Motorcomm YT922x Kyle Switch
2026-10-12  3:01   ` netdev-bot+sashiko

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=179177411161.434549.11883600135286117076@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jianmin.wang@motor-comm.com \
    --cc=kuba@kernel.org \
    --cc=kyle.switch@motor-comm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ming.xu@motor-comm.com \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sijia.huang@gl-inet.com \
    --cc=wei.zhang@gl-inet.com \
    --cc=xiaolin.xu@motor-comm.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