From nobody Tue Jun 16 18:00:33 2026 Received: from web04.chillydomains.com (web04.chillydomains.com [193.19.92.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1CDC38D6B8 for ; Wed, 29 Apr 2026 20:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.19.92.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492810; cv=none; b=EmKfyMlB5rJ4NN6yBPn2Aosm9GXJnYOILcX3C4Gq5ChRDqJve5+fTI9qN8w95TrOv+G+JgOk2alxZs/FPHF5yZr2ZHpUpAR8iTIXITCRpDOl1ioBDMdOinBscX7L5NcjOt4JZrLx6O1XQdIq99sqBIlrv6pTplWhQlorXCRKVfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492810; c=relaxed/simple; bh=pzvYNG7O3NjY4rozX4YN5+/6UT2OM6XcPT3k0XWZK4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MnPdcKWXM4AJOI/KhhwGrl5lTW+eox3tqxLOq1WWbJC9eq7rZZxILVY8bkvqP1sDI3BR4x1zigJ8Zwqs6CxGHy4vtFmAuKWozVakz2yLpQS1Mizw2Tt/0qRN3oZSMAvjJEdVu+M03tUCcpwyrAx3imFJ8pb9kVvHs+2fV2723r8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de; spf=none smtp.mailfrom=reauktion.de; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b=hExBLkeS; arc=none smtp.client-ip=193.19.92.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=reauktion.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b="hExBLkeS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web04.chillydomains.com; s=dkim; h=From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=1+9FwjtYEgcl+wQVdNXHv Cf5gn4Vs+2VsZJMRjOVxUg=; b=hExBLkeSN6Zv0RVgFL6xHch4tFBK2nfbDNdtN Tm4qYd9t0tDhlDWHhvm5WO28LqQseJttQHu3OZoodc5mG7Jdfyn9rXndtbmFwiIj BMtPkiOJe4CQJCGSZW4v7SOCiggD92vHQjp8DG5lhTt/dZ3aTASjXSJ8KD7ekYcB V33fuzjZ4/qRdw9s0RHawC/DxEVGFbUwjS5a21mE1TEwZnG9uy5tfqj3oK71lJ9Q FOGJI7W1KpGQOH6txgu+4LKMLKq/LpKcRejCDf9/NI0J5j+pzWTku79TgeuB2Ktn 1w8YLvd01M6tXlti/ljnko0/IBudX17HCj7arCKXF5wt9WYyg== Received: (qmail 2739233 invoked by uid 7799); 29 Apr 2026 21:53:26 +0200 Received: by simscan 1.4.0 ppid: 2739204, pid: 2739218, t: 0.6330s scanners: clamav: 0.103.9/m:62/d:27778 Received: from 31.29.52.71.dynamic-pppoe.dt.ipv4.wtnet.de (HELO localhost) (automation@reauktion.de@31.29.52.71) by web04.chillydomains.com with SMTP [62865]; 29 Apr 2026 21:53:25 +0200 From: Markus Fritsche To: Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Ezequiel Garcia , Philipp Zabel , Jacob Chen , Heiko Stuebner Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 1/3] media: videobuf2: add dma_resv release-fence helper Date: Wed, 29 Apr 2026 19:53:04 +0000 Message-ID: <20260429195306.239666-2-mfritsche@reauktion.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260429195306.239666-1-mfritsche@reauktion.de> References: <20260429195306.239666-1-mfritsche@reauktion.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add an opt-in API that lets vb2 producers populate a dma_resv exclusive write fence on the dmabufs they export to userspace, signalled when the buffer transitions to VB2_BUF_STATE_DONE. V4L2 producers historically don't propagate buffer-state-done into the dmabuf's dma_resv exclusive fence. Userspace consumers that import V4L2-produced dmabufs and wait on the dmabuf's implicit-sync fence (poll(POLLIN), DMA_BUF_IOCTL_EXPORT_SYNC_FILE) currently see either zero fences or a stub fence from dma_fence_get_stub(). This is correct by accident for the common case (clients call DQBUF before importing) but represents a contract gap. Drivers opt in by calling vb2_buffer_attach_release_fence(vb) from their buf_queue callback. The helper allocates a dma_fence on the queue's fence context (set up at vb2_core_queue_init), attaches it as DMA_RESV_USAGE_WRITE on each plane's dmabuf->resv, and stashes it in vb->release_fence. vb2_buffer_done signals + puts the fence as part of its state transition. For drivers that don't opt in, vb->release_fence stays NULL and the signal path is a no-op. Skips planes whose vb2_plane.dbuf is NULL =E2=80=94 buffers never exported via VIDIOC_EXPBUF (or imported via V4L2_MEMORY_DMABUF) have no dmabuf for userspace to wait on. Signed-off-by: Markus Fritsche --- .../media/common/videobuf2/videobuf2-core.c | 95 +++++++++++++++++++ include/media/videobuf2-core.h | 29 ++++++ 2 files changed, 124 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index b0523fc23..ee766aae0 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -26,6 +26,9 @@ #include #include =20 +#include +#include +#include #include #include =20 @@ -1179,6 +1182,86 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsign= ed int plane_no) } EXPORT_SYMBOL_GPL(vb2_plane_cookie); =20 +/* + * dma_resv release-fence integration. + * + * V4L2 producers historically don't propagate buffer-state-done into + * the dmabuf's dma_resv exclusive fence. Userspace consumers that + * wait on that fence (e.g. wayland compositors via poll(POLLIN) or + * DMA_BUF_IOCTL_EXPORT_SYNC_FILE) currently see either no fences or + * a stub fence from dma_fence_get_stub(). The opt-in API below lets + * a driver attach a real producer fence at QBUF time and have it + * signalled by vb2_buffer_done(). + */ + +static const char *vb2_dma_resv_get_driver_name(struct dma_fence *fence) +{ + return "videobuf2"; +} + +static const char *vb2_dma_resv_get_timeline_name(struct dma_fence *fence) +{ + return "vb2-release-fence"; +} + +static const struct dma_fence_ops vb2_dma_resv_fence_ops =3D { + .get_driver_name =3D vb2_dma_resv_get_driver_name, + .get_timeline_name =3D vb2_dma_resv_get_timeline_name, +}; + +int vb2_buffer_attach_release_fence(struct vb2_buffer *vb) +{ + struct vb2_queue *q =3D vb->vb2_queue; + struct dma_fence *fence; + unsigned int plane; + + if (WARN_ON(vb->release_fence)) + return -EINVAL; + + fence =3D kzalloc(sizeof(*fence), GFP_KERNEL); + if (!fence) + return -ENOMEM; + + dma_fence_init(fence, &vb2_dma_resv_fence_ops, &q->dma_resv_fence_lock, + q->dma_resv_fence_context, + atomic64_inc_return(&q->dma_resv_fence_seqno)); + + for (plane =3D 0; plane < vb->num_planes; plane++) { + struct dma_buf *dbuf =3D vb->planes[plane].dbuf; + + if (!dbuf) + continue; + + dma_resv_lock(dbuf->resv, NULL); + dma_resv_add_fence(dbuf->resv, fence, DMA_RESV_USAGE_WRITE); + dma_resv_unlock(dbuf->resv); + } + + /* One reference for the eventual signal in vb2_buffer_done. */ + vb->release_fence =3D dma_fence_get(fence); + + /* The dma_resv held its own reference per plane. Drop ours. */ + dma_fence_put(fence); + + return 0; +} +EXPORT_SYMBOL_GPL(vb2_buffer_attach_release_fence); + +static void vb2_buffer_signal_release_fence(struct vb2_buffer *vb, + enum vb2_buffer_state state) +{ + struct dma_fence *fence =3D vb->release_fence; + + if (!fence) + return; + + if (state =3D=3D VB2_BUF_STATE_ERROR) + dma_fence_set_error(fence, -EIO); + dma_fence_signal(fence); + dma_fence_put(fence); + vb->release_fence =3D NULL; +} + void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) { struct vb2_queue *q =3D vb->vb2_queue; @@ -1205,6 +1288,9 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_= buffer_state state) if (state !=3D VB2_BUF_STATE_QUEUED) __vb2_buf_mem_finish(vb); =20 + if (state !=3D VB2_BUF_STATE_QUEUED) + vb2_buffer_signal_release_fence(vb, state); + spin_lock_irqsave(&q->done_lock, flags); if (state =3D=3D VB2_BUF_STATE_QUEUED) { vb->state =3D VB2_BUF_STATE_QUEUED; @@ -2652,6 +2738,15 @@ int vb2_core_queue_init(struct vb2_queue *q) mutex_init(&q->mmap_lock); init_waitqueue_head(&q->done_wq); =20 + /* + * Per-queue dma_resv release-fence context. Drivers opt-in via + * vb2_buffer_attach_release_fence(); other drivers pay only the + * cost of the unused fields. + */ + q->dma_resv_fence_context =3D dma_fence_context_alloc(1); + atomic64_set(&q->dma_resv_fence_seqno, 0); + spin_lock_init(&q->dma_resv_fence_lock); + q->memory =3D VB2_MEMORY_UNKNOWN; =20 if (q->buf_struct_size =3D=3D 0) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 9b02aeba4..2bf3272d4 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -288,6 +288,12 @@ struct vb2_buffer { unsigned int skip_cache_sync_on_finish:1; =20 struct vb2_plane planes[VB2_MAX_PLANES]; + /* + * dma_resv release fence =E2=80=94 set by vb2_buffer_attach_release_fenc= e() + * (driver opt-in from buf_queue), signalled and put by + * vb2_buffer_done(). NULL for drivers that don't opt in. + */ + struct dma_fence *release_fence; struct list_head queued_entry; struct list_head done_entry; #ifdef CONFIG_VIDEO_ADV_DEBUG @@ -658,6 +664,15 @@ struct vb2_queue { spinlock_t done_lock; wait_queue_head_t done_wq; =20 + /* + * Per-queue dma_resv release-fence context. Drivers that opt + * into vb2_buffer_attach_release_fence() use these to allocate + * fences on a single per-queue timeline. + */ + u64 dma_resv_fence_context; + atomic64_t dma_resv_fence_seqno; + spinlock_t dma_resv_fence_lock; + unsigned int streaming:1; unsigned int start_streaming_called:1; unsigned int error:1; @@ -747,6 +762,20 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned= int plane_no); */ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); =20 +/** + * vb2_buffer_attach_release_fence() - opt-in dma_resv release fence. + * @vb: the buffer being queued to the producer. + * + * Drivers call this from their buf_queue callback to attach an + * exclusive write fence to each plane's dmabuf->resv. The fence + * is signalled and put by vb2_buffer_done() when the buffer + * transitions to VB2_BUF_STATE_DONE / _ERROR. Skips planes whose + * dbuf is NULL. + * + * Returns 0 on success, negative errno on allocation failure. + */ +int vb2_buffer_attach_release_fence(struct vb2_buffer *vb); + /** * vb2_discard_done() - discard all buffers marked as DONE. * @q: pointer to &struct vb2_queue with videobuf2 queue. --=20 2.47.3 From nobody Tue Jun 16 18:00:33 2026 Received: from web04.chillydomains.com (web04.chillydomains.com [193.19.92.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBD0D1A9F91 for ; Wed, 29 Apr 2026 20:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.19.92.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492811; cv=none; b=dqli8yMZaTITqFH2hUVl2Qge2HxcEqsWP7FE6yG9wQ1XfaD8nRbpqx4+2Sb3QAP8fieh2ceokaGd9/wVoM5LHCoHAa3ojDPFuHBXPIXMIvsO1UhjmxRd6JHwztRgMdYHkIphasr7/HVIeqPrh8JbhmERNylEXTJjBl1WgKmtcgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492811; c=relaxed/simple; bh=bpQhwmNJ5Qt5Sm/H8ouckcbUEO59Haf+aSyRcPSnAZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=isc5NB2pRgtVXFAaqgT5PVAICNS0PzRPBzL5KEWZEjzmhBqZTvwBY2gN6bNTAVz/D928etxDnsxOqGAm9oFhpB4UkQMxQO2BNOjT0k5p1dneiQCu2NxhwsuXA42iwdDz9NnSZMvrQEFrbaXb+FkL4fhkThyFxglInoXJIcdR+/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de; spf=none smtp.mailfrom=reauktion.de; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b=lrxD/WNw; arc=none smtp.client-ip=193.19.92.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=reauktion.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b="lrxD/WNw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web04.chillydomains.com; s=dkim; h=From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=+BMPRzE2ZaYndt8PUP9j3vTLvi6F1/BIe/ +XCjPPh4w=; b=lrxD/WNwHIEekuNqi8vyqW3sAshhJYlyBWCJnbqSeTMYEytjp+ UyGR2ATf8nRI1fDgeTXCln6LGbfU4BNAUXh/sUDzdti6LlZajf/4fLrePDzBpnfR Zo7FfaU9+6/4cWOP1EtpX0Nzmz3AyYUTl73wrxubhby8h1gzOUF1xTtmF0vyGvLV CjZU8gbZvp74M1UX9jJuJSqdVC+xjGUQYsICFy+ocDlBL0TMO0Ua+6ZF5cHRPUD/ DjvymalihIlfMzkrStbDUkw4uHkM/LTqfTPDlJT+m0gGPrUxqjE7F2chM01iLOPb OTNNJgyb9YhYocCpHiL/e7PC4y/B+Zw4YCyA== Received: (qmail 2739579 invoked by uid 7799); 29 Apr 2026 21:53:28 +0200 Received: by simscan 1.4.0 ppid: 2739543, pid: 2739553, t: 0.6181s scanners: clamav: 0.103.9/m:62/d:27778 Received: from 31.29.52.71.dynamic-pppoe.dt.ipv4.wtnet.de (HELO localhost) (automation@reauktion.de@31.29.52.71) by web04.chillydomains.com with SMTP [61968]; 29 Apr 2026 21:53:28 +0200 From: Markus Fritsche To: Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Ezequiel Garcia , Philipp Zabel , Jacob Chen , Heiko Stuebner Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 2/3] media: hantro: attach dma_resv release fence at buf_queue Date: Wed, 29 Apr 2026 19:53:05 +0000 Message-ID: <20260429195306.239666-3-mfritsche@reauktion.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260429195306.239666-1-mfritsche@reauktion.de> References: <20260429195306.239666-1-mfritsche@reauktion.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Opt the hantro driver into the new vb2 release-fence helper. When userspace QBUFs a buffer to hantro, the buffer is added to the driver's m2m queue via v4l2_m2m_buf_queue. We additionally call vb2_buffer_attach_release_fence() so each plane's dmabuf->resv gets a real producer fence attached. The fence is signalled by vb2_buffer_done when hantro completes the decode (via v4l2_m2m_buf_done_and_job_finish in hantro_drv.c, which converges on vb2_buffer_done). Wayland compositors (and any other userspace) that import hantro CAPTURE buffers and wait on the dmabuf's implicit-sync fence now wait on a real fence representing the producer's actual completion, not a stub. Validated end-to-end on PineTab2 (RK3566 / Mali-G52 / mainline 6.19 with this series backported) playing 1080p30 H.264 in chromium under stock KDE Plasma 6.6.4 Wayland: KWin's Transaction::watchDmaBuf wait completes correctly the moment hantro's IRQ fires, instead of falling back to a stub-resolved poll. Signed-off-by: Markus Fritsche --- drivers/media/platform/verisilicon/hantro_v4l2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index 62d3962c1..e95a3433a 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -877,6 +877,18 @@ static void hantro_buf_queue(struct vb2_buffer *vb) } =20 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); + + /* + * Opt in to vb2's dma_resv release-fence path. Userspace + * consumers that imported this buffer's dmabuf and wait on + * its implicit-sync fence (poll(POLLIN) or + * DMA_BUF_IOCTL_EXPORT_SYNC_FILE) get a real producer fence + * representing this device's completion, instead of the stub + * fence dma_buf_export_sync_file substitutes when dma_resv + * is empty. Best-effort: a fence-allocation failure means we + * lose implicit-sync precision, no functional regression. + */ + (void)vb2_buffer_attach_release_fence(vb); } =20 static bool hantro_vq_is_coded(struct vb2_queue *q) --=20 2.47.3 From nobody Tue Jun 16 18:00:33 2026 Received: from web04.chillydomains.com (web04.chillydomains.com [193.19.92.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26EF7383C95 for ; Wed, 29 Apr 2026 19:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.19.92.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492421; cv=none; b=A7cVOcAZ6+yd6ZRtGvoxOsUjm+fmNZiGhqnuPNwzbLVe5cnwFpNU2SVUn9u/kdIj2yuJnaBo8caSRtHMajUpiIzdTz2DupSBmvxpqTyIEp/JkNB1XRgAmY7Y/Cvc0En6WBjXJyCCHbX1R1Un1YouJdim0Jg+uQQ1g0GWowKHtwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777492421; c=relaxed/simple; bh=REH/NUdhinkJIbM6VqOY0rkDja+Ujbzq0BugVyp78aM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GoG1l2VVU/jI4na8r9towj8QHl78NO6a8LgaJM/H0RtgtAD3Bn9tD/cnnU/kLQDnsfS3Ii26dK3o2ZHaEVi+MOVjf4BO51LbYR3w92Edd/2IuMgfEeJyaN+w1z9+bWJD1fGBD5onbww3/nGVDKl0RfAJJKRFPnG5eYF19vcKadY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de; spf=none smtp.mailfrom=reauktion.de; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b=nGSlbyXY; arc=none smtp.client-ip=193.19.92.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reauktion.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=reauktion.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web04.chillydomains.com header.i=@web04.chillydomains.com header.b="nGSlbyXY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web04.chillydomains.com; s=dkim; h=From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=OaxA1KOQqFLnJwD8i8nhUbyHPWKOXYrj9Z YYoAP/kX0=; b=nGSlbyXYUKfQkPQwkan4V4FLTl1ALcyBc3+tUwIgRQWWxv/h2n pesTI414bf4N64kRjBeEU7tiq8EUc8Lt3K2VyQKx7gi/uE4xPiUZHDrY7kp9b/F4 oHJit6O9XlrqQYW4MFIBZkv9UdCHcSUMc/OMHRIvBSZtRhCECuv3o9eU3XyLpG9V TmJpMAYX7743WkMFHRFlvFATt01iFwwFinKlU6eewGwo3VYsymZlNMdFiI2mRIYh 3iMb+uUxr9SNY/mp3eHMABzA11kKqFvixLvby1WpBK3B2ddPiE27Vcc8VDeuGFsT ba9CvK9bEPNHt4W5Utk1BeuDJEL0QbRF4MgA== Received: (qmail 2740071 invoked by uid 7799); 29 Apr 2026 21:53:35 +0200 Received: by simscan 1.4.0 ppid: 2740007, pid: 2740026, t: 0.6149s scanners: clamav: 0.103.9/m:62/d:27778 Received: from 31.29.52.71.dynamic-pppoe.dt.ipv4.wtnet.de (HELO localhost) (automation@reauktion.de@31.29.52.71) by web04.chillydomains.com with SMTP [64183]; 29 Apr 2026 21:53:35 +0200 From: Markus Fritsche To: Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Ezequiel Garcia , Philipp Zabel , Jacob Chen , Heiko Stuebner Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 3/3] media: rockchip-rga: attach dma_resv release fence at buf_queue Date: Wed, 29 Apr 2026 19:53:06 +0000 Message-ID: <20260429195306.239666-4-mfritsche@reauktion.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260429195306.239666-1-mfritsche@reauktion.de> References: <20260429195306.239666-1-mfritsche@reauktion.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Opt the Rockchip RGA driver into the new vb2 release-fence helper. Same shape as the hantro patch: rga_buf_queue enqueues the buffer in the driver's m2m queue via v4l2_m2m_buf_queue and additionally attaches a release fence to each plane's dmabuf->resv via vb2_buffer_attach_release_fence(). vb2_buffer_done signals the fence when RGA completes the M2M operation. Userspace consumers of RGA-produced dmabufs (image-processing pipelines, screen-rotation servers, gstreamer flows on Rockchip boards) get spec-clean implicit-sync semantics, matching what hantro now does in the same patch series. Signed-off-by: Markus Fritsche --- drivers/media/platform/rockchip/rga/rga-buf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/= platform/rockchip/rga/rga-buf.c index 70808049d..5557ca632 100644 --- a/drivers/media/platform/rockchip/rga/rga-buf.c +++ b/drivers/media/platform/rockchip/rga/rga-buf.c @@ -153,6 +153,16 @@ static void rga_buf_queue(struct vb2_buffer *vb) struct rga_ctx *ctx =3D vb2_get_drv_priv(vb->vb2_queue); =20 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); + + /* + * Opt in to vb2's dma_resv release-fence path so userspace + * consumers of RGA-produced dmabufs get a real producer fence + * to wait on instead of the dma_buf core's stub fence. See + * the leading patch in this series for rationale. Best-effort: + * fence-allocation failure means we lose implicit-sync + * precision but the m2m operation itself proceeds normally. + */ + (void)vb2_buffer_attach_release_fence(vb); } =20 static void rga_buf_cleanup(struct vb2_buffer *vb) --=20 2.47.3