Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mkl@pengutronix.de
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	linux-can@vger.kernel.org, kernel@pengutronix.de,
	liucj1228@outlook.com, s.grosjean@peak-system.fr,
	stable@vger.kernel.org
Subject: Re: [PATCH net 13/15] can: dev: can_fill_info(): don't wake up controller if interface is down
Date: Wed, 04 Nov 2026 20:46:50 +0000	[thread overview]
Message-ID: <179382521036.488856.13184139645230625670@kernel.org> (raw)
In-Reply-To: <20261103204305.3211144-14-mkl@pengutronix.de>

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 commit message describes this as removing one trigger of a
  flexcan abort on i.MX8QXP.

--

can: dev: can_fill_info(): don't wake up controller if interface is down

This patch changes can_fill_info() and can_get_size() to skip
IFLA_CAN_BERR_COUNTER when the interface is not running. As a result,
do_get_berr_counter() is never called on a down interface. The goal is
to avoid a synchronous external abort in flexcan_get_berr_counter() on
i.MX8QXP when "ip link show" runs on an interface that was never brought
up.

Link: https://patch.msgid.link/20261027065012.191348-1-chunyuzhiqiang@yinhe.ht

> diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
> index 766d455950f55..b958c04d53db6 100644
> --- a/drivers/net/can/dev/netlink.c
> +++ b/drivers/net/can/dev/netlink.c

[ ... ]

> @@ -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)) ||

[Severity: Medium]
Is this meant to change the output for every CAN driver, and not only
flexcan?

can_fill_info() is the only core caller of priv->do_get_berr_counter.
With this check, no driver that sets the callback will report
IFLA_CAN_BERR_COUNTER on a down interface. can_get_size() gets the same
change.

Several drivers turn on their hardware inside the callback so that this
query works while the interface is down:

drivers/net/can/sun4i_can.c:sun4ican_get_berr_counter() {
    ...
	err = clk_prepare_enable(priv->clk);
    ...
}

drivers/net/can/c_can/c_can_main.c:c_can_get_berr_counter() {
    ...
	c_can_pm_runtime_get_sync(priv);
	err = __c_can_get_berr_counter(dev, bec);
	c_can_pm_runtime_put_sync(priv);
    ...
}

Other drivers do the same thing:

  bxcan_get_berr_counter() calls clk_prepare_enable()
  xcan_get_berr_counter() and ctucan_get_berr_counter() call
  pm_runtime_get_sync()
  rcar_can_get_berr_counter(), rkcanfd_get_berr_counter() and
  flexcan_get_berr_counter() call pm_runtime_resume_and_get()

The commit in the Fixes: tag, ec56acfef2af1, states this intent
directly: "flexcan_get_berr_counter() may be called from userspace even
if the interface is down ... This patch switches on the clocks".

After this change, the wake-up code in those drivers only runs when the
device is already active, so it no longer does anything useful. Should
that code be removed? Or would it be better to put the check in the
flexcan driver instead?

The commit message cites m_can as the precedent. Commit 91a55c72a821
fixed m_can inside the driver:

drivers/net/can/m_can/m_can.c:m_can_get_berr_counter() {
    ...
	/* Avoid waking up the controller if the interface is down */
	if (!(dev->flags & IFF_UP))
		return 0;
    ...
}

That version still sends the attribute, with zeroed counters. With this
patch, m_can sends no attribute at all for a down interface. Is that
change intended?

Because of the flexcan Fixes: tag and Cc: stable, this would be
backported to every stable tree since v3.16. After that, "ip -details
link show" would stop printing berr-counter for down interfaces on all
drivers, including ones where the query always worked.

The commit message does say that the attribute is no longer reported.
Could it also say that this applies to all CAN drivers, and that it
replaces the per-driver support for down interfaces?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103204305.3211144-2-mkl%40pengutronix.de

  reply	other threads:[~2026-11-04 20:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 20:30 [PATCH net 0/15] pull-request: can 2026-11-03 Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 01/15] can: dev: can_dropped_invalid_skb: drop CAN XL frames on non-CAN XL devices Marc Kleine-Budde
2026-11-03 20:48   ` netdev-bot+sinfo
2026-11-05  9:10   ` patchwork-bot+netdevbpf
2026-11-03 20:30 ` [PATCH net 02/15] can: isotp: check the frame type, not just the length Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 03/15] can: skb: make echo skb freeing safe in any IRQ context Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 04/15] can: skb: make CAN skb allocation failure paths IRQ-safe Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 05/15] can: dev: can_put_echo_skb(): free skb on invalid echo index Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 06/15] can: replace ARPHRD_CAN type checks with can_get_ml_priv() Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 07/15] can: isotp: check the return values of can_rx_register() in isotp_bind() Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 08/15] can: protect the receive lists with a per-device lock Marc Kleine-Budde
2026-11-04 20:46   ` netdev-bot+sashiko
2026-11-05  8:10     ` Oliver Hartkopp
2026-11-03 20:30 ` [PATCH net 09/15] can: raw, isotp: copy socket options outside of lock_sock() Marc Kleine-Budde
2026-11-04 20:46   ` netdev-bot+sashiko
2026-11-05  7:47     ` Oliver Hartkopp
2026-11-03 20:30 ` [PATCH net 10/15] can: proc: reset pkg_stats atomics individually Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 11/15] can: proc: skip stats calculation after reset in can_stat_update() Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 12/15] can: proc: remove pointers from CAN specific proc output Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 13/15] can: dev: can_fill_info(): don't wake up controller if interface is down Marc Kleine-Budde
2026-11-04 20:46   ` netdev-bot+sashiko [this message]
2026-11-04 23:08     ` Marc Kleine-Budde
2026-11-05  8:20       ` Paolo Abeni
2026-11-03 20:30 ` [PATCH net 14/15] can: dev: can_tdc_fill_info(): don't read automatic TDCV " Marc Kleine-Budde
2026-11-03 20:30 ` [PATCH net 15/15] can: peak_usb: pcan_usb_fd_decode_buf(): accept short uCAN end-of-list records Marc Kleine-Budde

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=179382521036.488856.13184139645230625670@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=liucj1228@outlook.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=s.grosjean@peak-system.fr \
    --cc=stable@vger.kernel.org \
    /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