[PATCH v2 1/2] can: virtio: fix RX/TX stall on interrupt before NAPI is enabled

From: Seonghyeon Lim via B4 Relay

Date: Fri Nov 20 2026 - 01:57:57 EST


From: Seonghyeon Lim <forfortuna@xxxxxxxxx>

virtio_can_open() sends the START command before it enables NAPI. Once
the device has started, an RX or TX interrupt can arrive in between.
The interrupt handler then disables the virtqueue callback and calls
napi_schedule(), which does nothing because NAPI is still disabled.
napi_enable() does not schedule a poll either, and only the poll
function re-enables the callback, so the queue can stall until the
device happens to send another interrupt.

Schedule NAPI once after napi_enable(), as virtio-net does in
virtnet_napi_do_enable(). This processes buffers that are already used
and re-enables the callback.

Fixes: 083082a4e6d8 ("can: virtio: Add virtio CAN driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Seonghyeon Lim <forfortuna@xxxxxxxxx>
---
drivers/net/can/virtio_can.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/net/can/virtio_can.c b/drivers/net/can/virtio_can.c
index f67d0bf09681..9055d7e43235 100644
--- a/drivers/net/can/virtio_can.c
+++ b/drivers/net/can/virtio_can.c
@@ -116,6 +116,19 @@ static void virtio_can_napi_enable(struct virtio_can_priv *priv)
if (!priv->napi_active) {
napi_enable(&priv->napi);
napi_enable(&priv->napi_tx);
+
+ /* An interrupt that arrived while NAPI was disabled has
+ * disabled the virtqueue callback but could not schedule
+ * NAPI, so no further interrupt may come. Schedule NAPI once
+ * to process pending buffers and re-enable the callback.
+ */
+ local_bh_disable();
+ virtqueue_napi_schedule(&priv->napi,
+ priv->vqs[VIRTIO_CAN_QUEUE_RX]);
+ virtqueue_napi_schedule(&priv->napi_tx,
+ priv->vqs[VIRTIO_CAN_QUEUE_TX]);
+ local_bh_enable();
+
priv->napi_active = true;
}
}

--
2.43.0