This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 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 a33a402e37f drivers/rpmsg/rpmsg_virtio: add an option to start the
device synchronously
a33a402e37f is described below
commit a33a402e37f436650368b4b49b83e138f34d4f83
Author: wangshaoxin <[email protected]>
AuthorDate: Wed Sep 2 11:21:21 2026 +0800
drivers/rpmsg/rpmsg_virtio: add an option to start the device synchronously
rpmsg_virtio_probe_cpuname() queues the rpmsg device bring-up on the rpmsg
work queue, so it returns before /dev/rpmsg/<cpu> exists and before any
service has seen the device. A board that wants to use the link right
after the probe has to wait for that on its own.
Add CONFIG_RPMSG_VIRTIO_START_SYNC to run the bring-up inline in the
probe instead. It blocks the caller of the probe until the device is up.
Default n, so the default behaviour is unchanged.
The help text states what the option needs: the bring-up then sends its
announcements outside the rpmsg work queue, so the work queues of both
cores must be allowed to recurse deep enough to answer all start-up
announcements. With RPMSG_RECURSIVE_LIMIT=3 on sim both cores hang:
Assertion failed : at file: .../rpmsg_virtio.c:303 task: sh
Signed-off-by: wangshaoxin <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
---
drivers/rpmsg/Kconfig | 15 +++++++++++++++
drivers/rpmsg/rpmsg_virtio.c | 12 ++++++++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index a3a4f2699e9..b0a6a91ecfd 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -316,5 +316,20 @@ config RPMSG_VIRTIO_PM_AUTORELAX
it prevents unnecessary power consumption by reducing the times
that system
enter and leave low-power states.
+config RPMSG_VIRTIO_START_SYNC
+ bool "rpmsg virtio start devices synchronously"
+ default n
+ ---help---
+ By default probe defers the rpmsg device bring-up to the rpmsg
work
+ queue. Enable this to run it inline instead, so the device is
ready
+ when probe returns, at the cost of blocking the probe caller.
+
+ The bring-up then announces the local services from outside the
+ rpmsg work queue, while the work queues of both cores answer
each
+ other's announcements and wait for tx buffers recursively. If
+ RPMSG_RECURSIVE_LIMIT is too small on either core, both cores
wait
+ for tx buffers forever: sim, with 17 services and 8 buffers,
needs
+ at least 4 on both cores.
+
endif # RPMSG_VIRTIO
diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c
index 8451496f204..6ee271704e6 100644
--- a/drivers/rpmsg/rpmsg_virtio.c
+++ b/drivers/rpmsg/rpmsg_virtio.c
@@ -86,7 +86,9 @@ struct rpmsg_virtio_priv_s
uint16_t headtx;
int sleepertx;
int timeouttx; /* Consecutive tx wait slices */
+#ifndef CONFIG_RPMSG_VIRTIO_START_SYNC
struct work_s startwork;
+#endif
#ifdef CONFIG_RPMSG_VIRTIO_PM
spinlock_t lock;
struct pm_wakelock_s wakelock;
@@ -799,6 +801,12 @@ static int rpmsg_virtio_notify_wait(FAR struct
rpmsg_device *rdev,
/****************************************************************************
* Name: rpmsg_virtio_start_worker
+ *
+ * Description:
+ * Register the rpmsg device and bring up the rpmsg virtio device. Runs
+ * either inline in the probe context (CONFIG_RPMSG_VIRTIO_START_SYNC) or
+ * on the rpmsg work queue.
+ *
****************************************************************************/
static void rpmsg_virtio_start_worker(FAR void *arg)
@@ -1013,9 +1021,13 @@ int rpmsg_virtio_probe_cpuname(FAR struct virtio_device
*vdev,
pm_wakelock_init(&priv->wakelock, name, PM_IDLE_DOMAIN, PM_IDLE);
#endif
+#ifdef CONFIG_RPMSG_VIRTIO_START_SYNC
+ rpmsg_virtio_start_worker(&priv->rpmsg);
+#else
rpmsg_queue_work(&priv->rpmsg, RPMSG_PRIO_DEFAULT,
&priv->startwork, rpmsg_virtio_start_worker,
&priv->rpmsg);
+#endif
}
else
{