Article View: linux.kernel.netdev
Article #4332[PATCH net v6 2/6] can: dev: add close_candev_cancel_restart_sync()
From: Cunhao Lu via B4 Relay
Date: Sat, 17 Oct 2026 14:50
Date: Sat, 17 Oct 2026 14:50
79 lines
9004 bytes
9004 bytes
From: Cunhao Lu <1579567540@qq.com>
Drivers may need to wait for bus-off recovery before tearing down the
IRQ and hardware resources used by their restart callback. Calling
close_candev() at that point also flushes echo skbs, which belongs after
the driver has quiesced the users of those buffers.
Add close_candev_cancel_restart_sync() in linux/can/dev.h so drivers can
cancel the core restart work separately, without accessing can_priv's
work item directly. The helper only cancels restart work; callers must
still stop its producers and call close_candev() for the final cleanup.
Use the helper in close_candev(), preserving its existing cancellation
and echo cleanup order.
The following Rockchip fix uses the helper at the start of rkcanfd_stop()
to wait for recovery before IRQ teardown, leaving echo cleanup to
close_candev().
Cc: stable@vger.kernel.org
Signed-off-by: Cunhao Lu <1579567540@qq.com>
---
Changes in v6:
- Describe the helper's use by the following Rockchip fix.
---
drivers/net/can/dev/dev.c | 4 +---
include/linux/can/dev.h | 12 ++++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index d5cb22db2a346..a5f4ce7cb5264 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -535,9 +535,7 @@ EXPORT_SYMBOL_GPL(of_can_transceiver);
*/
void close_candev(struct net_device *dev)
{
- struct can_priv *priv = netdev_priv(dev);
-
- cancel_delayed_work_sync(&priv->restart_work);
+ close_candev_cancel_restart_sync(dev);
can_flush_echo_skb(dev);
}
EXPORT_SYMBOL_GPL(close_candev);
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 6d0710d6f571d..a277d12332f15 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -22,6 +22,7 @@
#include <linux/can/skb.h>
#include <linux/ethtool.h>
#include <linux/netdevice.h>
+#include <linux/workqueue.h>
/*
* CAN mode
@@ -115,6 +116,17 @@ struct can_priv *safe_candev_priv(struct net_device *dev);
int open_candev(struct net_device *dev);
void close_candev(struct net_device *dev);
+
+/* Cancel bus-off restart before tearing down resources used by the restart
+ * callback. The driver must still call close_candev() for the final cleanup.
+ */
+static inline void close_candev_cancel_restart_sync(struct net_device *dev)
+{
+ struct can_priv *priv = netdev_priv(dev);
+
+ cancel_delayed_work_sync(&priv->restart_work);
+}
+
void can_set_default_mtu(struct net_device *dev);
void can_set_cap_info(struct net_device *dev);
int __must_check can_set_static_ctrlmode(struct net_device *dev,
--
2.34.1
Technical Details
Message-ID:
<20261017-rockchip-canfd-restart-close-v6-2-ed605feb4b6e@qq.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347754-linux-kernel-netdev=dewy.ruReferences:
<20261017-rockchip-canfd-restart-close-v6-0-ed605feb4b6e@qq.com>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-347754-linux-kernel-netdev=dewy.ru From: devnull+1579567540.qq.com@kernel.org (Cunhao Lu via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v6 2/6] can: dev: add close_candev_cancel_restart_sync() Date: Sat, 17 Oct 2026 22:50:52 +0800 Organization: Usenet Network Message-ID: <20261017-rockchip-canfd-restart-close-v6-2-ed605feb4b6e@qq.com> References: <20261017-rockchip-canfd-restart-close-v6-0-ed605feb4b6e@qq.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3065970"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ZktEuSowzUyRou00+dQZx8+2QBQ= sha256:pPyaa6WBMNYlX5Ba62m2zEisfmRILG+iVy9IgCIGBQs= sha1:29LOUwy/f+rQVVpwK3qDwDkkFXg= sha256:yEifLjPZNIgp12M8+xgcI4fxbtateArQQSeJ0jKUdXc= 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 D7D9B1106A7; Sat, 17 Oct 2026 17:51:15 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.39 X-Spam-Status: No, score=-3.39 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_REPLYTO_END_DIGIT=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-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 vlpzRky2aH54; Sat, 17 Oct 2026 17:51:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347754-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 714E41106F5; Sat, 17 Oct 2026 17:51:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 8B7C9360CD; Sat, 17 Oct 2026 14:51:00 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867F148F848; Sat, 17 Oct 2026 14:50:56 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AqsBEEtZ" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ABF13CCFB2; Sat, 17 Oct 2026 14:50:56 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792248656; cv=none; b=fn3VkMYYg1Q+9LcsSCddxuM+jxHYulf65T93DLAeRbFXtj9lxl3QjxeU8nPPcUSFe3Ef4JiqwHprKX334FbEGcDk1f3QCh79QfeWmZzABuN8si9++9VDLSI0HqKwP9mryLnrnfv9JSOYUdEycIN49Ul3vIJvETZTnjbSFkkWLOc= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792248656; c=relaxed/simple; bh=OYMczEsHLUYrVedhtGrdoP046Pr5eNXHENmvZsFgWlc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AtxVwXHjQ8nfvpJ96rvUKsabCwxpCjw04H0MiHWQk7b8xrFwriIjAAkRd2FmYAZ3nNKg5ETkn+Fe8C0JQlMK/4EhT5l18nDCzPy9crMi2YI6jWGjwfRbHccct2GlW/KXhUxJz6iUYBFr65RIZZmUiMbjZA22gdrZhmt6gLieGwE= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AqsBEEtZ; arc=none smtp.client-ip=10.30.226.201 X-Received: by smtp.kernel.org (Postfix) with ESMTPS id 1A1A9C2BD00; Sat, 17 Oct 2026 14:50:56 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1792248656; bh=OYMczEsHLUYrVedhtGrdoP046Pr5eNXHENmvZsFgWlc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AqsBEEtZWxIZew94vbtMF/nK1hkPKKQxOI7KuJ1HEkwd29ebUU+2BDSpPKspNpy0u oHsOMv/N8SI3IA5BxGh5FbhRGThX5hBJhXI/V5g/3p48BsQP/1/pJbwRFJhtqgmGIL XDN4CnNxi9GJq0NyKD7NNhM0kTndRTzgB/GP+8hOQBouQzh135p5yW6nGAeUWuj1wb t1MSDDlyxCq33a2Ey2vzw2AG2DfUrOz5su7e4xarXG2OvOkivxP552Wn840d6E4jH1 Ck7b2K5omHe3OUw09ErnkffI1uIqOEBuO5IwUH5ix/liDEHnmQabVJOZnq6CV0TRKo Qg4DVLgOeD4OQ== X-Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3669CCF2C9; Sat, 17 Oct 2026 14:50:55 +0000 (UTC) X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <20261017-rockchip-canfd-restart-close-v6-0-ed605feb4b6e@qq.com> X-Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, stable@vger.kernel.org, Cunhao Lu <1579567540@qq.com> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1792248654; l=2657; i=1579567540@qq.com; s=20261015; h=from:subject:message-id; bh=VwOo682oM6+dAV7fJCgpLEeH4L12b6gOYwxj8t1Ev6Y=; b=KeIFB3H3BBGOrDJgQ59ZE8/YPihhu+tHIiSYSvL6/U1RZuIEWXdVXMQTSm39OXqkVJ+xb0dDp GtLPWHDlOdTD5bA/tuIkmvvhjExqyHaHc5nw2slYCS0UCYfHUZ01LZe X-Developer-Key: i=1579567540@qq.com; a=ed25519; pk=sUTWrzlIwT4C7ctjNfVZAzzg0G7QUn2XxRGpYsw4RtM= X-Endpoint-Received: by B4 Relay for 1579567540@qq.com/20261015 with auth_id=1177 X-Original-From: Cunhao Lu <1579567540@qq.com> X-Reply-To: 1579567540@qq.com