From: sashiko-bot@kernel.org
To: "Maíra Canal" <mcanal@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RFC 02/12] drm/shmem: Provide a generic {begin, end}_cpu_access() implementation
Date: Fri, 30 Oct 2026 21:04:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-191509@kernel.org> (raw)
In-Reply-To: <20261030-v3d-cached-maps-v1-2-0a6a6b363382@igalia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/shmem: wrong vmap flush order in drm_gem_shmem_prime_end_cpu_access()
--
commit 4543a541900e1a7c8880d3f04fbf76393b153371
Author: Boris Brezillon <boris.brezillon@collabora.com>
drm/shmem: Provide a generic {begin, end}_cpu_access() implementation
This commit adds default dma_buf_ops implementations for map_dma_buf,
unmap_dma_buf, begin_cpu_access, and end_cpu_access to drm_gem_shmem_helper
so that CPU caches and vmap ranges are synchronized across the exporter and
all mapped attachments.
[Severity: Medium]
In drivers/gpu/drm/drm_gem_shmem_helper.c, inside
drm_gem_shmem_prime_end_cpu_access() (around line 1093), should
flush_kernel_vmap_range(shmem->vaddr, shmem->base.size) be called before
iterating over dma_buf->attachments and calling
dma_sync_sgtable_for_device(attach->dev, sgt, dir)?
Currently, drm_gem_shmem_prime_end_cpu_access() syncs each attachment's
sg_table for the device first, then calls flush_kernel_vmap_range() on
shmem->vaddr, and finally calls dma_sync_sgtable_for_device() on shmem->sgt.
When a cacheable shmem GEM object (with map_wc set to false) is exported,
mapped by an importing device via drm_gem_shmem_prime_map_dma_buf(), and
also mapped into kernel virtual address space via drm_gem_shmem_vmap_locked(),
modifications made through shmem->vaddr may sit in a virtually indexed or
aliasing cache line (such as on 32-bit arm with vivt or vipt-aliasing caches
and an outer l2 cache, or mips with primary d-cache aliasing). Calling
dma_sync_sgtable_for_device() on the importer attachments before
flush_kernel_vmap_range() means the virtual alias in shmem->vaddr has not yet
been written back when dma_sync_sgtable_for_device() cleans the physical
mapping, cleans the outer cache, or copies to swiotlb bounce buffers, which
can leave importing devices reading stale data.
As documented in Documentation/core-api/cachetlb.rst and done in other
dma-buf exporters such as system_heap_dma_buf_end_cpu_access() and
cma_heap_dma_buf_end_cpu_access(), flush_kernel_vmap_range() should happen
before all dma_sync_sgtable_for_device() calls.
Similarly, in drm_gem_shmem_prime_begin_cpu_access() (around line 1058),
invalidate_kernel_vmap_range(shmem->vaddr, shmem->base.size) is placed
between syncing shmem->sgt and syncing dma_buf->attachments. Should
invalidate_kernel_vmap_range() be called after all
dma_sync_sgtable_for_cpu() calls have completed so that both exporter and
importer sg_table syncs are ordered consistently with respect to the kernel
vmap range invalidation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030-v3d-cached-maps-v1-0-0a6a6b363382@igalia.com?part=2
next prev parent reply other threads:[~2026-10-30 21:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 20:50 [PATCH RFC 00/12] drm/v3d: Add support for write-back cacheable BOs Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 01/12] drm/prime: Allow custom dma_buf_ops in PRIME helpers Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 02/12] drm/shmem: Provide a generic {begin, end}_cpu_access() implementation Maíra Canal
2026-10-30 21:04 ` sashiko-bot [this message]
2026-10-30 20:50 ` [PATCH RFC 03/12] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
2026-10-30 21:11 ` sashiko-bot
2026-10-30 20:50 ` [PATCH RFC 04/12] drm/panfrost: Use PRIME helpers with custom dma_buf_ops Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 05/12] drm/panfrost: Use common shmem helpers for dma_buf CPU access Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 06/12] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 07/12] drm/panthor: Use PRIME helpers with custom dma_buf_ops Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 08/12] drm/amdgpu: Use drm_gem_prime_export_with_ops() Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 09/12] drm/v3d: Provide a custom dma_buf implementation Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 10/12] drm/v3d: Add flag to map BOs write-back cacheable Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 11/12] drm/v3d: Add a DRM_IOCTL_V3D_SYNC_BO ioctl Maíra Canal
2026-10-30 20:50 ` [PATCH RFC 12/12] drm/v3d: Advertise support for write-back cacheable BOs Maíra Canal
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=sashiko-outbox-191509@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mcanal@igalia.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.