From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: "Steven Price" <steven.price@arm.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
dri-devel@lists.freedesktop.org,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Akash Goel" <akash.goel@arm.com>,
"Rob Clark" <robin.clark@oss.qualcomm.com>,
"Sean Paul" <sean@poorly.run>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Akhil P Oommen" <akhilpo@oss.qualcomm.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Chris Diamand" <chris.diamand@arm.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Alice Ryhl" <aliceryhl@google.com>,
kernel@collabora.com
Subject: Re: [PATCH v3 9/9] drm/panthor: Add a GEM shrinker
Date: Mon, 16 Feb 2026 09:57:14 +0100 [thread overview]
Message-ID: <20260216095714.40a7e5ec@fedora> (raw)
In-Reply-To: <aY9oM5MY6Jntm3oy@sobremesa>
On Fri, 13 Feb 2026 18:23:34 +0000
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> > +static int remap_evicted_vma(struct drm_gpuvm_bo *vm_bo,
> > + struct panthor_vma *evicted_vma,
> > + struct panthor_vm_op_ctx *op_ctx)
> > +{
> > + struct panthor_vm *vm = container_of(vm_bo->vm, struct panthor_vm, base);
> > + struct panthor_gem_object *bo = to_panthor_bo(vm_bo->obj);
> > + struct drm_gpuva *va;
> > + bool found = false;
> > + int ret;
> > +
> > + ret = panthor_vm_op_ctx_prealloc_pts(op_ctx);
> > + if (ret)
> > + goto out_cleanup;
> > +
> > + /* Take op_lock to protect against va insertion/removal. */
> > + mutex_lock(&vm->op_lock);
> > + drm_gpuvm_bo_for_each_va(va, vm_bo) {
> > + struct panthor_vma *vma = container_of(va, struct panthor_vma, base);
> > +
> > + if (vma != evicted_vma)
> > + continue;
> > +
> > + /* We can't rely solely on pointer equality, because the VMA might have been
> > + * freed and a new one allocated at the same address. If the evicted bit
> > + * is still set, we're sure it's our VMA, because population/eviction is
> > + * serialized with the BO resv lock.
> > + */
>
> At first I thought to avoid having VM_BIND operations change the VM's VMA's in the interval between
> select_evicted_vma() and remap_evicted_vma(), maybe you could take the VM's operation lock around both of them
> in panthor_vm_restore_vmas(). But because the same lock is taken in the dma signalling path and
> panthor_vm_op_ctx_prealloc_pts() can sleep, then we cannot do that. Maybe you could add a note clarifying this?
Sure, how about
index 78b875a59d1e..9ce4077bef8e 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -2395,7 +2395,11 @@ static int remap_evicted_vma(struct drm_gpuvm_bo *vm_bo,
if (ret)
goto out_cleanup;
- /* Take op_lock to protect against va insertion/removal. */
+ /* Take op_lock to protect against va insertion/removal. Note that the
+ * evicted_vma selection was done with the same lock held, but we had
+ * to release it so we can allocate PTs, because this very same lock
+ * is taken in a DMA-signalling path.
+ */
mutex_lock(&vm->op_lock);
drm_gpuvm_bo_for_each_va(va, vm_bo) {
struct panthor_vma *vma = container_of(va, struct panthor_vma, base);
@@ -2403,10 +2407,11 @@ static int remap_evicted_vma(struct drm_gpuvm_bo *vm_bo,
if (vma != evicted_vma)
continue;
- /* We can't rely solely on pointer equality, because the VMA might have been
- * freed and a new one allocated at the same address. If the evicted bit
- * is still set, we're sure it's our VMA, because population/eviction is
- * serialized with the BO resv lock.
+ /* Because we had to release the lock between the evicted_vma selection
+ * and its repopulation, we can't rely solely on pointer equality (the
+ * VMA might have been freed and a new one allocated at the same address).
+ * If the evicted bit is still set, we're sure it's our VMA, because
+ * population/eviction is serialized with the BO resv lock.
*/
if (vma->evicted)
found = true;
?
prev parent reply other threads:[~2026-02-16 8:57 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 8:03 [PATCH v3 0/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 1/9] drm/gem: Consider GEM object reclaimable if shrinking fails Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 2/9] drm/panthor: Move panthor_gems_debugfs_init() to panthor_gem.c Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 3/9] drm/panthor: Group panthor_kernel_bo_xxx() helpers Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 4/9] drm/panthor: Don't call drm_gpuvm_bo_extobj_add() if the object is private Boris Brezillon
2026-02-11 15:57 ` Steven Price
2026-02-12 11:04 ` Liviu Dudau
2026-02-11 8:03 ` [PATCH v3 5/9] drm/panthor: Part ways with drm_gem_shmem_object Boris Brezillon
2026-02-11 15:58 ` Steven Price
2026-02-12 11:07 ` Boris Brezillon
2026-02-12 14:20 ` Liviu Dudau
2026-02-12 19:46 ` Chia-I Wu
2026-02-13 18:01 ` Adrián Larumbe
2026-02-16 9:06 ` Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 6/9] drm/panthor: Lazily allocate pages on mmap() Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 7/9] drm/panthor: Split panthor_vm_prepare_map_op_ctx() to prepare for reclaim Boris Brezillon
2026-02-11 8:03 ` [PATCH v3 8/9] drm/panthor: Track the number of mmap on a BO Boris Brezillon
2026-02-11 16:08 ` Steven Price
2026-02-12 11:08 ` Boris Brezillon
2026-02-12 17:16 ` Liviu Dudau
2026-02-11 8:03 ` [PATCH v3 9/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-02-13 0:43 ` Chia-I Wu
2026-02-13 9:12 ` Boris Brezillon
2026-02-16 8:50 ` Boris Brezillon
2026-02-13 1:19 ` Chia-I Wu
2026-02-16 8:51 ` Boris Brezillon
2026-02-13 18:23 ` Adrián Larumbe
2026-02-16 8:57 ` 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=20260216095714.40a7e5ec@fedora \
--to=boris.brezillon@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=akash.goel@arm.com \
--cc=akhilpo@oss.qualcomm.com \
--cc=aliceryhl@google.com \
--cc=chris.diamand@arm.com \
--cc=dakr@kernel.org \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=konradybcio@kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=thomas.hellstrom@linux.intel.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