mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, cursoragent@cursor.com,
	opendmb@gmail.com, bcm-kernel-feedback-list@broadcom.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, zakkemble@gmail.com,
	horms@kernel.org, ryotkkr98@gmail.com,
	linux-kernel@vger.kernel.org, nb@tipi-net.de
Subject: Re: [PATCH net 2/8] net: bcmgenet: initialize u64 stats seq counter for all queues
Date: Tue, 22 Sep 2026 00:58:46 +0000	[thread overview]
Message-ID: <179003872658.2160803.12033283808833060821@kernel.org> (raw)
In-Reply-To: <20260918000732.276506-3-florian.fainelli@broadcom.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 commit has no Signed-off-by line and carries tool artifacts
  that must not reach upstream: `Change-Id:…

Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but writers to
  the same `tx_rings[i].stats64.syncp` are not mutually exclusive, which…

--

net: bcmgenet: initialize u64 stats seq counter for all queues

bcmgenet_probe() only initialized the u64_stats_sync seq counters up to
priv->hw_params->rx_queues and priv->hw_params->tx_queues, leaving the
seq counters for rings 1..4 uninitialized while ethtool -S still reads
them.  The patch initializes both rx_rings[] and tx_rings[] seq counters
for all GENET_MAX_MQ_CNT + 1 entries.

A couple of questions below, one about the trailer block and one about
the locking around the tx ring syncp that this loop initializes.

>     Fixes: ffc2c8c4a714 ("net: bcmgenet: Initialize u64 stats seq counter")
>     Assisted-by: LLM
>     Co-authored-by: Cursor <cursoragent@cursor.com>
>     Change-Id: I6c3debbd9fa5e7a151789fccf3d9a38db184f434

[Severity: Low]
The trailer block has no Signed-off-by line from the author or submitter,
which Documentation/process/submitting-patches.rst lists as mandatory for
the Developer's Certificate of Origin.  Was it dropped by accident?

The Gerrit Change-Id line is also still present, along with the
Assisted-by and Co-authored-by: Cursor trailers.  Should the Change-Id be
stripped before posting, since stable backport tooling parses this
Fixes:/Signed-off-by trailer block?

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 7b089de9484e3..055e1362173b4 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -4134,10 +4134,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
>  		priv->rx_rings[i].rx_max_coalesced_frames = 1;
>  
>  	/* Initialize u64 stats seq counter for 32bit machines */
> -	for (i = 0; i <= priv->hw_params->rx_queues; i++)
> +	for (i = 0; i <= GENET_MAX_MQ_CNT; i++) {
>  		u64_stats_init(&priv->rx_rings[i].stats64.syncp);
> -	for (i = 0; i <= priv->hw_params->tx_queues; i++)
>  		u64_stats_init(&priv->tx_rings[i].stats64.syncp);
> +	}

[Severity: Medium]
This isn't a bug introduced by this patch, but while looking at the tx
syncp being initialized here: are the writers to a given
tx_rings[i].stats64.syncp actually mutually exclusive on 32-bit?

The NAPI-side writer in __bcmgenet_tx_reclaim() runs with ring->lock
held, taken by bcmgenet_tx_poll() and bcmgenet_tx_reclaim():

	spin_lock_bh(&ring->lock);
	released = __bcmgenet_tx_reclaim(dev, ring);
	...
	u64_stats_update_begin(&stats->syncp);
	u64_stats_add(&stats->packets, pkts_compl);
	u64_stats_add(&stats->bytes, bytes_compl);
	u64_stats_update_end(&stats->syncp);

bcmgenet_timeout() writes the same syncp after bcmgenet_tx_reclaim() has
already dropped that lock:

	bcmgenet_tx_reclaim(dev, ring, true);
	...
	txq_trans_cond_update(txq);

	BCMGENET_STATS64_INC((&ring->stats64), errors);

The timeout callback is invoked from dev_watchdog() as:

	netif_freeze_queues(dev);
	dev->netdev_ops->ndo_tx_timeout(dev, i);
	netif_unfreeze_queues(dev);

which stops queueing but does not quiesce the TX NAPI, so
bcmgenet_tx_poll() for the same ring can be running on another CPU.

On 32-bit, __u64_stats_update_begin() is only:

	preempt_disable_nested();
	write_seqcount_begin(&syncp->seq);

so there is no cross-CPU exclusion and the sequence increment is a plain
read-modify-write.  Can interleaved writers here hand readers such as
bcmgenet_get_stats64() and bcmgenet_get_ethtool_stats() torn 64-bit
values, or leave the sequence permanently odd so that later readers spin
in read_seqcount_begin()?

Would moving the errors increment under ring->lock be appropriate?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260918000732.276506-1-florian.fainelli%40broadcom.com

  parent reply	other threads:[~2026-09-22  0:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  0:07 [PATCH net 0/8] net: bcmgenet: Collection of bug fixes Florian Fainelli
2026-09-18  0:07 ` [PATCH net 1/8] net: bcmgenet: fix 64-bit RTNL stats reading in ethtool on 32-bit systems Florian Fainelli
2026-09-18 10:13   ` Nicolai Buchwitz
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 2/8] net: bcmgenet: initialize u64 stats seq counter for all queues Florian Fainelli
2026-09-18 10:13   ` Nicolai Buchwitz
2026-09-22  0:58   ` netdev-bot+sashiko [this message]
2026-09-18  0:07 ` [PATCH net 3/8] net: bcmgenet: do not skip WoL power up on GENET V1 Florian Fainelli
2026-09-18 10:16   ` Nicolai Buchwitz
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 4/8] net: bcmgenet: clean up RX NAPI on bcmgenet_init_rx_queues failure Florian Fainelli
2026-09-18 10:43   ` Nicolai Buchwitz
2026-09-18 17:39     ` Florian Fainelli
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 5/8] net: bcmgenet: acquire ring lock with BH disabled in bcmgenet_dump_tx_queue Florian Fainelli
2026-09-18 10:57   ` Nicolai Buchwitz
2026-09-18 17:40     ` Florian Fainelli
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 6/8] net: bcmgenet: validate Ethernet address in bcmgenet_set_mac_addr Florian Fainelli
2026-09-18 11:00   ` Nicolai Buchwitz
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 7/8] net: bcmgenet: zero-initialize Transmit Status Block in bcmgenet_add_tsb Florian Fainelli
2026-09-18 11:03   ` Nicolai Buchwitz
2026-09-18 17:41     ` Florian Fainelli
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:07 ` [PATCH net 8/8] net: bcmgenet: mask DMA_TIMEOUT_MASK when reading DMA_RING0_TIMEOUT Florian Fainelli
2026-09-18 10:13   ` Nicolai Buchwitz
2026-09-22  0:58   ` netdev-bot+sashiko
2026-09-18  0:12 ` [PATCH net 0/8] net: bcmgenet: Collection of bug fixes Florian Fainelli

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=179003872658.2160803.12033283808833060821@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=cursoragent@cursor.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ryotkkr98@gmail.com \
    --cc=zakkemble@gmail.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

all inboxes | Powered by JetHome®