Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kuncy7@gmail.com
Cc: ansuelsmth@gmail.com, andrew@lunn.ch, olteanv@gmail.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, yongzhao.derek@gmail.com,
	luixo-public@luixo.me, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/4] net: dsa: qca8k: drop MIB autocast frames once the request is over
Date: Sun, 22 Nov 2026 11:03:56 +0000	[thread overview]
Message-ID: <179534543662.3135.202577949827301799@kernel.org> (raw)
In-Reply-To: <20261118104104.26684-3-kuncy7@gmail.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] In qca8k_get_ethtool_stats_eth()
  (drivers/net/dsa/qca/qca8k-8xxx.c), the patch now calls…

--

net: dsa: qca8k: drop MIB autocast frames once the request is over

This patch adds a spinlock shared by qca8k_get_ethtool_stats_eth() and the
rx handler to protect the MIB autocast request. The request is retired
(data set to NULL) on exit or once every port has reported, so late frames
no longer write into the freed ethtool buffer. It also replaces the
port_parsed refcount with a ports_seen bitmap, and waits for MIB_BUSY to
clear before sending a new autocast request.

> diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
> index 3c8044a4d1fa1..4de7da9c8ecbe 100644
> --- a/drivers/net/dsa/qca/qca8k-8xxx.c
> +++ b/drivers/net/dsa/qca/qca8k-8xxx.c

[ ... ]

> @@ -1721,13 +1737,25 @@ qca8k_get_ethtool_stats_eth(struct dsa_switch *ds, int port, u64 *data)
>  
>  	mutex_lock(&mib_eth_data->mutex);
>  
> +	mutex_lock(&priv->reg_mutex);
> +
> +	/* A request that timed out may have left the switch still sending
> +	 * its autocast. Let it finish before asking for another one, so
> +	 * that as few of its frames as possible are taken for ours.
> +	 */
> +	ret = qca8k_busy_wait(priv, QCA8K_REG_MIB, QCA8K_MIB_BUSY);
> +	if (ret) {
> +		mutex_unlock(&priv->reg_mutex);
> +		goto out;
> +	}

[Severity: Low]
Is it known when the switch clears MIB_BUSY for the QCA8K_MIB_CAST
function?

The commit message says:

  Wait for MIB_BUSY to clear before asking for the next
  autocast, as qca8k_mib_init() does after a flush, so that at most the
  frames already on their way to the host can be taken for the new
  request

That is only true if BUSY stays set until the switch has sent every
autocast frame. The only other user, qca8k_mib_init(), waits on BUSY
after QCA8K_MIB_FLUSH, and a flush sends no frames. Neither the driver
nor commit 5c957c7ca78c says how BUSY behaves for CAST.

Suppose BUSY clears as soon as the counters are captured. Could all seven
frames of a timed-out autocast then arrive after the new request is
published, and fill ports_seen on their own?

There is also a cost when BUSY never clears, for example if the MIB engine
is wedged or the CPU port cannot transmit. qca8k_busy_wait() polls with
sleep_us = 0 and a QCA8K_BUSY_WAIT_TIMEOUT of 2000 ms:

    return regmap_read_poll_timeout(priv->regmap, reg, val, !(val & mask), 0,
                                    QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC);

Here it runs with both mib_eth_data->mutex and priv->reg_mutex held.
Would each ETHTOOL_GSTATS call then poll back to back for up to 2 s
before falling back to register reads? Other reg_mutex users would be
blocked for that time. Before this patch, the same case cost one 5 ms
completion timeout per call.

>  
>  	reinit_completion(&mib_eth_data->rw_done);
>  
> +	spin_lock_bh(&mib_eth_data->lock);
>  	mib_eth_data->req_port = dp->index;
>  	mib_eth_data->data = data;
> -	refcount_set(&mib_eth_data->port_parsed, QCA8K_NUM_PORTS);
> -
> -	mutex_lock(&priv->reg_mutex);
> +	mib_eth_data->ports_seen = 0;
> +	spin_unlock_bh(&mib_eth_data->lock);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118104104.26684-1-kuncy7%40gmail.com

  reply	other threads:[~2026-11-22 11:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:41 [PATCH net-next v3 0/4] net: dsa: qca8k: fix the MIB autocast and management frame handlers Stanislaw Pal
2026-11-18 10:41 ` [PATCH net-next v3 1/4] net: dsa: qca8k: read each register into its own word over MDIO Stanislaw Pal
2026-11-18 10:41 ` [PATCH net-next v3 2/4] net: dsa: qca8k: drop MIB autocast frames once the request is over Stanislaw Pal
2026-11-22 11:03   ` netdev-bot+sashiko [this message]
2026-11-18 10:41 ` [PATCH net-next v3 3/4] net: dsa: qca8k: check the length of MIB autocast frames Stanislaw Pal
2026-11-18 10:41 ` [PATCH net-next v3 4/4] net: dsa: qca8k: bound the data of a management ack frame Stanislaw Pal
2026-11-19 13:39   ` Stanislaw Pal
2026-11-22 11:03   ` 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=179534543662.3135.202577949827301799@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuncy7@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luixo-public@luixo.me \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=yongzhao.derek@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