Article View: linux.kernel.netdev
Article #26220Re: [PATCH net-next v18 1/6] net: dsa: motorcomm: initialize dsa_switch based on chipid
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 08:57
Date: Thu, 03 Dec 2026 08:57
186 lines
14937 bytes
14937 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] yt92xx_register_switch() in drivers/net/dsa/motorcomm/chip.c
is called from yt921x_mdio_probe().
- [Low] The commit message promises a "data-driven lookup by the chip
ID", but yt92xx_series_lookup() in drivers/net/dsa/motorcomm/chip.c…
- [Low] The patch adds YT921X_AGEING_TIME_UNIT (5000U) in chip.h and uses
it to compute the advertised ds->ageing_time_min/max in…
--
net: dsa: motorcomm: initialize dsa_switch based on chipid
This commit replaces the hardcoded dsa_switch setup in yt921x_mdio_probe()
with a lookup on the major revision read from YT921X_CHIP_ID. It adds
struct yt92xx_series and a yt92xx_series_table[] with a single YT921x
entry. The matched series is stored in yt921x_priv.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 82f364986aebd..197dadb1046a4 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -2699,6 +2699,68 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {
> .setup = yt921x_dsa_setup,
> };
>
> +static const struct yt92xx_series yt92xx_series_table[] = {
> + [YT92XX_MODE_YT921X] = {
> + .name = "YT921x",
> + .max_ports = YT921X_PORT_NUM,
> + .num_lag_ids = YT921X_LAG_NUM,
> + .ageing_time_min = 1U * YT921X_AGEING_TIME_UNIT,
> + .ageing_time_max = U16_MAX * YT921X_AGEING_TIME_UNIT,
[Severity: Low]
This isn't a bug, but the advertised ageing range now uses the new
YT921X_AGEING_TIME_UNIT. The function that programs the register still
uses a literal:
drivers/net/dsa/motorcomm/chip.c:yt921x_dsa_set_ageing_time() {
...
/* AGEING reg is set in 5s step */
ctrl = clamp(msecs / 5000, 1, U16_MAX);
...
}
Should yt921x_dsa_set_ageing_time() use YT921X_AGEING_TIME_UNIT, or the
series data? Then the range DSA validates against and the value written
to YT921X_AGEING would come from one definition.
Later in the series, YT922X_AGEING_TIME_UNIT is added with a value of
6000U. The YT922x ops don't install .set_ageing_time today, so nothing is
mismatched yet. The two values could drift apart if the op were ever
shared.
> + .dscp_prio_mapping_is_global = true,
> + .assisted_learning_on_cpu_port = true,
> + .switch_ops = &yt921x_dsa_switch_ops,
> + .mac_ops = &yt921x_phylink_mac_ops
> + },
> +};
> +
> +static const struct yt92xx_series *yt92xx_series_lookup(u32 major)
> +{
> + if (major == YT9215_MAJOR || major == YT9218_MAJOR)
> + return &yt92xx_series_table[YT92XX_MODE_YT921X];
> + else
> + return NULL;
> +}
[Severity: Low]
The commit message describes this as:
"a data-driven lookup by the chip ID and Major"
However, yt92xx_series_lookup() is a hardcoded if-chain over the majors.
The supported majors are already listed in yt921x_infos[]. During .setup,
yt921x_chip_detect() reads YT921X_CHIP_ID again and matches it against
that table. Isn't this a second copy of the same list?
If a major is added to one list and not the other, probe in
yt92xx_register_switch() and setup in yt921x_chip_detect() would disagree
about whether the chip is supported. The later patch "net: dsa:
motorcomm: Add support for Motorcomm YT922x" already has to update both
places for YT9224_MAJOR.
Would it be simpler to add a series pointer to each yt921x_info entry and
do a single detection pass?
> +
> +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);
[Severity: Medium]
Is it safe to read YT921X_CHIP_ID here before the SMI state machine has
been realigned?
This is now the first register access to the switch, and nothing calls
yt921x_reg_mdio_reset() before it. The comment above
yt921x_reg_mdio_reset() describes this ordering as the problem the reset
was added to solve:
* An SMI register access is 4 MDIO frames. An interrupted access leaves the
* machine in an unknown state, and every following access fails or acts on a
* stale address.
...
* Furthermore, the driver verifies the chip id before
* firing the reset, so the reset can never be triggered reliably.
yt921x_reg_mdio_read() only checks MDIO bus return codes. The FSM can be
left misaligned, for example by an interrupted access from a bootloader,
a kexec, or a previous driver instance. In that case the read still
succeeds, but returns 0xdeaddead or stale data. For example, starting in
DHw:
DHw --awr--> AH --awr--> ALr --dr--> 0xdead --dr--> 0xdead
The major then comes out as 0xdead, yt92xx_series_lookup() returns NULL,
and probe fails:
yt921x_mdio_probe()
yt92xx_register_switch()
yt921x_reg_read(priv, YT921X_CHIP_ID, &chipid) /* returns 0 */
yt92xx_series_lookup(0xdead) /* NULL */
return -ENODEV;
This happens before dsa_register_switch(), so .setup never runs and
yt921x_chip_reset() never gets to realign the FSM:
drivers/net/dsa/motorcomm/chip.c:yt921x_chip_reset() {
...
res = yt921x_reg_mdio_reset(priv->reg_ctx);
...
res = yt921x_chip_detect(priv);
...
}
Probe is not retried after -ENODEV. The switch ports stay unavailable
until the driver is manually unbound and rebound.
Before this patch, probe did no register access, so the realign always
ran first. The later YT922x support patch keeps the same read in
yt92xx_register_switch().
Would it work to call yt921x_reg_mdio_reset(priv->reg_ctx) under
reg_lock before this read? Another option is to pick the series from the
OF compatible and leave the chip ID check to yt921x_chip_reset(), after
the realign.
> + if (res) {
> + dev_err(dev, "Failed to read Chip ID with errcode: %d\n", res);
> + return res;
> + }
> +
> + major = FIELD_GET(YT921X_CHIP_ID_MAJOR, chipid);
> + series = yt92xx_series_lookup(major);
> + if (!series) {
> + dev_err(dev, "Unknown Chip ID: 0x%x, or unknown Major: 0x%x\n",
> + chipid, major);
> + return -ENODEV;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202084022.3716891-1-kyle.switch%40motor-comm.com
Technical Details
Message-ID:
<179628824686.3146.10831703982542427707@kernel.org>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376413-linux-kernel-netdev=dewy.ruReferences:
<20261202084022.3716891-2-kyle.switch@motor-comm.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376413-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v18 1/6] net: dsa: motorcomm: initialize dsa_switch based on chipid Date: Thu, 03 Dec 2026 08:57:26 +0000 Organization: Usenet Network Message-ID: <179628824686.3146.10831703982542427707@kernel.org> References: <20261202084022.3716891-2-kyle.switch@motor-comm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2441173"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:IUpeSvb0RGmm8+96TaHNM7X8+jA= sha256:7sxDLKJUxV8ctiJOsM4kwUqk0PAkSiOgIIja++xdBuE= sha1:hQIHDpET8adR1pYrYS1UW78rWDs= sha256:Jev4HV6u8SULRbnrmZh10wX+/u9F7cT8pgA114h/zac= 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 8BB2211788E; Thu, 3 Dec 2026 11:57:49 +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 dUn0uHZDdH4k; Thu, 3 Dec 2026 11:57:45 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376413-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 60A4811787E; Thu, 3 Dec 2026 11:57:36 +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 A839427DA6; Thu, 3 Dec 2026 08:57:30 +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=1796288249; b=BCzUsQJ8mUyLQbgMuxfFKqnU0ErRNFnx9rrwt6jpuBadh4C7xNfqEoHFMrAEkRUtB3W5 BMIiGeGF2x2f67thYLLBucUSNchrPbo0Cl9qNNc1GrHPs9+3LQJP8hFXzvsvClfDuxYn6 PdGffOIwDDHEe6DatkPl/Vp1l7QLLiw5vrKvf+RryL7zV9aGaHafpA1/k1x2mPSjcwmkR GwHilyffBMzHHOLXdubbxBhwdTnN8sUf+soIddJRxLnjZLKilrRE/i+kw2ni+uUj6LNKf CdN60kYVWPrsu8eZtlRHfuaTDNLewP/RX81er5QewaUkGqDP6vnRBLPgc27eLTbOWFg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288249; 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=W+cHc/oGpKm2egd9GJYFQoTlXDXMkahi4/tWf5jyth4=; b=RHnCA04mhfvgAhIGOmfJax6u2DwcCtaYJ+La83cDqCSd9pXkvBma/l38O0NgVjdSGMZk M1uJE3x+xC1smMoZDqM7f/BvJIJLEMW5aiEaVHhsEJs0fJ36zIhLur1/yUr9KRKjTcVlp CWEqkn7Dr+mGWiLBx96TjYKvL/g7araCcRUWNCGKCNkuh8pcIIXWJAWvL+0Vq2VIOK837 NAt9lN+GsGTR508XJWeNbhpBhTP91Mnjh+n2EeWBeJMmMPgYAQ+YWAhXMrmYkYw9FV9vE uq8Sk1Zf3OVGxviB9AX9d47okJ9BP3/kBbGIX2MNxH3Sy2q/8Vs0onyEQMbF7uXh3LA== 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=YJQAzSsN; 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 B4AB9606A33C; Thu, 3 Dec 2026 08:57:29 +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=YJQAzSsN 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=1796288248; b=fYrtNDLnjE3h6Te9aR/9x8Ro2EYN6Vt3RqP80PCGX+8yVpF1fynRO2fB4bs/L7hhL7K3 8PDb46gcMU/QKjV4lFcuuLGC6o7QddQ+JYy/hlxr7MZgVqFxR5rCohq9cC3dBVaa5pWO+ vNDiksDXnWWd/wyfj6NWnqnHJmAgakzgP4KhvCIfZFKzv2nhy9bo0fIlF1mdHa3cxK0r0 zFsyJ+pq70XZeyqQYtwSWaa68Hvt2R/d3piGasma/+atRO2gV0oblL+/ZwVQpYYrZUiSR Uh8L8MBChtSR15z6OFxCITNVpS9Eq7QLDJf06v9vKh8cx5p2SHMJP2O+8bi+YrXZWKA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288248; 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=W+cHc/oGpKm2egd9GJYFQoTlXDXMkahi4/tWf5jyth4=; b=jELwZnPwa6lYIepJI9//BbLNLSwd0KtMEBDzWY8x1R4FYw5yl3iAz+cKnTrr+dvdk2X3 deBw5iP3vwDEH0sm3/fZzTjR8bLNtR07R1QxxWosfhjn6piwXtUeG7MunXG4l+BI93MmW J5tp14nha5OScKkg/dSF5EcLzOajYDfkaXrJXeV8YFeEA5h6eWBL/KeKfAab5nPF3EAcJ VZ06n/A23O9EhQqVOJbSwWpSy0ANvQYLQWtLeYDLOyvIV8IlJBr2bAS0u7mzZ4KedjVqN Ka/JS2TtsrW4ZGdtzWjRN4jSUIScTqGb5Zvxf9/xtaeovTc4JwdyMNz8BNgX0R7nLVw== 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=YJQAzSsN; 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 D1EA8606A322; Thu, 3 Dec 2026 08:57:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD0B1F00893; Thu, 3 Dec 2026 08:57:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796288248; bh=W+cHc/oGpKm2egd9GJYFQoTlXDXMkahi4/tWf5jyth4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YJQAzSsNYNPQxozAboKgS6tlqD7AdGTWY93sctALXVmwAEKavhbg1vlc3IbpLGCvF dse8ECSvjuixA8EM2mmk2IiYevjPHi5Qb5vXdzXUXrKYQ2UPa1JsykBLBc3lO0b0aS ZG9H6RR9WmMuVLNIGqwBR65xt43SKdegwmwW+vOXzhHuMEOZG9T4seMTIjr05uHdM5 gZEPdPDQZqTxEiSQmY6Oi3SiPk9h8fYG23mu7moOuo2Jd5+rDI++69LSvx2gwVrxlI YxCfVIoml2ZHmazVL4LQySaO7Wgj4FQ4HaOvCdGHCZAaAAOMSbcsNuZbcEieOaXgEY nV4O+i7+TV8gA== X-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, devicetree@vger.kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, david.laight.linux@gmail.com, 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 X-In-Reply-To: <20261202084022.3716891-2-kyle.switch@motor-comm.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