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=1795872104; b=mRKtNDqPyIobXXJCGozReB/dIyqKRLzarISpYCzjbAHmhotAQpDjdaQJqEdRIRH9IdPL hLs6OXpCw0lNuxKKG8p9NZTlH2BXL/rhwus0YEKpwegXzwTkD4ytVOnOKgqT7DY+RVlIG AVN7ScWVsdXoIodNxS5B1bU8zt+5C2GbC+7OF4dFoDQm2sXbd4OadZ1iQO1NBZY3orx27 iZ3arPawhl/14m68TmV+o3raIGhQcdu0orugen6PFXJcVqdTR28IuBLZhOUvn0g9UHUG+ Gvzdtg0SKT3uc6scpdd6Ttj6Aj7szC8FNMEDiZk5TiSb7yJNwp4SZrKyL1yj0AaY5NA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795872104; 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=txbrippXbbto//PuUyVFQrF7mD6O+ydugMaLoWLIJYI=; b=DQghCU1yKPgbIFk0OlZPdSJb+rrVYVyxqV8QyN/UbwbI69NbhLGHBuA12ZZLtQ+LNn80 wUJ6CFqaIgzP0VRFpoyJ1OlI3GKmGxIcFk/OA/i5YHVeVaLjwpOMihAJ8Z+xfRDUSF4Nn Z9nxnGB9o7gL/GyMNn1mMPsUG3F2F0OWDsAfDUS5SlgNHz9ADohplC1c/BjXfdXfKbLou y/pxPTpuvtfCqu7MhMudI1x0EvaEk2cAesrG3J/AoaDuRqZyu6xdDZmosLFWnxEXVO/MI iOBea4NEZKyBi7uMX/s68W3gjtR+xyueshh43C/vKxOaYhIxJKI1fpCbwgaMLv9aIvA== 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=HFb0opRg; 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 522EF606A32A for ; Sat, 28 Nov 2026 13:21:44 +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=HFb0opRg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33DF21F000C1; Sat, 28 Nov 2026 13:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795872103; bh=txbrippXbbto//PuUyVFQrF7mD6O+ydugMaLoWLIJYI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=HFb0opRg23ZYEryUbwgIe9gkDGiDQZgWFWOzlvVfa+FqboIf9YNyOLVQOFmtY2pOi jEUnTj39fWc9p/pGRZqa2LPPIiGPTsJgcJBs1KdztOveflWXpy5zkoZCb9Di39aDZl zYUXCqTo16Ghq1MVlvk8L5hvT7alO5WtmHg7s1q88Lf/dSj3l89Zia4qIk7RMZ42py 8WLR69piv7bTW9DoTp44iWLroHcsWGs9CHKTkJ44Lg1vFXGmt4XPb4HGA2gKBN1wgP b8jsg/EJNK4XNm/BMXGgi/L5ceTIlFvGIpKHhC0wUCaUBGJFjXw9Hbd++7uBzJPgv7 A8uJQZG8I6WQA== Subject: Re: [PATCH net 2/2] net: dsa: realtek: rtl8365mb: soft reset switch core after conduit comes up From: netdev-bot+sashiko@kernel.org To: juraj.sladek@littleit.sk Cc: linusw@kernel.org, luizluca@gmail.com, alvin.sipraga@analog.com, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, contact@c127.dev, netdev@vger.kernel.org Date: Sat, 28 Nov 2026 13:21:42 +0000 Message-ID: <179587210275.3135.16334129438019832908@kernel.org> In-Reply-To: <20261127-rtl8365mb-hsgmii-fix-v1-2-f2827126aa6a@littleit.sk> References: <20261127-rtl8365mb-hsgmii-fix-v1-2-f2827126aa6a@littleit.sk> 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 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 5 · 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] The whole switch core is soft-reset (CHIP_RESET.SW_RST) 3 seconds after every time the conduit becomes operational, for as long… - [Medium] The reset is gated only on mb->sds_in_use, but rtl8365mb_pcs_config() sets mb->sds_in_use = true for SGMII as well as… - [Medium] rtl8365mb_conduit_state_change() ignores its `conduit` argument, so the new cancel/schedule logic reacts to every conduit of… - [Medium] On conduit down, rtl8365mb_conduit_state_change() cancels sds_core_reset_work with the non-sync cancel_delayed_work(), which… - [Medium] rtl8365mb_sds_core_reset_work() asserts SW_RST without any lock that serializes it against the driver's other multi-register… - [Low] The new rtl8365mb_sds_core_reset_work() writes CHIP_RESET (0x1322) under different assumptions than the existing code that… -- net: dsa: realtek: rtl8365mb: soft reset switch core after conduit comes up This adds a delayed work that soft resets the switch core (CHIP_RESET.SW_RST) 3 seconds after the conduit becomes operational while the SerDes is in use. The goal is to recover the CPU port on an RTL8367S connected to an IPQ5018 over HSGMII, which sometimes stops forwarding frames from the CPU or forwards them corrupted. The work is cancelled on conduit down, and synchronously in rtl8365mb_teardown(). > diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c > index 54d90121ecd26..f307581107f2e 100644 > --- a/drivers/net/dsa/realtek/rtl8365mb_main.c > +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c [ ... ] > @@ -3094,11 +3096,48 @@ static int rtl8365mb_reset_chip(struct realtek_priv *priv) > 20000, 1e6); > } > > +/* On an RTL8367S connected to an IPQ5018 over HSGMII, the port MAC behind the > + * SerDes occasionally ends up, after the link comes up, in a state where the [ ... ] > +static void rtl8365mb_sds_core_reset_work(struct work_struct *work) > +{ > + struct rtl8365mb *mb = container_of(to_delayed_work(work), > + struct rtl8365mb, > + sds_core_reset_work); > + struct realtek_priv *priv = mb->priv; > + u32 val; > + int ret; > + > + ret = regmap_update_bits(priv->map, RTL8365MB_CHIP_RESET_REG, > + RTL8365MB_CHIP_RESET_SW_MASK, > + RTL8365MB_CHIP_RESET_SW_MASK); [Severity: Low] rtl8365mb_reset_chip() writes the same CHIP_RESET register with priv->write_reg_noack(). It then sleeps 100 ms before polling, with a 1 second timeout: priv->write_reg_noack(priv, RTL8365MB_CHIP_RESET_REG, FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); ... msleep(100); realtek_smi_write_reg_noack() also carries this comment: /* There is one single case when we need to use this accessor and that * is when issueing soft reset. Since the device reset as soon as we write * that bit, no ACK will come back for natural reasons. */ Does SW_RST behave differently on the bus? If it also suppresses the ACK, regmap_update_bits() would fail on SMI-attached switches. The worker would then print "failed to soft reset switch core" even though the reset went out, and it would skip the completion poll. The tested board is MDIO-attached. There, write_reg_noack is realtek_mdio_write(), so the testing would not show this difference. Is a 100 ms poll timeout enough, given the 1 second reset time documented in rtl8365mb_reset_chip()? > + if (!ret) > + ret = regmap_read_poll_timeout(priv->map, > + RTL8365MB_CHIP_RESET_REG, val, > + !(val & RTL8365MB_CHIP_RESET_SW_MASK), > + 1000, 100000); [Severity: Medium] What keeps this reset from overlapping the driver's other multi-register sequences? regmap_update_bits() holds priv->map_lock only for the read-modify-write. regmap_read_poll_timeout() sleeps between reads with map_lock released. So while SW_RST is still asserted, other contexts can start register sequences, for example: phylink poll (mb->pcs.poll = true) -> pcs_get_state -> rtl8365mb_sds_read() (separate ADR write, CMD write, BUSY poll and DATA read) mib_work or ethtool -> rtl8365mb_mib_counter_read() under mib_lock VLAN/L2 table ops -> rtl8365mb_table_access() under map_lock indirect PHY OCP accesses A table operation already in progress holds map_lock throughout, so the reset can't interrupt it. A new one can still start during the reset window, though, and a SerDes or MIB sequence can be split across the reset. The 3 second timer starts at conduit up. That is also when userspace typically creates bridges and adds VLANs and FDB entries. Could writes issued during the reset be lost? Could a PCS poll read a bogus link status and make phylink bounce the CPU link? The commit message says the reset keeps the driver's configuration. Does that only hold for writes that completed before the reset? > + if (ret) > + dev_err(priv->dev, "failed to soft reset switch core: %pe\n", > + ERR_PTR(ret)); > +} [ ... ] > @@ -3108,13 +3147,20 @@ static void rtl8365mb_conduit_state_change(struct dsa_switch *ds, > struct rtl8365mb *mb = priv->chip_data; > int ret; > > - if (!operational || !mb->sds_in_use) > + if (!operational) { > + cancel_delayed_work(&mb->sds_core_reset_work); > + return; > + } [Severity: Medium] rtl8365mb_conduit_state_change() never looks at its conduit argument. rtl8365mb_setup() accepts several CPU ports, and the RTL8367S chip info lists both a SerDes and an RGMII external interface: { 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) }, { 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | PHY_INTF(RGMII) }, Say ports 6 and 7 are both CPU ports, and the RGMII conduit goes down within 3 seconds of the SerDes conduit coming up. Would that cancel the reset meant for the SerDes CPU port? The SerDes conduit stays operational and gets no further up event, so the port could stay in the broken state this patch is meant to recover from. The reverse case: when the RGMII conduit comes up, it passes the global mb->sds_in_use check. That triggers a SerDes datapath reset and a switch-wide SW_RST even though the SerDes link did not change. The same happens when the SerDes is used for a user port and the CPU port is RGMII, since rtl8365mb_phylink_get_caps() advertises SGMII/2500BASEX for any port whose extint supports it. Every conduit up would then reset the whole switch core. Should this check that the conduit is the one behind the SerDes CPU port? > + > + if (!mb->sds_in_use) > return; [Severity: Medium] rtl8365mb_pcs_config() sets mb->sds_in_use for SGMII as well as 2500base-x: if (interface == PHY_INTERFACE_MODE_2500BASEX) { sds_jam = rtl8365mb_sds_jam_hsgmii; ... mb->sds_in_use = true; The commit message and the new comment above rtl8365mb_sds_core_reset_work() describe the problem only for an RTL8367S connected to an IPQ5018 over HSGMII, and only the Archer AX55 was tested. Is it intended that every SerDes user now gets an unconditional switch-core soft reset after conduit up? That includes SGMII setups and the Mercusys MR80X HSGMII board the Fixes: commit was tested on. SGMII support predates commit 987137345f33. Because of the Fixes: tag, stable backports would also change behaviour for SGMII configurations that existed before that commit. Could the commit message cover the wider scope, or could the reset be limited to the affected mode? > > ret = rtl8365mb_sds_reset_datapath(priv); > if (ret) > dev_err(priv->dev, "failed to reset SerDes data path: %pe\n", > ERR_PTR(ret)); > + > + schedule_delayed_work(&mb->sds_core_reset_work, 3 * HZ); [Severity: Medium] This schedules a SW_RST every time the conduit becomes operational, not only on the first bring-up after rtl8365mb_setup(). In net/dsa/user.c, a NETDEV_CHANGE on the conduit calls: dsa_tree_conduit_oper_state_change(dst, dev, netif_oper_up(dev)); It also calls dsa_tree_conduit_admin_state_change() based on qdisc_tx_is_noop(). Both reach dsa_tree_conduit_state_change() -> rtl8365mb_conduit_state_change(). So each of the following resets the switch core 3 seconds later: ip link set down/up on the conduit a conduit carrier flap a conduit driver reset a qdisc change Does that interrupt forwarding on every user port, including bridged user-to-user traffic that never touches the CPU? All of the testing in the commit message is on boots. After a runtime SW_RST, does the L2 LUT keep its contents? That includes the host FDB/MDB entries DSA installs (assisted_learning_on_cpu_port and fdb_isolation are set) as well as learned entries. What about STP state and isolation masks programmed at runtime? Nothing re-applies or checks that state after the reset. Should the reset be limited to the first conduit up after setup? > } [ ... ] > @@ -3323,7 +3371,9 @@ static int rtl8365mb_setup(struct dsa_switch *ds) > static void rtl8365mb_teardown(struct dsa_switch *ds) > { > struct realtek_priv *priv = ds->priv; > + struct rtl8365mb *mb = priv->chip_data; > > + cancel_delayed_work_sync(&mb->sds_core_reset_work); [Severity: Medium] cancel_delayed_work_sync() is only reached through .teardown. On the shutdown path, dsa_switch_shutdown() closes the conduits and unlinks the user ports but never calls ds->ops->teardown: rtl83xx_shutdown() dsa_switch_shutdown() netif_close_many() ... rtl8365mb_conduit_state_change(operational=false) cancel_delayed_work() dev_set_drvdata(priv->dev, NULL); cancel_delayed_work() does not wait for an instance that is already running. The worker can be running for up to about 100 ms (the SW_RST write plus the poll). Can it keep using priv->map after shutdown has returned? The comment on rtl83xx_shutdown() notes that the parent bus may implement .shutdown() as .remove(). In that case devres frees the devm_kzalloc()'d realtek_priv, which also holds struct rtl8365mb and this delayed_work. Would a worker still running then use freed memory? The same non-sync cancel matters at runtime. If the conduit goes down and up while the worker runs, rtl8365mb_sds_reset_datapath() can issue its rtl8365mb_sds_write() sequences while SW_RST may still be asserted. A reset can also complete after the conduit was reported non-operational. The existing per-port mib_work has a similar gap on shutdown. > rtl8365mb_stats_teardown(priv); > rtl8365mb_irq_teardown(priv); > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-rtl8365mb-hsgmii-fix-v1-0-f2827126aa6a%40littleit.sk