This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a1ed075602466aa06145d2ba179f777f417b116e
Author: Bowen Wang <[email protected]>
AuthorDate: Thu May 21 16:58:28 2026 +0800

    drivers/rpmsg/rpmsg_virtio: ignore rx interrupts until the vdev is started
    
    The rx callback is installed through the config, so an rx interrupt can
    arrive while rpmsg_init_vdev_with_config() is still running.
    rpmsg_virtio_rx_dispatch() then reads rvdev->rvq, which is set only after
    the virtqueues are created, and on SMP it can also run concurrently with
    the initial dispatch in rpmsg_virtio_start(). Set an init flag after that
    initial dispatch and ignore rx interrupts before it; the initial dispatch
    handles what arrived earlier.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rpmsg/rpmsg_virtio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c
index df83d862b83..33bdb9fc30e 100644
--- a/drivers/rpmsg/rpmsg_virtio.c
+++ b/drivers/rpmsg/rpmsg_virtio.c
@@ -88,6 +88,7 @@ struct rpmsg_virtio_priv_s
   struct pm_wakelock_s            wakelock;
   struct wdog_s                   wdog;
 #endif
+  bool                            init;
 };
 
 /****************************************************************************
@@ -642,8 +643,13 @@ static void rpmsg_virtio_rx_callback(FAR struct virtqueue 
*vq)
   FAR struct rpmsg_virtio_priv_s *priv =
     metal_container_of(vq->vq_dev->priv, struct rpmsg_virtio_priv_s, rvdev);
 
-  rpmsg_virtio_rx_update(priv, vq);
-  rpmsg_virtio_rx_dispatch(priv);
+  if (priv->init)
+    {
+      /* Start response interrupt when rpmsg virtio initialized */
+
+      rpmsg_virtio_rx_update(priv, vq);
+      rpmsg_virtio_rx_dispatch(priv);
+    }
 }
 
 /****************************************************************************
@@ -806,6 +812,7 @@ static int rpmsg_virtio_start(FAR struct 
rpmsg_virtio_priv_s *priv)
 
   rpmsg_virtio_rx_update(priv, priv->rvdev.rvq);
   rpmsg_virtio_rx_dispatch(priv);
+  priv->init = true;
 
   /* Open tx buffer return callback before the services created below can
    * wait for a tx buffer.

Reply via email to