Repository navigation
Conversation
|
I don't think this is the right solution as it will break keyboard input on apple desktop devices with only an apple keyboard connected. |
The USB keyboard driver polls with nonblock set, but xHCI ignores it and waits up to XHCI_INT_TIMEOUT (1 s) for every poll. Keyboards that honour SET_IDLE answer within the 40 ms idle period, so this goes unnoticed. Keyboards with USB_HID_QUIRK_POLL_NO_REPORT_IDLE (Apple, Keychron) send nothing until a key changes, so every poll waits out the full second. With such a keyboard on stdin, the UEFI console timer polls it between EFI block reads, and GRUB takes about 80 s instead of a few seconds to load the kernel and initramfs. Seen on an M1 Pro MacBook Pro with a USB-C Magic Keyboard with Touch ID (05ac:029a) on a USB-C hub. Give up on non-blocking interrupt transfers after 20 ms, like dwc2, which already returns at once for them. A report a keyboard queues in the meantime stays in its endpoint and is picked up by the next poll. Probing a keyboard still uses the full timeout. Link: AsahiLinux#21 Link: AsahiLinux#33 Signed-off-by: Christian Bartels <christian@thebartels.de>
e9a53c2 to
bf08a2f
Compare
|
Thanks, that makes sense. I hadn't thought about desktops with only an Apple keyboard. I've replaced the ignorelist change with a timeout change. What I found: on xHCI the keyboard poll passes The new commit makes xHCI honour I didn't gate it on the quirk itself. The quirk lives in Tested on a 14" M1 Pro (j314s) with the USB-C Magic Keyboard with Touch ID (
I also moved the PR to |
|
Thanks for separating blocking probe from ordinary polling. I checked bf08a2f and found two existing timeout/cancellation paths that become more frequent with the shorter wait:
Both controls reproduce on ec49c9d too; these are base defects, not cleanup code introduced by this PR. Normal reports and blocking probes pass. Also, 20 ms is the initial wait: cancellation can add three 200 ms waits. No hardware qualification claimed. Before we package the shorter timeout, could cancellation retain a matching completed report and balance DMA mappings after proven completion/stop? Failed STOP/SET_DEQ acknowledgements need to preserve uncertain DMA ownership rather than blindly unmapping. That would make the improvement much safer for idle and bursty keyboards. |
abort_td() acknowledged every transfer event that arrived after the Stop Endpoint command, including one whose transfer had completed between the caller's timeout and the stop. The caller then reported a timeout with no data, so an interrupt report that did arrive (a key press during idle keyboard polling) was lost. Its completion-code check never fired either: the misplaced parenthesis made it test `transfer_len != COMP_STOP` instead of the completion code. On timeout, xhci_bulk_tx() and xhci_ctrl_tx() also returned without unmapping the transfer buffer. With the IOMMU in translated mode every cancelled poll left an IOVA mapping behind. Have abort_td() report how the transfer ended: stopped, completed (with a copy of its event), or unknown when the Stop Endpoint or Set TR Dequeue command was not acknowledged. xhci_bulk_tx() now returns the result of a transfer that completed late (when the event is for the TD's last TRB), and unmaps the buffer once the controller is known to be done with it. When a command was not acknowledged the buffer stays mapped, as the controller may still write to it. Signed-off-by: Christian Bartels <christian@thebartels.de>
|
Thanks for checking this so carefully. I've pushed a follow-up commit,
Tested on a 14" MacBook Pro M1 Pro (j314s) as a local Disclosure: both commits in this PR were written with the help of an AI coding assistant (Claude). I reviewed and tested them on my own hardware, but I know this project doesn't accept LLM-generated contributions, so please close the PR if that rules it out. I'm offering the same patches to the Aurora side, which packages U-Boot for these Macs (omacom/linux-aurora#83). |
The USB keyboard driver polls with nonblock set, but xHCI ignores it and
waits up to XHCI_INT_TIMEOUT (1 s) for every poll. Keyboards that honour
SET_IDLE answer within the 40 ms idle period, so this goes unnoticed.
Keyboards with USB_HID_QUIRK_POLL_NO_REPORT_IDLE (Apple, Keychron) send
nothing until a key changes, so every poll waits out the full second.
With such a keyboard on stdin, the UEFI console timer polls it between
EFI block reads, and GRUB takes about 80 s instead of a few seconds to
load the kernel and initramfs. Seen on an M1 Pro MacBook Pro with a
USB-C Magic Keyboard with Touch ID (05ac:029a) on a USB-C hub.
Give up on non-blocking interrupt transfers after 20 ms, like dwc2,
which already returns at once for them. A report a keyboard queues in
the meantime stays in its endpoint and is picked up by the next poll.
Probing a keyboard still uses the full timeout.
Fixes #33
See also #21