All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/i915/intel_memory_region: Handle -ENODEV path individually
@ 2021-12-13 18:12 Zbigniew Kempczyński
  2021-12-13 19:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Zbigniew Kempczyński @ 2021-12-13 18:12 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

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>
---
 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-14 17:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-13 18:12 [igt-dev] [PATCH i-g-t] lib/i915/intel_memory_region: Handle -ENODEV path individually Zbigniew Kempczyński
2021-12-13 19:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2021-12-14  0:36 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-12-14  7:48   ` Zbigniew Kempczyński
2021-12-14 17:51     ` Vudum, Lakshminarayana
2021-12-14  4:33 ` [igt-dev] [PATCH i-g-t] " Dixit, Ashutosh
2021-12-14  5:04   ` Dixit, Ashutosh
2021-12-14 17:18 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.