Mesa (main): intel/stub: Implement DRM_I915_QUERY_MEMORY_REGIONS
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Dec 9 19:22:43 UTC 2021
Module: Mesa
Branch: main
Commit: 832db9d9008e32f2da5d4180b9a3a896258bce20
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=832db9d9008e32f2da5d4180b9a3a896258bce20
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Mon Dec 6 12:56:01 2021 -0800
intel/stub: Implement DRM_I915_QUERY_MEMORY_REGIONS
Borrowed from sim-drm.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14132>
---
src/intel/tools/intel_noop_drm_shim.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/intel/tools/intel_noop_drm_shim.c b/src/intel/tools/intel_noop_drm_shim.c
index ec237cb23e2..fbb475da9ac 100644
--- a/src/intel/tools/intel_noop_drm_shim.c
+++ b/src/intel/tools/intel_noop_drm_shim.c
@@ -352,6 +352,40 @@ i915_ioctl_query(int fd, unsigned long request, void *arg)
item->length = -EINVAL;
break;
+ case DRM_I915_QUERY_MEMORY_REGIONS: {
+ uint32_t num_regions = i915.devinfo.has_local_mem ? 2 : 1;
+ struct drm_i915_query_memory_regions *info =
+ (struct drm_i915_query_memory_regions*)(uintptr_t)item->data_ptr;
+ size_t data_length = sizeof(struct drm_i915_query_memory_regions) +
+ num_regions * sizeof(struct drm_i915_memory_region_info);
+
+ if (item->length == 0) {
+ item->length = data_length;
+ return 0;
+ } else if (item->length < (int32_t)data_length) {
+ item->length = -EINVAL;
+ return -1;
+ } else {
+ memset(info, 0, data_length);
+ info->num_regions = num_regions;
+ info->regions[0].region.memory_class = I915_MEMORY_CLASS_SYSTEM;
+ info->regions[0].region.memory_instance = 0;
+ /* Report 4Gb even if it's not actually true, it looks more like a
+ * real device.
+ */
+ info->regions[0].probed_size = 4ull * 1024 * 1024 * 1024;
+ info->regions[0].unallocated_size = -1ll;
+ if (i915.devinfo.has_local_mem) {
+ info->regions[1].region.memory_class = I915_MEMORY_CLASS_DEVICE;
+ info->regions[1].region.memory_instance = 0;
+ info->regions[1].probed_size = 4ull * 1024 * 1024 * 1024;
+ info->regions[1].unallocated_size = -1ll;
+ }
+ return 0;
+ }
+ break;
+ }
+
default:
fprintf(stderr, "Unknown drm_i915_query_item id=%lli\n", item->query_id);
item->length = -EINVAL;
More information about the mesa-commit
mailing list