USB HUB: Fix a deadlock that can occur if the HCD and the HUB try to share the high priority work queue. Now how work must be done on the low priority work queue.

This commit is contained in:
Gregory Nutt
2015-04-29 08:32:17 -06:00
parent 119bd7fe8a
commit d8c31bdf20
2 changed files with 49 additions and 17 deletions
+22 -6
View File
@@ -668,8 +668,9 @@ Configurations
CONFIG_LPC31_EHCI_PREALLOCATE=y
RTOS Features -> Work Queue Support
CONFIG_SCHED_WORKQUEUE=y : Work queue support is needed
CONFIG_SCHED_HPWORKSTACKSIZE=1536
CONFIG_SCHED_WORKQUEUE=y : High priority queue support is needed
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKSTACKSIZE=1536 (1024 seems to work okay too)
b. Hub Support.
@@ -678,11 +679,26 @@ Configurations
CONFIG_USBHOST_HUB=y : Enable the hub class
CONFIG_USBHOST_ASYNCH=y : Asynchronous I/O supported needed for hubs
System Type -> USB host configuration
To be provided
RTOS Features -> Work Queue Support
CONFIG_SCHED_LPWORK=y : Low priority queue support is needed
CONFIG_SCHED_LPNTHREADS=1
CONFIG_SCHED_LPWORKSTACKSIZE=1024
Logic nesting becomes deeper with a hub and it may also be
necessary to increase some stack sizes.
NOTES:
1. It is necessary to perform work on the low-priority work queue
(vs. the high priority work queue) because:
a. Deferred work requires some delays and waiting, and
b. There are dependencies between the waiting and driver
interrupt related work. Since that interrupt related work
will performed on the high priority work queue, there would
be the likelihood of deadlocks if you wait for events on the
high priority work thread that can only occur if the high
priority work thread is available to post those events.
2. Logic nesting becomes deeper with a hub and it may also be
necessary to increase some stack sizes.
c. USB Mass Storage Class. With this class enabled, you can support
connection of USB FLASH storage drives. Support for the USB
+27 -11
View File
@@ -955,20 +955,36 @@ Configuration Sub-Directories
2. I used this configuration to test the USB hub class. I did this
testing with the following changes to the configuration:
CONFIG_USBHOST_HUB=y : Enable the hub class
CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs
Drivers -> USB Host Driver Support
CONFIG_USBHOST_HUB=y : Enable the hub class
CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs
CONFIG_LPC17_USBHOST_NASYNCH=8 : Allow up to 8 asynchronous requests
CONFIG_USBHOST_NEDS=3 : Increase number of endpoint descriptors from 2
CONFIG_USBHOST_NTDS=4 : Increase number of transfer descriptors from 3
CONFIG_USBHOST_TDBUFFERS=4 : Increase number of transfer buffers from 3
CONFIG_USBHOST_IOBUFSIZE=256 : Decrease the size of I/O buffers from 512
System Type -> USB host configuration
CONFIG_LPC17_USBHOST_NASYNCH=8 : Allow up to 8 asynchronous requests
CONFIG_USBHOST_NEDS=3 : Increase number of endpoint descriptors from 2
CONFIG_USBHOST_NTDS=4 : Increase number of transfer descriptors from 3
CONFIG_USBHOST_TDBUFFERS=4 : Increase number of transfer buffers from 3
CONFIG_USBHOST_IOBUFSIZE=256 : Decrease the size of I/O buffers from 512
I also increased some stack sizes:
RTOS Features -> Work Queue Support
CONFIG_SCHED_LPWORK=y : Low priority queue support is needed
CONFIG_SCHED_LPNTHREADS=1
CONFIG_SCHED_LPWORKSTACKSIZE=1024
CONFIG_EXAMPLES_HIDKBD_STACKSIZE=2048 : Was 1024
CONFIG_HIDKBD_STACKSIZE=2048 : Was 1024
CONFIG_SCHED_HPWORKSTACKSIZE=2048 : Was 1024
NOTES:
1. It is necessary to perform work on the low-priority work queue
(vs. the high priority work queue) because deferred hub-related
work requires some delays and waiting that is not appropriate on
the high priority work queue.
2. I also increased some stack sizes. These values are not tuned.
When I ran into stack size issues, I just increased the size of
all threads that had smaller stacks.
CONFIG_EXAMPLES_HIDKBD_STACKSIZE=2048 : Was 1024
CONFIG_HIDKBD_STACKSIZE=2048 : Was 1024
CONFIG_SCHED_HPWORKSTACKSIZE=2048 : Was 1024 (1024 is probably ok)
STATUS:
2015-04-26: The hub basically works. I do get crashes in the LPC16 USB host driver