add remote poweroff support
Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
parent
e8550a02b9
commit
378470f611
@ -26,6 +26,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -130,7 +131,7 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
FAR const char *name, uint32_t dest);
|
||||
|
||||
static int rptun_dev_start(FAR struct remoteproc *rproc);
|
||||
static int rptun_dev_stop(FAR struct remoteproc *rproc);
|
||||
static int rptun_dev_stop(FAR struct remoteproc *rproc, bool stop_ns);
|
||||
static int rptun_dev_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
@ -225,25 +226,31 @@ static inline void rptun_pm_action(FAR struct rptun_priv_s *priv,
|
||||
static void rptun_worker(FAR void *arg)
|
||||
{
|
||||
FAR struct rptun_priv_s *priv = arg;
|
||||
unsigned long cmd = priv->cmd;
|
||||
|
||||
switch (priv->cmd)
|
||||
priv->cmd = RPTUNIOC_NONE;
|
||||
switch (cmd)
|
||||
{
|
||||
case RPTUNIOC_START:
|
||||
if (priv->rproc.state == RPROC_OFFLINE)
|
||||
{
|
||||
rptun_dev_start(&priv->rproc);
|
||||
}
|
||||
else
|
||||
{
|
||||
rptun_dev_stop(&priv->rproc, false);
|
||||
rptun_dev_start(&priv->rproc);
|
||||
}
|
||||
break;
|
||||
|
||||
case RPTUNIOC_STOP:
|
||||
if (priv->rproc.state != RPROC_OFFLINE)
|
||||
{
|
||||
rptun_dev_stop(&priv->rproc);
|
||||
rptun_dev_stop(&priv->rproc, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
priv->cmd = RPTUNIOC_NONE;
|
||||
remoteproc_get_notification(&priv->rproc, RPTUN_NOTIFY_ALL);
|
||||
}
|
||||
|
||||
@ -462,10 +469,10 @@ static int rptun_notify_wait(FAR struct remoteproc *rproc, uint32_t id)
|
||||
|
||||
static void *rptun_get_priv_by_rdev(FAR struct rpmsg_device *rdev)
|
||||
{
|
||||
struct rpmsg_virtio_device *rvdev;
|
||||
struct virtio_device *vdev;
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
struct remoteproc *rproc;
|
||||
FAR struct rpmsg_virtio_device *rvdev;
|
||||
FAR struct virtio_device *vdev;
|
||||
FAR struct remoteproc_virtio *rpvdev;
|
||||
FAR struct remoteproc *rproc;
|
||||
|
||||
if (!rdev)
|
||||
{
|
||||
@ -748,16 +755,33 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rptun_dev_stop(FAR struct remoteproc *rproc)
|
||||
static int rptun_dev_stop(FAR struct remoteproc *rproc, bool stop_ns)
|
||||
{
|
||||
FAR struct rptun_priv_s *priv = rproc->priv;
|
||||
FAR struct rpmsg_device *rdev = &priv->rvdev.rdev;
|
||||
FAR struct metal_list *node;
|
||||
FAR struct metal_list *tmp;
|
||||
FAR struct rptun_cb_s *cb;
|
||||
|
||||
rdev->support_ns = stop_ns;
|
||||
|
||||
#ifdef CONFIG_RPTUN_PING
|
||||
rptun_ping_deinit(&priv->ping);
|
||||
#endif
|
||||
|
||||
nxrmutex_lock(&priv->lock);
|
||||
|
||||
metal_list_for_each_safe(&priv->bind, node, tmp)
|
||||
{
|
||||
FAR struct rptun_bind_s *bind;
|
||||
|
||||
bind = metal_container_of(node, struct rptun_bind_s, node);
|
||||
metal_list_del(node);
|
||||
kmm_free(bind);
|
||||
}
|
||||
|
||||
nxrmutex_unlock(&priv->lock);
|
||||
|
||||
/* Unregister callback from mbox */
|
||||
|
||||
RPTUN_UNREGISTER_CALLBACK(priv->dev);
|
||||
@ -779,15 +803,15 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc)
|
||||
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
/* Remote proc stop and shutdown */
|
||||
|
||||
remoteproc_shutdown(rproc);
|
||||
|
||||
/* Remote proc remove */
|
||||
|
||||
rpmsg_deinit_vdev(&priv->rvdev);
|
||||
remoteproc_remove_virtio(rproc, priv->rvdev.vdev);
|
||||
|
||||
/* Remote proc stop and shutdown */
|
||||
|
||||
remoteproc_shutdown(rproc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
From f06b90cdc478124eba45b3be4f3630e8a729c51b Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Tue, 25 Jul 2023 14:25:58 +0800
|
||||
Subject: [PATCH] libmetal: add metal_list_for_each_safe() support
|
||||
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/list.h | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/lib/list.h libmetal/lib/list.h
|
||||
index eb0e7b3..3e8d17f 100644
|
||||
--- a/lib/list.h
|
||||
+++ libmetal/lib/list.h
|
||||
@@ -98,6 +98,10 @@ static inline struct metal_list *metal_list_first(struct metal_list *list)
|
||||
(node) != (list); \
|
||||
(node) = (node)->next)
|
||||
|
||||
+#define metal_list_for_each_safe(list, node, temp) \
|
||||
+ for(node = (list)->next, temp = node->next; \
|
||||
+ node != (list); node = temp, temp = node->next)
|
||||
+
|
||||
static inline bool metal_list_find_node(struct metal_list *list,
|
||||
struct metal_list *node)
|
||||
{
|
||||
--
|
||||
2.25.1
|
||||
|
@ -33,6 +33,9 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
|
||||
""
|
||||
INSTALL_COMMAND
|
||||
""
|
||||
PATCH_COMMAND
|
||||
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0001-libmetal-add-metal_list_for_each_safe-support.patch
|
||||
DOWNLOAD_NO_PROGRESS true
|
||||
TIMEOUT 30)
|
||||
|
||||
|
@ -77,6 +77,7 @@ libmetal.zip:
|
||||
$(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,v$(VERSION).zip,libmetal.zip)
|
||||
$(Q) unzip -o libmetal.zip
|
||||
$(Q) mv libmetal-$(VERSION) libmetal
|
||||
$(Q) patch -p0 < 0001-libmetal-add-metal_list_for_each_safe-support.patch
|
||||
|
||||
.libmetal_headers: libmetal.zip
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user