drm/qxl: fix some driver shutdown issues.
Subsystems (4)
Gerd Hoffmann
maintainerv3 cover drm/qxl: fix some driver shutdown issues.
Some progress. Not complete though, I still
get an unclean mm warning on shutdown due to
some release objects not being freed yet.
Gerd Hoffmann (4):
drm/qxl: use drmm_mode_config_init
drm/qxl: unpin release objects
drm/qxl: release shadow on shutdown
drm/qxl: handle shadow in primary destroy
drivers/gpu/drm/qxl/qxl_display.c | 11 +++++++++-- drivers/gpu/drm/qxl/qxl_release.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 7 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 1/4 drm/qxl: use drmm_mode_config_init
--- drivers/gpu/drm/qxl/qxl_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +3 -2
@@ -1195,7 +1195,9 @@ int qxl_modeset_init(struct qxl_device *qdev)int i;int ret; -drm_mode_config_init (&qdev->ddev); + ret =drmm_mode_config_init (&qdev->ddev); +if (ret) +return ret; ret =qxl_create_monitors_object (qdev);if (ret)
@@ -1228,5 +1230,4 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) {qxl_destroy_monitors_object (qdev); -drm_mode_config_cleanup (&qdev->ddev); }
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 1/4] drm/qxl: use drmm_mode_config_init
Am 20.01.21 um 12:12 schrieb Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Daniel Vetter <[email protected]>
Quoted 26 lines
--- drivers/gpu/drm/qxl/qxl_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +3
-2@@ -1195,7 +1195,9 @@ int qxl_modeset_init(struct qxl_device *qdev)int i;int ret; -drm_mode_config_init (&qdev->ddev); + ret =drmm_mode_config_init (&qdev->ddev); +if (ret) +return ret; ret =qxl_create_monitors_object (qdev);if (ret)@@ -1228,5 +1230,4 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) {qxl_destroy_monitors_object (qdev); -drm_mode_config_cleanup (&qdev->ddev); }
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 2/4 drm/qxl: unpin release objects
In reply to Gerd HoffmannBalances the qxl_create_bo(..., pinned=true, ...); call in qxl_release_bo_alloc().
--- drivers/gpu/drm/qxl/qxl_release.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/qxl/qxl_release.c +1 -0
@@ -166,6 +166,7 @@ qxl_release_free_list(struct qxl_release *release) entry =container_of (release->bos.next, struct qxl_bo_list, tv.head); bo =to_qxl_bo (entry->tv.bo); + bo->tbo.pin_count =0 ;/* ttm_bo_unpin(&bo->tbo); */ qxl_bo_unref (&bo);list_del (&entry->tv.head);kfree (entry);
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerRe: [PATCH v3 2/4] drm/qxl: unpin release objects
Hi
Am 20.01.21 um 12:12 schrieb Gerd Hoffmann:
Quoted 13 lines
Balances the
qxl_create_bo(..., pinned=true, ...); call inqxl_release_bo_alloc().Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_release.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_release.c +0
-0
drivers/gpu/drm/qxl/qxl_release.c qxl_release_free_list(struct qxl_release *release) · line 169
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_release.c +1
-0@@ -166,6 +166,7 @@ qxl_release_free_list(struct qxl_release *release) entry =container_of (release->bos.next, struct qxl_bo_list, tv.head); bo =to_qxl_bo (entry->tv.bo); + bo->tbo.pin_count =0 ;/* ttm_bo_unpin(&bo->tbo); */
This code looks like a workaround or a bug.
AFAICT the only place with pre-pinned BO is qdev->dumb_shadow_bo. Can you remove the pinned flag entirely and handle pinning as part of dumb_shadow_bo's code.
Otherwise maybe use
if (pin_count)
ttm_bo_unpin();
WARN_ON(pin_count); /* should always be 0 now */
with a comment similar to the commit's description.
Best regards
Thomas
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_release.c +0
-0qxl_bo_unref (&bo);list_del (&entry->tv.head);kfree (entry);
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerRe: [PATCH v3 2/4] drm/qxl: unpin release objects
Quoted 23 lines · Thomas Zimmermann
Hi
Am 20.01.21 um 12:12 schrieb Gerd Hoffmann:
Quoted 13 lines
Balances the
qxl_create_bo(..., pinned=true, ...); call inqxl_release_bo_alloc().Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_release.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_release.c +0
-0drivers/gpu/drm/qxl/qxl_release.c qxl_release_free_list(struct qxl_release *release) · line 169
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_release.c +1
-0@@ -166,6 +166,7 @@ qxl_release_free_list(struct qxl_release *release) entry =container_of (release->bos.next, struct qxl_bo_list, tv.head); bo =to_qxl_bo (entry->tv.bo); + bo->tbo.pin_count =0 ;/* ttm_bo_unpin(&bo->tbo); */ This code looks like a workaround or a bug.
Quoted 3 lines
AFAICT the only place with pre-pinned BO is
qdev->dumb_shadow_bo. Can you remove the pinned flag entirely and handle pinning as part of dumb_shadow_bo's code.
No, the release objects are pinned too, and they must be pinned (qxl commands are in there, and references are placed in the qxl rings, so allowing them to roam is a non-starter).
Quoted 3 lines
if (
pin_count)ttm_bo_unpin();
WARN_ON(pin_count); /* should always be 0 now */
Well, the pin_count is 1 at this point.
No need for the if().
Just calling ttm_bo_unpin() here makes lockdep unhappy.
Not calling ttm_bo_unpin() makes ttm_bo_release() throw a WARN() because of the pin.
Clearing pin_count (which is how ttm fixes things up in the error path) works.
I'm open to better ideas.
take care,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 2/4] drm/qxl: unpin release objects
Quoted 34 lines · Gerd Hoffmann
Quoted 23 lines · Thomas Zimmermann
Hi
Am 20.01.21 um 12:12 schrieb Gerd Hoffmann:
Quoted 13 lines
Balances the
qxl_create_bo(..., pinned=true, ...); call inqxl_release_bo_alloc().Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_release.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/qxl/qxl_release.c +0
-0drivers/gpu/drm/qxl/qxl_release.c qxl_release_free_list(struct qxl_release *release) · line 169
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_release.c +1
-0@@ -166,6 +166,7 @@ qxl_release_free_list(struct qxl_release *release) entry =container_of (release->bos.next, struct qxl_bo_list, tv.head); bo =to_qxl_bo (entry->tv.bo); + bo->tbo.pin_count =0 ;/* ttm_bo_unpin(&bo->tbo); */ This code looks like a workaround or a bug.
Quoted 3 lines
AFAICT the only place with pre-pinned BO is
qdev->dumb_shadow_bo. Can you remove the pinned flag entirely and handle pinning as part of dumb_shadow_bo's code.No, the release objects are pinned too, and they must be pinned (qxl commands are in there, and references are placed in the qxl rings, so allowing them to roam is a non-starter).
Quoted 8 lines
Quoted 3 lines
if (
pin_count)ttm_bo_unpin();
WARN_ON(pin_count); /* should always be 0 now */Well, the
pin_countis 1 at this point.
No need for theif().Just calling
ttm_bo_unpin()here makes lockdep unhappy.
How does that one splat? But yeah if that's a problem should be explained in the comment. I'd then also only do a pin_count--; to make sure you can still catch other pin leaks if you have them. Setting it to 0 kinda defeats the warning.
-Daniel
Quoted 16 lines
Not calling
ttm_bo_unpin()makesttm_bo_release()throw aWARN()because of the pin.Clearing
pin_count(which is how ttm fixes things up in the error path) works.I'm open to better ideas.
take care,
Gerd_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
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
Gerd Hoffmann
maintainerRe: [PATCH v3 2/4] drm/qxl: unpin release objects
Quoted 6 lines
Quoted 1 line
Just calling
ttm_bo_unpin()here makes lockdep unhappy.How does that one splat? But yeah if that's a problem should be explained in the comment. I'd then also only do a pin_count--; to make sure you can still catch other pin leaks if you have them. Setting it to 0 kinda defeats the warning.
Figured the unpin is at the completely wrong place while trying to reproduce the lockdep splat ...
take care,
Gerd
From 43befab4a935114e8620af62781666fa81288255 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Mon, 25 Jan 2021 13:10:50 +0100
Subject: [PATCH] drm/qxl: unpin release objects
Balances the qxl_create_bo(..., pinned=true, ...); call in qxl_release_bo_alloc().
--- drivers/gpu/drm/qxl/qxl_release.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/qxl/qxl_release.c +1 -0
@@ -347,6 +347,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,mutex_lock (&qdev->release_mutex);if (qdev->current_release_bo_offset[cur_idx] +1 >= releases_per_bo[cur_idx]) { +qxl_bo_unpin (qdev->current_release_bo[cur_idx]);qxl_bo_unref (&qdev->current_release_bo[cur_idx]); qdev->current_release_bo_offset[cur_idx] =0 ; qdev->current_release_bo[cur_idx] =NULL ;
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 3/4 drm/qxl: release shadow on shutdown
In reply to Gerd HoffmannIn case we have a shadow surface on shutdown release it so it doesn't leak.
--- drivers/gpu/drm/qxl/qxl_display.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -1229,5 +1229,9 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) { +if (qdev->dumb_shadow_bo) { +drm_gem_object_put (&qdev->dumb_shadow_bo->tbo.base); + qdev->dumb_shadow_bo =NULL ; + }qxl_destroy_monitors_object (qdev); }
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Thomas Zimmermann
maintainerRe: [PATCH v3 3/4] drm/qxl: release shadow on shutdown
Hi
Am 20.01.21 um 12:12 schrieb Gerd Hoffmann:
Quoted 13 lines
In case we have a shadow surface on shutdown release it so it doesn't leak.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_display.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/qxl/qxl_display.c +0
-0
drivers/gpu/drm/qxl/qxl_display.c int qxl_modeset_init(struct qxl_device *qdev) · line 1232
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_display.c +1
-0@@ -1229,5 +1229,9 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) { +if (qdev->dumb_shadow_bo) {
Wrt to my comment on patch 2, this might be the place to unpin the BO.
Quoted 6 lines
drivers/gpu/drm/qxl/qxl_display.c +3
-0+drm_gem_object_put (&qdev->dumb_shadow_bo->tbo.base); + qdev->dumb_shadow_bo =NULL ; + }qxl_destroy_monitors_object (qdev); }
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 4/4 drm/qxl: handle shadow in primary destroy
In reply to Gerd Hoffmannqxl_primary_atomic_disable must check whenever the framebuffer bo has a shadow surface and in case it has check the shadow primary status.
--- drivers/gpu/drm/qxl/qxl_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +2 -0
@@ -562,6 +562,8 @@ static void qxl_primary_atomic_disable(struct drm_plane *plane,if (old_state->fb) {struct qxl_bo *bo =gem_to_qxl_bo (old_state->fb->obj[0 ]); +if (bo->shadow) + bo = bo->shadow;if (bo->is_primary) {qxl_io_destroy_primary (qdev); bo->is_primary = false;
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization