diff options
author | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2020-10-02 16:48:03 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-11-16 10:31:08 +0100 |
commit | 6e8c09bb8d60a0b905295e9e2c999b39953c5bf3 (patch) | |
tree | 098f90bdc19823547200d1b4de6e39a40c05627f /drivers/media/test-drivers/vivid/vivid-kthread-out.c | |
parent | media: zoran: fix spelling mistake and make error message more meaningful (diff) | |
download | linux-6e8c09bb8d60a0b905295e9e2c999b39953c5bf3.tar.xz linux-6e8c09bb8d60a0b905295e9e2c999b39953c5bf3.zip |
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>
Diffstat (limited to 'drivers/media/test-drivers/vivid/vivid-kthread-out.c')
-rw-r--r-- | drivers/media/test-drivers/vivid/vivid-kthread-out.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/media/test-drivers/vivid/vivid-kthread-out.c b/drivers/media/test-drivers/vivid/vivid-kthread-out.c index 6780687978f9..79c57d14ac4e 100644 --- a/drivers/media/test-drivers/vivid/vivid-kthread-out.c +++ b/drivers/media/test-drivers/vivid/vivid-kthread-out.c @@ -167,7 +167,7 @@ static int vivid_thread_vid_out(void *data) break; if (!mutex_trylock(&dev->mutex)) { - schedule_timeout_uninterruptible(1); + schedule(); continue; } @@ -233,7 +233,9 @@ static int vivid_thread_vid_out(void *data) next_jiffies_since_start = jiffies_since_start; wait_jiffies = next_jiffies_since_start - jiffies_since_start; - schedule_timeout_interruptible(wait_jiffies ? wait_jiffies : 1); + while (jiffies - cur_jiffies < wait_jiffies && + !kthread_should_stop()) + schedule(); } dprintk(dev, 1, "Video Output Thread End\n"); return 0; |