[igt-dev] [PATCH i-g-t 1/2] lib/i915/intel_memory_region: Provide system memory region stub

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Dec 8 17:24:15 UTC 2021


For stable kernels we can currently get -ENODEV on integrated gens
when no CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM is set.

Provide system memory region stub to avoid failing on querying
kernel for memory regions.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
 lib/i915/intel_memory_region.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 058b273dc..668e39439 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -123,9 +123,18 @@ struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
 	 * Any DRM_I915_QUERY_MEMORY_REGIONS specific errors are encoded in the
 	 * item.length, even though the ioctl might still return success.
 	 */
+
 	if (item.length < 0) {
-		igt_critical("DRM_I915_QUERY_MEMORY_REGIONS failed with %d\n",
-			     item.length);
+		/*
+		 * If kernel supports query but not memory regions query
+		 * just return predefined system memory region only.
+		 */
+		size_t sys_qi_size =
+			(char *) &query_info->regions[1] - (char *) query_info;
+
+		query_info = calloc(1, sys_qi_size);
+		query_info->num_regions = 1;
+		query_info->regions[0].region.memory_class = I915_MEMORY_CLASS_SYSTEM;
 		goto out;
 	}
 
-- 
2.26.0



More information about the igt-dev mailing list