All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Fix error handling in drm_mm eviction kselftest
@ 2017-01-10 14:40 Chris Wilson
  2017-01-11  6:54 ` Joonas Lahtinen
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2017-01-10 14:40 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, Joonas Lahtinen

        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.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 560b32842912 ("drm: kselftest for drm_mm and eviction")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/selftests/test-drm_mm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index ab091042f317..1e71bc182ca9 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -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);
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix error handling in drm_mm eviction kselftest
  2017-01-10 14:40 [PATCH] drm: Fix error handling in drm_mm eviction kselftest Chris Wilson
@ 2017-01-11  6:54 ` Joonas Lahtinen
  2017-01-11  7:54   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Joonas Lahtinen @ 2017-01-11  6:54 UTC (permalink / raw)
  To: Chris Wilson, dri-devel; +Cc: Daniel Vetter

On ti, 2017-01-10 at 14:40 +0000, Chris Wilson wrote:
>         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.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: 560b32842912 ("drm: kselftest for drm_mm and eviction")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

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

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix error handling in drm_mm eviction kselftest
  2017-01-11  6:54 ` Joonas Lahtinen
@ 2017-01-11  7:54   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2017-01-11  7:54 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: Daniel Vetter, dri-devel

On Wed, Jan 11, 2017 at 08:54:35AM +0200, Joonas Lahtinen wrote:
> On ti, 2017-01-10 at 14:40 +0000, Chris Wilson wrote:
> >         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.
> > 
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Fixes: 560b32842912 ("drm: kselftest for drm_mm and eviction")
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Ah, as mentioned previously, we soon need tests for the selftests :)
> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Applied, thanks.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-01-11  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10 14:40 [PATCH] drm: Fix error handling in drm_mm eviction kselftest Chris Wilson
2017-01-11  6:54 ` Joonas Lahtinen
2017-01-11  7:54   ` Daniel Vetter

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.