From 4ea6fd4f203cb57fc4e6c5158bafdba501a3ceb7 Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Wed, 2 Mar 2022 11:12:29 +0100 Subject: [PATCH] ipc_service: Start the wq only once No need to start the wq every time the mbox is initialized, it must be done once for all the instances (it is shared by all the instances). Signed-off-by: Carlo Caione --- .../ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c b/subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c index fc7dc926434..be77774a8eb 100644 --- a/subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c +++ b/subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c @@ -271,9 +271,6 @@ static int mbox_init(const struct device *instance) struct backend_data_t *data = instance->data; int err; - k_work_queue_start(&mbox_wq, mbox_stack, K_KERNEL_STACK_SIZEOF(mbox_stack), - WQ_PRIORITY, NULL); - k_work_init(&data->mbox_work, mbox_callback_process); err = mbox_register_callback(&conf->mbox_rx, mbox_callback, data); @@ -471,12 +468,19 @@ static int backend_init(const struct device *instance) { const struct backend_config_t *conf = instance->config; struct backend_data_t *data = instance->data; + static bool wq_started; data->role = conf->role; k_mutex_init(&data->rpmsg_inst.mtx); atomic_set(&data->state, STATE_READY); + if (!wq_started) { + k_work_queue_start(&mbox_wq, mbox_stack, K_KERNEL_STACK_SIZEOF(mbox_stack), + WQ_PRIORITY, NULL); + wq_started = true; + } + return 0; }