mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Cunhao Lu" <1579567540@qq.com>
To: netdev-bot+sashiko <netdev-bot+sashiko@kernel.org>
Cc: mkl <mkl@pengutronix.de>, kernel <kernel@pengutronix.de>,
	mailhol <mailhol@kernel.org>, heiko <heiko@sntech.de>,
	socketcan <socketcan@hartkopp.net>, davem <davem@davemloft.net>,
	edumazet <edumazet@kernel.org>, kuba <kuba@kernel.org>,
	pabeni <pabeni@redhat.com>, horms <horms@kernel.org>,
	corbet <corbet@lwn.net>, skhan <skhan@linuxfoundation.org>,
	rdunlap <rdunlap@infradead.org>, wg <wg@grandegger.com>,
	linux-can <linux-can@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-rockchip <linux-rockchip@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-doc <linux-doc@vger.kernel.org>,
	stable <stable@vger.kernel.org>
Subject: Re: [PATCH net v10 07/10] can: rockchip_canfd: serialize TX with bus-off and restart
Date: Sat, 21 Nov 2026 16:05:44 +0800	[thread overview]
Message-ID: <tencent_890958230A01CC88727EE94DD33400322D08@qq.com> (raw)
In-Reply-To: <179521934168.3131.3588718854244956629@kernel.org>

Hi,

> [Severity: Low]
> This isn't a bug introduced by this patch, but can priv->tc be updated
> here while the IRQ handler is reading it?
>
> [...]
>
> timecounter_read() writes cycle_last, frac and nsec as separate stores.
> Suppose the worker runs on one CPU while the CAN IRQ converts a timestamp
> on another. Can the conversion then combine a new cycle_last with an old
> nsec and produce a wrong hardware timestamp?

Yes, at 07/10 it can. This patch drains timestamp work and IRQ handlers
before restart reinitializes the timecounter. It does not serialize the
worker with timestamp conversion during normal operation. Patch 09/10
puts timecounter_read() and timecounter_init() under timestamp_lock;
10/10 takes the same lock around timecounter_cyc2time() in the IRQ path.

> Separately, the bus-off path in rkcanfd_chip_stop() only does a non-sync
> cancel:
> 
> rkcanfd_timestamp_stop(priv);
> __rkcanfd_chip_stop(priv, state);
>
> Here rkcanfd_timestamp_stop() is cancel_delayed_work(). If the worker is
> already running, it can re-arm itself and keep reading the counter while
> the controller is in reset.

That race also predates 07/10. It is fixed in 09/10: the bus-off path
clears timestamp_active under the same lock the worker holds while
reading the counter. An in-flight read therefore finishes before reset,
and disable_delayed_work() prevents the worker from rearming itself.


> Both appear to be fixed later in this series:
> 
>   "can: rockchip_canfd: serialize timecounter timestamp conversion" holds
>   timestamp_lock around timecounter_cyc2time(), timecounter_read() and
>   timecounter_init().
> 
>   "can: rockchip_canfd: prevent timestamp work from rearming after
>   bus-off" uses disable_delayed_work() and a timestamp_active flag.

Best regards,
Cunhao Lu

  reply	other threads:[~2026-11-21  8:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:39 [PATCH net v10 00/10] can: fix Rockchip TX stalls and bus-off restart/close races Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 01/10] can: rockchip_canfd: prevent TX stall on echo skb failure Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 02/10] can: rockchip_canfd: serialize TX state and command writes Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 03/10] can: dev: check netif_running() before bus-off recovery Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 04/10] can: dev: add close_candev_cancel_restart_sync() Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 05/10] can: rockchip_canfd: cancel bus-off restart before closing the device Cunhao Lu via B4 Relay
2026-11-21  0:02   ` netdev-bot+sashiko
2026-11-21  7:55     ` Cunhao Lu
2026-11-19  8:39 ` [PATCH net v10 06/10] can: rockchip_canfd: disable RX offload on open failure Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 07/10] can: rockchip_canfd: serialize TX with bus-off and restart Cunhao Lu via B4 Relay
2026-11-21  0:02   ` netdev-bot+sashiko
2026-11-21  8:05     ` Cunhao Lu [this message]
2026-11-19  8:39 ` [PATCH net v10 08/10] can: rockchip_canfd: retry the outstanding TX buffer Cunhao Lu via B4 Relay
2026-11-21  0:02   ` netdev-bot+sashiko
2026-11-21  7:49     ` Cunhao Lu
2026-11-19  8:39 ` [PATCH net v10 09/10] can: rockchip_canfd: prevent timestamp work from rearming after bus-off Cunhao Lu via B4 Relay
2026-11-19  8:39 ` [PATCH net v10 10/10] can: rockchip_canfd: serialize timecounter timestamp conversion Cunhao Lu via B4 Relay
2026-11-21  0:02   ` netdev-bot+sashiko
2026-11-21  8:07     ` Cunhao Lu

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=tencent_890958230A01CC88727EE94DD33400322D08@qq.com \
    --to=1579567540@qq.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=heiko@sntech.de \
    --cc=horms@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=socketcan@hartkopp.net \
    --cc=stable@vger.kernel.org \
    --cc=wg@grandegger.com \
    /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

all inboxes | Powered by JetHome®