Skip to content

Return queued buffers on stream start failure - #57

Open
grawis wants to merge 1 commit into
sysprog21:masterfrom
grawis:fix-start-streaming-failure
Open

Return queued buffers on stream start failure#57
grawis wants to merge 1 commit into
sysprog21:masterfrom
grawis:fix-start-streaming-failure

Conversation

@grawis

@grawis grawis commented Aug 23, 2026

Copy link
Copy Markdown

If start_streaming() fails after buffers have been queued to the driver, vb2 requires the driver to return all owned buffers.

Previously, vcam_start_streaming() returned immediately when kthread_create() failed, leaving buffers in the active queue. This can violate the vb2 start_streaming() failure contract.

Drain the active queue under the driver lock and return each buffer with VB2_BUF_STATE_QUEUED before propagating the kthread_create() error.

Build-tested with Linux 6.17.0-23-generic headers.


Summary by cubic

Return queued buffers when start_streaming() fails to create the submitter thread, complying with the vb2 failure contract. Previously we returned -ECANCELED and left buffers in the active queue; now we drain the queue, complete buffers as VB2_BUF_STATE_QUEUED, and propagate the actual kthread_create() error.

  • Introduces vcam_return_queued_buffers() to drain vcam_out_vidq.active under out_q_slock.
  • Uses IS_ERR()/PTR_ERR() for kthread_create(), sets sub_thr_id to NULL, and returns the real error code.
  • Affects only the failure path before wake_up_process(); normal start behavior is unchanged.
  • Callers may now receive a driver error (e.g., -ENOMEM, -EINTR) instead of -ECANCELED.

Written for commit 081d978. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant