From fa264ff7e76e75bdc8e53340104c4e1cc09febd3 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 11 Nov 2019 09:09:40 -0600 Subject: [PATCH] drivers/rptun/rptun.c: Refine the start/stop flow to support the repeat boot. --- arch/Kconfig | 1 + drivers/rptun/rptun.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 25b1361ed3..d06a58feaf 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -70,6 +70,7 @@ config ARCH_SIM select ARCH_HAVE_TICKLESS select ARCH_HAVE_POWEROFF select ARCH_HAVE_TESTSET + select ARCH_NOINTC select SERIAL_CONSOLE ---help--- Linux/Cywgin user-mode simulation. diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index cdf13d493e..1d817d8573 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -76,7 +76,6 @@ struct rptun_priv_s struct metal_list bind; struct metal_list node; int pid; - bool started; }; struct rptun_bind_s @@ -369,6 +368,12 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) unsigned int role = RPMSG_REMOTE; int ret; + ret = remoteproc_config(&priv->rproc, NULL); + if (ret) + { + return ret; + } + if (RPTUN_GET_FIRMWARE(priv->dev)) { struct rptun_store_s store = @@ -492,7 +497,6 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) RPTUN_REGISTER_CALLBACK(priv->dev, rptun_callback, priv); - priv->started = true; return 0; } @@ -525,9 +529,9 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc) nxsem_post(&g_rptun_sem); - /* Remote proc stop */ + /* Remote proc stop and shutdown */ - remoteproc_stop(rproc); + remoteproc_shutdown(rproc); /* Remote proc remove */ @@ -544,7 +548,6 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc) kmm_free(bind); } - priv->started = false; return 0; } @@ -557,14 +560,14 @@ static int rptun_dev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) switch (cmd) { case RPTUNIOC_START: - if (!priv->started) + if (priv->rproc.state == RPROC_OFFLINE) { ret = rptun_dev_start(&priv->rproc); } break; case RPTUNIOC_STOP: - if (priv->started) + if (priv->rproc.state != RPROC_OFFLINE) { ret = rptun_dev_stop(&priv->rproc); } @@ -829,9 +832,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) priv->dev = dev; metal_list_init(&priv->bind); - remoteproc_init(&priv->rproc, &g_rptun_ops, priv); - remoteproc_config(&priv->rproc, NULL); if (RPTUN_IS_AUTOSTART(dev)) {