🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7755

[PATCH v8 1/2] can: dev: can_fill_info(): don't wake up controller if interface is down

#7755
From: ChunYuZhiQiang
Date: Tue, 27 Oct 2026 06:50
75 lines
11902 bytes
If the interface is down, the CAN controller might be powered down and
its clocks gated. Don't call do_get_berr_counter() to read the bus error
counters if the interface is down, and adjust can_get_size() to match.

This removes one trigger for a synchronous external abort seen on
i.MX8QXP when "ip link show" is run on a flexcan interface that was
never brought up. The underlying cause is platform-specific: on i.MX8QXP
the CAN clocks are gated through the SCU LPCG and the subsystem shares
the IMX_SC_R_CAN_0 power domain, and there is a window after
pm_runtime_resume_and_get() returns where the clock has not reached the
module yet. This patch avoids the netlink query path while the interface
is down, but does not root-cause the LPCG window itself.

As a result, IFLA_CAN_BERR_COUNTER is no longer reported for down
interfaces. Userspace must treat the attribute as optional.

The issue was triggered on an i.MX8QXP board by running "ip link show"
without ever bringing the interface up:

    Internal error: synchronous external abort: 0000000096000210

    pc : flexcan_read_le+0x0/0x18
    lr : flexcan_get_berr_counter+0x4c/0x8c
    Call trace:
     flexcan_read_le+0x0/0x18
     flexcan_get_berr_counter+0x4c/0x8c
     can_fill_info+0x1f8/0x434
     rtnl_fill_ifinfo+0x8fc/0xbb4
     rtnl_dump_ifinfo+0x364/0x448

This is the same class of problem fixed for m_can in
commit 91a55c72a821 ("can: m_can: m_can_get_berr_counter(): don't
wake up controller if interface is down").

Fixes: ec56acfef2af1 ("can: flexcan: flexcan_get_berr_counter(): switch on clocks before accessing ecr register")
Cc: stable@vger.kernel.org
Signed-off-by: ChunYuZhiQiang <chunyuzhiqiang@yinhe.ht>
---
v8:
 - Split the TDCV gating into a separate net-next-only patch.
 - Drop the "generic logic problem that exists on all platforms"
   wording. This patch removes one trigger, it is not a root-cause fix
   for the i.MX8QXP LPCG clock window.
 - The Fixes: tag points to ec56acfef2af1 because this patch supersedes
   the down-interface readback behavior it introduced, not because that
   commit was buggy.
---
 drivers/net/can/dev/netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index 766d455950f5..b958c04d53db 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -812,7 +812,7 @@ static size_t can_get_size(const struct net_device *dev)
 	size += nla_total_size(sizeof(u32));			/* IFLA_CAN_STATE */
 	size += nla_total_size(sizeof(struct can_ctrlmode));	/* IFLA_CAN_CTRLMODE */
 	size += nla_total_size(sizeof(u32));			/* IFLA_CAN_RESTART_MS */
-	if (priv->do_get_berr_counter)				/* IFLA_CAN_BERR_COUNTER */
+	if (priv->do_get_berr_counter && netif_running(dev))	/* IFLA_CAN_BERR_COUNTER */
 		size += nla_total_size(sizeof(struct can_berr_counter));
 	if (priv->termination_const) {
 		size += nla_total_size(sizeof(priv->termination));		/* IFLA_CAN_TERMINATION */
@@ -1006,7 +1006,7 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	    nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) ||
 	    nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) ||
 
