Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Florian Krischer <florian.krischer@fkr.dev>
To: Dmitry Osipenko <digetx@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Thierry Reding <thierry.reding@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-media@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/2] media: tegra-vde: map capture planes bidirectionally
Date: Sun, 29 Nov 2026 18:46:51 +0100	[thread overview]
Message-ID: <20261129174651.4117938-2-florian.krischer@fkr.dev> (raw)
In-Reply-To: <20261129174651.4117938-1-florian.krischer@fkr.dev>

The decoder writes pictures into CAPTURE buffers and reads those
pictures again when they are used as H.264 references. The CAPTURE
queue and the driver's DMA-BUF import path currently describe the
planes as device-write-only.

Mark the CAPTURE queue bidirectional and use the direction set by
videobuf2 for the driver's DMA-BUF imports. This keeps both mapping
paths in sync and preserves the OUTPUT direction. Leave allocation
attributes and auxiliary buffers unchanged.

Signed-off-by: Florian Krischer <florian.krischer@fkr.dev>
---
Build-tested for ARM with W=1 on media-committers/next with the
separately submitted mutex fix applied.
On an ASUS SL101 running v7.4-rc4 with the mutex fix, both the
baseline and the two-patch RFC completed three 60-frame H.264
decodes (4 I-frames, 56 P-frames) with identical I420 hashes.
Ioctl tracing confirmed MMAP CAPTURE on both kernels. Neither
run logged a new VDE warning. DMA-BUF import and cross-direction
reuse remain untested.

Does this scope make sense for CAPTURE planes? I would also welcome
feedback on cache-maintenance costs on noncoherent systems.

Thanks for taking a look.

 drivers/media/platform/nvidia/tegra-vde/v4l2.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -151,7 +151,6 @@
 	struct tegra_ctx *ctx = vb2_get_drv_priv(vq);
 	struct tegra_m2m_buffer *tb = vb_to_tegra_buf(vb);
 	struct tegra_vde *vde = ctx->vde;
-	enum dma_data_direction dma_dir;
 	struct sg_table *sgt;
 	unsigned int i;
 	int err;
@@ -167,17 +166,12 @@
 			return err;
 	}
 
-	if (V4L2_TYPE_IS_OUTPUT(vq->type))
-		dma_dir = DMA_TO_DEVICE;
-	else
-		dma_dir = DMA_FROM_DEVICE;
-
 	for (i = 0; i < vb->num_planes; i++) {
 		if (vq->memory == VB2_MEMORY_DMABUF) {
 			get_dma_buf(vb->planes[i].dbuf);
 
 			err = tegra_vde_dmabuf_cache_map(vde, vb->planes[i].dbuf,
-							 dma_dir, &tb->a[i],
+							 vq->dma_dir, &tb->a[i],
 							 &tb->dma_base[i]);
 			if (err) {
 				dma_buf_put(vb->planes[i].dbuf);
@@ -386,6 +380,8 @@
 	dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
 	dst_vq->io_modes = VB2_DMABUF | VB2_MMAP;
 	dst_vq->lock = &vde->v4l2_lock;
+	/* VDE reads decoded pictures back as references. */
+	dst_vq->bidirectional = true;
 	dst_vq->dma_attrs = dma_attrs;
 	dst_vq->mem_ops = mem_ops;
 	dst_vq->ops = &tegra_qops;

base-commit: fb8b2c10a588f1384b98280b1c32307da9db4747

      reply	other threads:[~2026-11-29 17:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 17:46 [RFC PATCH 1/2] media: tegra-vde: match DMA direction on cache reuse Florian Krischer
2026-11-29 17:46 ` Florian Krischer [this message]

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=20261129174651.4117938-2-florian.krischer@fkr.dev \
    --to=florian.krischer@fkr.dev \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=thierry.reding@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