i2c: nomadik: support short xfer timeouts using waitqueue & hrtimer
authorThéo Lebrun <theo.lebrun@bootlin.com>
Wed, 6 Mar 2024 17:59:25 +0000 (18:59 +0100)
committerAndi Shyti <andi.shyti@kernel.org>
Tue, 12 Mar 2024 10:50:44 +0000 (11:50 +0100)
commit7489cd43a2ea26c963c422c08e943a4a616fdb15
treed7917c7d85376333edf3f106449725486085f571
parenta9f5cd892354425dcba67692e0afe3af6a2b4b1f
i2c: nomadik: support short xfer timeouts using waitqueue & hrtimer

Replace the completion by a waitqueue for synchronization from IRQ
handler to task. For short timeouts, use hrtimers, else use timers.
Usecase: avoid blocking the I2C bus for too long when an issue occurs.

The threshold picked is one jiffy: if timeout is below that, use
hrtimers. This threshold is NOT configurable.

Implement behavior but do NOT change fetching of timeout. This means the
timeout is unchanged (200ms) and the hrtimer case will never trigger.

A waitqueue is used because it supports both desired timeout approaches.
See wait_event_timeout() and wait_event_hrtimeout(). An atomic boolean
serves as synchronization condition.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-nomadik.c