Skip to contentSkip to conversation

drm: Fix error handling in drm_mm eviction kselftest

PATCH Applied Chris Wilson 3 participants 3 messages Jan 10, 2017 – Jan 11, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Fix error handling in drm_mm eviction kselftest

drivers/gpu/drm/selftests/test-drm_mm.c:1277 evict_everything()
warn: calling list_del() inside list_for_each

The list_del() inside the error handling in the eviction loop is overkill. We have to undo the eviction scan to return the drm_mm back to a recoverable state, so have to iterate over the full list, but we only want to report the error once and once we have an error we can return early.

Fixes 560b32842912 ("drm: kselftest for drm_mm and eviction")
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/selftests/test-drm_mm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/selftests/test-drm_mm.c +9 -3
index ab091042f317..1e71bc182ca9 100644
@@ -1272,13 +1272,19 @@ static bool evict_everything(struct drm_mm *mm,
 		if (drm_mm_scan_add_block(&scan, &e->node))
 			break;
 	}
+
+	err = 0;
 	list_for_each_entry(e, &evict_list, link) {
 		if (!drm_mm_scan_remove_block(&scan, &e->node)) {
-			pr_err("Node %lld not marked for eviction!\n",
-			       e->node.start);
-			list_del(&e->link);
+			if (!err) {
+				pr_err("Node %lld not marked for eviction!\n",
+				       e->node.start);
+				err = -EINVAL;
+			}
 		}
 	}
+	if (err)
+		return false;
 
 	list_for_each_entry(e, &evict_list, link)
 		drm_mm_remove_node(&e->node);
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Chris Wilson

        drivers/gpu/drm/selftests/test-drm_mm.c:1277 evict_everything()
        warn: calling list_del() inside list_for_each

The list_del() inside the error handling in the eviction loop is overkill. We have to undo the eviction scan to return the drm_mm back to a recoverable state, so have to iterate over the full list, but we only want to report the error once and once we have an error we can return early.

Quoted 5 lines
Fixes 560b32842912 ("drm: kselftest for drm_mm and eviction")
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>

Ah, as mentioned previously, we soon need tests for the selftests :)

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 16 lines · Joonas Lahtinen
Quoted 9 lines · Chris Wilson

        drivers/gpu/drm/selftests/test-drm_mm.c:1277 evict_everything()
        warn: calling list_del() inside list_for_each

The list_del() inside the error handling in the eviction loop is overkill. We have to undo the eviction scan to return the drm_mm back to a recoverable state, so have to iterate over the full list, but we only want to report the error once and once we have an error we can return early.

Quoted 5 lines
Fixes 560b32842912 ("drm: kselftest for drm_mm and eviction")
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 3 lines

Ah, as mentioned previously, we soon need tests for the selftests :)

Applied, thanks.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel