[igt-dev] [PATCH i-g-t] lib/i915/intel_memory_region: Handle -ENODEV path individually
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Mon Dec 13 18:12:08 UTC 2021
As Ashutosh noticed I've handled errors from the kernel too wide
packing it to same error bag and returning system memory region in this
case. That's of course is wrong and can lead to return system memory on
discrete if invalid arguments would be passed to the query.
Return previous behavior of query memory regions handling -ENODEV path
individually. For this error lets assume we got kernel which doesn't
support this query yet so returning system memory region is a reasonable
choice because this region exists for all of i915 gens.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Reported-by: Ashutosh Dixit <ashutosh.dixit 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, 9 insertions(+), 3 deletions(-)
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 2263f1984..dfbb8acf0 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -124,10 +124,11 @@ struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
* item.length, even though the ioctl might still return success.
*/
- if (item.length < 0) {
+ if (item.length == -ENODEV) {
/*
- * If kernel supports query but not memory regions query
- * just return predefined system memory region only.
+ * If kernel supports query but not memory regions and it
+ * returns -ENODEV just return predefined system memory region
+ * only.
*/
size_t sys_qi_size = offsetof(typeof(*query_info), regions[1]);
@@ -135,6 +136,11 @@ struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
query_info->num_regions = 1;
query_info->regions[0].region.memory_class = I915_MEMORY_CLASS_SYSTEM;
goto out;
+ } else if (item.length < 0) {
+ /* Any other error are critial so no fallback is possible */
+ igt_critical("DRM_I915_QUERY_MEMORY_REGIONS failed with %d\n",
+ item.length);
+ goto out;
}
query_info = calloc(1, item.length);
--
2.32.0
More information about the igt-dev
mailing list