You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/30 07:00:19 UTC
[incubator-nuttx] 05/13: rptun: add rptun_panic for both master & salve
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 7471d096cc22a78387c8e3b7d86e3890e668ddcf
Author: ligd <li...@xiaomi.com>
AuthorDate: Fri Jan 21 16:20:30 2022 +0800
rptun: add rptun_panic for both master & salve
Signed-off-by: ligd <li...@xiaomi.com>
---
drivers/rptun/rptun.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 3187759..3323e66 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -53,8 +53,9 @@
#define RPTUNIOC_NONE 0
#define NO_HOLDER (INVALID_PROCESS_ID)
-#define RPTUN_STATUS_MASK 0xf
-#define RPTUN_STATUS_PANIC 0xf
+#define RPTUN_STATUS_FROM_MASTER 0x8
+#define RPTUN_STATUS_MASK 0x7
+#define RPTUN_STATUS_PANIC 0x7
/****************************************************************************
* Private Types
@@ -311,23 +312,22 @@ static int rptun_callback(FAR void *arg, uint32_t vqid)
{
FAR struct rptun_priv_s *priv = arg;
- if (!RPTUN_IS_MASTER(priv->dev))
- {
- int status = rpmsg_virtio_get_status(&priv->vdev);
+ int status = rpmsg_virtio_get_status(&priv->vdev);
- if (status & VIRTIO_CONFIG_STATUS_NEEDS_RESET)
+ if ((status & VIRTIO_CONFIG_STATUS_NEEDS_RESET)
+ && (RPTUN_IS_MASTER(priv->dev) ^
+ !!(status & RPTUN_STATUS_FROM_MASTER)))
+ {
+ status &= RPTUN_STATUS_MASK;
+ if (status == RPTUN_STATUS_PANIC)
+ {
+ PANIC();
+ }
+ else
{
- status &= RPTUN_STATUS_MASK;
- if (status == RPTUN_STATUS_PANIC)
- {
- PANIC();
- }
- else
- {
#ifdef CONFIG_BOARDCTL_RESET
- board_reset(status);
+ board_reset(status);
#endif
- }
}
}
@@ -725,8 +725,10 @@ static int rptun_dev_reset(FAR struct remoteproc *rproc, int value)
{
FAR struct rptun_priv_s *priv = rproc->priv;
- rpmsg_virtio_set_status(&priv->vdev,
- (value & RPTUN_STATUS_MASK) | VIRTIO_CONFIG_STATUS_NEEDS_RESET);
+ value = (value & RPTUN_STATUS_MASK) | VIRTIO_CONFIG_STATUS_NEEDS_RESET
+ | (RPTUN_IS_MASTER(priv->dev) ? RPTUN_STATUS_FROM_MASTER : 0);
+
+ rpmsg_virtio_set_status(&priv->vdev, value);
return RPTUN_NOTIFY(priv->dev, RPTUN_NOTIFY_ALL);
}
@@ -1097,8 +1099,7 @@ int rptun_reset(FAR const char *cpuname, int value)
priv = metal_container_of(node, struct rptun_priv_s, node);
- if (RPTUN_IS_MASTER(priv->dev) &&
- !strcmp(RPTUN_GET_CPUNAME(priv->dev), cpuname))
+ if (!strcmp(RPTUN_GET_CPUNAME(priv->dev), cpuname))
{
rptun_dev_reset(&priv->rproc, value);
}