Input: ps2-gpio - use ktime for IRQ timekeeping
Using jiffies for the IRQ timekeeping is not sufficient for two reasons:
(1) Usually jiffies have a resolution of 1ms to 10ms. The IRQ intervals
based on the clock frequency of PS2 protocol specification (10kHz -
16.7kHz) are between ~60us and 100us only. Therefore only those IRQ
intervals can be detected which are either at the end of a transfer
or are overly delayed. While this is sufficient in most cases, since
we have quite a lot of ways to detect faulty transfers, it can
produce false positives in rare cases: When the jiffies value
changes right between two interrupt that are in time, we wrongly
assume that we missed one or more clock cycles.
(2) Some gpio controllers (e.g. the one in the bcm283x chips) may generate
spurious IRQs when processing interrupts in the frequency given by PS2
devices.
Both issues can be fixed by using ktime resolution for IRQ timekeeping.
However, it is still possible to miss clock cycles without detecting
them. When the PS2 device generates the falling edge of the clock signal
we have between ~30us and 50us to sample the data line, because after
this time we reach the next rising edge at which the device changes the
data signal already. But, the only thing we can detect is whether the
IRQ interval is within the given period. Therefore it is possible to
have an IRQ latency greater than ~30us to 50us, sample the wrong bit on
the data line and still be on time with the next IRQ. However, this can
only happen when within a given transfer the IRQ latency increases
slowly.
___ ______ ______ ______ ___
\ / \ / \ / \ /
\ / \ / \ / \ /
\______/ \______/ \______/ \______/
|-----------------| |--------|
60us/100us 30us/50us
Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de>
Link: https://lore.kernel.org/r/20220215160208.34826-3-danilokrummrich@dk-develop.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>