summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2021-12-13 19:12:08 +0100
committerZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2021-12-15 08:02:06 +0100
commit4a181917e4f5c1ad070cecf6c2a828a19ce59ada (patch)
tree16d5eb11abdbcac873ba0f7e2ad66285653493df
parentbe84fe4f151bc092e068cab5cd0cd19c34948b40 (diff)
lib/i915/intel_memory_region: Handle -ENODEV path individually
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@intel.com> Reported-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
-rw-r--r--lib/i915/intel_memory_region.c12
1 files 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);