From 21ac210ab2da270ffb4fa0c20e19402cf80c60e5 Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Mon, 29 Jul 2024 09:21:16 -0300 Subject: [PATCH] panfrost: make PAN_MESA_DEBUG=dump really show all GPU memory The flag is advertised to dump all GPU memory, but really only dumps mapped memory, so some significant pieces (like textures) are left out. Change this by mapping as much as possible when the dump flag is given. Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_bo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_bo.c b/src/gallium/drivers/panfrost/pan_bo.c index 61f92c6135c..af85d3aeb5b 100644 --- a/src/gallium/drivers/panfrost/pan_bo.c +++ b/src/gallium/drivers/panfrost/pan_bo.c @@ -368,6 +368,14 @@ panfrost_bo_create(struct panfrost_device *dev, size_t size, uint32_t flags, { struct panfrost_bo *bo; + if (dev->debug & PAN_DBG_DUMP) { + /* Make sure to CPU-map all BOs except growable ones, so that + we can dump them when PAN_MESA_DEBUG=dump. */ + if (!(flags & PAN_BO_GROWABLE)) { + flags &= ~PAN_BO_INVISIBLE; + } + flags &= ~PAN_BO_DELAY_MMAP; + } /* Kernel will fail (confusingly) with EPERM otherwise */ assert(size > 0); @@ -499,6 +507,10 @@ panfrost_bo_import(struct panfrost_device *dev, int fd) bo->ptr.gpu = vm_op.va.start; bo->flags = PAN_BO_SHARED; p_atomic_set(&bo->refcnt, 1); + + /* mmap imported BOs when PAN_MESA_DEBUG=dump */ + if (dev->debug & PAN_DBG_DUMP) + panfrost_bo_mmap(bo); } else { /* bo->refcnt == 0 can happen if the BO * was being released but panfrost_bo_import() acquired the