* [PATCH v5 0/6] drm/qxl: fix driver shutdown issues.
@ 2021-02-03 13:16 Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 1/6] drm/qxl: use drmm_mode_config_init Gerd Hoffmann
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel; +Cc: Gerd Hoffmann
Almost there. Still getting this on driver unbind:
kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_put(=
) is being called
[ ... ]
Call Trace:
ttm_device_fini+0x133/0x1b0 [ttm]
qxl_ttm_fini+0x2f/0x40 [qxl]
qxl_device_fini+0x88/0x120 [qxl]
drm_minor_release+0x3d/0x60
but I don't think this is the qxl driver's fault.
v5:
- add release_event wait queue.
- also cleanup qxl_fence_wait().
Gerd Hoffmann (6):
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
drm/qxl: properly free qxl releases
drm/qxl: simplify qxl_fence_wait
drivers/gpu/drm/qxl/qxl_drv.h | 2 ++
drivers/gpu/drm/qxl/qxl_cmd.c | 1 +
drivers/gpu/drm/qxl/qxl_display.c | 11 ++++++--
drivers/gpu/drm/qxl/qxl_irq.c | 1 +
drivers/gpu/drm/qxl/qxl_kms.c | 22 +++++++++++++--
drivers/gpu/drm/qxl/qxl_release.c | 45 +++++--------------------------
6 files changed, 40 insertions(+), 42 deletions(-)
--=20
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v5 1/6] drm/qxl: use drmm_mode_config_init
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 2/6] drm/qxl: unpin release objects Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: Thomas Zimmermann, David Airlie, Daniel Vetter, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/qxl/qxl_display.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 012bce0cdb65..38d6b596094d 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -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);
}
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 2/6] drm/qxl: unpin release objects
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 1/6] drm/qxl: use drmm_mode_config_init Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 14:00 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 3/6] drm/qxl: release shadow on shutdown Gerd Hoffmann
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
Balances the qxl_create_bo(..., pinned=true, ...);
call in qxl_release_bo_alloc().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/qxl/qxl_release.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index c52412724c26..28013fd1f8ea 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -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;
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 3/6] drm/qxl: release shadow on shutdown
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 1/6] drm/qxl: use drmm_mode_config_init Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 2/6] drm/qxl: unpin release objects Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 14:05 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy Gerd Hoffmann
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
In case we have a shadow surface on shutdown release
it so it doesn't leak.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/qxl/qxl_display.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 38d6b596094d..60331e31861a 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -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);
}
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
` (2 preceding siblings ...)
2021-02-03 13:16 ` [PATCH v5 3/6] drm/qxl: release shadow on shutdown Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 14:07 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 5/6] drm/qxl: properly free qxl releases Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Gerd Hoffmann
5 siblings, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
qxl_primary_atomic_disable must check whenever the framebuffer bo has a
shadow surface and in case it has check the shadow primary status.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/qxl/qxl_display.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 60331e31861a..f5ee8cd72b5b 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -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;
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 5/6] drm/qxl: properly free qxl releases
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
` (3 preceding siblings ...)
2021-02-03 13:16 ` [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 14:12 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Gerd Hoffmann
5 siblings, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
Reorganize 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.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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 | 22 ++++++++++++++++++++--
drivers/gpu/drm/qxl/qxl_release.c | 2 ++
5 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 01354b43c413..6dd57cfb2e7c 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -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;
diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 54e3c3a97440..7e22a81bfb36 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -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;
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index ddf6588a2a38..d312322cacd1 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -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);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 4a60a52ab62e..616aea948863 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -286,8 +286,26 @@ 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]);
+ 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);
+
qxl_gem_fini(qdev);
qxl_bo_fini(qdev);
flush_work(&qdev->gc_work);
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 28013fd1f8ea..43a5436853b7 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -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]) {
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
` (4 preceding siblings ...)
2021-02-03 13:16 ` [PATCH v5 5/6] drm/qxl: properly free qxl releases Gerd Hoffmann
@ 2021-02-03 13:16 ` Gerd Hoffmann
2021-02-03 14:14 ` Thomas Zimmermann
2021-02-03 15:16 ` kernel test robot
5 siblings, 2 replies; 13+ messages in thread
From: Gerd Hoffmann @ 2021-02-03 13:16 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Dave Airlie
Now that we have the new release_event wait queue we can just
use that in qxl_fence_wait() and simplify the code alot.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/qxl/qxl_release.c | 42 +++----------------------------
1 file changed, 4 insertions(+), 38 deletions(-)
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 43a5436853b7..b6f4b8dcf228 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -59,53 +59,19 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr,
{
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;
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v5 2/6] drm/qxl: unpin release objects
2021-02-03 13:16 ` [PATCH v5 2/6] drm/qxl: unpin release objects Gerd Hoffmann
@ 2021-02-03 14:00 ` Thomas Zimmermann
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Zimmermann @ 2021-02-03 14:00 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU,
Dave Airlie, open list, open list:DRM DRIVER FOR QXL VIRTUAL GPU
[-- Attachment #1.1.1: Type: text/plain, Size: 1205 bytes --]
Am 03.02.21 um 14:16 schrieb Gerd Hoffmann:
> Balances the qxl_create_bo(..., pinned=true, ...);
> call in qxl_release_bo_alloc().
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/qxl/qxl_release.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index c52412724c26..28013fd1f8ea 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -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;
>
--
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
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 3/6] drm/qxl: release shadow on shutdown
2021-02-03 13:16 ` [PATCH v5 3/6] drm/qxl: release shadow on shutdown Gerd Hoffmann
@ 2021-02-03 14:05 ` Thomas Zimmermann
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Zimmermann @ 2021-02-03 14:05 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU,
Dave Airlie, open list, open list:DRM DRIVER FOR QXL VIRTUAL GPU
[-- Attachment #1.1.1: Type: text/plain, Size: 1225 bytes --]
Hi
Am 03.02.21 um 14:16 schrieb Gerd Hoffmann:
> In case we have a shadow surface on shutdown release
> it so it doesn't leak.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> drivers/gpu/drm/qxl/qxl_display.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 38d6b596094d..60331e31861a 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -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;
> + }
In qxl_plane_prepare_fb(), qdev->dumb_shadow_bo is being created as
pinned object. Wouldn't it have to be unpinned here and during the
release in qxl_plane_prepare_fb()?
Best regards
Thomas
> qxl_destroy_monitors_object(qdev);
> }
>
--
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
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy
2021-02-03 13:16 ` [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy Gerd Hoffmann
@ 2021-02-03 14:07 ` Thomas Zimmermann
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Zimmermann @ 2021-02-03 14:07 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU,
Dave Airlie, open list, open list:DRM DRIVER FOR QXL VIRTUAL GPU
[-- Attachment #1.1.1: Type: text/plain, Size: 1168 bytes --]
Am 03.02.21 um 14:16 schrieb Gerd Hoffmann:
> qxl_primary_atomic_disable must check whenever the framebuffer bo has a
> shadow surface and in case it has check the shadow primary status.
I believe you :)
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> drivers/gpu/drm/qxl/qxl_display.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 60331e31861a..f5ee8cd72b5b 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -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;
>
--
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
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 5/6] drm/qxl: properly free qxl releases
2021-02-03 13:16 ` [PATCH v5 5/6] drm/qxl: properly free qxl releases Gerd Hoffmann
@ 2021-02-03 14:12 ` Thomas Zimmermann
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Zimmermann @ 2021-02-03 14:12 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU,
Dave Airlie, open list, open list:DRM DRIVER FOR QXL VIRTUAL GPU
[-- Attachment #1.1.1: Type: text/plain, Size: 4332 bytes --]
Am 03.02.21 um 14:16 schrieb Gerd Hoffmann:
> Reorganize 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.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> 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 | 22 ++++++++++++++++++++--
> drivers/gpu/drm/qxl/qxl_release.c | 2 ++
> 5 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 01354b43c413..6dd57cfb2e7c 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -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;
> diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
> index 54e3c3a97440..7e22a81bfb36 100644
> --- a/drivers/gpu/drm/qxl/qxl_cmd.c
> +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
> @@ -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;
> diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
> index ddf6588a2a38..d312322cacd1 100644
> --- a/drivers/gpu/drm/qxl/qxl_irq.c
> +++ b/drivers/gpu/drm/qxl/qxl_irq.c
> @@ -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);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 4a60a52ab62e..616aea948863 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -286,8 +286,26 @@ 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]);
> + 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);
> +
> qxl_gem_fini(qdev);
> qxl_bo_fini(qdev);
> flush_work(&qdev->gc_work);
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 28013fd1f8ea..43a5436853b7 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -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]) {
>
--
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
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait
2021-02-03 13:16 ` [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Gerd Hoffmann
@ 2021-02-03 14:14 ` Thomas Zimmermann
2021-02-03 15:16 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: Thomas Zimmermann @ 2021-02-03 14:14 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list:DRM DRIVER FOR QXL VIRTUAL GPU,
Dave Airlie, open list, open list:DRM DRIVER FOR QXL VIRTUAL GPU
[-- Attachment #1.1.1: Type: text/plain, Size: 2439 bytes --]
Am 03.02.21 um 14:16 schrieb Gerd Hoffmann:
> Now that we have the new release_event wait queue we can just
> use that in qxl_fence_wait() and simplify the code alot.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/qxl/qxl_release.c | 42 +++----------------------------
> 1 file changed, 4 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 43a5436853b7..b6f4b8dcf228 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -59,53 +59,19 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr,
> {
> 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;
>
--
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
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait
2021-02-03 13:16 ` [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Gerd Hoffmann
2021-02-03 14:14 ` Thomas Zimmermann
@ 2021-02-03 15:16 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-02-03 15:16 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: kbuild-all, David Airlie, open list,
open list:DRM DRIVER FOR QXL VIRTUAL GPU, Gerd Hoffmann,
Dave Airlie
[-- Attachment #1: Type: text/plain, Size: 3697 bytes --]
Hi Gerd,
I love your patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.11-rc6 next-20210125]
[cannot apply to drm/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gerd-Hoffmann/drm-qxl-fix-driver-shutdown-issues/20210203-211739
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-a013-20210202 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/0b11c8d52de8c79900ab632aa3527f19c442efc6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gerd-Hoffmann/drm-qxl-fix-driver-shutdown-issues/20210203-211739
git checkout 0b11c8d52de8c79900ab632aa3527f19c442efc6
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/gpu/drm/qxl/qxl_release.c: In function 'qxl_fence_wait':
>> drivers/gpu/drm/qxl/qxl_release.c:61:22: warning: variable 'release' set but not used [-Wunused-but-set-variable]
61 | struct qxl_release *release;
| ^~~~~~~
vim +/release +61 drivers/gpu/drm/qxl/qxl_release.c
2f453ed4038526 Maarten Lankhorst 2014-04-02 56
f54d1867005c33 Chris Wilson 2016-10-25 57 static long qxl_fence_wait(struct dma_fence *fence, bool intr,
f54d1867005c33 Chris Wilson 2016-10-25 58 signed long timeout)
2f453ed4038526 Maarten Lankhorst 2014-04-02 59 {
2f453ed4038526 Maarten Lankhorst 2014-04-02 60 struct qxl_device *qdev;
2f453ed4038526 Maarten Lankhorst 2014-04-02 @61 struct qxl_release *release;
2f453ed4038526 Maarten Lankhorst 2014-04-02 62 unsigned long cur, end = jiffies + timeout;
2f453ed4038526 Maarten Lankhorst 2014-04-02 63
2f453ed4038526 Maarten Lankhorst 2014-04-02 64 qdev = container_of(fence->lock, struct qxl_device, release_lock);
2f453ed4038526 Maarten Lankhorst 2014-04-02 65 release = container_of(fence, struct qxl_release, base);
2f453ed4038526 Maarten Lankhorst 2014-04-02 66
f54d1867005c33 Chris Wilson 2016-10-25 67 if (dma_fence_is_signaled(fence))
2f453ed4038526 Maarten Lankhorst 2014-04-02 68 goto signaled;
2f453ed4038526 Maarten Lankhorst 2014-04-02 69
2f453ed4038526 Maarten Lankhorst 2014-04-02 70 qxl_io_notify_oom(qdev);
0b11c8d52de8c7 Gerd Hoffmann 2021-02-03 71 if (!wait_event_timeout(qdev->release_event,
0b11c8d52de8c7 Gerd Hoffmann 2021-02-03 72 dma_fence_is_signaled(fence),
0b11c8d52de8c7 Gerd Hoffmann 2021-02-03 73 timeout))
2f453ed4038526 Maarten Lankhorst 2014-04-02 74 return 0;
2f453ed4038526 Maarten Lankhorst 2014-04-02 75
2f453ed4038526 Maarten Lankhorst 2014-04-02 76 signaled:
2f453ed4038526 Maarten Lankhorst 2014-04-02 77 cur = jiffies;
2f453ed4038526 Maarten Lankhorst 2014-04-02 78 if (time_after(cur, end))
2f453ed4038526 Maarten Lankhorst 2014-04-02 79 return 0;
2f453ed4038526 Maarten Lankhorst 2014-04-02 80 return end - cur;
2f453ed4038526 Maarten Lankhorst 2014-04-02 81 }
2f453ed4038526 Maarten Lankhorst 2014-04-02 82
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37567 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-02-03 15:17 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 13:16 [PATCH v5 0/6] drm/qxl: fix driver shutdown issues Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 1/6] drm/qxl: use drmm_mode_config_init Gerd Hoffmann
2021-02-03 13:16 ` [PATCH v5 2/6] drm/qxl: unpin release objects Gerd Hoffmann
2021-02-03 14:00 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 3/6] drm/qxl: release shadow on shutdown Gerd Hoffmann
2021-02-03 14:05 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 4/6] drm/qxl: handle shadow in primary destroy Gerd Hoffmann
2021-02-03 14:07 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 5/6] drm/qxl: properly free qxl releases Gerd Hoffmann
2021-02-03 14:12 ` Thomas Zimmermann
2021-02-03 13:16 ` [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Gerd Hoffmann
2021-02-03 14:14 ` Thomas Zimmermann
2021-02-03 15:16 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).