๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20401

Re: [PATCH net-next v3 2/4] net: dsa: qca8k: drop MIB autocast frames once the request is over

#20401
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 11:03
93 lines
11337 bytes
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
Technical Details
Message-ID: <179534543662.3135.202577949827301799@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368663-linux-kernel-netdev=dewy.ru
References: <20261118104104.26684-3-kuncy7@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368663-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179534543662.3135.202577949827301799@kernel.org>
References: <20261118104104.26684-3-kuncy7@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3618302"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7Q6OorfzMqEtTy1QcuMiLxE7NtU= sha256:z2NrobJ1H05EQT37nbAse8P2q+8WsX1FBzTrBG26G1g=
	sha1:Frj9jm1uNTmLTyPJxzQTz0xA2ec= sha256:OaUbJld9DNpq/eBbz6lTvt4wQjByjF669+R5YB96Eps=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1673B125D76; Sun, 22 Nov 2026 14:04:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Df2pqMmvlBxJ;
	Sun, 22 Nov 2026 14:04:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368663-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id DA1A0125D75; Sun, 22 Nov 2026 14:04:08 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2A59B30221; Sun, 22 Nov 2026 11:04:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795345444;
	b=JcRKx5VeBIuswBg8rjKXNnzddbAbXGu+NyOFIkoosa6xgH44jIgU4tAcqA7QZ5paFJWd
	 tJABGMGobhJnxw9dQkcVUrc906G7CAiT5sONSFNTNsIqpcYuNhjsFYLZl5VGhmdktVCPh
	 st/ZYkSCJWR+FbiuRlGTQOxacUj8/5xtyv68GutDAOsVBarojzWtmemWzrdBhEgr+Oz5Y
	 D9HG7WJjEIRkmwp35iuiDdkm1iz+WzXl95P9UDP7xwiMtjkIvT5GyMOt00tGZUR/IZB9T
	 aCOsUTen/ai4k/QHBJ+tuLx7Q48EKIYRpMMPgdOrErJvDVq+FDWrUV72LzIZ9ilMlow==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795345444;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=zlL5tiXLL4jgQNgfM7bff8pxYMFjionRbtAB8mOGuHc=;
	b=AgeEcBCvC4pysuQgTj4nAwbAR8vivNMR6QrXgJU0Foeqk8WRKbXuiIi8CwxlaWwr1Uff
	 PX0N7vtfHDy6iVJOmHq30JzD+8G+jBfgxb/JWMap54wiR3bAxdplWKkxPPBCoOqRMZAgF
	 qw6/iH/1ICBEfKRyf7Hlqj1+a6yXMh62w9RVd9b0iL16mRCygeXC/hwG1T4LI1IvM/eN4
	 cw8lOjJhS1kVBOAgtsTY5s3E7/tKJWiuBt3LQu1zJEXAKBQBKfUrc9csECekWwKT0Iiyx
	 oaF3rYVnYpxbVH3mSOKVS6U1Gf9VuvpLVmnfthSus3Acd9O9FCUkpWvaLq8sIgeMwNQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CR7MnOVp;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 005C1606A333;
	Sun, 22 Nov 2026 11:04:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CR7MnOVp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795345438;
	b=dftQ2Rr8Thyk0RaCUFkNp1ONWimwYSb3ZVlsTbxghkhc9pKZYA0iK+7r7+IJaCUFutnU
	 O/CHAnRTkTa36HSL0mY19eftrL+rBZ4B+sJq8QiHchBULsabdVXri02cxZ81yfNYC1RIO
	 NVniw2aT0sgY4iGwV5vx0WrIwGG+73bAnsNUTSYie74Pk1yOfe/H3RAHejqICB5PHySBP
	 Jii15ihpBsgmmQLI1m7AbRs1Q736HPjxwlhaxfyAyiNDCrVMWj/eAZTNjJSmpvwrBjub/
	 LEHzzThNes0HD5nYmz/rcbIsjDIqdI8GmNnRbG0zqfr0cWoWraoWxzypxMTW1dWeW4Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795345438;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=zlL5tiXLL4jgQNgfM7bff8pxYMFjionRbtAB8mOGuHc=;
	b=wMS60rzG0yfeuP/wZty1esdxurIBIpLEx485Qf5G/HiHOru/mgoLa/jeejPRnfAZ7Ve2
	 HwsBCgXs9kUIUKOTWJlDsrSfmPLgsGPEdKbGZJmkxJ+1Z78HnYtT5LugFh3AuWVQLJqdx
	 yH7nUC+6shHqOrl5f9q5nx0LMInwahYbG6as+/OdB09BxQodZsOKAKZyWkL4fj14AR4s2
	 NBGZi/YPwmWnZiAHafzYs+PENj0G8FO5SJQqRNu8kHhaQRfF5wLDUu1TnVCOR569Qd9vs
	 uwz2Z9Y3LtSVMjrjBr/y36aMiXpAxIdRCJh71vcEVhmVIQ2Nnn8Uz68oRVZaz6wU1Tg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CR7MnOVp;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C9A9606A320;
	Sun, 22 Nov 2026 11:03:57 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1906E1F000C0;
	Sun, 22 Nov 2026 11:03:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795345437;
	bh=zlL5tiXLL4jgQNgfM7bff8pxYMFjionRbtAB8mOGuHc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=CR7MnOVpKnc0SWYSnG7yiGEba8tE9Dnyb/HqVXow/SnFD+7iqx3nd4DTYR96+6kPF
	 dtKBmOf514bc+gQgkmXBcqE4zlXeeKHHn9XVB2dYGeEbaS2Rbq/2HW+fx3O/G0pqTp
	 kMn7fuFi9pZrokVUfcT4lNQoSM6oWmGejvltrMIl7eHzSiItqDzw0EUF0bbTA8BW/g
	 8fUYl2+9gy+v79usD8Z/BTo/4cQhm/ssWCuuie4+vdWa9fT//kcn0MsQ/5E+pWYB5s
	 8No2ty3hV7XRk2gOcTluBT5IlCnzJAdaTb9plJdQP4c7/qI2/SOGeJk6oMViS8kFfC
	 2osjLtn/ebjbw==
X-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
X-In-Reply-To: <20261118104104.26684-3-kuncy7@gmail.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list