mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-09 13:15:21 +00:00
The USB infrastructure currently uses the system work queue for offloading transfers, CDC-ACM UART transmission/reception, and device firmware activities. This causes problems when the system work queue is also used to initiate some activities (such as UART) that normally complete without requiring an external thread: in that case the USB infrastructure is prevented from making progress because the system work queue is blocked waiting for the USB infrastructure to provide data. Break the dependency by allowing the USB infrastructure to use a dedicated work queue which doesn't depend on availability of the system work queue. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
31 lines
732 B
C
31 lines
732 B
C
/*
|
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
* Copyright (c) 2018 Intel Corporation
|
|
* Copyright (c) 2016 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <kernel.h>
|
|
#include <init.h>
|
|
#include <usb_work_q.h>
|
|
|
|
K_KERNEL_STACK_DEFINE(z_usb_work_q_stack, CONFIG_USB_WORKQUEUE_STACK_SIZE);
|
|
|
|
struct k_work_q z_usb_work_q;
|
|
|
|
static int z_usb_work_q_init(const struct device *dev)
|
|
{
|
|
ARG_UNUSED(dev);
|
|
|
|
k_work_q_start(&z_usb_work_q,
|
|
z_usb_work_q_stack,
|
|
K_KERNEL_STACK_SIZEOF(z_usb_work_q_stack),
|
|
CONFIG_USB_WORKQUEUE_PRIORITY);
|
|
k_thread_name_set(&z_usb_work_q.thread, "usbworkq");
|
|
|
|
return 0;
|
|
}
|
|
|
|
SYS_INIT(z_usb_work_q_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|