From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Maíra Canal" <mcanal@igalia.com>
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Faith Ekstrand" <faith.ekstrand@collabora.com>,
"Rob Herring" <robh@kernel.org>,
"Steven Price" <steven.price@arm.com>,
"Adrián Larumbe" <adrian.larumbe@collabora.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Akash Goel" <akash.goel@arm.com>,
"Karunika Choo" <karunika.choo@arm.com>,
"Lukas Zapolskas" <lukas.zapolskas@arm.com>,
"Chris Diamand" <chris.diamand@arm.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Alice Ryhl" <aliceryhl@google.com>,
kernel-dev@igalia.com, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs
Date: Fri, 20 Nov 2026 10:56:54 +0100 [thread overview]
Message-ID: <20261120105654.63e1c254@fedora1.home> (raw)
In-Reply-To: <20261119-pan-drop-dma-buf-hooks-v1-0-6c6f1629e7f9@igalia.com>
Hi Maira,
On Thu, 19 Nov 2026 16:38:15 -0300
Maíra Canal <mcanal@igalia.com> wrote:
> This series follows up on the discussion in the V3D cached maps series
> [1], about how to handle CPU-cached BOs that are shared through dma-buf.
>
> As pointed by Faith and Boris, when a buffer is shared through dma-buf,
> there's no way to ensure that a client will properly bracket their CPU
> accesses with DMA_BUF_IOCTL_SYNC. With WC mappings, waiting on fences is
> enough to guarantee consistency. However, with WB mappings, a missed sync
> can leave dirty cache lines behind, which another client can end up
> writing over.
>
> PanVK already keeps WB_MMAP BOs private, so this series only makes the
> kernel enforce the same policy on Panfrost and Panthor. As WB_MMAP BOs can
> no longer be exported, the custom dma_buf_ops providing begin/end_cpu_access()
> are no longer needed for them and are replaced by the default PRIME ops.
>
> - Patch 1 adds the drm_gem_shmem_sync() helper, taken from [2].
> - Patches 2 and 5 refuse to export WB_MMAP BOs in Panfrost and Panthor.
> - Patches 3 and 6 drop the custom dma_buf_ops from Panfrost and Panthor.
> - Patch 4 converts Panfrost to drm_gem_shmem_sync(). V3D will also use it
> to implement its cached maps, which I'll send in a separate series.
>
> Patches 3 and 6 need some extra attention as they aren't a no-op on
> IO-coherent GPUs. In this case, all BOs are CPU-mapped WB, and the custom
> begin/end_cpu_access() could be used to sync the mappings of non-coherent
> importers.
Ah, I completely forgot about this, thanks for the reminder. If we have
a system where the GPU is IO-coherent, but the video decoder or the
display controller isn't, we either need to force CPU-uncached
mappings for everybody with extra forced syncs on the UMD side for that
case (right now we assume that IO coherent implies always-WB IIRC), or
we need CPU access signalization with a proper begin/end_cpu_access()
implementation to keep things consistent when cross-dev sharing is
involved. I think this was the very reason I decided to keep the
begin/end_cpu_access() implementation in panfrost/panthor in the first
place.
Note that the same problem can exist if the other device is the
exporter and is IO coherent, but the GPU isn't. If the exporter were to
expose CPU mappings as cached without proper sync hooks, we'd face the
same problem. One way to avoid it would be to never CPU map imported
buffers in mesa, but IIRC, that's not an option.
>
> However, I decided to send these patches either way because they only
> restore the behavior prior to commits 3ae6637378e6 and 925ad0c26dd8, which
> is what we discussed in [1] (IIUC). Also, Mesa writes through the GEM mmap
> without DMA_BUF_IOCTL_SYNC, so it never relied on these hooks anyway.
Mesa doesn't, but there might be other elements in-between (video
decoder, and some custom layers analyzing/touching frames from the CPU
before they're passed to the GPU). I get the "it used to work" argument,
but I'm worried we're going backwards here. I also hate the fact we're
going back to a "broken" implementation without even updating the dmabuf
docs to explain that this sync-around-CPU-access mechanism is
deprecated/fragile/broken and shouldn't be relied on.
>
> Still, if you think this would be problematic, I can drop patches 3 and 6.
I was about to suggest forcing uncached CPU mappings for shareable BOs
on systems where the GPU is IO coherent, but there's actually no way we
can know whether a BO will be exported on not on Panfrost (on Panthor
we at least have this exclusive_vm thing that gives this guarantee). So
there's actually no way around it, it's either going back to a "broken"
state (broken in the sense it's not doing what it's supposed to, but no
one really complained in the past) or keep this sync logic to try to do
our best (even if it's not entirely safe, especially if the importer
does crazy stuff like pretending to be UMA when it's not).
Sorry for not having a better answer than: it might be okay, but it
looks wrong. Every time I tried to understand what's expected from us
for this shared buffer synchronization, I ended up more confused than
before...
>
> The Panthor changes were tested on hardware, but Panfrost changes were
> only compile-tested.
Could you prepare a custom gfx-ci kernel [1] so we can check that mesa
CI is not regressed by this change? I know none of the tests in mesa CI
would normally hit the removed logic, but better safe than sorry.
Regards,
Boris
[1]https://gitlab.freedesktop.org/gfx-ci/linux
prev parent reply other threads:[~2026-11-20 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
2026-11-19 19:38 ` [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops Maíra Canal
2026-11-19 19:38 ` [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
2026-11-19 19:38 ` [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops Maíra Canal
2026-11-20 9:56 ` Boris Brezillon [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=20261120105654.63e1c254@fedora1.home \
--to=boris.brezillon@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=akash.goel@arm.com \
--cc=aliceryhl@google.com \
--cc=chris.diamand@arm.com \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=faith.ekstrand@collabora.com \
--cc=karunika.choo@arm.com \
--cc=kernel-dev@igalia.com \
--cc=liviu.dudau@arm.com \
--cc=lukas.zapolskas@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/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