You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/26 16:58:32 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5847: rptun related update

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



##########
File path: drivers/rptun/rptun.c
##########
@@ -141,14 +162,14 @@ static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev,
 
 static struct remoteproc_ops g_rptun_ops =
 {
-  .init          = rptun_init,
-  .remove        = rptun_remove,
-  .config        = rptun_config,
-  .start         = rptun_start,
-  .stop          = rptun_stop,
-  .notify        = rptun_notify,
-  .get_mem       = rptun_get_mem,
-  .can_recursive = rptun_can_recursive,
+  .init           = rptun_init,
+  .remove         = rptun_remove,
+  .config         = rptun_config,
+  .start          = rptun_start,
+  .stop           = rptun_stop,
+  .notify         = rptun_notify,
+  .get_mem        = rptun_get_mem,
+  .wait_tx_buffer = rptun_wait_tx_buffer,

Review comment:
       Can we rework this to be C89 compatible init?

##########
File path: drivers/rptun/Make.defs
##########
@@ -22,9 +22,14 @@
 
 ifeq ($(CONFIG_RPTUN),y)
 
-CSRCS += rptun.c
+CSRCS += rptun.c rptun_dump.c
+
+ifeq ($(CONFIG_RPTUN_PING),y)
+CSRCS += rptun_ping.c
+endif
 
 DEPPATH += --dep-path rptun
 VPATH += :rptun
 CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)rptun}
+CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)openamp$(DELIM)open-amp$(DELIM)lib}

Review comment:
       ```suggestion
   ifeq ($(CONFIG_OPENAMP),y)
   CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)openamp$(DELIM)open-amp$(DELIM)lib}
   endif
   ```

##########
File path: drivers/rptun/rptun.c
##########
@@ -814,6 +1009,60 @@ static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev,
  * Public Functions
  ****************************************************************************/
 
+int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem)
+{
+  FAR struct rptun_priv_s *priv;
+  int ret;
+
+  if (!ept)

Review comment:
       do we need to check `sem` for non-NULL here?

##########
File path: drivers/rptun/rptun_ping.c
##########
@@ -0,0 +1,192 @@
+/****************************************************************************
+ * drivers/rptun/rptun_ping.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include <inttypes.h>
+#include <string.h>
+
+#include "rptun.h"
+
+/****************************************************************************
+ * Pre-processor definitions
+ ****************************************************************************/
+
+#ifndef MIN
+  #define MIN(n,m)                  (((n) < (m)) ? (n) : (m))
+#endif
+
+#ifndef MAX
+  #define MAX(n,m)                  (((n) < (m)) ? (m) : (n))
+#endif
+
+#define RPTUN_PING_EPT_NAME         "rpmsg-ping"
+#define RPTUN_PING_SEND             1
+#define RPTUN_PING_SEND_NOACK       2
+#define RPTUN_PING_ACK              3
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+begin_packed_struct struct rptun_ping_msg_s
+{
+  uint32_t                 cmd;

Review comment:
       we can use single space indentation for struct members

##########
File path: drivers/rptun/rptun.c
##########
@@ -814,6 +1009,60 @@ static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev,
  * Public Functions
  ****************************************************************************/
 
+int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem)
+{
+  FAR struct rptun_priv_s *priv;
+  int ret;
+
+  if (!ept)
+    {
+      return -EINVAL;
+    }
+
+  priv = rptun_get_priv_by_rdev(ept->rdev);
+  if (!priv || !rptun_is_recursive(priv))
+    {
+      return nxsem_wait_uninterruptible(sem);
+    }
+
+  while (1)
+    {
+      ret = nxsem_trywait(sem);
+      if (ret >= 0)
+        {
+          break;
+        }
+
+      nxsem_wait(&priv->sem);
+      rptun_worker(priv);
+    }
+
+  return ret;
+}
+
+int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem)
+{
+  FAR struct rptun_priv_s *priv;
+  int semcount;
+  int ret;
+
+  if (!ept)

Review comment:
       do we need to check `sem` for non-NULL here?




-- 
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-unsubscribe@nuttx.apache.org

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