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


The following commit(s) were added to refs/heads/master by this push:
     new 16a1e6222c8 drivers/rptun: go back to offline when the start fails 
before running
16a1e6222c8 is described below

commit 16a1e6222c8ff34a2b07ac2fc0bb15267a7892cd
Author: Bowen Wang <[email protected]>
AuthorDate: Thu Nov 5 21:09:49 2026 +0800

    drivers/rptun: go back to offline when the start fails before running
    
    remoteproc_config() moves the core to RPROC_READY. When loading the
    firmware or setting the resource table fails after that,
    rptun_do_start() returns with the core still READY: rptun_dev_stop()
    then refuses with -EBUSY, and every later start fails because
    remoteproc_config() only accepts an OFFLINE core.
    
    Put the core back to OFFLINE on that path, as remoteproc_shutdown()
    does after a failed remoteproc_start().
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rptun/rptun.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 206728f2dd1..1d6ec9f6180 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -1174,7 +1174,18 @@ static int rptun_do_start(FAR struct remoteproc *rproc)
 
       /* Remote proc start */
 
-      if (ret >= 0)
+      if (ret < 0)
+        {
+          /* remoteproc_config() left it READY, which only
+           * remoteproc_start() leaves; go back so that rptun_dev_stop()
+           * and a later start see an idle core.
+           */
+
+          metal_mutex_acquire(&rproc->lock);
+          rproc->state = RPROC_OFFLINE;
+          metal_mutex_release(&rproc->lock);
+        }
+      else
         {
           ret = remoteproc_start(rproc);
           if (ret >= 0)

Reply via email to