use vb2 queue lock for waits - #58
Open
grawis wants to merge 1 commit into
Open
Conversation
Linux 7 removed the wait_prepare and wait_finish callbacks from struct vb2_ops. vcam already provides vcam_mutex through vb2_queue.lock, so remove the redundant callbacks and let videobuf2 manage the lock while blocking for buffers. Tested with Linux 6.17 headers and on Linux 7.0 with v4l2-compliance and 100-frame MMAP streaming.
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="videobuf.c">
<violation number="1" location="videobuf.c:141">
P2: On kernels before ~6.6/6.7 (which lack the vb2 behavior added in upstream commit 88785982 where NULL wait_prepare/wait_finish auto-unlock q->lock), deleting these callbacks makes the blocking DQBUF wait hold `vcam_mutex` for its whole duration. Since the same mutex is `vdev->lock`, a thread blocked in DQBUF keeps the device lock, stalling concurrent STREAMOFF/QBUF/REQBUFS from other fds. The driver still targets old kernels via its version guards (6.8 and 4.17), so guard the removal: keep the two helper functions and restore the assignments for pre-6.6/6.7 kernels.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| .buf_queue = vcam_out_buffer_queue, | ||
| .start_streaming = vcam_start_streaming, | ||
| .stop_streaming = vcam_stop_streaming, | ||
| .wait_prepare = vcam_outbuf_unlock, |
There was a problem hiding this comment.
P2: On kernels before ~6.6/6.7 (which lack the vb2 behavior added in upstream commit 88785982 where NULL wait_prepare/wait_finish auto-unlock q->lock), deleting these callbacks makes the blocking DQBUF wait hold vcam_mutex for its whole duration. Since the same mutex is vdev->lock, a thread blocked in DQBUF keeps the device lock, stalling concurrent STREAMOFF/QBUF/REQBUFS from other fds. The driver still targets old kernels via its version guards (6.8 and 4.17), so guard the removal: keep the two helper functions and restore the assignments for pre-6.6/6.7 kernels.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At videobuf.c, line 141:
<comment>On kernels before ~6.6/6.7 (which lack the vb2 behavior added in upstream commit 88785982 where NULL wait_prepare/wait_finish auto-unlock q->lock), deleting these callbacks makes the blocking DQBUF wait hold `vcam_mutex` for its whole duration. Since the same mutex is `vdev->lock`, a thread blocked in DQBUF keeps the device lock, stalling concurrent STREAMOFF/QBUF/REQBUFS from other fds. The driver still targets old kernels via its version guards (6.8 and 4.17), so guard the removal: keep the two helper functions and restore the assignments for pre-6.6/6.7 kernels.</comment>
<file context>
@@ -103,18 +103,6 @@ static void vcam_stop_streaming(struct vb2_queue *vb2_q)
spin_unlock_irqrestore(&dev->out_q_slock, flags);
}
-static void vcam_outbuf_lock(struct vb2_queue *vq)
-{
- struct vcam_device *dev = vb2_get_drv_priv(vq);
- mutex_lock(&dev->vcam_mutex);
-}
-
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Linux 7 removed
wait_prepareandwait_finishfromstruct vb2_ops.vcam already sets
vb2_queue.locktovcam_mutex, so this patch removesthe obsolete callbacks and relies on the existing queue lock mechanism.
This keeps the blocking buffer-wait behavior unchanged while allowing vcam
to build with Linux 7 headers.
Testing
6.17.0-23-genericheaders.7.0.0-28-generic.v4l2-compliance -d /dev/video0 -f:48 succeeded, 0 failed, 0 warnings.v4l2-ctl.All frames reported
bytesused=921600; output size was92160000bytes (640 * 480 * 3 * 100).Summary by cubic
Switches vcam waits to the videobuf2 queue lock to restore build compatibility with Linux 7. Linux 7 removes
wait_prepare/wait_finish, so we drop those callbacks and rely onvb2_queue.lock = vcam_mutex, preserving the previous blocking semantics.v4l2-compliance(all pass) and 100-frame MMAP streaming (consistentbytesused).Written for commit 178abf2. Summary will update on new commits.