From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v6 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X
Date: Sat, 30 May 2026 00:50:12 +0000 [thread overview]
Message-ID: <20260530005012.E02381F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260527-dsa_lan9645x_switch_driver_base-v6-4-4d409ae64f3c@microchip.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The CPU port is excluded from multicast flooding groups, breaking IPv6 Neighbor Discovery.
- [Medium] The ingress tail drop watermark (SYS_ATOP) for the internal CPU port is left uninitialized, causing CPU-injected frames to be dropped.
- [Medium] A Time-of-Check to Time-of-Use (TOCTOU) race condition in RGMII collision handling allows mutually exclusive ports to be enabled simultaneously.
--
commit 663f05e1c5287dac7978b55faa5152a3c2ee95f8
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
net: dsa: lan9645x: add basic dsa driver for LAN9645X
This commit adds the LAN9645X basic DSA driver with initialization, parent
regmap requests, port module initialization, and phylink integration.
> --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
[ ... ]
> @@ -112,6 +112,323 @@ static int lan9645x_setup(struct dsa_switch *ds)
> + lan9645x_port_cpu_init(lan9645x);
> +
> + /* Multicast to all front ports */
> + lan_wr(front_ports, lan9645x, ANA_PGID(PGID_MC));
> +
> + /* IP multicast to all front ports */
> + lan_wr(front_ports, lan9645x, ANA_PGID(PGID_MCIPV4));
> + lan_wr(front_ports, lan9645x, ANA_PGID(PGID_MCIPV6));
[Severity: High]
Will this configuration exclude the CPU port from multicast flooding groups?
Since front_ports only contains the user ports, BIT(CPU_PORT) is omitted
from the PGID_MC, PGID_MCIPV4, and PGID_MCIPV6 masks. Failing to flood IPv6
multicast traffic to the CPU could break IPv6 Neighbor Discovery (Router and
Neighbor Solicitations).
> +
> + /* Unicast to all front ports */
> + lan_wr(front_ports, lan9645x, ANA_PGID(PGID_UC));
> +
> + /* Broadcast to cpu and all front ports */
> + lan_wr(BIT(CPU_PORT) | front_ports, lan9645x, ANA_PGID(PGID_BC));
> +
> --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_phylink.c
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_phylink.c
[ ... ]
> @@ -103,6 +103,50 @@ static int lan9645x_phylink_mac_prepare(struct phylink_config *config,
> + unsigned int mode,
> + phy_interface_t iface)
> +{
[ ... ]
> + /* RGMII_0 is a 2:1 mux shared between port 4 and port 7. Reject
> + * collisions by looking at current hardware state: the driver
> + * maintains the invariant that RGMII_0_CFG=1 iff port 4 owns
> + * RGMII_0, and for port 7 when GMII_ENA bit 7 is set this implies port
> + * 7 owns RGMII_0.
> + */
> + if (is_rgmii) {
> + hw_cfg = lan_rd(lan9645x, HSIO_HW_CFG);
> + gmii_ena = HSIO_HW_CFG_GMII_ENA_GET(hw_cfg);
> +
> + if (port == 4 && (gmii_ena & BIT(7)))
> + return -EBUSY;
> + if (port == 7 && (gmii_ena & BIT(4)) &&
> + HSIO_HW_CFG_RGMII_0_CFG_GET(hw_cfg))
> + return -EBUSY;
> + }
> +
> + lan_rmw(HSIO_HW_CFG_GMII_ENA_SET(BIT(port)),
> + HSIO_HW_CFG_GMII_ENA_SET(BIT(port)), lan9645x, HSIO_HW_CFG);
[Severity: Medium]
Is there a race condition between reading and writing the HSIO_HW_CFG register?
Phylink mac_prepare callbacks can be invoked concurrently from per-port
workqueues. If ports 4 and 7 negotiate link simultaneously, both could pass the
busy check before either writes its GMII_ENA bit, leading to conflicting
hardware states on the shared RGMII_0 mux. Does this read-modify-write sequence
need switch-level locking?
> --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c
[ ... ]
> @@ -77,6 +77,20 @@ void lan9645x_port_set_tail_drop_wm(struct lan9645x *lan9645x)
> +{
> + int shared_per_port;
> + struct dsa_port *dp;
> +
> + /* Configure tail dropping watermark */
> + shared_per_port =
> + lan9645x->shared_queue_sz / (lan9645x->num_phys_ports + 1);
> +
> + /* The total memory size is divided by number of front ports plus CPU
> + * port.
> + */
> + dsa_switch_for_each_available_port(dp, lan9645x->ds)
> + lan_wr(lan9645x_wm_enc(shared_per_port), lan9645x,
> + SYS_ATOP(dp->index));
[Severity: Medium]
Will this leave the tail drop watermark uninitialized for the CPU port?
The memory size calculation correctly accounts for lan9645x->num_phys_ports + 1
to include the CPU port (index 9). However, dsa_switch_for_each_available_port
only iterates over DSA-known ports (indices 0 to 8). Since SYS_ATOP(9) is
skipped, its watermark remains 0. Could this cause CPU-injected jumbo frames to
be dropped on ingress?
> +
> + /* Tail dropping active based only on per port ATOP wm */
> + lan_wr(lan9645x_wm_enc(lan9645x->shared_queue_sz), lan9645x,
> + SYS_ATOP_TOT_CFG);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260527-dsa_lan9645x_switch_driver_base-v6-0-4d409ae64f3c@microchip.com?part=4
next prev parent reply other threads:[~2026-05-30 0:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 14:49 [PATCH net-next v6 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-27 15:39 ` Jonas Gorski
2026-05-28 10:45 ` Jens Emil Schulz Ostergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot [this message]
2026-05-27 14:49 ` [PATCH net-next v6 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
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=20260530005012.E02381F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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