]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
evdev: Make open(2) and close(3) handlers sleepable.
authorVladimir Kondratyev <wulf@FreeBSD.org>
Tue, 21 Apr 2020 10:26:58 +0000 (13:26 +0300)
committerVladimir Kondratyev <wulf@FreeBSD.org>
Thu, 7 Jan 2021 23:18:41 +0000 (02:18 +0300)
commitd276eae674d22214d6a58d1f4871053ceb0cb9f5
tree02e18ebd3c817bb7fe897d429783b35975cd8783
parent5af73ad51b8c2e640608af0b7a1982be5c204b96
evdev: Make open(2) and close(3) handlers sleepable.

At the beginning of evdev there was a LOR between hardware driver's and
evdev client list locks as they were taken in different order at
driver's interrupt and evdev open()/close() handlers.

The LOR was fixed with introduction of evdev_register_mtx() function
which allowed to use a hardware driver's lock as evdev client list lock.
While this works good with PS/2 and USB, this does not work with I2C.
Unlike PS/2 and USB, I2C open()/close() handlers do unbound sleeps
while waiting for I2C bus to release and while performing IO.
This change uses epoch(9) for traversing evdev client list in interrupt
handler to avoid the LOR thus making possible to convert evdev client
list lock to sleepable sx.

While here add brief locking protocol description.

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D27865
sys/dev/evdev/cdev.c
sys/dev/evdev/evdev.c
sys/dev/evdev/evdev.h
sys/dev/evdev/evdev_private.h