OSDN Git Service

media: vivid: fix (partially) timing issues
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 2 Oct 2020 14:48:03 +0000 (16:48 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 16 Nov 2020 09:31:08 +0000 (10:31 +0100)
commit6e8c09bb8d60a0b905295e9e2c999b39953c5bf3
tree098f90bdc19823547200d1b4de6e39a40c05627f
parent5e3a81d42e1d50ec66d47186da25d833750ba4e3
media: vivid: fix (partially) timing issues

The vivid driver is a bit flaky w.r.t. the kthread timing, esp. when
running inside a virtual machine.

This is caused by calling schedule_timeout_uninterruptible(1) which can
actually take more than one jiffie. A while loop with schedule() turns out
to be a lot more precise. Also, if mutex_trylock() fails, then just call
schedule() instead of schedule_timeout_uninterruptible(1). There is no need
to wait until the next jiffer, just schedule(), then try to get the lock
again.

This is still not precise enough, it is still relatively easy to get missed
frames. This really should be converted to use a proper timer, but for now
this solves the worst problems.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/test-drivers/vivid/vivid-kthread-cap.c
drivers/media/test-drivers/vivid/vivid-kthread-out.c
drivers/media/test-drivers/vivid/vivid-kthread-touch.c
drivers/media/test-drivers/vivid/vivid-sdr-cap.c