CV-Bowen commented on code in PR #21381:
URL: https://github.com/apache/nuttx/pull/21381#discussion_r4475999367


##########
drivers/rpmsg/rpmsg_virtio.c:
##########
@@ -252,10 +251,83 @@ static bool rpmsg_virtio_is_recursive(FAR struct 
rpmsg_virtio_priv_s *priv)
 
 static void rpmsg_virtio_rx_worker(FAR struct rpmsg_virtio_priv_s *priv)
 {
-  if (rpmsg_virtio_available_rx(priv))
+  FAR struct virtio_device *vdev = priv->vdev;
+  FAR struct rpmsg_virtio_device *rvdev = vdev->priv;
+  FAR struct rpmsg_device *rdev = &rvdev->rdev;
+  FAR struct rpmsg_endpoint *ept;
+  FAR struct rpmsg_hdr *rp_hdr;
+  bool release = false;
+  bool last = false;
+  uint32_t len;
+  uint16_t idx;
+  int status;
+
+  if (!rpmsg_virtio_available_rx(priv))
     {
-      priv->cbrx(priv->rvdev.rvq);
+      return;
     }
+
+  metal_mutex_acquire(&rdev->lock);
+  while (!last)
+    {
+      /* Process the received data from remote node */
+
+      rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx, &last);
+      if (!rp_hdr)
+        {
+          break;
+        }
+
+      rp_hdr->reserved = idx;
+
+      /* Get the channel node from the remote device channels list. */
+
+      ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);

Review Comment:
   Fixed: rpmsg_virtio_rx_worker() drops a message whose length does not fit 
its buffer, as rpmsg_virtio_rx_callback() does.



##########
drivers/rpmsg/rpmsg_virtio.c:
##########
@@ -596,23 +696,24 @@ static int rpmsg_virtio_start(FAR struct 
rpmsg_virtio_priv_s *priv)
       return ret;
     }
 
-  priv->cbrx = priv->rvdev.rvq->callback;
-  priv->cbtx = priv->rvdev.svq->callback;
   priv->notifytx = priv->rvdev.svq->notify;
-  priv->rvdev.rvq->callback = rpmsg_virtio_rx_callback;
-  priv->rvdev.svq->callback = rpmsg_virtio_tx_callback;
   priv->rvdev.svq->notify = rpmsg_virtio_tx_notify;
   priv->rvdev.notify_wait_cb = rpmsg_virtio_notify_wait;
   priv->rvdev.rdev.ns_unbind_cb = rpmsg_ns_unbind;
 
   /* Wake up the rx thread to process message */
 
+  rpmsg_virtio_update_rx(priv, priv->rvdev.rvq);
   rpmsg_virtio_wakeup_rx(priv);
 
   /* Broadcast device_created to all registers */
 
   rpmsg_device_created(&priv->rpmsg);
 
+  /* Open tx buffer return callback */
+
+  virtqueue_enable_cb(priv->rvdev.svq);

Review Comment:
   Fixed: the tx callback is enabled before rpmsg_device_created().



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to