Skip to content

Commit e5f93e5

Browse files
committed
fixup! Bluetooth: Host: Add bt_taskq workqueue for quick non-blocking tasks
1 parent 54338e6 commit e5f93e5

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

subsys/bluetooth/host/Kconfig

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ config BT_LONG_WQ_INIT_PRIO
3535

3636
endif # BT_LONG_WQ
3737

38-
config BT_TASKQ_STACK_SIZE_WITH_PROMPT
39-
bool "Override BT taskq thread stack size"
40-
41-
config BT_TASKQ_STACK_SIZE
42-
int
43-
prompt "BT taskq thread stack size" if BT_HCI_TX_STACK_SIZE_WITH_PROMPT
44-
default 1024
45-
46-
config BT_TASKQ_THREAD_PRIO
47-
int
48-
# -1 is the least urgent cooperative priority.
49-
# tx_processor() needs a cooperative thread for now.
50-
default -1
51-
5238
config BT_HCI_HOST
5339
# Hidden option to make the conditions more intuitive
5440
bool
@@ -179,6 +165,7 @@ menu "Bluetooth Host"
179165

180166
if BT_HCI_HOST
181167

168+
rsource "Kconfig.bt_taskq"
182169
rsource "../mesh/Kconfig"
183170
rsource "../audio/Kconfig"
184171

subsys/bluetooth/host/bt_taskq.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,36 @@
77
*/
88

99
#include <zephyr/autoconf.h>
10-
#include <zephyr/kernel.h>
1110
#include <zephyr/init.h>
11+
#include <zephyr/kernel.h>
1212
#include <zephyr/kernel/thread_stack.h>
13+
#include <zephyr/sys/util_macro.h>
14+
#include <zephyr/toolchain.h>
1315

1416
static K_THREAD_STACK_DEFINE(bt_taskq_stack, CONFIG_BT_TASKQ_STACK_SIZE);
15-
struct k_work_q bt_taskq;
17+
static struct k_work_q bt_taskq;
1618

17-
static int bt_taskq_init(void)
19+
__maybe_unused static int bt_taskq_init(void)
1820
{
19-
struct k_work_queue_config cfg = {
20-
.name = "bt_taskq",
21-
};
21+
struct k_work_queue_config cfg = {};
22+
23+
if (IS_ENABLED(CONFIG_THREAD_NAME)) {
24+
cfg.name = "bt_taskq";
25+
}
2226

2327
k_work_queue_start(&bt_taskq, bt_taskq_stack, K_THREAD_STACK_SIZEOF(bt_taskq_stack),
2428
CONFIG_BT_TASKQ_THREAD_PRIO, &cfg);
2529

2630
return 0;
2731
}
2832

33+
#if defined(CONFIG_BT_TASKQ_DEDICATED)
2934
/* The init priority is set to POST_KERNEL 999, the last level
3035
* before APPLICATION.
3136
*/
3237
SYS_INIT(bt_taskq_init, POST_KERNEL, 999);
38+
#endif /* CONFIG_BT_TASKQ_DEDICATED */
39+
40+
/* Exports */
41+
struct k_work_q *const bt_taskq_chosen =
42+
COND_CODE_1(CONFIG_BT_TASKQ_DEDICATED, (&bt_taskq), (&k_sys_work_q));

subsys/bluetooth/host/bt_taskq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
*
3838
* Available in APPLICATION initialization level and later.
3939
*/
40-
extern struct k_work_q bt_taskq;
40+
extern struct k_work_q *const bt_taskq_chosen;

0 commit comments

Comments
 (0)