Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v5 9/9] net: dsa: lan9645x: add port statistics
Date: Tue, 19 May 2026 12:27:27 +0000	[thread overview]
Message-ID: <20260519122727.ABC98C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260518-dsa_lan9645x_switch_driver_base-v5-9-968fbf34ffa3@microchip.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Deadlock due to `spin_lock()` being used in both process and softirq contexts without disabling bottom halves.
- [Medium] Duplication of standard kernel statistics in the driver-private `ethtool -S` interface.
--

commit 59f4819b8342d3e4580ddccbc972e0d8f002441f
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
Date:   Mon May 18 12:25:04 2026 +0000

net: dsa: lan9645x: add port statistics

This commit adds support for maintaining and updating a 64-bit software
cache of 32-bit hardware port counters. It introduces multiple ethtool
and netlink statistics callbacks to expose these counters.

> 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
[ ... ]
> +static const struct lan9645x_ethtool_stat lan9645x_port_ethtool_stats[] = {
> +	{ "rx_cat_drop",        SCNT_RX_CAT_DROP },
[ ... ]
> +	{ "rx_green_prio_7",    SCNT_RX_GREEN_PRIO_7 },
> +	{ "tx_drop",            SCNT_TX_DROP },

Is it necessary to include tx_drop in the private ethtool strings?

The networking subsystem guidelines indicate that counters with a standard
uAPI should use that standard interface instead of the driver-private ethtool
output. Since tx_drop is already aggregated and exposed via the standard
netlink interface in lan9645x_stats_get_stats64(), could this be removed
from the private stats?

[ ... ]
> +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);

Can a deadlock occur here if the CPU is interrupted by a softirq?

The sw_lock is acquired with spin_lock() in process-context functions like
this one (which is called via a periodic workqueue), but it is also acquired
in lan9645x_stats_get_stats64() below:

[ ... ]
> +/* Called in atomic context */
> +void lan9645x_stats_get_stats64(struct lan9645x *lan9645x, int port,
> +				struct rtnl_link_stats64 *stats)
> +{
> +	struct lan9645x_stats *s = lan9645x->stats;
> +	u64 *c;
> +
> +	c = STAT_COUNTERS(lan9645x, LAN9645X_STAT_PORTS, port);
> +
> +	spin_lock(&s->sw_lock);

Since lan9645x_stats_get_stats64() can be called from atomic or softirq
context during packet processing, if a softirq interrupts a process holding
the lock on the same CPU, it seems it would spin forever.

Should the process-context paths use spin_lock_bh() instead to prevent this?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260518-dsa_lan9645x_switch_driver_base-v5-0-968fbf34ffa3@microchip.com?part=9

      reply	other threads:[~2026-05-19 12:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 12:24 [PATCH net-next v5 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-05-18 12:24 ` [PATCH net-next v5 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-19 12:27   ` sashiko-bot
2026-05-18 12:24 ` [PATCH net-next v5 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-05-19 12:27   ` sashiko-bot
2026-05-19 16:33     ` Conor Dooley
2026-05-18 12:24 ` [PATCH net-next v5 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-05-18 12:24 ` [PATCH net-next v5 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-19 12:27   ` sashiko-bot
2026-05-18 12:25 ` [PATCH net-next v5 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-05-19 12:27   ` sashiko-bot
2026-05-18 12:25 ` [PATCH net-next v5 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-05-18 12:25 ` [PATCH net-next v5 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-05-18 12:25 ` [PATCH net-next v5 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-05-19 12:27   ` sashiko-bot
2026-05-18 12:25 ` [PATCH net-next v5 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-05-19 12:27   ` 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=20260519122727.ABC98C2BCB3@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