[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260105173342.65654f22@kernel.org>
Date: Mon, 5 Jan 2026 17:33:42 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: David Yang <mmyangfl@...il.com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>, Vladimir Oltean
<olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: yt921x: Protect MIB stats
with a lock
On Mon, 5 Jan 2026 10:09:01 +0800 David Yang wrote:
> - pp->rx_frames = mib->rx_64byte + mib->rx_65_127byte +
> - mib->rx_128_255byte + mib->rx_256_511byte +
> - mib->rx_512_1023byte + mib->rx_1024_1518byte +
> - mib->rx_jumbo;
> - pp->tx_frames = mib->tx_64byte + mib->tx_65_127byte +
> - mib->tx_128_255byte + mib->tx_256_511byte +
> - mib->tx_512_1023byte + mib->tx_1024_1518byte +
> - mib->tx_jumbo;
> -
> - if (res)
> + if (res) {
> dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
> port, res);
> - return res;
> + return res;
> + }
> +
> + rx_frames = mib->rx_64byte + mib->rx_65_127byte +
> + mib->rx_128_255byte + mib->rx_256_511byte +
> + mib->rx_512_1023byte + mib->rx_1024_1518byte +
> + mib->rx_jumbo;
> + tx_frames = mib->tx_64byte + mib->tx_65_127byte +
> + mib->tx_128_255byte + mib->tx_256_511byte +
> + mib->tx_512_1023byte + mib->tx_1024_1518byte +
> + mib->tx_jumbo;
Should this not use mib_new now? (or live inside the spin lock after
copying over?)
> + spin_lock(&pp->stats_lock);
> + *mib = *mib_new;
> + pp->rx_frames = rx_frames;
> + pp->tx_frames = tx_frames;
> + spin_unlock(&pp->stats_lock);
> diff --git a/drivers/net/dsa/yt921x.h b/drivers/net/dsa/yt921x.h
> index 61bb0ab3b09a..0c9d1b6cbc23 100644
> --- a/drivers/net/dsa/yt921x.h
> +++ b/drivers/net/dsa/yt921x.h
> @@ -533,9 +533,14 @@ struct yt921x_port {
> bool isolated;
>
> struct delayed_work mib_read;
> + /* protect the access to mib, rx_frames and tx_frames */
> + spinlock_t stats_lock;
looks like spin_lock_init() is missing
Powered by blists - more mailing lists