Mesa (master): intel/dump_gpu: only write BOs mapped by the driver

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 7 11:36:26 UTC 2020


Module: Mesa
Branch: master
Commit: 63c90acc9eba2c7252794b415ad4d5ace6956c4e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=63c90acc9eba2c7252794b415ad4d5ace6956c4e

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu Oct  3 02:13:32 2019 +0300

intel/dump_gpu: only write BOs mapped by the driver

Track what BOs are mapped by the driver and only write those. We can
safely assume that when not mapped there is no data to save.

v2: Don't forget to return the ret (Rafael)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2201>

---

 src/intel/tools/intel_dump_gpu.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c
index 24dd1dffcaa..1b6a1fa6cb9 100644
--- a/src/intel/tools/intel_dump_gpu.c
+++ b/src/intel/tools/intel_dump_gpu.c
@@ -65,6 +65,7 @@ struct bo {
    uint32_t size;
    uint64_t offset;
    void *map;
+   bool mapped;
 };
 
 static struct bo *bos;
@@ -285,12 +286,14 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
       else
          data = bo->map;
 
-      if (bo == batch_bo) {
-         aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,
-                               GET_PTR(data), bo->size, bo->offset);
-      } else {
-         aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,
-                               GET_PTR(data), bo->size, bo->offset);
+      if (bo->mapped) {
+         if (bo == batch_bo) {
+            aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,
+                                  GET_PTR(data), bo->size, bo->offset);
+         } else {
+            aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,
+                                  GET_PTR(data), bo->size, bo->offset);
+         }
       }
 
       if (data != bo->map)
@@ -331,6 +334,7 @@ add_new_bo(unsigned fd, int handle, uint64_t size, void *map)
 
    bo->size = size;
    bo->map = map;
+   bo->mapped = false;
 }
 
 static void
@@ -342,6 +346,7 @@ remove_bo(int fd, int handle)
       munmap(bo->map, bo->size);
    bo->size = 0;
    bo->map = NULL;
+   bo->mapped = false;
 }
 
 __attribute__ ((visibility ("default"))) int
@@ -636,6 +641,16 @@ ioctl(int fd, unsigned long request, ...)
          return ret;
       }
 
+      case DRM_IOCTL_I915_GEM_MMAP: {
+         ret = libc_ioctl(fd, request, argp);
+         if (ret == 0) {
+            struct drm_i915_gem_mmap *mmap = argp;
+            struct bo *bo = get_bo(fd, mmap->handle);
+            bo->mapped = true;
+         }
+         return ret;
+      }
+
       default:
          return libc_ioctl(fd, request, argp);
       }



More information about the mesa-commit mailing list