From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD0B1F00893; Thu, 3 Dec 2026 08:57:27 +0000 (UTC) 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== Subject: Re: [PATCH net-next v18 1/6] net: dsa: motorcomm: initialize dsa_switch based on chipid 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, 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 Date: Thu, 03 Dec 2026 08:57:26 +0000 Message-ID: <179628824686.3146.10831703982542427707@kernel.org> In-Reply-To: <20261202084022.3716891-2-kyle.switch@motor-comm.com> References: <20261202084022.3716891-2-kyle.switch@motor-comm.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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