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 a63f7fb8fe26239526c415620787c7be62ebf80c Author: Yongrong Wang <[email protected]> AuthorDate: Thu Nov 27 16:01:19 2025 +0800 drivers/rpmsg: take the rx worker priority from the virtio config The rx work queues of every rpmsg device were created at CONFIG_RPMSG_WQUEUE_PRIORITY. Pass the priority to rpmsg_init_wqueues(), and let rpmsg_virtio read it from the priority field of struct fw_rsc_config when the device offers VIRTIO_RPMSG_F_PRIORITY. Without the feature, and for the global work queues, the priority stays CONFIG_RPMSG_WQUEUE_PRIORITY. Signed-off-by: Bowen Wang <[email protected]> Signed-off-by: Yongrong Wang <[email protected]> --- drivers/rpmsg/rpmsg.c | 15 ++++++--------- drivers/rpmsg/rpmsg.h | 4 ++-- drivers/rpmsg/rpmsg_virtio.c | 16 ++++++++++++++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c index 560cffb8d3f..eccff6c09ee 100644 --- a/drivers/rpmsg/rpmsg.c +++ b/drivers/rpmsg/rpmsg.c @@ -312,7 +312,7 @@ static void rpmsg_rx_worker(FAR void *arg) } static int rpmsg_create_wqueues(FAR struct rpmsg_wqueue_s *wqueues, - FAR const char *name) + FAR const char *name, uint8_t priority) { FAR struct rpmsg_wqueue_s *wqueue; char wqname[64]; @@ -324,11 +324,8 @@ static int rpmsg_create_wqueues(FAR struct rpmsg_wqueue_s *wqueues, snprintf(wqname, sizeof(wqname), "rpmsg-%.*s-%d", RPMSG_NAME_SIZE, name, i); wqueue = &wqueues[i]; - wqueue->kwqueue = work_queue_create(wqname, - CONFIG_RPMSG_WQUEUE_PRIORITY + i, - NULL, - CONFIG_RPMSG_WQUEUE_STACKSIZE, - 1); + wqueue->kwqueue = work_queue_create(wqname, priority + i, NULL, + CONFIG_RPMSG_WQUEUE_STACKSIZE, 1); if (wqueue->kwqueue == NULL) { rpmsgerr("rpmsg wqueue [%d] create failed\n", i); @@ -353,7 +350,7 @@ void rpmsg_initialize(void) { rpmsg_procfs_initialize(); #ifdef CONFIG_RPMSG_WQUEUE_GLOBAL - rpmsg_create_wqueues(g_rpmsg_wqueues, "glb"); + rpmsg_create_wqueues(g_rpmsg_wqueues, "glb", CONFIG_RPMSG_WQUEUE_PRIORITY); #endif } @@ -1016,9 +1013,9 @@ void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg, } #ifndef CONFIG_RPMSG_WQUEUE_GLOBAL -int rpmsg_init_wqueues(FAR struct rpmsg_s *rpmsg) +int rpmsg_init_wqueues(FAR struct rpmsg_s *rpmsg, uint8_t priority) { - return rpmsg_create_wqueues(rpmsg->wqueues, rpmsg->cpuname); + return rpmsg_create_wqueues(rpmsg->wqueues, rpmsg->cpuname, priority); } void rpmsg_deinit_wqueues(FAR struct rpmsg_s *rpmsg) diff --git a/drivers/rpmsg/rpmsg.h b/drivers/rpmsg/rpmsg.h index 63ba916a760..0fcbac65254 100644 --- a/drivers/rpmsg/rpmsg.h +++ b/drivers/rpmsg/rpmsg.h @@ -143,10 +143,10 @@ int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg, void rpmsg_unregister(FAR const char *path, FAR struct rpmsg_s *rpmsg); #ifdef CONFIG_RPMSG_WQUEUE_GLOBAL -# define rpmsg_init_wqueues(rpmsg) (0) +# define rpmsg_init_wqueues(rpmsg, priority) (0) # define rpmsg_deinit_wqueues(rpmsg) #else -int rpmsg_init_wqueues(FAR struct rpmsg_s *rpmsg); +int rpmsg_init_wqueues(FAR struct rpmsg_s *rpmsg, uint8_t priority); void rpmsg_deinit_wqueues(FAR struct rpmsg_s *rpmsg); #endif diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c index 7ade09b3b15..ee323c97257 100644 --- a/drivers/rpmsg/rpmsg_virtio.c +++ b/drivers/rpmsg/rpmsg_virtio.c @@ -51,7 +51,8 @@ 1 << VIRTIO_RPMSG_F_ACK | \ 1 << VIRTIO_RPMSG_F_BUFSZ | \ 1 << VIRTIO_RPMSG_F_CPUNAME | \ - 1 << VIRTIO_RPMSG_F_BUFADDR) + 1 << VIRTIO_RPMSG_F_BUFADDR | \ + 1 << VIRTIO_RPMSG_F_PRIORITY) #ifdef CONFIG_OPENAMP_CACHE # define RPMSG_VIRTIO_INVALIDATE(x) metal_cache_invalidate(&x, sizeof(x)) @@ -833,6 +834,7 @@ int rpmsg_virtio_probe_cpuname(FAR struct virtio_device *vdev, { FAR struct rpmsg_virtio_priv_s *priv; uint64_t features; + uint8_t priority; #ifdef CONFIG_RPMSG_VIRTIO_PM char name[64]; #endif @@ -889,7 +891,17 @@ int rpmsg_virtio_probe_cpuname(FAR struct virtio_device *vdev, strlcpy(priv->rpmsg.cpuname, cpuname, VIRTIO_RPMSG_CPUNAME_SIZE); } - ret = rpmsg_init_wqueues(&priv->rpmsg); + if (virtio_has_feature(vdev, VIRTIO_RPMSG_F_PRIORITY)) + { + virtio_read_config(vdev, offsetof(struct fw_rsc_config, priority), + &priority, sizeof(priority)); + } + else + { + priority = CONFIG_RPMSG_WQUEUE_PRIORITY; + } + + ret = rpmsg_init_wqueues(&priv->rpmsg, priority); if (ret >= 0) { #ifdef CONFIG_RPMSG_VIRTIO_PM
