[igt-dev] [PATCH i-g-t 2/2] lib/i915/intel_memory_region: Add fallback for creating gem bo
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Thu Dec 9 20:04:53 UTC 2021
For stable kernels we get -ENODEV on integrated where gem_create_ext()
call tries to allocate bo in system memory. Instead of asserting this
case we can fallback to gem_create() as this allocation can be resolved
using legacy call.
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 | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index fd29eec90..2263f1984 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -197,8 +197,23 @@ int __gem_create_in_memory_region_list(int fd, uint32_t *handle, uint64_t *size,
.num_regions = num_regions,
.regions = to_user_pointer(mem_regions),
};
+ int ret;
- return __gem_create_ext(fd, size, handle, &ext_regions.base);
+ ret = __gem_create_ext(fd, size, handle, &ext_regions.base);
+
+ /*
+ * Provide fallback for stable kernels if region passed in the array
+ * can be system memory. In this case we get -ENODEV but still
+ * we're able to allocate gem bo in system memory using legacy call.
+ */
+ if (ret == -ENODEV)
+ for (int i = 0; i < num_regions; i++)
+ if (mem_regions[i].memory_class == I915_MEMORY_CLASS_SYSTEM) {
+ ret = __gem_create(fd, size, handle);
+ break;
+ }
+
+ return ret;
}
/* gem_create_in_memory_region_list:
--
2.26.0
More information about the igt-dev
mailing list