[igt-dev] [PATCH i-g-t 2/3] lib/xe_query: Add memory region getter from region mask

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Fri Mar 31 09:16:59 UTC 2023


Due to xe is strict regarding bo create size we need to be aware
what's driver allocations restrictions. Add a getter for memory
region which describes requirements.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 lib/xe/xe_query.c | 12 ++++++++++++
 lib/xe/xe_query.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index f281bc4a31..24a258a5e1 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -426,6 +426,18 @@ struct drm_xe_engine_class_instance *xe_hw_engine(int fd, int idx)
 	return &xe_dev->hw_engines[idx];
 }
 
+struct drm_xe_query_mem_region *xe_mem_region(int fd, uint64_t region)
+{
+	struct xe_device *xe_dev;
+	int region_idx = ffs(region) - 1;
+
+	xe_dev = find_in_cache(fd);
+	igt_assert(xe_dev);
+	igt_assert(xe_dev->mem_usage->num_regions > region_idx);
+
+	return &xe_dev->mem_usage->regions[region_idx];
+}
+
 /**
  * xe_number_hw_engine:
  * @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index fddd05cf73..0d4b810a10 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -83,6 +83,7 @@ uint64_t vram_memory(int fd, int gt);
 uint64_t vram_if_possible(int fd, int gt);
 struct drm_xe_engine_class_instance *xe_hw_engines(int fd);
 struct drm_xe_engine_class_instance *xe_hw_engine(int fd, int idx);
+struct drm_xe_query_mem_region *xe_mem_region(int fd, uint64_t region);
 unsigned int xe_number_hw_engines(int fd);
 bool xe_has_vram(int fd);
 //uint64_t xe_vram_size(int fd);
-- 
2.34.1



More information about the igt-dev mailing list