drm/qxl: fix driver shutdown issues.
Subsystems (5)
Gerd Hoffmann
maintainerv6 cover drm/qxl: fix driver shutdown issues.
v5:
- add release_event wait queue.
- also cleanup qxl_fence_wait().
v6:
- add shadow pinning fix (Thomas).
- use ram for dumb allocation.
Gerd Hoffmann (10):
[hack] silence ttm fini WARNING
Revert "drm/qxl: do not run release if qxl failed to init" drm/qxl: use drmm_mode_config_init
drm/qxl: unpin release objects
drm/qxl: release shadow on shutdown
drm/qxl: properly pin/unpin shadow
drm/qxl: handle shadow in primary destroy drm/qxl: properly free qxl releases
drm/qxl: simplify qxl_fence_wait
drm/qxl: allocate dumb buffers in ram
drivers/gpu/drm/qxl/qxl_drv.h | 2 ++ drivers/gpu/drm/qxl/qxl_cmd.c | 1 + drivers/gpu/drm/qxl/qxl_display.c | 15 ++++++++-- drivers/gpu/drm/qxl/qxl_drv.c | 2 -- drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- drivers/gpu/drm/qxl/qxl_irq.c | 1 + drivers/gpu/drm/qxl/qxl_kms.c | 28 +++++++++++++++--- drivers/gpu/drm/qxl/qxl_release.c | 47 +++++-------------------------- drivers/gpu/drm/ttm/ttm_device.c | 2 +- 9 files changed, 50 insertions(+), 50 deletions(-)
Signature · 7 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v6 1/10 silence ttm fini WARNING
kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_put() is being called.
WARNING: CPU: 0 PID: 209 at lib/kobject.c:750 kobject_put+0x3a/0x60 [ ... ] Call Trace: ttm_device_fini+0x133/0x1b0 [ttm] qxl_ttm_fini+0x2f/0x40 [qxl] --- drivers/gpu/drm/ttm/ttm_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_device.c +1 -1
@@ -50,7 +50,7 @@ static void ttm_global_release(void) goto out;kobject_del (&glob->kobj); -kobject_put (&glob->kobj); +// kobject_put(&glob->kobj); ttm_mem_global_release (&ttm_mem_glob);__free_page (glob->dummy_read_page);memset (glob,0 ,sizeof (*glob));
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v6 01/10] [hack] silence ttm fini WARNING
?
What's the background here?
Christian.
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 15 lines
kobject: '(null)' ((
____ptrval____)): is not initialized, yetkobject_put()is being called.WARNING: CPU: 0 PID: 209 at lib/kobject.c:750 kobject_put+0x3a/0x60 [ ... ] Call Trace: ttm_device_fini+0x133/0x1b0 [ttm] qxl_ttm_fini+0x2f/0x40 [qxl] --- drivers/gpu/drm/ttm/ttm_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_device.c +0
-0
drivers/gpu/drm/ttm/ttm_device.c static void ttm_global_release(void) · line 56
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_device.c +1
-1@@ -50,7 +50,7 @@ static void ttm_global_release(void) goto out;kobject_del (&glob->kobj); -kobject_put (&glob->kobj); +// kobject_put(&glob->kobj); ttm_mem_global_release (&ttm_mem_glob);__free_page (glob->dummy_read_page);memset (glob,0 ,sizeof (*glob));
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerRe: [PATCH v6 01/10] [hack] silence ttm fini WARNING
Quoted 13 lines · Christian König
?
What's the background here?
Christian.
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 6 lines
kobject: '(null)' ((
____ptrval____)): is not initialized, yetkobject_put()is being called.WARNING: CPU: 0 PID: 209 at lib/kobject.c:750 kobject_put+0x3a/0x60 [ ... ] Call Trace: ttm_device_fini+0x133/0x1b0 [ttm] qxl_ttm_fini+0x2f/0x40 [qxl]
Happens on driver removal. Seen with both qxl and bochs (the later using vram helpers).
Testcase: "drmtest --unbind" (https://git.kraxel.org/cgit/drminfo/).
static int try_unbind(int card)
{
char path[256];
char *device, *name;
int fd;
snprintf(path, sizeof(path), "/sys/class/drm/card%d/device", card);
device = realpath(path, NULL);
if (device == NULL) {
fprintf(stderr, "%s: can't resolve sysfs device path\n", __func__);
return -1;
}
snprintf(path, sizeof(path), "%s/driver/unbind", device);
fd = open(path, O_WRONLY);
if (fd < 0) {
fprintf(stderr, "open %s: %s\n", path, strerror(errno));
return -1;
}
name = strrchr(device, '/') + 1;
write(fd, name, strlen(name));
close(fd);
return 0;
}take care,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v6 2/10 Revert "drm/qxl: do not run release if qxl failed to init"
In reply to Gerd HoffmannThis reverts commit b91907a6241193465ca92e357adf16822242296d.
Patch is broken, it effectively makes qxl_drm_release() a nop because on normal driver shutdown qxl_drm_release() is called *after* drm_dev_unregister().
--- drivers/gpu/drm/qxl/qxl_drv.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -2
@@ -144,8 +144,6 @@ static void qxl_drm_release(struct drm_device *dev)* reodering qxl_modeset_fini() + qxl_device_fini() calls is * non-trivial though. */ -if (!dev->registered) -return ;qxl_modeset_fini (qdev);qxl_device_fini (qdev); }
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v6 02/10] Revert "drm/qxl: do not run release if qxl failed to init"
Hi
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 1 line
This reverts commit
b91907a6241193465ca92e357adf16822242296d.
This should be in the correct format, as given by 'dim cite'.
dim cite b91907a6241193465ca92e357adf16822242296db91907a62411 ("drm/qxl: do not run release if qxl failed to init")
Quoted 16 lines
Patch is broken, it effectively makes
qxl_drm_release()a nop because on normal driver shutdownqxl_drm_release()is called *after*drm_dev_unregister().Cc Tong Zhang <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/qxl/qxl_drv.c +0
-0
drivers/gpu/drm/qxl/qxl_drv.c static void qxl_drm_release(struct drm_device *dev) · line 148
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-2@@ -144,8 +144,6 @@ static void qxl_drm_release(struct drm_device *dev)* reodering qxl_modeset_fini() + qxl_device_fini() calls is * non-trivial though. */ -if (!dev->registered) -return ;
I'm not sure what the original problem was, but I'm sure that this isn't the fix for it. If there's a problem with shutdown, the operations rather have to be reordered correctly.
With the citation style address:
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-0qxl_modeset_fini (qdev);qxl_device_fini (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
Re: [PATCH v6 02/10] Revert "drm/qxl: do not run release if qxl failed to init"
Hi Thomas,
The original problem was qxl_device_init() can fail, when it fails there is no need to call
qxl_modeset_fini(qdev); qxl_device_fini(qdev);
But those two functions are otherwise called in the qxl_drm_release() -
I have posted an updated patch.
The new patch use the following logic
+ if (!qdev->ddev.mode_config.funcs)
+ return; qxl_modeset_fini(qdev); qxl_device_fini(qdev);
Thanks,
- Tong
Quoted 49 lines · Thomas Zimmermann
Hi
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 1 line
This reverts commit
b91907a6241193465ca92e357adf16822242296d.This should be in the correct format, as given by 'dim cite'.
dim cite
b91907a6241193465ca92e357adf16822242296db91907a62411("drm/qxl: do not run release if qxl failed to init")Quoted 13 lines
Patch is broken, it effectively makes
qxl_drm_release()a nop because on normal driver shutdownqxl_drm_release()is called *after*drm_dev_unregister().Cc Tong Zhang <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c static void qxl_drm_release(struct drm_device *dev) · line 148
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-2@@ -144,8 +144,6 @@ static void qxl_drm_release(struct drm_device *dev)* reodering qxl_modeset_fini() + qxl_device_fini() calls is * non-trivial though. */ -if (!dev->registered) -return ;I'm not sure what the original problem was, but I'm sure that this isn't the fix for it. If there's a problem with shutdown, the operations rather have to be reordered correctly.
With the citation style address:
Quoted 3 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-0qxl_modeset_fini (qdev);qxl_device_fini (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
Thomas Zimmermann
maintainerRe: [PATCH v6 02/10] Revert "drm/qxl: do not run release if qxl failed to init"
Hi Tong
Am 04.02.21 um 19:52 schrieb Tong Zhang:
Quoted 7 lines
Hi Thomas,
The original problem was
qxl_device_init()can fail, when it fails there is no need to callqxl_modeset_fini(qdev); qxl_device_fini(qdev);But those two functions are otherwise called in the
qxl_drm_release()-
OK, makes sense. Thanks for the explanation.
Review
Quoted 6 lines
I have posted an updated patch.
The new patch use the following logic(quoted diff) +2
-0+ if (!qdev->ddev.mode_config.funcs) + return;
This is again just papering over the issue. Better don't call qxl_drm_release() in the error path if qxl_device_init() fails.
I see two solutions: either roll-back manually, or use our new managed DRM interfaces. This is what the other drivers do.
Best regards
Thomas
Quoted 57 lines
qxl_modeset_fini(qdev); qxl_device_fini(qdev);Thanks,
- TongQuoted 49 lines · Thomas Zimmermann
Hi
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 1 line
This reverts commit
b91907a6241193465ca92e357adf16822242296d.This should be in the correct format, as given by 'dim cite'.
dim cite
b91907a6241193465ca92e357adf16822242296db91907a62411("drm/qxl: do not run release if qxl failed to init")Quoted 13 lines
Patch is broken, it effectively makes
qxl_drm_release()a nop because on normal driver shutdownqxl_drm_release()is called *after*drm_dev_unregister().Cc Tong Zhang <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/qxl/qxl_drv.c +0
-0drivers/gpu/drm/qxl/qxl_drv.c static void qxl_drm_release(struct drm_device *dev) · line 148
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-2@@ -144,8 +144,6 @@ static void qxl_drm_release(struct drm_device *dev)* reodering qxl_modeset_fini() + qxl_device_fini() calls is * non-trivial though. */ -if (!dev->registered) -return ;I'm not sure what the original problem was, but I'm sure that this isn't the fix for it. If there's a problem with shutdown, the operations rather have to be reordered correctly.
With the citation style address:
Quoted 3 lines
drivers/gpu/drm/qxl/qxl_drv.c +0
-0qxl_modeset_fini (qdev);qxl_device_fini (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
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
Re: [PATCH v6 02/10] Revert "drm/qxl: do not run release if qxl failed to init"
Quoted 13 lines · Thomas Zimmermann
Hi Tong
Review
Quoted 4 lines
I have posted an updated patch.
The new patch use the following logic(quoted diff) +2
-0+ if (!qdev->ddev.mode_config.funcs) + return;This is again just papering over the issue. Better don't call
qxl_drm_release()in the error path ifqxl_device_init()fails.
Quoted 4 lines
I see two solutions: either roll-back manually, or use our new managed DRM interfaces. This is what the other drivers do.
Best regards
Thomas
IMHO - qdev->ddev.mode_config.funcs is set only if the initialization is successful, so using this as an indicator of error case looks ok to me.
The other two options you suggested would require some serious significant amount of work to be done, which I don’t think I currently have such ability to do.
Thanks,
- Tong
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v6 3/10 drm/qxl: use drmm_mode_config_init
In reply to Gerd Hoffmann--- 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 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v6 4/10 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
@@ -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 v6 5/10 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
Re: [PATCH v6 05/10] drm/qxl: release shadow on shutdown
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 4 lines
In case we have a shadow surface on shutdown release it so it doesn't leak.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 19 lines
--- 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
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 v6 6/10 drm/qxl: properly pin/unpin shadow
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_display.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +4 -0
@@ -802,12 +802,14 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, }if (user_bo->shadow != qdev->dumb_shadow_bo) {if (user_bo->shadow) { +qxl_bo_unpin (user_bo->shadow);drm_gem_object_put (&user_bo->shadow->tbo.base); user_bo->shadow =NULL ; }drm_gem_object_get (&qdev->dumb_shadow_bo->tbo.base); user_bo->shadow = qdev->dumb_shadow_bo; +qxl_bo_pin (user_bo->shadow); } }
@@ -833,6 +835,7 @@ static void qxl_plane_cleanup_fb(struct drm_plane *plane,qxl_bo_unpin (user_bo);if (old_state->fb != plane->state->fb && user_bo->shadow) { +qxl_bo_unpin (user_bo->shadow);drm_gem_object_put (&user_bo->shadow->tbo.base); user_bo->shadow =NULL ; }
@@ -1230,6 +1233,7 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) {if (qdev->dumb_shadow_bo) { +qxl_bo_unpin (qdev->dumb_shadow_bo);drm_gem_object_put (&qdev->dumb_shadow_bo->tbo.base); qdev->dumb_shadow_bo =NULL ; }
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v6 06/10] drm/qxl: properly pin/unpin shadow
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 2 lines
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>
Thanks for this.
Quoted 40 lines
--- drivers/gpu/drm/qxl/qxl_display.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/qxl/qxl_display.c +4
-0@@ -802,12 +802,14 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, }if (user_bo->shadow != qdev->dumb_shadow_bo) {if (user_bo->shadow) { +qxl_bo_unpin (user_bo->shadow);drm_gem_object_put (&user_bo->shadow->tbo.base); user_bo->shadow =NULL ; }drm_gem_object_get (&qdev->dumb_shadow_bo->tbo.base); user_bo->shadow = qdev->dumb_shadow_bo; +qxl_bo_pin (user_bo->shadow); } }@@ -833,6 +835,7 @@ static void qxl_plane_cleanup_fb(struct drm_plane *plane,qxl_bo_unpin (user_bo);if (old_state->fb != plane->state->fb && user_bo->shadow) { +qxl_bo_unpin (user_bo->shadow);drm_gem_object_put (&user_bo->shadow->tbo.base); user_bo->shadow =NULL ; }@@ -1230,6 +1233,7 @@ int qxl_modeset_init(struct qxl_device *qdev)void qxl_modeset_fini (struct qxl_device *qdev) {if (qdev->dumb_shadow_bo) { +qxl_bo_unpin (qdev->dumb_shadow_bo);drm_gem_object_put (&qdev->dumb_shadow_bo->tbo.base); qdev->dumb_shadow_bo =NULL ; }
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 v6 7/10 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
Gerd Hoffmann
maintainerPATCH v6 8/10 drm/qxl: properly free qxl releases
In reply to Gerd HoffmannReorganize qxl_device_fini() a bit.
Add missing unpin() calls.
Count releases. Add wait queue for releases. That way qxl_device_fini() can easily wait until everything is ready for proper shutdown.
--- drivers/gpu/drm/qxl/qxl_drv.h | 2 ++ drivers/gpu/drm/qxl/qxl_cmd.c | 1 + drivers/gpu/drm/qxl/qxl_irq.c | 1 + drivers/gpu/drm/qxl/qxl_kms.c | 28 ++++++++++++++++++++++++---- drivers/gpu/drm/qxl/qxl_release.c | 2 ++ 5 files changed, 30 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +2 -0
@@ -214,6 +214,8 @@ struct qxl_device {spinlock_t release_lock;struct idr release_idr;uint32_t release_seqno; +atomic_t release_count; +wait_queue_head_t release_event;spinlock_t release_idr_lock;struct mutex async_io_mutex;unsigned int last_sent_io_cmd;
drivers/gpu/drm/qxl/qxl_cmd.c +1 -0
@@ -254,6 +254,7 @@ int qxl_garbage_collect(struct qxl_device *qdev) } } +wake_up_all (&qdev->release_event);DRM_DEBUG_DRIVER ("%d\n" , i);return i;
drivers/gpu/drm/qxl/qxl_irq.c +1 -0
@@ -87,6 +87,7 @@ int qxl_irq_init(struct qxl_device *qdev)init_waitqueue_head (&qdev->display_event);init_waitqueue_head (&qdev->cursor_event);init_waitqueue_head (&qdev->io_cmd_event); +init_waitqueue_head (&qdev->release_event);INIT_WORK (&qdev->client_monitors_config_work, qxl_client_monitors_config_work_func);atomic_set (&qdev->irq_received,0 );
drivers/gpu/drm/qxl/qxl_kms.c +24 -4
@@ -286,11 +286,31 @@ int qxl_device_init(struct qxl_device *qdev,void qxl_device_fini (struct qxl_device *qdev) { -qxl_bo_unref (&qdev->current_release_bo[0 ]); -qxl_bo_unref (&qdev->current_release_bo[1 ]); -qxl_gem_fini (qdev); -qxl_bo_fini (qdev); +int cur_idx; + +for (cur_idx =0 ; cur_idx <3 ; cur_idx++) { +if (!qdev->current_release_bo[cur_idx]) +continue ; +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 ; + } + +/* +* Ask host to release resources (+fill release ring), +* then wait for the release actually happening. +*/ +qxl_io_notify_oom (qdev); +wait_event_timeout (qdev->release_event, +atomic_read (&qdev->release_count) ==0 , +HZ );flush_work (&qdev->gc_work); +qxl_surf_evict (qdev); +qxl_vram_evict (qdev); + +qxl_gem_fini (qdev); +qxl_bo_fini (qdev);qxl_ring_free (qdev->command_ring);qxl_ring_free (qdev->cursor_ring);qxl_ring_free (qdev->release_ring);
drivers/gpu/drm/qxl/qxl_release.c +2 -0
@@ -196,6 +196,7 @@ qxl_release_free(struct qxl_device *qdev,qxl_release_free_list (release);kfree (release); } +atomic_dec (&qdev->release_count); } static int qxl_release_bo_alloc(struct qxl_device *qdev,
@@ -344,6 +345,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size, *rbo =NULL ;return idr_ret; } +atomic_inc (&qdev->release_count);mutex_lock (&qdev->release_mutex);if (qdev->current_release_bo_offset[cur_idx] +1 >= releases_per_bo[cur_idx]) {
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Gerd Hoffmann
maintainerPATCH v6 9/10 drm/qxl: simplify qxl_fence_wait
In reply to Gerd HoffmannNow that we have the new release_event wait queue we can just use that in qxl_fence_wait() and simplify the code alot.
--- drivers/gpu/drm/qxl/qxl_release.c | 44 +++---------------------------- 1 file changed, 4 insertions(+), 40 deletions(-)
drivers/gpu/drm/qxl/qxl_release.c +4 -40
@@ -58,54 +58,18 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr, signed long timeout) {struct qxl_device *qdev; -struct qxl_release *release; -int count =0 , sc =0 ; -bool have_drawable_releases;unsigned long cur, end = jiffies + timeout; qdev = container_of(fence->lock, struct qxl_device, release_lock); - release = container_of(fence, struct qxl_release, base); - have_drawable_releases = release->type ==QXL_RELEASE_DRAWABLE ; - -retry: - sc++;if (dma_fence_is_signaled (fence)) goto signaled;qxl_io_notify_oom (qdev); - -for (count =0 ; count <11 ; count++) { -if (!qxl_queue_garbage_collect (qdev, true)) -break ; - -if (dma_fence_is_signaled (fence)) - goto signaled; - } - -if (dma_fence_is_signaled (fence)) - goto signaled; - -if (have_drawable_releases || sc <4 ) { -if (sc >2 ) -/* back off */ -usleep_range (500 ,1000 ); - -if (time_after (jiffies, end)) -return 0 ; - -if (have_drawable_releases && sc >300 ) { -DMA_FENCE_WARN (fence,"failed to wait on release %llu " -"after spincount %d\n" , - fence->context & ~0xf0000000 , sc); - goto signaled; - } - goto retry; - } -/* -* yeah, original sync_obj_wait gave up after 3 spins when -* have_drawable_releases is not set. -*/ +if (!wait_event_timeout (qdev->release_event, +dma_fence_is_signaled (fence), + timeout)) +return 0 ; signaled: cur = jiffies;
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Gerd Hoffmann
maintainerPATCH v6 10/10 drm/qxl: allocate dumb buffers in ram
In reply to Gerd Hoffmanndumb buffers are shadowed anyway, so there is no need to store them in device memory. Use QXL_GEM_DOMAIN_CPU (TTM_PL_SYSTEM) instead.
--- drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_dumb.c +1 -1
@@ -59,7 +59,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, surf.stride = pitch; surf.format = format; r =qxl_gem_object_create_with_handle (qdev, file_priv, -QXL_GEM_DOMAIN_SURFACE , +QXL_GEM_DOMAIN_CPU , args->size, &surf, &qobj, &handle);if (r)
Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v6 10/10] drm/qxl: allocate dumb buffers in ram
Am 04.02.21 um 15:57 schrieb Gerd Hoffmann:
Quoted 2 lines
dumb buffers are shadowed anyway, so there is no need to store them in device memory. Use
QXL_GEM_DOMAIN_CPU(TTM_PL_SYSTEM) instead.
Makes sense. I had similar issues in other drivers about the placement of buffers. For them, all new buffers now go into system ram by default, and only move into device memory when they have to.
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 18 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/qxl/qxl_dumb.c +1
-1@@ -59,7 +59,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, surf.stride = pitch; surf.format = format; r =qxl_gem_object_create_with_handle (qdev, file_priv, -QXL_GEM_DOMAIN_SURFACE , +QXL_GEM_DOMAIN_CPU , args->size, &surf, &qobj, &handle);if (r)
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