From: hoff.benjamin.k@gmail.com
To: mchehab@kernel.org, hverkuil+cisco@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH v3 4/5] media: hws: harden video DMA queue ownership
Date: Mon, 29 Jun 2026 14:26:48 -0400 [thread overview]
Message-ID: <20260629182649.247879-5-hoff.benjamin.k@gmail.com> (raw)
In-Reply-To: <20260629182649.247879-1-hoff.benjamin.k@gmail.com>
From: Ben Hoff <hoff.benjamin.k@gmail.com>
Keep no-signal completion on the same queue ownership path as normal
video completion. Program a newly selected buffer before publishing it as
active, restore it to the capture queue if programming fails, and report
the failure without leaving stale active or prepared-buffer state behind.
Signed-off-by: Ben Hoff <hoff.benjamin.k@gmail.com>
---
drivers/media/pci/hws/hws_video.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/media/pci/hws/hws_video.c b/drivers/media/pci/hws/hws_video.c
index 3a7b2abda502..58bcc2e7030d 100644
--- a/drivers/media/pci/hws/hws_video.c
+++ b/drivers/media/pci/hws/hws_video.c
@@ -330,8 +330,8 @@ static bool hws_force_no_signal_frame(struct hws_video *v, const char *tag)
struct hws_pcie_dev *hws;
unsigned long flags;
struct hwsvideo_buffer *buf = NULL, *next = NULL;
- bool have_next = false;
bool programmed = false;
+ int ret = 0;
if (!v)
return false;
@@ -354,22 +354,31 @@ static bool hws_force_no_signal_frame(struct hws_video *v, const char *tag)
if (v->next_prepared) {
next = v->next_prepared;
v->next_prepared = NULL;
- next->slot = HWS_VIDEO_DIRECT_SLOT;
v->active = next;
- have_next = true;
+ programmed = true;
} else if (!list_empty(&v->capture_queue)) {
next = list_first_entry(&v->capture_queue,
struct hwsvideo_buffer, list);
list_del_init(&next->list);
if (v->queued_count)
v->queued_count--;
- next->slot = HWS_VIDEO_DIRECT_SLOT;
- v->active = next;
- have_next = true;
+ ret = hws_program_dma_for_buffer(hws, v->channel_index, next);
+ if (ret) {
+ list_add(&next->list, &v->capture_queue);
+ v->queued_count++;
+ next = NULL;
+ } else {
+ v->active = next;
+ programmed = true;
+ }
} else {
v->active = NULL;
}
spin_unlock_irqrestore(&v->irq_lock, flags);
+ if (ret)
+ dev_warn_ratelimited(&hws->pdev->dev,
+ "%s: failed to arm no-signal buffer ch=%u ret=%d\n",
+ tag, v->channel_index, ret);
if (!buf)
return false;
/* Complete buffer with a neutral frame so dequeuers keep running. */
@@ -385,10 +394,6 @@ static bool hws_force_no_signal_frame(struct hws_video *v, const char *tag)
vb2v->vb2_buf.timestamp = ktime_get_ns();
vb2_buffer_done(&vb2v->vb2_buf, VB2_BUF_STATE_DONE);
}
- if (have_next && next) {
- if (!hws_program_dma_for_buffer(hws, v->channel_index, next))
- programmed = true;
- }
if (programmed) {
wmb(); /* ensure descriptors visible before enabling capture */
hws_enable_video_capture(hws, v->channel_index, true);
--
2.54.0
next prev parent reply other threads:[~2026-06-29 18:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 18:26 [PATCH v3 0/5] media: hws: add HDMI audio capture support hoff.benjamin.k
2026-06-29 18:26 ` [PATCH v3 1/5] media: hws: program video DMA through remap windows hoff.benjamin.k
2026-06-29 18:26 ` [PATCH v3 2/5] media: hws: add shared scratch DMA arena hoff.benjamin.k
2026-06-29 18:26 ` [PATCH v3 3/5] media: hws: add video bounce path for shared remap windows hoff.benjamin.k
2026-06-29 18:26 ` hoff.benjamin.k [this message]
2026-06-29 18:26 ` [PATCH v3 5/5] media: hws: add HDMI audio capture support hoff.benjamin.k
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=20260629182649.247879-5-hoff.benjamin.k@gmail.com \
--to=hoff.benjamin.k@gmail.com \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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