Skip to content

Commit 8ad024e

Browse files
ipopovhathach
authored andcommitted
Even when we get an empty "status change" interrupt from the hub, schedule another interrupt poll.
During enumeration, when there are multiple devices attached to the hub as it's plugged into the Pi Pico, enumeration hangs, because we get a "status change" callback with value zero. With this patch, we retry several times on "zero" status change callbacks, until eventually we succeed. This is the cheapo hub that exhibits this behavior, but I assume it's not the only one: https://www.amazon.com/gp/product/B083RQMC7S. While debugging this, I consulted the implementation in the Linux kernel. There, hub setup explicitly checks each port individually, before starting to depend on "status change" interrupts: https://elixir.bootlin.com/linux/latest/source/drivers/usb/core/hub.c#L1133. We probably should do something like that here, but it's a much bigger change.
1 parent 069e1ef commit 8ad024e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/host/hub.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,13 @@ bool hub_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32
361361
break;
362362
}
363363
}
364+
365+
// The status change event was neither for the hub, nor for any of
366+
// its ports. (For example `p_hub->status_change == 0`.) This
367+
// shouldn't happen, but it does with some devices. Initiate the
368+
// next interrupt poll here, because we've scheduled no other work
369+
// whose completion can initiate it.
370+
hub_edpt_status_xfer(dev_addr);
364371
}
365372

366373
// NOTE: next status transfer is queued by usbh.c after handling this request

0 commit comments

Comments
 (0)