1
0
Fork 0
forked from forks/qmk_firmware
qmk_firmware/tmk_core/protocol
Purdea Andrei dbd65d01b6
Fix how USB queue overflow is handled in chibios. (#12576)
* Fix how USB queue overflow is handled in chibios.

This commit reverts PR 12472 (commit c823fe2d3f),
and it implements the original intent of the commit in a better way.
The original intent of the above mentioned commit was to not deadlock the
keyboard when console is enabled, and hid_listen is not started.

The above mentioned commit had a few drawbacks:
1) When a lot of data was printed to the console, the queue would get full,
and drop data, even if hid_listen was running. (For example having matrix debug
enabled just didn't work right at all)
2) I believe the function in which this was implemented is used by all other
USB endpoints, so with the above change, overflow, and data loss could
happen in other important functions of QMK as well.

This commit implements deadlock prevention in a slightly similar way to how
it's done on AVR. There is an additional static local variable, that memorizes
whether the console has timeouted before. If we are in the timeouted=false
state, then we send the character normally with a 5ms timeout. If it does
time out, then hid_listen is likely not running, and future characters should
not be sent with a timeout, but those characters should still be sent if there
is space in the queue. The difference between the AVR implementation and this
one is that the AVR implementation checks the queue state directly, but this
implementation instead attempts to write the character with a zero timeout.
If it fails, then we remain in the timeouted=true state, if it succeeds, then
hid_listen started removing data from the queue, so we can go out of the
timeouted=true state.

* Added comment explaining the timeouted logic to console flow control.

* Console flow control: refactor chibios flowcontrol code to make it more readable, and rename the timeouted variable to timed_out on both chibios and lufa. Changed comments to says timed_out is an approximation of listener_disconnected, to make it clear that it's not the same thing

* fix typo
2021-04-25 13:11:41 +10:00
..
arm_atsam Format code according to conventions (#12024) 2021-02-26 17:47:22 +11:00
chibios Fix how USB queue overflow is handled in chibios. (#12576) 2021-04-25 13:11:41 +10:00
lufa Fix how USB queue overflow is handled in chibios. (#12576) 2021-04-25 13:11:41 +10:00
midi Move API_SYSEX_MAX_SIZE out of config_common.h (#12302) 2021-03-25 22:30:42 +11:00
usb_hid Remove DESCRIPTION (#9732) 2020-07-16 15:49:18 +10:00
vusb Format code according to conventions (#12046) 2021-02-27 22:35:41 +00:00
adb.c Update ADB impelemtation in TMK Core (#11168) 2020-12-29 19:18:16 -08:00
adb.h Update ADB impelemtation in TMK Core (#11168) 2020-12-29 19:18:16 -08:00
arm_atsam.mk 2020 November 28 Breaking Changes Update (#11053) 2020-11-28 12:02:18 -08:00
chibios.mk Ensure single newline at EOF for core files (#11310) 2020-12-28 04:36:32 +11:00
ibm4704.c Initial vusb console support (#8559) 2020-05-03 01:25:39 +01:00
ibm4704.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
lufa.mk Remove support for Adafruit EZ-Key (#10103) 2020-08-29 14:30:02 -07:00
m0110.c Remove legacy print backward compatiblitly (#11805) 2021-02-06 16:56:13 +00:00
m0110.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
midi.mk Merge ChibiOS and LUFA descriptor support (#2362) 2018-02-08 15:07:46 -05:00
news.c clang-format changes 2019-08-30 15:01:52 -07:00
news.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
next_kbd.c clang-format changes 2019-08-30 15:01:52 -07:00
next_kbd.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
ps2.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
ps2_busywait.c clang-format changes 2019-08-30 15:01:52 -07:00
ps2_interrupt.c clang-format changes 2019-08-30 15:01:52 -07:00
ps2_io.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
ps2_io_avr.c clang-format changes 2019-08-30 15:01:52 -07:00
ps2_mouse.c Remove legacy print backward compatiblitly (#11805) 2021-02-06 16:56:13 +00:00
ps2_mouse.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
ps2_usart.c clang-format changes 2019-08-30 15:01:52 -07:00
serial.h Serial refactor (#11521) 2021-02-06 09:20:48 +11:00
serial_mouse.h Change include guards in tmk_core/ and drivers/ to pragma once (#11240) 2020-12-26 15:56:11 +11:00
serial_mouse_microsoft.c clang-format changes 2019-08-30 15:01:52 -07:00
serial_mouse_mousesystems.c clang-format changes 2019-08-30 15:01:52 -07:00
serial_soft.c remove SERIAL_SOFT_DEBUG macro (#7625) 2019-12-13 18:06:18 -08:00
serial_uart.c Manual formatting fix for serial_uart.c (#11806) 2021-02-06 14:15:30 +00:00
usb_descriptor.c Add support for 8 buttons to mouse report (#10807) 2021-01-28 04:38:34 +11:00
usb_descriptor.h Manually run formatting CI process (#11375) 2021-01-01 03:50:32 +11:00
usb_descriptor_common.h Allow for overriding RAW endpoint usage page and ID. (#8834) 2020-05-21 20:31:42 +10:00
usb_hid.mk cleanup usb-usb converter code 2017-08-15 23:14:41 -04:00
vusb.mk Additional cleanups for V-USB code (#9310) 2020-08-29 14:30:02 -07:00
xt.h [CI] Format code according to conventions (#12277) 2021-03-18 12:28:50 +11:00
xt_interrupt.c [CI] Format code according to conventions (#12277) 2021-03-18 12:28:50 +11:00