From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v9 9/9] net: dsa: lan9645x: add port statistics
Date: Thu, 09 Jul 2026 09:19:19 +0000 [thread overview]
Message-ID: <20260709091920.390B11F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260708-dsa_lan9645x_switch_driver_base-v9-9-0d1512a326d7@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Potential spinlock deadlock due to using `spin_lock()` instead of `spin_lock_bh()` for `sw_lock`, which is shared between process context and SoftIRQ context.
--
--- Patch [9]: [PATCH net-next v9 9/9] net: dsa: lan9645x: add port statistics ---
commit 3c87269564235dbc14761981f5b167363d8b2671
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
net: dsa: lan9645x: add port statistics
Add statistics support for the port counters. The driver maintains a 64-bit
software cache and updates it frequently from a delayed work item to handle
hardware overflows.
> diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_stats.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_stats.c
> new file mode 100644
> index 0000000000000..e38f510eb8f66
> --- /dev/null
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_stats.c
> @@ -0,0 +1,929 @@
[ ... ]
> +static void __lan9645x_stats_view_idx_update(struct lan9645x *lan9645x,
> + enum lan9645x_view_stat_type vtype,
> + int idx)
> +{
> + struct lan9645x_stats *s = lan9645x->stats;
> +
> + lockdep_assert_held(&s->hw_lock);
> +
> + if (!__lan9645x_stats_view_idx_hw_read(lan9645x, vtype, idx)) {
> + spin_lock(&s->sw_lock);
[Severity: High]
Could this lead to a deadlock if a softirq interrupts the process context
while the lock is held?
In __lan9645x_stats_view_idx_update() this lock is acquired from the
background workqueue context using a plain spin_lock().
However, lan9645x_stats_get_stats64() is called from atomic/softirq
context and also tries to acquire s->sw_lock:
/* Called in atomic context */
void lan9645x_stats_get_stats64(...)
{
...
spin_lock(&s->sw_lock);
...
}
If a network softirq fires on the same CPU while the background workqueue
holds sw_lock, it seems the softirq would spin forever waiting for the lock.
Should the process-context callers use spin_lock_bh() instead?
> + __lan9645x_stats_view_idx_transfer(lan9645x, vtype, idx);
> + spin_unlock(&s->sw_lock);
> + }
> +}
[ ... ]
> +void lan9645x_stats_get_ethtool_stats(struct lan9645x *lan9645x, int port,
> + u64 *data)
> +{
> + struct lan9645x_stats *stats = lan9645x->stats;
> + u64 *c;
> + int i;
> +
> + c = lan9645x_stats_view_idx_update(lan9645x, LAN9645X_STAT_PORTS, port);
> +
> + spin_lock(&stats->sw_lock);
[Severity: High]
Similar to the background updater above, should this ethtool callback
also use spin_lock_bh() to protect against the softirq reader?
> + for (i = 0; i < ARRAY_SIZE(lan9645x_port_ethtool_stats); i++)
> + *data++ = c[lan9645x_port_ethtool_stats[i].idx];
> + spin_unlock(&stats->sw_lock);
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-dsa_lan9645x_switch_driver_base-v9-0-0d1512a326d7@microchip.com?part=9
prev parent reply other threads:[~2026-07-09 9:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 9:18 [PATCH net-next v9 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-07-09 9:19 ` sashiko-bot
2026-07-08 9:18 ` [PATCH net-next v9 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-07-09 9:19 ` sashiko-bot
2026-07-08 9:18 ` [PATCH net-next v9 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-07-08 9:18 ` [PATCH net-next v9 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-07-09 9:19 ` sashiko-bot [this message]
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=20260709091920.390B11F00A3D@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 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.