๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21357

Re: [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend

#21357
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 22:44
100 lines
11900 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch fixes the profile-index/hardware mismatch only in
  bcmgenet_init_dim().

--

net: bcmgenet: keep DIM from getting stuck after close or suspend

The patch moves net_dim() so it runs before napi_complete_done() in the
RX poll, and it flushes the DIM work on close/suspend instead of
cancelling it. It also resets the DIM state in bcmgenet_init_dim() and
starts profile_ix from the default profile, so that it matches what
bcmgenet_init_rx_coalesce() programs into the hardware.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 4d2be2a21ed1b..f702916e7bfaf 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c

[ ... ]

> @@ -2702,8 +2703,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
>  {
>  	struct bcmgenet_net_dim *dim = &ring->dim;
>  
> +	memset(&dim->dim, 0, sizeof(dim->dim));
>  	INIT_WORK(&dim->dim.work, cb);
>  	dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
> +	/* Match the profile bcmgenet_init_rx_coalesce() programs */
> +	dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;

[Severity: Medium]
Does the same profile index mismatch still happen through the ethtool
path?

bcmgenet_init_dim() only runs from bcmgenet_init_rx_ring(), which means
on open or resume. The default profile is also written to the hardware
at runtime by bcmgenet_set_ring_rx_coalesce(), and that path does not
touch ring->dim.dim:

drivers/net/ethernet/broadcom/genet/bcmgenet.c:bcmgenet_set_ring_rx_coalesce() {
    ...
	if (ec->use_adaptive_rx_coalesce && !ring->dim.use_dim) {
		moder = net_dim_get_def_rx_moderation(ring->dim.dim.mode);
		usecs = moder.usec;
		pkts = moder.pkts;
	}

	ring->dim.use_dim = ec->use_adaptive_rx_coalesce;
	bcmgenet_set_rx_coalesce(ring, usecs, pkts);
}

Here is one sequence on a running interface. DIM moves to profile 3.
Then the user runs "ethtool -C ethX adaptive-rx off" followed by
"ethtool -C ethX adaptive-rx on". The hardware now has the default EQE
profile, but profile_ix, tune_state, steps, prev_stats and start_sample
still hold the values from before adaptive-rx was turned off.

On the next net_dim(), net_dim_decision() steps from the stale
profile_ix. bcmgenet_dim_work() then programs a profile that is a
neighbour of 3 instead of a neighbour of the default.

If tune_state is DIM_PARKING_ON_TOP and traffic is steady, no work gets
queued at all. The hardware then stays on the default profile while DIM
believes another profile is active.

This looks like the "profile index no longer matches the hardware"
state the commit message describes, reached here without any close or
suspend. Would it make sense to reset ring->dim.dim (state and
profile_ix) in bcmgenet_set_ring_rx_coalesce() whenever the default
profile is programmed?

A related case: when adaptive-rx is already on, any "ethtool -C" call
skips the default-profile branch. It writes the static
rx_coalesce_usecs/rx_max_coalesced_frames into every RX ring, while DIM
keeps its old profile_ix.

bcmgenet_get_coalesce() reports ring 0's hardware values. So in that
case, could rings other than ring 0 end up with ring 0's DIM-chosen
values while their own DIM state points somewhere else?

>  	dim->event_ctr = 0;
>  	dim->packets = 0;
>  	dim->bytes = 0;

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-nb-genet-dim-stats-net-v2-0-1a7cece7dd1a%40tipi-net.de
Technical Details
Message-ID: <179547388219.3135.3983701344870558554@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369823-linux-kernel-netdev=dewy.ru
References: <20261120-nb-genet-dim-stats-net-v2-1-1a7cece7dd1a@tipi-net.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369823-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck
 after close or suspend
Date: Mon, 23 Nov 2026 22:44:42 +0000
Organization: Usenet Network
Message-ID: <179547388219.3135.3983701344870558554@kernel.org>
References: <20261120-nb-genet-dim-stats-net-v2-1-1a7cece7dd1a@tipi-net.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4001699"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6dK7KUN7RjpF3c9R3JRjl5rsw/M= sha256:jHcbHMCtZJWW0C2RRbPEJF9K+W44h8Hn5hrqL4msTLM=
	sha1:PY0RzGxW/iAGhW8N1buc7pM0wGY= sha256:2ZqDwUQ5ZRU5/fDh0bic2SkFrhAss1DALwO7Fqunz14=
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 B8A58125DC6; Tue, 24 Nov 2026 01:45:03 +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 AZfk84DPOTf6;
	Tue, 24 Nov 2026 01:44:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369823-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 46A90125DB9; Tue, 24 Nov 2026 01:44:51 +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 AB42D34993; Mon, 23 Nov 2026 22:44:49 +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=1795473889;
	b=xB+F7T+ynStBYbN8m//QwGZO9DYqgaZ30hZHZQm1lavmVQxU6AeXCGfKiy5LPgkMSw0R
	 Y4J+bhFIYaW/9/7XOEzq2JxNgKIp0pJTA4Ndd26YjUoce/LzuD/oPv8cAlRkauHl3DrQT
	 WnDfgQNr91OqCSYBcLQLd715jh3XDde8Ftl5+9/40pptdJZTwsQPupS+BfWO0cTmlXifx
	 Kg9tf8NOL/tKL/1rho4i5LTweb/lgtDYKzvJslum4G3OFAlLs4kJIE/U+40QJD9QotK9l
	 2rJb2UAcZgUuRBYwbiBpkz+m/5/iJ6J3gxkxLRowpnzKdwhb4aN9x9nDcofkaFHQnng==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795473889;
	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=c+0Ma9X2QkRN49uznkQtF/yuoBfodJySs+FWYvD0gu0=;
	b=DWu6gQ4ygWhNMURqUUW2/nMZGNvGda8LuHw1guaxXujSVyPCcthFbiOMhlNF/jAzI7Xz
	 8Fwd2VBo8kEUoV+aBdDKfQDz4hvG274PUD5yyqqTkZ3fvsQWE/YLeF837SB6fxMjHpX6D
	 kXmkGysBpUQ0732/FFKq3LL9rptNFOa/dChvEc7nDq8bdO9VJW/h+7jCRc4e3p8oFCU67
	 +14q1cHxCA5Lh68LGe+/jREfBgcPhnR4OJ87fcFMbOIA/wMXkkIAHtWN4Hp78YCMFGQpS
	 DatmfUhnVgyZOE2LePrDUo0A749oOIlu1zbqtxwJjBYP7ym+p6anZ+B7SO64rPlBmHw==
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=Mq3cIE7P;
	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 81626606A322;
	Mon, 23 Nov 2026 22:44:49 +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=Mq3cIE7P
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=1795473883;
	b=syh36eDRDvRlqn12MJTvg3CGYiNy/GZmbvR+b9pM7LR7eJeIaphlPQZuqs5uBg9be3Q1
	 w6Ra65SCo9r5XZobHwLPYwgAJFs0sCgoQmoTZnHstcPcqx9XhssJJ2xQ65Yil+TMUm/fF
	 LEHu2lqaVRAEbHBcupZUwjs6CVCuHKosmjvWS1zav444sW8RZGPiZCWyJcujujRwDo6tz
	 dcjMZpUO5BVRQ3IC8DiX/7V3aa0M+Gv8Ao9iAo0ZSvBmQ8KocojprFStpzN1D3jvrQQjw
	 5OucxVWx2hS3gttWCogn+jwEhCbdrDFYuf4UGYOCMBIxfaHuoeP8ilI4gFvRQfiO1PQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795473883;
	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=c+0Ma9X2QkRN49uznkQtF/yuoBfodJySs+FWYvD0gu0=;
	b=fo4a2p9RMTZyP7RlH7x6G+fsrcdWXAgJyTnzgvxDwmZHIyWsvxLsECUJgkzTaWzC5z6s
	 95JiFDIIi+CsBeqwSkzcjK7D+lVtK9aauc9K2cvL6Axl8yVNxpAl5mYQPKeyl0GIY1tIf
	 S8Nu83ulQLsam889lr2jR9/rRtYEYwNRivEmfgJHUo7aIi3uRzs405P7cWF6d9b6gWsKt
	 ID2uuAGdmgAPubANgfmCBz17JMKuuKRCsf/4nE27ig7l+A/hltFM0liiFeQ4pcMZ4YPLv
	 xbbDesTeEuWceluwWN8HGB0kPjI1PcAdIVWfx/OcbZQDJEn0wfaNxp+5DPfQ/b503KQ==
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=Mq3cIE7P;
	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 9C004606A31E;
	Mon, 23 Nov 2026 22:44:43 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC52B1F000C0;
	Mon, 23 Nov 2026 22:44:42 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795473883;
	bh=c+0Ma9X2QkRN49uznkQtF/yuoBfodJySs+FWYvD0gu0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Mq3cIE7PCEjhH331bS5NNxyABLMWSJtCf2wfgetyCLwuxYfE8ft2z6jPLU8N5nFaj
	 tDwnaQf9H2Hf36JzjYKAYbD8V6sG98G2K4e8mAZ31BdY+Sbw/FTOjXdzqdHzs1XJJi
	 dJXOnNaTnT8bz18xrCMP3b39KP45pEXLILiYDjjAxV9zBHzSpurw4HiKYjmIBm4vQD
	 UUvNtzr8Kj+gfihq8oXQtLqHcSKLBjKVxuNQ6LuUeFY6QBjxedY3y/h9zbOjyMfSSE
	 YIivlmk98BflO9hKhkYRAvJv+Hi5fU57jLo2YNW1gaU4Jh2pT36bVDjHIa764yRUW0
	 zIzZrLMJ06ZSQ==
X-Cc: opendmb@gmail.com, florian.fainelli@broadcom.com, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 justin.chen@broadcom.com, pgynther@google.com,
 bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261120-nb-genet-dim-stats-net-v2-1-1a7cece7dd1a@tipi-net.de>
X-sashiko-severity: Medium
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