From: "Christian König" <christian.koenig@amd.com>
To: Karl Mehltretter <kmehltretter@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomasz Figa <tfiga@chromium.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Hans de Goede <hansg@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Nicolas Dufresne <nicolas@ndufresne.ca>,
Sumit Semwal <sumit.semwal@linaro.org>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/3] media: synchronize CPU access to imported DMA-BUFs
Date: Thu, 12 Nov 2026 10:52:14 +0100 [thread overview]
Message-ID: <698c5faa-609f-405e-a33a-a48fefd8d411@amd.com> (raw)
In-Reply-To: <avUvHGb4talXW7qS@gmail.com>
On 11/12/26 04:16, Karl Mehltretter wrote:
> On Sat, Nov 07, 2026 at 12:59:46PM +0100, Laurent Pinchart wrote:
>> Hi Karl,
>>
>> We discussed in v1 how this is not the right approach. Why are you
>> posting a v2 without addressing that ? You need to go back to the design
>> table.
>>
>
> v1 ended with two conflicting positions on non-coherent DMA-BUFs:
>
> - Laurent [1] and Nicolas [2]: end_cpu_access(WRITE) only marks the CPU
> cache dirty, and non-coherent DMA importers clean before starting DMA.
> Persistent DRM/KMS imports then need a sync call on each submission.
> - Christian [3]: devices must access DMA-BUFs coherently with the CPU,
> using begin/end_cpu_access() around CPU accesses. Importing a buffer
> with dirty CPU caches onto a non-coherent device is intentionally
> unsupported. Today cma_heap and system_heap sync all mapped
> attachments inside begin/end_cpu_access().
>
> On my Pi 500+ with a USB UVC camera (640x480 YUYV) and V3D on CMA
> DMA-BUFs:
>
> - Without vb2 CPU sync, V3D reads stale data on 8/8 zero-copy frames.
> - With vb2 begin/end_cpu_access() on cma_heap, zero-copy V3D is clean
> (0/8 stale). CPU capture takes 91 us/frame without a V3D import, and
> 144 us/frame when an idle V3D PRIME import is attached.
> - With a test heap that tracks CPU cache state and syncs imported BOs
> at V3D job submission, zero-copy V3D stays clean (0/8 stale) and the
> idle-V3D CPU read drops back to 89 us/frame.
>
> Question to all: should I look at opt-in cache-state tracking in
> dma-buf (with a sync call before DMA submission), or keep
> begin/end_cpu_access() as is and handle CPU consumers via V4L2 cache
> hints?
A sync call before DMA operation is something we intentionally rejected.
Background is that exporters should export the buffers as they need/use it and not have specialized handling just to serve importers which would be not testable without the importer etc...
What we could do is to consistently use begin/end_cpu_access() and/or let exporters expose if their buffers might be dirty in the CPU cache so that importers can properly reject them.
Regards,
Christian.
>
> [1] https://lore.kernel.org/r/20261021175900.GG15441@killaraus.ideasonboard.com/
> [2] https://lore.kernel.org/r/7e4c7707880e9092180d28484ecf674be29b40a0.camel@ndufresne.ca/
> [3] https://lore.kernel.org/r/1e798600-5a76-412a-959c-94313629baf4@amd.com/
>
> Thanks,
> Karl
prev parent reply other threads:[~2026-11-12 9:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 10:47 [PATCH v2 0/3] media: synchronize CPU access to imported DMA-BUFs Karl Mehltretter
2026-11-07 10:47 ` [PATCH v2 1/3] media: videobuf2: add opt-in DMA-BUF CPU access Karl Mehltretter
2026-11-07 10:47 ` [PATCH v2 2/3] media: uvcvideo: synchronize imported DMA-BUFs for " Karl Mehltretter
2026-11-07 10:47 ` [PATCH v2 3/3] media: vivid: " Karl Mehltretter
2026-11-07 10:59 ` [PATCH v2 0/3] media: synchronize CPU access to imported DMA-BUFs Laurent Pinchart
2026-11-12 3:16 ` Karl Mehltretter
2026-11-12 9:52 ` Christian König [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=698c5faa-609f-405e-a33a-a48fefd8d411@amd.com \
--to=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hansg@kernel.org \
--cc=hverkuil@kernel.org \
--cc=kmehltretter@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=sumit.semwal@linaro.org \
--cc=tfiga@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.