On Sat, 27 Jun 2020 00:21:06 GMT, John Neffenger <github.com+1413266+jgn...@openjdk.org> wrote:
> Fixes [JDK-8201568](https://bugs.openjdk.java.net/browse/JDK-8201568). I thought I could avoid fixing this bug simply by waiting a few years, but the old devices from 2012 and 2013 where the problem occurs are still supported and still even being sold (refurbished) by the manufacturer. The Monocle EPD platform has a work-around for the bug in the method `EPDInputDeviceRegistry.createDevice`. The problem does not occur on newer 2015 and 2018 devices that I tested. ### Background The Neonode zForce touchscreen input device almost always fails when it is opened immediately after being closed. Once it fails, no input events are received. The device driver logs the following messages to the kernel ring buffer: [drivers/input/touchscreen/zforce_i2c.c-425] zforce_i2c_open() [zForce_ir_touch_recv_data-145] command Activate (0) ... [zForce_ir_touch_recv_data-154] command Resolution (0) ... [zForce_ir_touch_recv_data-179] command Frequency (0) ... [drivers/input/touchscreen/zforce_i2c.c-440] zforce_i2c_close() [drivers/input/touchscreen/zforce_i2c.c-425] zforce_i2c_open() [zForce_ir_touch_recv_data-142] command Deactivate ... [zForce_ir_touch_recv_data-198] command overrun (8) ... This pull request reorders the initialization sequence to be "open, open, close" instead of "open, close, open" so that the input device is never actually closed. With this change, the file reference count remains above zero so the call to close it is ignored, and the device driver logs the following messages to the ring buffer: [drivers/input/touchscreen/zforce_i2c.c-425] zforce_i2c_open() [zForce_ir_touch_recv_data-145] command Activate (0) ... [zForce_ir_touch_recv_data-154] command Resolution (0) ... [zForce_ir_touch_recv_data-179] command Frequency (0) ... In both cases, when the program exits or is canceled with `Ctrl-C`, the input device is closed normally: [drivers/input/touchscreen/zforce_i2c.c-440] zforce_i2c_close() [zForce_ir_touch_recv_data-142] command Deactivate ... ### Summary I decided to go ahead and submit this pull request for the following reasons: 1. we know of at least one input device where the code causes problems, so there could be others; 2. this makes progress towards removing 48 lines of work-around code from `EPDInputDeviceRegistry`; and 3. opening and closing an input device is expensive enough that we probably shouldn't close it when we know we're going to open it again only two statements later. ------------- PR: https://git.openjdk.java.net/jfx/pull/258