All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cunhao Lu" <1579567540@qq.com>
Cc: linux-can@vger.kernel.org,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Oliver Hartkopp" <socketcan@hartkopp.net>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH net v5 3/6] can: rockchip_canfd: cancel bus-off restart before closing the device
Date: Thu, 15 Oct 2026 09:57:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-172613@kernel.org> (raw)
In-Reply-To: <20261015-rockchip-canfd-restart-close-v5-3-ae77327037c9@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] can: rockchip_canfd: missing mask flush before free_irq() risks storm
--

commit 761946c971cc50dc5c7a42016ab27b61a872001e
Author: Cunhao Lu <1579567540@qq.com>

can: rockchip_canfd: cancel bus-off restart before closing the device

This patch fixes issues in the driver's close and restart paths by reordering
operations in ndo_stop(). It synchronously cancels restart work earlier, masks
device interrupts, and synchronizes IRQs without disabling the shared IRQ line.

> diff --git a/drivers/net/can/rockchip/rockchip_canfd-core.c b/drivers/net/can/rockchip/rockchip_canfd-core.c
> index 37c1c22c40c9f..4b3db07242395 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-core.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-core.c
[ ... ]
> @@ -356,7 +357,18 @@ static int rkcanfd_set_mode(struct net_device *ndev,
>  
>  	switch (mode) {
>  	case CAN_MODE_START:
> +		rkcanfd_chip_interrupts_disable(priv);
> +		/* Flush the interrupt mask write before suspending the handler. */
> +		rkcanfd_read(priv, RKCANFD_REG_INT_MASK);
> +		/* Keep shared IRQs from accessing the device during restart. */
> +		WRITE_ONCE(priv->irq_suspended, true);
> +		/* Wait for handlers that already passed the suspended check. */
> +		synchronize_irq(ndev->irq);
> +		rkcanfd_timestamp_stop_sync(priv);
> +
>  		rkcanfd_chip_start(priv);
[ ... ]
> @@ -758,6 +775,7 @@ static int rkcanfd_stop(struct net_device *ndev)
>  {
>  	struct rkcanfd_priv *priv = netdev_priv(ndev);
>  
> +	close_candev_cancel_restart_sync(ndev);
>  	netif_stop_queue(ndev);
>  
>  	rkcanfd_chip_interrupts_disable(priv);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Does rkcanfd_stop() also need a readback flush after disabling hardware
interrupts, similar to the one added above in rkcanfd_set_mode()?

Without a readback flush before the subsequent free_irq() call, if the
shared IRQ line receives an interrupt before the posted write reaches
the bus, the CPU could receive the interrupt after the handler has been
deregistered. Could this cause an unhandled interrupt storm that disables
the shared IRQ line entirely?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-rockchip-canfd-restart-close-v5-0-ae77327037c9@qq.com?part=3

  reply	other threads:[~2026-10-15  9:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  9:45 [PATCH net v5 0/6] can: fix bus-off restart and device close races Cunhao Lu via B4 Relay
2026-10-15  9:45 ` Cunhao Lu
2026-10-15  9:45 ` Cunhao Lu via B4 Relay
2026-10-15  9:45 ` [PATCH net v5 1/6] can: dev: prevent bus-off recovery when the interface is not running Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45   ` Cunhao Lu via B4 Relay
2026-10-15  9:56   ` sashiko-bot
2026-10-15 10:22     ` Cunhao Lu
2026-10-15  9:45 ` [PATCH net v5 2/6] can: dev: add close_candev_cancel_restart_sync() Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45 ` [PATCH net v5 3/6] can: rockchip_canfd: cancel bus-off restart before closing the device Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45   ` Cunhao Lu via B4 Relay
2026-10-15  9:57   ` sashiko-bot [this message]
2026-10-15 10:13     ` Cunhao Lu
2026-10-15  9:45 ` [PATCH net v5 4/6] can: rockchip_canfd: prevent timestamp work from rearming after bus-off Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45   ` Cunhao Lu via B4 Relay
2026-10-15  9:45 ` [PATCH net v5 5/6] can: rockchip_canfd: serialize TX with bus-off and restart Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45   ` Cunhao Lu via B4 Relay
2026-10-15  9:45 ` [PATCH net v5 6/6] can: rockchip_canfd: serialize timecounter timestamp conversion Cunhao Lu via B4 Relay
2026-10-15  9:45   ` Cunhao Lu
2026-10-15  9:45   ` Cunhao Lu via B4 Relay

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=sashiko-outbox-172613@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=1579567540@qq.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.