From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Sasha Levin <sashal@kernel.org>,
tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org,
linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.11 10/20] media: vb2: use lock if wait_prepare/finish are NULL
Date: Sun, 24 Nov 2024 07:50:40 -0500 [thread overview]
Message-ID: <20241124125124.3339648-10-sashal@kernel.org> (raw)
In-Reply-To: <20241124125124.3339648-1-sashal@kernel.org>
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[ Upstream commit 88785982a19daa765e30ab3a605680202cfaee4e ]
If the wait_prepare or wait_finish callback is set, then call it.
If it is NULL and the queue lock pointer is not NULL, then just
unlock/lock that mutex.
This allows simplifying drivers by dropping the wait_prepare and
wait_finish ops (and eventually the vb2_ops_wait_prepare/finish helpers).
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/media/common/videobuf2/videobuf2-core.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 97605c2e25dac..47d73759f9f75 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -2004,7 +2004,10 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
* become ready or for streamoff. Driver's lock is released to
* allow streamoff or qbuf to be called while waiting.
*/
- 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);
/*
* All locks have been released, it is safe to sleep now.
@@ -2014,12 +2017,16 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
!list_empty(&q->done_list) || !q->streaming ||
q->error);
+ if (q->ops->wait_finish)
+ call_void_qop(q, wait_finish, q);
+ else if (q->lock)
+ mutex_lock(q->lock);
+
+ q->waiting_in_dqbuf = 0;
/*
* We need to reevaluate both conditions again after reacquiring
* the locks or return an error if one occurred.
*/
- call_void_qop(q, wait_finish, q);
- q->waiting_in_dqbuf = 0;
if (ret) {
dprintk(q, 1, "sleep was interrupted\n");
return ret;
--
2.43.0
next prev parent reply other threads:[~2024-11-24 12:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-24 12:50 [PATCH AUTOSEL 6.11 01/20] gpio: free irqs that are still requested when the chip is being removed Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 02/20] spi: spi-fsl-lpspi: Adjust type of scldiv Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 03/20] HID: add per device quirk to force bind to hid-generic Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 04/20] soc: qcom: pd-mapper: Add QCM6490 PD maps Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 05/20] media: v4l: Add luma 16-bit interlaced pixel format Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 06/20] media: uvcvideo: " Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 07/20] media: uvcvideo: RealSense D421 Depth module metadata Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 08/20] media: uvcvideo: Add a quirk for the Kaiweets KTI-W02 infrared camera Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 09/20] media: uvcvideo: Force UVC version to 1.0a for 0408:4033 Sasha Levin
2024-11-24 12:50 ` Sasha Levin [this message]
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 11/20] media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108 Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 12/20] mmc: core: Add SD card quirk for broken poweroff notification Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 13/20] mmc: sdhci-esdhc-imx: enable quirks SDHCI_QUIRK_NO_LED Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 14/20] firmware: qcom: scm: Allow QSEECOM on Dell XPS 13 9345 Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 15/20] soc: imx8m: Probe the SoC driver as platform driver Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 16/20] HID: bpf: Fix NKRO on Mistel MD770 Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 17/20] regmap: maple: Provide lockdep (sub)class for maple tree's internal lock Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 18/20] selftests/resctrl: Protect against array overflow when reading strings Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 19/20] USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW Sasha Levin
2024-11-24 12:50 ` [PATCH AUTOSEL 6.11 20/20] HID: magicmouse: Apple Magic Trackpad 2 USB-C driver support Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241124125124.3339648-10-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab+huawei@kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox