Skip to contentSkip to conversation

drm/i915: Fix list corruption in vma_unbind

PATCH In review Daniel Vetter 4 participants 5 messages Aug 29, 2013

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

PATCH 1/1 drm/i915: Fix list corruption in vma_unbind

The saga around the breadcrumb vmas used by execbuf continues ...

This time around we've managed to unconditionally move the object to the unbound list on the last vma unbind even though it might never have been on either the bound or unbound list. Hilarity ensued.

Chris Wilson tracked this one down but compared to his patches I've simply opted to completely separate the unbound case for not-yet bound vmas. Otherwise we imo end up with semantically hard to parse checks around the list_move_tail(global_list, ...).

This is exercised by the new swapping variants of
igt/tests/gem_evict_everything.

Cc: Chris Wilson <[email protected]>
Cc: Ben Widawsky <[email protected]>
Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=84818

---
 drivers/gpu/drm/i915/i915_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +5 -3
index d9eee14..d12dfc3 100644
@@ -2624,8 +2624,11 @@ int i915_vma_unbind(struct i915_vma *vma)
 	if (list_empty(&vma->vma_link))
 		return 0;
 
-	if (!drm_mm_node_allocated(&vma->node))
-		goto destroy;
+	if (!drm_mm_node_allocated(&vma->node)) {
+		i915_gem_vma_destroy(vma);
+
+		return 0;
+	}
 
 	if (obj->pin_count)
 		return -EBUSY;
@@ -2665,7 +2668,6 @@ int i915_vma_unbind(struct i915_vma *vma)
 
 	drm_mm_remove_node(&vma->node);
 
-destroy:
 	i915_gem_vma_destroy(vma);
 
 	/* Since the unbound list is global, only move to that list if
Signature · 1 line
1.8.4.rc3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Daniel Vetter

The saga around the breadcrumb vmas used by execbuf continues ...

This time around we've managed to unconditionally move the object to the unbound list on the last vma unbind even though it might never have been on either the bound or unbound list. Hilarity ensued.

Chris Wilson tracked this one down but compared to his patches I've simply opted to completely separate the unbound case for not-yet bound vmas. Otherwise we imo end up with semantically hard to parse checks around the list_move_tail(global_list, ...).

Quoted 7 lines

This is exercised by the new swapping variants of
igt/tests/gem_evict_everything.

Cc: Chris Wilson <[email protected]>
Cc: Ben Widawsky <[email protected]>
Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=84818

Quoted 9 lines
---
 drivers/gpu/drm/i915/i915_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index d9eee14..d12dfc3 100644

drivers/gpu/drm/i915/i915_gem.c int i915_vma_unbind(struct i915_vma *vma) · line 2629

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +3 -2
@@ -2624,8 +2624,11 @@ int i915_vma_unbind(struct i915_vma *vma)
 	if (list_empty(&vma->vma_link))
 		return 0;
 
-	if (!drm_mm_node_allocated(&vma->node))
-		goto destroy;
+	if (!drm_mm_node_allocated(&vma->node)) {
+		i915_gem_vma_destroy(vma);
+

I'm equivocal on this particular whitespace. For such short branches, it looks neater with a tight return.

Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2 -0
+		return 0;
+	}
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Daniel Vetter

The saga around the breadcrumb vmas used by execbuf continues ...

This time around we've managed to unconditionally move the object to the unbound list on the last vma unbind even though it might never have been on either the bound or unbound list. Hilarity ensued.

Chris Wilson tracked this one down but compared to his patches I've simply opted to completely separate the unbound case for not-yet bound vmas. Otherwise we imo end up with semantically hard to parse checks around the list_move_tail(global_list, ...).

This is exercised by the new swapping variants of
igt/tests/gem_evict_everything.

Quoted 6 lines
Quoted 4 lines

Cc: Chris Wilson <[email protected]>
Cc: Ben Widawsky <[email protected]>
Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=84818

Merged, but I've dropped the paragraph about the igt tests again - I just can't hit the bug any more :( Also I've fixed the bugzilla link, it pointed at an attachment instead of the bug.
-Daniel

Quoted 27 lines
Quoted 10 lines
---
 drivers/gpu/drm/i915/i915_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index d9eee14..d12dfc3 100644

drivers/gpu/drm/i915/i915_gem.c int i915_vma_unbind(struct i915_vma *vma) · line 2629

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +3 -2
@@ -2624,8 +2624,11 @@ int i915_vma_unbind(struct i915_vma *vma)
 	if (list_empty(&vma->vma_link))
 		return 0;
 
-	if (!drm_mm_node_allocated(&vma->node))
-		goto destroy;
+	if (!drm_mm_node_allocated(&vma->node)) {
+		i915_gem_vma_destroy(vma);
+

I'm equivocal on this particular whitespace. For such short branches, it looks neater with a tight return.

Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2 -0
+		return 0;
+	}
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 21 lines · Daniel Vetter
Quoted 20 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The saga around the breadcrumb vmas used by execbuf continues ...

This time around we've managed to unconditionally move the object to the unbound list on the last vma unbind even though it might never have been on either the bound or unbound list. Hilarity ensued.

Chris Wilson tracked this one down but compared to his patches I've simply opted to completely separate the unbound case for not-yet bound vmas. Otherwise we imo end up with semantically hard to parse checks around the list_move_tail(global_list, ...).

This is exercised by the new swapping variants of
igt/tests/gem_evict_everything.

Cc: Chris Wilson <[email protected]>
Cc: Ben Widawsky <[email protected]>
Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=84818

Quoted 5 lines
Quoted 1 line

Merged, but I've dropped the paragraph about the igt tests again - I just can't hit the bug any more :( Also I've fixed the bugzilla link, it pointed at an attachment instead of the bug.

It fixed the tests for me, just got a whole new trace when using GL. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Tested-by
#4 lore raw
Quoted 22 lines · Chris Wilson
Quoted 21 lines · Daniel Vetter
Quoted 20 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The saga around the breadcrumb vmas used by execbuf continues ...

This time around we've managed to unconditionally move the object to the unbound list on the last vma unbind even though it might never have been on either the bound or unbound list. Hilarity ensued.

Chris Wilson tracked this one down but compared to his patches I've simply opted to completely separate the unbound case for not-yet bound vmas. Otherwise we imo end up with semantically hard to parse checks around the list_move_tail(global_list, ...).

This is exercised by the new swapping variants of
igt/tests/gem_evict_everything.

Cc: Chris Wilson <[email protected]>
Cc: Ben Widawsky <[email protected]>
Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=84818

Quoted 11 lines
Quoted 5 lines
Quoted 1 line

Merged, but I've dropped the paragraph about the igt tests again - I just can't hit the bug any more :( Also I've fixed the bugzilla link, it pointed at an attachment instead of the bug.

It fixed the tests for me, just got a whole new trace when using GL. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

I'm not really sure why the assertion I added blew up :/

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center