This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c210b821b6a4ed87619321543b325163c2a3e867 Author: wangyongrong <[email protected]> AuthorDate: Fri Apr 24 16:58:33 2026 +0800 drivers/rptun: ask the peer to stop itself when the transport cannot rptun_stop() relied on the transport's stop op to stop the remote core. A transport without one, such as rptun_bmp, left the peer running and unaware that the master had gone. When the master has no stop op, or it returns -ENOTSUP, set a new RPTUN_STATUS_STOP bit (BOARDIOC_SOFTRESETCAUSE_MAX + 1) and notify the peer. The peer sees it in rptun_check_peer_status(), clears its resource table pointer so that a shared interrupt line does not trigger it again, and stops its side with rptun_dev_stop() from the HP work queue. rptun_bmp drops its empty stop op to use this path, and the work item in rptun_priv_s is now always built. The slave side still returns OK from rptun_stop(), so that remoteproc_shutdown() takes it offline. Signed-off-by: wangyongrong <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/rptun/rptun.c | 36 +++++++++++++++++++++++++++++++++--- drivers/rptun/rptun_bmp.c | 7 ------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index 098c221c7dc..ce973a889cf 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -69,6 +69,7 @@ #define rptunvbs(format, ...) syslog(LOG_ALERT, format, ##__VA_ARGS__) #define RPTUN_STATUS_PAUSE BOARDIOC_SOFTRESETCAUSE_MAX +#define RPTUN_STATUS_STOP (BOARDIOC_SOFTRESETCAUSE_MAX + 1) /**************************************************************************** * Private Types @@ -91,9 +92,7 @@ struct rptun_priv_s bool stop; pid_t pid; FAR const void *trace_va; -#if defined(CONFIG_BOARDCTL_RESET) || defined(CONFIG_BOARDCTL_POWEROFF) struct work_s work; -#endif }; struct rptun_store_s @@ -286,7 +285,19 @@ static int rptun_stop(FAR struct remoteproc *rproc) if (RPTUN_IS_MASTER(priv->dev)) { - ret = RPTUN_STOP(priv->dev); + ret = -ENOTSUP; + if (priv->dev->ops->stop != NULL) + { + ret = RPTUN_STOP(priv->dev); + } + + /* The transport cannot stop the peer, ask the peer to stop itself */ + + if (ret == -ENOTSUP) + { + rptun_set_status(priv, RPTUN_STATUS_STOP); + ret = OK; + } } return ret; @@ -934,6 +945,13 @@ static void rptun_boardctl_work(FAR void *arg) } #endif +static void rptun_stop_work(FAR void *arg) +{ + FAR struct rptun_priv_s *priv = arg; + + rptun_dev_stop(&priv->rproc); +} + static void rptun_check_peer_status(FAR struct rptun_priv_s *priv) { uint32_t status; @@ -967,6 +985,18 @@ static void rptun_check_peer_status(FAR struct rptun_priv_s *priv) RPTUN_GET_CPUNAME(priv->dev)); PANIC_WITH_MSG(msg); } + else if (RPTUN_STATUS_CHECK(status, RPTUN_STATUS_STOP)) + { + /* Remote requested channel stop, stop local side. + * Clear rsc_table to prevent re-triggering from shared + * interrupt line (function returns early if rsc_table is NULL). + */ + + priv->rproc.rsc_table = NULL; + syslog(LOG_EMERG, "Stop by remote core: %s\n", + RPTUN_GET_CPUNAME(priv->dev)); + work_queue(HPWORK, &priv->work, rptun_stop_work, priv, 0); + } else if(status != 0u) { syslog(LOG_EMERG, "FATAL: Reset by remote core: %s reason: %u\n", diff --git a/drivers/rptun/rptun_bmp.c b/drivers/rptun/rptun_bmp.c index 1bb1f2522af..d882a093f3f 100644 --- a/drivers/rptun/rptun_bmp.c +++ b/drivers/rptun/rptun_bmp.c @@ -63,7 +63,6 @@ FAR resource_table *rptun_bmp_get_resource(FAR struct rptun_dev_s *dev); static bool rptun_bmp_is_autostart(FAR struct rptun_dev_s *dev); static bool rptun_bmp_is_master(FAR struct rptun_dev_s *dev); static int rptun_bmp_start(FAR struct rptun_dev_s *dev); -static int rptun_bmp_stop(FAR struct rptun_dev_s *dev); static int rptun_bmp_notify(FAR struct rptun_dev_s *dev, uint32_t notifyid); static int rptun_bmp_register_callback(FAR struct rptun_dev_s *dev, @@ -83,7 +82,6 @@ static const struct rptun_ops_s g_rptun_bmp_ops = .is_autostart = rptun_bmp_is_autostart, .is_master = rptun_bmp_is_master, .start = rptun_bmp_start, - .stop = rptun_bmp_stop, .notify = rptun_bmp_notify, .register_callback = rptun_bmp_register_callback, }; @@ -139,11 +137,6 @@ static int rptun_bmp_start(FAR struct rptun_dev_s *dev) return 0; } -static int rptun_bmp_stop(FAR struct rptun_dev_s *dev) -{ - return 0; -} - static int rptun_bmp_notify(FAR struct rptun_dev_s *dev, uint32_t vqid) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev;
