hcq2 USB: unplugging chestnut during a copy hangs forever
Author: elkoledCreated Sep 23, 2026Updated Sep 30, 2026
Bug on pinned tinygrad in openpilot master 9d0446a4b.
Since 918a2d9fd, if chestnut is disconnected during a copy, the wait loops in usb_drained / usb_reap (runtime/support/usb.py) never exit. The process stays at 100% CPU. usb_chunk also ignores the return value of libusb_submit_transfer.
With HCQ2=0 the same fault raises an I/O error within a second which is the preferred behavior.
When the disconnect raises, the dead device stays in the host's pending, so the next sync on the host raises "NPY hang detected". Dead devices should be removed from pending.
Repro (comma four)
SIZE=256000000 GMMU=0 DEV=USB+AMD python3 test/external/external_test_usb_asm24.py TestDevCopySpeeds.testCopyCPUtoDefault
# While running, disconnect chestnut:
echo 0 | sudo tee /sys/bus/usb/devices/4-1/authorized
# result
comma@comma-d292bc85:/data/openpilot/tinygrad_repo$ SIZE=256000000 GMMU=0 DEV=USB+AMD PYTHONPATH=. /usr/local/venv/bin/python test/external/external_test_usb_asm24.py TestDevCopySpeeds.testCopyCPUtoDefault
copyin of 256.00 MB: 9134.50 ms @ 28.03 MB/s
copyin of 256.00 MB: 759.07 ms @ 337.25 MB/s
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^CSource: tinygrad/tinygrad