On 25.2.2025 13.59, Michal Pecio wrote:
xhci_move_dequeue_past_td() uses a relatively complex and inefficient procedure to find new dequeue position after the cancelled TD. Replace it with a simpler function which moves dequeue immediately to the first pending TD, or to enqueue if the ring is empty. The outcome should be basically equivalent, because we only clear xHC cache if it stopped or halted on some cancelled TD and moving past the TD effectively means moving to the first remaining TD, if any.
This new way relies on td_list being in sync and up to date. i.e. hardware dequeue can't be ahead of first TD in list. One bad scenario could be something like: class driver queues TD1 class driver queues TD2 Class driver cancels TD2, queue stop endpoint command (Class driver cancels TD1) (optional) xHC hardware just completed TD1 and stop endpoint command at the same time, xHC hw may have advanced the hw dequeue to TD2, write event for stop endpoint command, and then write transfer event for TD1 completion. (xHC hardware may do things in odd order) Now we detect that hw dequeue is in the cancelled TD2 but with TD1 is till in the td_list. This new solution would move dequeue back to TD1 beginning, and process it again. Thanks Mathias