[igt-dev] [PATCH] tests/kms: Return false in gem_has_lmem for kernels not having DRM_I915_QUERY_MEMORY_REGIONS support
Vidya Srinivas
vidya.srinivas at intel.com
Sat Jul 24 16:46:24 UTC 2021
Starting commit (tests/kms: Create buffer object from LMEM for discrete)
it checks for LMEM. This is breaking older kernels like 5.4 without
DRM_I915_QUERY_MEMORY_REGIONS support.
Patch returns false from gem_has_lmem if kernel doesnt have support
for DRM_I915_QUERY_MEMORY_REGIONS.
Signed-off-by: Lin Charlton <charston.lin at intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas at intel.com>
Change-Id: Ia5bb2f0bb9ca1e854bb03c12dfed6646584bbb9b
---
lib/i915/intel_memory_region.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 144ae12ca7a0..e553d7ec0f1c 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -76,6 +76,17 @@ bool gem_has_query_support(int fd)
return __i915_query(fd, &query) == 0;
}
+bool gem_has_memregion_query_support(int fd)
+{
+ struct drm_i915_query_item item;
+ int ret;
+
+ memset(&item, 0, sizeof(item));
+ item.query_id = DRM_I915_QUERY_MEMORY_REGIONS;
+ ret = __i915_query_items(fd, &item, 1);
+ return ret;
+}
+
const char *get_memory_region_name(uint32_t region)
{
uint16_t class = MEMORY_TYPE_FROM_REGION(region);
@@ -164,6 +175,9 @@ uint8_t gem_get_lmem_region_count(int fd)
*/
bool gem_has_lmem(int fd)
{
+ if (gem_has_memregion_query_support(fd) == ENOSYS ||
+ gem_has_memregion_query_support(fd) == ENOTSUP)
+ return false;
return gem_get_lmem_region_count(fd) > 0;
}
--
2.26.2
More information about the igt-dev
mailing list