Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: manuel.janocha@amperfied.com
Cc: s-vadapalli@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org,
	netdev@vger.kernel.org, kuniyu@google.com
Subject: Re: [PATCH net v3 2/4] net: ethernet: ti: cpsw_ale: serialize ALE table accesses
Date: Thu, 03 Dec 2026 10:57:17 +0000	[thread overview]
Message-ID: <179629543778.3146.6031678129130928601@kernel.org> (raw)
In-Reply-To: <20261202-cpsw-ale-lock-v3-2-b40dc361d6b9@amperfied.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The comment this patch adds to struct cpsw_ale
  (drivers/net/ethernet/ti/cpsw_ale.h, lines 99-101) says ale->lock…

--

net: ethernet: ti: cpsw_ale: serialize ALE table accesses

This patch adds a spinlock to struct cpsw_ale. The lock is taken with
spin_lock_bh() in all exported ALE functions that access the table
through the shared index and data registers. With it, concurrent
ndo_set_rx_mode() and VLAN or address operations on different ports can
no longer interleave register accesses and corrupt table entries.

[ ... ]

> diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
> index 87b7d1b3a34a9..f72db771bfa99 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.h
> +++ b/drivers/net/ethernet/ti/cpsw_ale.h
> @@ -96,6 +96,10 @@ struct cpsw_ale {
>  	u32			vlan_field_bits;
>  	unsigned long		*p0_untag_vid_mask;
>  	const struct ale_entry_fld *vlan_entry_tbl;
> +	/* serializes access to the ALE table (index and data registers),
> +	 * the VLAN mask mux registers and p0_untag_vid_mask
> +	 */
> +	spinlock_t		lock;
>  };

[Severity: Low]
This isn't a bug, but is the comment accurate for p0_untag_vid_mask? Only
the writers of the bitmap take the lock. The reader in the same header
does not:

drivers/net/ethernet/ti/cpsw_ale.h:
static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
{
	return test_bit(vid, ale->p0_untag_vid_mask);
}

Its caller, cpsw_rx_vlan_encap() in cpsw_priv.c, runs in the RX path
without ale->lock:

	if (!cpsw_ale_get_vlan_p0_untag(cpsw->ale, vid)) {

The writer is cpsw_ale_set_vlan_untag(). It is reached from
__cpsw_ale_add_vlan(), cpsw_ale_vlan_del_modify_int() and
cpsw_ale_del_vlan(), which all hold ale->lock now. It uses
bitmap_set()/bitmap_clear() with nbits == 1, and these compile to the
non-atomic __set_bit()/__clear_bit().

Would it be clearer to say that the lock serializes writers of
p0_untag_vid_mask and that the RX path reads it without the lock? The
other option is to switch the writer to set_bit()/clear_bit(), which
makes the lockless read explicit.

The comment is also unchanged later in the series apart from the added
mention of the control registers.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-cpsw-ale-lock-v3-0-b40dc361d6b9%40amperfied.com

  reply	other threads:[~2026-12-03 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 10:29 [PATCH net v3 0/4] net: ethernet: ti: cpsw_ale: fix lost ALE entries Manuel Janocha via B4 Relay
2026-12-02 10:29 ` [PATCH net v3 1/4] net: netcp: do not disable interrupts in the VLAN callbacks Manuel Janocha via B4 Relay
2026-12-03 10:57   ` netdev-bot+sashiko
2026-12-02 10:29 ` [PATCH net v3 2/4] net: ethernet: ti: cpsw_ale: serialize ALE table accesses Manuel Janocha via B4 Relay
2026-12-03 10:57   ` netdev-bot+sashiko [this message]
2026-12-02 10:29 ` [PATCH net v3 3/4] net: ethernet: ti: cpsw_ale: serialize control register updates Manuel Janocha via B4 Relay
2026-12-02 10:29 ` [PATCH net v3 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads Manuel Janocha via B4 Relay
2026-12-03 10:57   ` netdev-bot+sashiko

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=179629543778.3146.6031678129130928601@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=manuel.janocha@amperfied.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rogerq@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=vigneshr@ti.com \
    /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