USB: cdc-acm: support flushing write buffers (TCOFLUSH)
authorSimon Arlott <simon@octiron.net>
Sun, 20 Aug 2023 19:13:01 +0000 (20:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Aug 2023 12:46:11 +0000 (14:46 +0200)
commit09867af36969067d89c96ab1452656977f30e22a
treecabeda0f16da38deac88780bd560f02259f0bbb5
parent4b3cd783808bb327d931bbb1324d6c367443b721
USB: cdc-acm: support flushing write buffers (TCOFLUSH)

If the serial device never reads data written to it (because it is "output
only") then the write buffers will still be waiting for the URB to complete
on close(), which will hang for 30s until the closing_wait timeout expires.

This can happen with the ESP32-H2/ESP32-C6 USB serial interface. Changing
the port closing_wait timeout is a privileged operation but flushing the
output buffer is not a privileged operation.

Implement the flush_buffer tty operation to cancel in-progress writes so
that tcflush(fd, TCOFLUSH) can be used to unblock the serial port before
close.

Signed-off-by: Simon Arlott <simon@octiron.net>
Link: https://lore.kernel.org/r/555fbc4c-043b-8932-fb9b-a208d61ffbe4@0882a8b5-c6c3-11e9-b005-00805fc181fe.uuid.home.arpa
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-acm.c