From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Akash Goel <akash.goel@arm.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>, Chia-I Wu <olvaffe@gmail.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Boris Brezillon <boris.brezillon@collabora.com>
Subject: [PATCH 3/3] drm/panthor: Move cache-flush after UPDATE(UNMAPPED)
Date: Thu, 24 Sep 2026 14:30:45 +0200 [thread overview]
Message-ID: <20260924-panthor-mmu-fixes-v1-3-e25f9b106466@collabora.com> (raw)
In-Reply-To: <20260924-panthor-mmu-fixes-v1-0-e25f9b106466@collabora.com>
Right now, there's a theoretical window during which the GPU can populate
the cache with data from a VM that's about to be evicted through the
UPDATE(UNMAPPED) command.
In practice this won't happen (hence the absence of Fixes tag) because
when panthor_mmu_as_disable() is called, the VM is guaranteed to be idle
(no active CSG pointing to this VM), but as we say, better safe than
sorry.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/panthor/panthor_mmu.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 038a092fd08c..bb71274aa36b 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -631,12 +631,6 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
panthor_mmu_irq_disable_events(&ptdev->mmu->irq,
panthor_mmu_as_fault_mask(ptdev, as_nr));
- /* Flush+invalidate RW caches, invalidate RO ones. */
- ret = panthor_gpu_flush_caches(ptdev, CACHE_CLEAN | CACHE_INV,
- CACHE_CLEAN | CACHE_INV, 0);
- if (ret)
- return ret;
-
if (vm && vm->locked_region.size) {
/* Unlock the region if there's a lock pending. */
ret = as_send_cmd_and_wait(ptdev, vm->as.id, AS_COMMAND_UNLOCK);
@@ -648,7 +642,18 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
gpu_write64(mmu->iomem, AS_MEMATTR(as_nr), 0);
gpu_write64(mmu->iomem, AS_TRANSCFG(as_nr), AS_TRANSCFG_ADRMODE_UNMAPPED);
- return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UPDATE);
+ ret = as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UPDATE);
+ if (ret)
+ return ret;
+
+ /* Flush+invalidate RW caches after we've unmapped, to make sure any
+ * cacheline eviction is effective before we potentially return
+ * memory pointed by this VM to the system. This needs to be done
+ * after the UPDATE(UNMAPPED) operation to guarantee that not further
+ * PT-walk can pull VM data into the cache.
+ */
+ return panthor_gpu_flush_caches(ptdev, CACHE_CLEAN | CACHE_INV,
+ CACHE_CLEAN | CACHE_INV, 0);
}
static u32 panthor_mmu_fault_mask(struct panthor_device *ptdev, u32 value)
--
2.55.0
prev parent reply other threads:[~2026-09-24 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 12:30 [PATCH 0/3] drm/panthor: Misc MMU fixes/robustness improvements Boris Brezillon
2026-09-24 12:30 ` [PATCH 1/3] drm/panthor: Don't invalidate OTHER caches Boris Brezillon
2026-09-24 12:30 ` [PATCH 2/3] drm/panthor: Fully disable the AS even if it's going to be re-assigned Boris Brezillon
2026-09-24 12:30 ` 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=20260924-panthor-mmu-fixes-v1-3-e25f9b106466@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=airlied@gmail.com \
--cc=akash.goel@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--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
all inboxes | Powered by JetHome®