diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2024-10-17 17:09:23 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2024-10-28 09:19:47 +0100 |
commit | 1d8aaa86a32a76021f6c37fff9f7c3a26f48dae7 (patch) | |
tree | a96fed3b3b6b3a5ebbe29cb676f83d9881324654 | |
parent | c9ec6f1736363b2b2bb4e266997389740f628441 (diff) | |
download | linux-stable-1d8aaa86a32a76021f6c37fff9f7c3a26f48dae7.tar.gz linux-stable-1d8aaa86a32a76021f6c37fff9f7c3a26f48dae7.tar.bz2 linux-stable-1d8aaa86a32a76021f6c37fff9f7c3a26f48dae7.zip |
media: videobuf2-core: update vb2_thread if wait_finish/prepare are NULL
The vb2_thread is used for DVB support. This will queue and dequeue buffers
automatically.
It calls wait_finish/prepare around vb2_core_dqbuf() and vb2_core_qbuf(),
but that assumes all drivers have these ops set. But that will change
due to commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL").
So instead just check if the callback is available, and if not, use
q->lock, just as __vb2_wait_for_done_vb() does.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-core.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index d064e0664851..d2275c878ea9 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -3218,10 +3218,17 @@ static int vb2_thread(void *data) continue; prequeue--; } else { - call_void_qop(q, wait_finish, q); - if (!threadio->stop) + if (!threadio->stop) { + if (q->ops->wait_finish) + call_void_qop(q, wait_finish, q); + else if (q->lock) + mutex_lock(q->lock); ret = vb2_core_dqbuf(q, &index, NULL, 0); - call_void_qop(q, wait_prepare, q); + if (q->ops->wait_prepare) + call_void_qop(q, wait_prepare, q); + else if (q->lock) + mutex_unlock(q->lock); + } dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret); if (!ret) vb = vb2_get_buffer(q, index); @@ -3233,12 +3240,19 @@ static int vb2_thread(void *data) if (vb->state != VB2_BUF_STATE_ERROR) if (threadio->fnc(vb, threadio->priv)) break; - call_void_qop(q, wait_finish, q); if (copy_timestamp) vb->timestamp = ktime_get_ns(); - if (!threadio->stop) + if (!threadio->stop) { + if (q->ops->wait_finish) + call_void_qop(q, wait_finish, q); + else if (q->lock) + mutex_lock(q->lock); ret = vb2_core_qbuf(q, vb, NULL, NULL); - call_void_qop(q, wait_prepare, q); + if (q->ops->wait_prepare) + call_void_qop(q, wait_prepare, q); + else if (q->lock) + mutex_unlock(q->lock); + } if (ret || threadio->stop) break; } |