Skip to content

Commit

Permalink
Check for ongoing transfers on the OUT endpoint (qmk#16974)
Browse files Browse the repository at this point in the history
...when attempting to start a receiving USB transfer. Previously, we would
check on the IN endpoint which is the transmitting part of the USB endpoint.
This is wrong and lead to two USB transfers being started immediately
after each other in case of e.g. RAW HID endpoints:

1. When finishing an OUT transfer the low level USB driver calls the out_cb
callback, which in turn initiates another OUT transfer by calling
qmkusbDataReceived.

2. When the raw hid receive channel runs empty inside the raw_hid task,
another OUT transfer is started to potentially fill the channel again. This
happens by calling ibnotify.

Both events occur directly after each other, thus triggering the bug.
  • Loading branch information
KarlK90 authored and zykrah committed Jul 2, 2022
1 parent 87c6fb9 commit f792284
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tmk_core/protocol/chibios/usb_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static bool qmkusb_start_receive(QMKUSBDriver *qmkusbp) {
}

/* Checking if there is already a transaction ongoing on the endpoint.*/
if (usbGetReceiveStatusI(qmkusbp->config->usbp, qmkusbp->config->bulk_in)) {
if (usbGetReceiveStatusI(qmkusbp->config->usbp, qmkusbp->config->bulk_out)) {
return true;
}

Expand Down

0 comments on commit f792284

Please sign in to comment.