[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
Thu Dec 9 20:04:52 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.
v2: use offsetof() instead of manual size calculation
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
lib/i915/intel_memory_region.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 058b273dc..fd29eec90 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -123,9 +123,17 @@ 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 = offsetof(typeof(*query_info), regions[1]);
+
+ 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