From: Jakub Kicinski <kuba@kernel.org>
To: "Łukasz Majewski" <lukasz.majewski@mailbox.org>
Cc: andrew@lunn.ch, shawnguo@kernel.org, krzk+dt@kernel.org,
linux-kernel@vger.kernel.org, edumazet@google.com,
netdev@vger.kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
davem@davemloft.net, conor+dt@kernel.org, horms@kernel.org,
richardcochran@gmail.com, robh@kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
wahrenst@gmx.net, s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com
Subject: Re: [net-next,v22,2/7] net: mtip: The L2 switch driver for imx287
Date: Tue, 3 Feb 2026 17:47:14 -0800 [thread overview]
Message-ID: <20260203174714.79388301@kernel.org> (raw)
In-Reply-To: <20260203211955.23ef4355@wsk>
On Tue, 3 Feb 2026 21:19:55 +0100 Łukasz Majewski wrote:
> > > +static void mtip_write_atable(struct switch_enet_private *fep, int
> > > index,
> > > + u32 write_lo, u32 write_hi)
> > > +{
> > > + struct addr_table64b_entry __iomem *atable_base =
> > > + fep->hwentry->mtip_table64b_entry;
> > > +
> > > + writel(write_lo, &atable_base[index].lo);
> > > + writel(write_hi, &atable_base[index].hi);
> > > +}
> >
> > Can these functions race with concurrent access? Looking at the
> > callers, mtip_write_atable is called from two different paths:
> >
> > 1. Static entry updates: mtip_config_switch -> esw_mac_addr_static ->
> > mtip_update_atable_static -> mtip_write_atable (no lock held)
> >
> > 2. Dynamic entry updates: timer callback -> mtip_mgnt_timer ->
> > mtip_atable_dynamicms_learn_migration ->
> > mtip_update_atable_dynamic1 -> mtip_write_atable (learn_lock held)
> >
> > The learn_lock only protects the dynamic entry path. The static entry
> > path runs during link changes (mtip_switch_restart called from
> > mtip_adjust_link) without lock protection.
> >
> > Both paths can access the same hash block in the address table
> > (determined by GET_BLOCK_PTR(hash)). If the timer fires during a link
> > change callback, both can concurrently access the table, potentially
> > causing torn reads (reading .lo from one entry version and .hi from
> > another) or torn writes (the entry is in an inconsistent state
> > between the two writel calls).
> >
> > Would extending learn_lock to protect all address table access work,
> > or is a separate hw_lock needed for hardware register access?
> >
>
> This is handled in another way:
>
> 1. Partial write is not possible as this IP block handles it in order
> (with some kind of 'latch' registers):
>
> "VFxxx Controller Reference Manual, Rev. 0, 10/2016"
> 11.5.4 MAC address lookup table
>
> "Each entry must be written or read with the low address accessed first
> followed by the high address"
>
> 2. The code for dynamic IP writing will not "touch" the entries for
> "static" MAC addresses - Figure 11-70 - bit 49 is "Record Type":
> 1 - static entry
> 0 - dynamic entry
>
> IMHO, we are "safe" here.
My reading of the AI's comment was that there is no lock in SW so two
SW threads can write:
Thread A Thread B
write_lo
write_lo
write_hi
write_hi
next prev parent reply other threads:[~2026-02-04 1:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 23:34 [net-next v22 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski
2026-01-31 23:34 ` [net-next v22 1/7] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski
2026-01-31 23:34 ` [net-next v22 2/7] net: mtip: The L2 switch driver for imx287 Lukasz Majewski
2026-02-03 1:39 ` [net-next,v22,2/7] " Jakub Kicinski
2026-02-03 20:19 ` Łukasz Majewski
2026-02-04 1:47 ` Jakub Kicinski [this message]
2026-02-04 9:24 ` Łukasz Majewski
2026-01-31 23:34 ` [net-next v22 3/7] net: mtip: Add buffers management functions to the L2 switch driver Lukasz Majewski
2026-01-31 23:34 ` [net-next v22 4/7] net: mtip: Add net_device_ops " Lukasz Majewski
2026-02-03 1:42 ` [net-next,v22,4/7] " Jakub Kicinski
2026-02-03 10:03 ` Łukasz Majewski
2026-02-03 13:32 ` Andrew Lunn
2026-01-31 23:34 ` [net-next v22 5/7] net: mtip: Add mtip_switch_{rx|tx} " Lukasz Majewski
2026-01-31 23:34 ` [net-next v22 6/7] net: mtip: Extend the L2 switch driver with management operations Lukasz Majewski
2026-01-31 23:34 ` [net-next v22 7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations Lukasz Majewski
2026-02-03 1:44 ` [net-next,v22,7/7] " Jakub Kicinski
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=20260203174714.79388301@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=festevam@gmail.com \
--cc=horms@kernel.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.majewski@mailbox.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=wahrenst@gmx.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.