Skip to contentSkip to conversation

drm/core: Do not call drm_framebuffer_remove internally during teardown.

PATCH In review Maarten Lankhorst 3 participants 5 messages Sep 9, 2015

Subsystems (2)
lore
Share & tools
lore

Maarten Lankhorst

author maintainer
#0 lore raw

PATCH 1/1 drm/core: Do not call drm_framebuffer_remove internally during teardown.

This may cause issues because encoders are already destroyed so removing active primaries may use freed memory. Instead free the fb directly, ignoring refcount.

---
 drivers/gpu/drm/drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_crtc.c +1 -1
index 474f328535a1..9b9c4b41422a 100644
@@ -5742,7 +5742,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	 */
 	WARN_ON(!list_empty(&dev->mode_config.fb_list));
 	list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) {
-		drm_framebuffer_remove(fb);
+		drm_framebuffer_free(&fb->refcount);
 	}
 
 	list_for_each_entry_safe(plane, plt, &dev->mode_config.plane_list,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 3 lines · Maarten Lankhorst

This may cause issues because encoders are already destroyed so removing active primaries may use freed memory. Instead free the fb directly, ignoring refcount.

So what about fixing the cause, not the symptom? That is remove framebuffers before nuking crtc/encoders/etc.

Quoted 26 lines
---
 drivers/gpu/drm/drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_crtc.c +1 -1
index 474f328535a1..9b9c4b41422a 100644
@@ -5742,7 +5742,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	 */
 	WARN_ON(!list_empty(&dev->mode_config.fb_list));
 	list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) {
-		drm_framebuffer_remove(fb);
+		drm_framebuffer_free(&fb->refcount);
 	}
 
 	list_for_each_entry_safe(plane, plt, &dev->mode_config.plane_list,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 7 lines · Ville Syrjälä
Quoted 3 lines · Maarten Lankhorst

This may cause issues because encoders are already destroyed so removing active primaries may use freed memory. Instead free the fb directly, ignoring refcount.

So what about fixing the cause, not the symptom? That is remove framebuffers before nuking crtc/encoders/etc.

Also by that point we shouldn't have any framebuffers left (the WARN_ON is for that), so not sure what's the point of this patch. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author maintainer
#3 lore raw

Op 09-09-15 om 13:59 schreef Daniel Vetter:

Quoted 11 lines
Quoted 6 lines · Ville Syrjälä
Quoted 3 lines · Maarten Lankhorst

This may cause issues because encoders are already destroyed so removing active primaries may use freed memory. Instead free the fb directly, ignoring refcount.

So what about fixing the cause, not the symptom? That is remove framebuffers before nuking crtc/encoders/etc.

Also by that point we shouldn't have any framebuffers left (the WARN_ON is for that), so not sure what's the point of this patch. -Daniel

Yes, but the current way would crash on atomic because encoders are already done. This removes a caller of drm_framebuffer_remove and uses the correct destroy function regardless even when refcounts are leaked. :)

~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 9 lines · Maarten Lankhorst

Op 09-09-15 om 13:59 schreef Daniel Vetter:

Quoted 8 lines
Quoted 6 lines · Ville Syrjälä
Quoted 3 lines · Maarten Lankhorst

This may cause issues because encoders are already destroyed so removing active primaries may use freed memory. Instead free the fb directly, ignoring refcount.

So what about fixing the cause, not the symptom? That is remove framebuffers before nuking crtc/encoders/etc.

Quoted 7 lines
Quoted 3 lines

Also by that point we shouldn't have any framebuffers left (the WARN_ON is for that), so not sure what's the point of this patch. -Daniel

Yes, but the current way would crash on atomic because encoders are already done. This removes a caller of drm_framebuffer_remove and uses the correct destroy function regardless even when refcounts are leaked. :)

Makes some sense I guess ... applied to drm-misc, thanks. -Daniel

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