RevolutionPi / piControl

Kernel module for data exchange with RevPi I/O-Modules and Gateways
81 stars 24 forks source link

piControl: compact: Avoid starving USB traffic [REVPI-2336] #65

Closed l1k closed 2 years ago

l1k commented 2 years ago

On kernel 5.10, piControl's high-priority tasks may starve USB traffic, with keyboard and network URBs seemingly timing out. The issue is confined to dwc_otg and cannot be reproduced with dwc2. However, lack of the FIQ optimization makes switching to dwc2 unattractive.

It turns out that raising the RT priority of dwc_otg's IRQ threads above spi2 and piControl resolves the issue, at the expense of occasional lost or premature cycles. USB traffic is handled in softirq (tasklet) context and it appears on kernel 5.10 that's done on exit from the dwc_otg IRQ threads, whereas on 4.19 is was done by the ktimersoftd threads.

The name of the dwc_otg IRQ threads contains the IRQ number, which is variable. In addition, there are two threads with identical name due to TASK_COMM_LEN truncation. Amend set_kthread_prios() to cope with these two particularities.

linosanfilippo-kunbus commented 2 years ago

Why not simply lower the priority of spi2, piControl ain and piControl i/o below the dwc_otg helper threads? That would be much less code changes...

l1k commented 2 years ago

That would lower their priority vis-à-vis all other IRQ threads (such as spi0, used for SPI Ethernet).