-	    (priv->do_get_berr_counter &&
+	    (priv->do_get_berr_counter && netif_running(dev) &&
 	     !priv->do_get_berr_counter(dev, &bec) &&
 	     nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) ||
 
-- 
2.47.3
Technical Details
Message-ID: <20261027065012.191348-1-chunyuzhiqiang@yinhe.ht>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352244-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352244-linux-kernel-netdev=dewy.ru
From: chunyuzhiqiang@yinhe.ht (ChunYuZhiQiang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v8 1/2] can: dev: can_fill_info(): don't wake up controller if interface is down
Date: Tue, 27 Oct 2026 14:50:11 +0800
Organization: Usenet Network
Message-ID: <20261027065012.191348-1-chunyuzhiqiang@yinhe.ht>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1480829"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HqIlyfhtY8+tb6FgdeuZGO5SpOs= sha256:5sRGgzGFC3mWk236Jx0TuCbAkoqEB5avw4pPC6I2Srw=
	sha1:2/stlk7K+yQjeTHukSAn1LrwEPk= sha256:dL7YQEVVzPWEX2vpgcfOLcxEenWLpXHAG9d4+aWJe54=
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 AC98F125BDB; Tue, 27 Oct 2026 09:56:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, UNPARSEABLE_RELAY=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=yinhe.ht
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 hImVF_jm08ap;
	Tue, 27 Oct 2026 09:56:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-352244-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=yinhe.ht
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id AF909125BDD; Tue, 27 Oct 2026 09:55:56 +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 63A4E29A39; Tue, 27 Oct 2026 06:54:32 +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=1793084072;
	b=F5YFrq5POZeh8AKEXj9/qVMzS3gtfZJKZeFY6H0Ze5TMshqAUkBNcFPYtRAavrbdgNb/
	 WH5qPkEWRevrKQaroPThY4HbMkVgmpM5fXwDkVWg9ccdYUObCgat0rzHcXqgTb0mICGut
	 h3DYaYQakedfrZuKylAjGwK6YBl2EcRyvyMswIbs/TNjYIWu9qZo2+Tia3LPhyDVTdJX3
	 Gwvipr6P5+kskNWWHKg00lKDYO+RcYB+NVYLuN5aYA18rQPKMExOP+2oLWcuoOg/NwH/R
	 RVSlTCg8L8MvpkeoBDGyhhGkQsxKTp1tVZDDUoNMRmn/IFekEVsi3qxkkeLYfmAYoaQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793084072;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=YrOHwr2cBOrKGm18bmWaUo32ETpL71CCu8ZjYKcsUSw=;
	b=rBQbLKX9emgWzIiTQcKpjR5xWgNuKR9Y0+z8Wa2Rzwd0fwvDs6qZ2yrps7AWeHEAc2rc
	 G93bgXlyInWx+/4tE8z5B1R/sYnoo4FjilF2GNsIJtIJ2zUDr3cQszgSgN4Xs1IGBlZjf
	 MVM6T7BNVrR7K53dbwffGbxJaOqARpakE+5EEQiBlN17UC0vaIUdWTsQaFHkv7baCLMjm
	 yznhkxo4f1TMUxpgaZzVfZvIrSvVD9Q3GqBiiS1QXNnnrWyIkBDxSIeAVqejM+WIqFKfV
	 +RvYrfaGo0dSJ7S0WsJ1RS5Yzq9/GhHfPIkjM+LYy2kaENeQLODkHvaWe2WemMfEXBg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=yinhe.ht header.i=@yinhe.ht header.a=rsa-sha256 header.s=default header.b=Wk5P6q9e;
	dmarc=none header.from=yinhe.ht;
	spf=pass smtp.mailfrom=yinhe.ht;
	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 EC833606A321;
	Tue, 27 Oct 2026 06:54:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=yinhe.ht header.i=@yinhe.ht header.a=rsa-sha256 header.s=default header.b=Wk5P6q9e
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.218
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793084071;
	b=HnYrwoI8+kr7Mads5W78gDJiexJcCR/LPOUvQJY9MkqaB+edS0a/1z9LImtDIbYcBiO8
	 79Bm0R4qZ76WPnHxL+aLzJYTLARN5km2xprviZkzmHhDtDSRcQs4MCo7eqiVdtTJge/P0
	 wuFMYuGckv4WstkwBs/zTJ94uhy0nEDl4i0KMyOaZMszKhPvgHPlY46Agg8B97DgWt8Bs
	 yjbo6PbzmxI6FR+Gfq4uwawFsm+ghh3Rz50WWWXY5PGcYGp9edjwqKkwi1Akh2EPUJjxD
	 Q+T/tGiJfJQcjAb3VEdjhgLMHYfMnoM+Qb9icuDoCWN4/+WTt/xi0hZaiHkJ41WkNIQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793084071;
	h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=YrOHwr2cBOrKGm18bmWaUo32ETpL71CCu8ZjYKcsUSw=;
	b=Y9yw0re5OrqnEbG/MO9fG6AEf04VRkrLr7dEfsrno/kbuUwyiT4AmxNVl/PDe1MP7ubR
	 3C2xoRFnefcPIvaEMf343p+4bOjHhB/NpVJ2Lei2hemzRCay+z1Yuy6wK864g2VBVhwuA
	 dTpJACg5QY1BfzPWPSl5DmhE/lJzQmDg1RtakfoRxYavEEXNDGvAFw6uxyBaxNDssaBvb
	 1mVH6kwU5LByXXomH6b3x5RRGYk+jxl9gQ4P7jo53NtD/KH7zXyKX87VyzfklX/4oktdf
	 OXqQJHeNxlgVnwa3GEBeaa54VLLYs+v0CQmYk108UMugDh7PEjzd4G/h27y2tbtp0Rw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=yinhe.ht;
	spf=pass smtp.mailfrom=yinhe.ht;
	dkim=pass header.d=yinhe.ht header.i=@yinhe.ht header.a=rsa-sha256 header.s=default header.b=Wk5P6q9e;
	arc=none smtp.remote-ip=115.124.28.218
X-Received: from out28-218.mail.aliyun.com (out28-218.mail.aliyun.com [115.124.28.218])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB7D0606A32A;
	Tue, 27 Oct 2026 06:54:27 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB7D0606A32A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=yinhe.ht
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yinhe.ht
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=yinhe.ht; s=default;
	t=1793084059; h=From:To:Subject:Date:Message-ID:MIME-Version;
	bh=YrOHwr2cBOrKGm18bmWaUo32ETpL71CCu8ZjYKcsUSw=;
	b=Wk5P6q9eUxyIVuAI8yo2sGK/lTGTo9l4726PmFzJS7QtquNw/58guZNZ35B9x1fJfi8aU3Z8vDows9+2kxYpnjzpVG6qQS6bcANBF9MlwD+fZwkg/qhnl3PKFIKiJbXyxtNpiFKB1F8Zt56DhPDvvm+g8Cuee4x7MW/1BQx4hcLrG5H0AMrfCqLQnm00G6Icy3BSsNefm+XKgaxbesfd7IKz4VYQ+rDImEi+EQjU8AsIFkB/66dDa5IG+wwYVx/oXDXTi/yUnisBsbmc0xAFvZAq47NsOieXqLohhpInkIFPU/VJx0S8/uKnnLyugCqlHsmTjtbpwZYz0qZh+DcmsA==
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07478032|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0924047-0.00429912-0.903296;FP=13982794750684426156|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam011083099174;MF=chunyuzhiqiang@yinhe.ht;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.jqWjvoC_1793084058;
X-Received: from galx..(mailfrom:chunyuzhiqiang@yinhe.ht fp:SMTPD_---.jqWjvoC_1793084058 cluster:ay29)
          by smtp.aliyun-inc.com;
          Tue, 27 Oct 2026 14:54:19 +0800
X-Cc: netdev@vger.kernel.org,
	linux-can@vger.kernel.org,
	mkl@pengutronix.de,
	mailhol@kernel.org,
	kernel@pengutronix.de,
	haibo.chen@oss.nxp.com,
	shawnguo@kernel.org,
	imx@lists.linux.dev,
	stable@vger.kernel.org,
	ChunYuZhiQiang <chunyuzhiqiang@yinhe.ht>
X-Mailer: git-send-email 2.47.3
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