pkarashchenko commented on a change in pull request #5847:
URL: https://github.com/apache/incubator-nuttx/pull/5847#discussion_r837249928



##########
File path: drivers/rptun/rptun.c
##########
@@ -59,13 +68,24 @@ struct rptun_priv_s
 {
   FAR struct rptun_dev_s       *dev;
   struct remoteproc            rproc;
-  struct rpmsg_virtio_device   vdev;
-  struct rpmsg_virtio_shm_pool shm_pool;
+  struct rpmsg_virtio_device   rvdev;
+  struct rpmsg_virtio_shm_pool tx_shpool;
+  struct rpmsg_virtio_shm_pool rx_shpool;
   struct metal_list            bind;
   struct metal_list            node;
   sem_t                        sem;
-  int                          tid;
   unsigned long                cmd;
+#ifdef CONFIG_RPTUN_WORKQUEUE
+  struct work_s                work;
+#else
+  int                          tid;

Review comment:
       Minor
   ```suggestion
     pid_t                        tid;
   ```

##########
File path: drivers/rptun/rptun.c
##########
@@ -238,56 +259,145 @@ static void rptun_unlock(void)
     }
 }
 
+#ifdef CONFIG_RPTUN_PM
+static inline void rptun_pm_action(FAR struct rptun_priv_s *priv,
+                                   bool stay)
+{
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  if (stay && !priv->stay)
+    {
+      pm_stay(0, PM_IDLE);
+      priv->stay = true;
+    }
+
+  if (!stay && priv->stay && !rptun_buffer_nused(&priv->rvdev, false))
+    {
+      pm_relax(0, PM_IDLE);
+      priv->stay = false;
+    }
+
+  leave_critical_section(flags);
+}
+
+#else
+#  define rptun_pm_action(priv, stay)
+#endif
+
+static void rptun_worker(FAR void *arg)
+{
+  FAR struct rptun_priv_s *priv = arg;
+
+  switch (priv->cmd)
+    {
+      case RPTUNIOC_START:
+        if (priv->rproc.state == RPROC_OFFLINE)
+          {
+            rptun_dev_start(&priv->rproc);
+          }
+        break;
+
+      case RPTUNIOC_STOP:
+        if (priv->rproc.state != RPROC_OFFLINE)
+          {
+            rptun_dev_stop(&priv->rproc);
+          }
+        break;
+    }
+
+  priv->cmd = RPTUNIOC_NONE;
+  remoteproc_get_notification(&priv->rproc, RPTUN_NOTIFY_ALL);
+
+  rptun_pm_action(priv, false);
+}
+
+static void rptun_post(FAR struct rptun_priv_s *priv)
+{
+  int semcount;
+
+  nxsem_get_value(&priv->sem, &semcount);
+  while (semcount++ < 1)
+    {
+      nxsem_post(&priv->sem);
+    }
+}
+
+#ifdef CONFIG_RPTUN_WORKQUEUE
+static void rptun_wakeup(FAR struct rptun_priv_s *priv)
+{
+  work_queue(HPWORK, &priv->work, rptun_worker, priv, 0);
+  rptun_post(priv);
+}
+
+static void rptun_in_recursive(int tid, FAR void *arg)
+{
+  if (gettid() == tid)
+    {
+      *((FAR bool *)arg) = true;
+    }

Review comment:
       Minor
   ```suggestion
     *((FAR bool *)arg) = (gettid() == tid);
   ```




-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to