Skip to contentSkip to conversation

drm/qxl: fix stale mm entries on driver shutdown

PATCH Superseded Gerd Hoffmann 3 participants 7 messages Sep 29, 2020

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

v2 cover drm/qxl: fix stale mm entries on driver shutdown

v2: repost, add a pin fix.

Gerd Hoffmann (4):
drm/qxl: use drmm_mode_config_init
drm/qxl: release shadow on shutdown
drm/qxl: handle shadow in primary destroy
drm/qxl: use qxl pin function

 drivers/gpu/drm/qxl/qxl_display.c | 11 +++++++++--
 drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)
Signature · 7 lines
2.27.0


_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#1 lore raw

PATCH v2 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
index 65de1f69af58..5bef8f121e54 100644
@@ -1186,7 +1186,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)
@@ -1219,5 +1221,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 · 1 line
2.27.0
author maintainer
#2 lore raw

PATCH v2 2/4 drm/qxl: release shadow on shutdown

In reply to Gerd Hoffmann

In 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
index 5bef8f121e54..1d9c51022be4 100644
@@ -1220,5 +1220,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 · 1 line
2.27.0
author maintainer
#3 lore raw

PATCH v2 3/4 drm/qxl: handle shadow in primary destroy

In reply to 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.

---
 drivers/gpu/drm/qxl/qxl_display.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +2 -0
index 1d9c51022be4..d133e6c2aaf4 100644
@@ -561,6 +561,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 · 1 line
2.27.0
author maintainer
#4 lore raw

PATCH v2 4/4 drm/qxl: use qxl pin function

In reply to Gerd Hoffmann

Otherwise ttm throws a WARN because we try to pin without a reservation.

Fixes 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
---
 drivers/gpu/drm/qxl/qxl_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_object.c +1 -1
index d3635e3e3267..eb45267d51db 100644
@@ -145,7 +145,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		return r;
 	}
 	if (pinned)
-		ttm_bo_pin(&bo->tbo);
+		qxl_bo_pin(bo);
 	*bo_ptr = bo;
 	return 0;
 }
Signature · 6 lines
2.27.0

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#5 lore raw

Re: [PATCH v2 4/4] drm/qxl: use qxl pin function

Quoted 13 lines · Gerd Hoffmann

Otherwise ttm throws a WARN because we try to pin without a reservation.

Fixes 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
---
 drivers/gpu/drm/qxl/qxl_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_object.c +0 -0
index d3635e3e3267..eb45267d51db 100644

drivers/gpu/drm/qxl/qxl_object.c int qxl_bo_create(struct qxl_device *qdev, · line 148

Quoted 5 lines
drivers/gpu/drm/qxl/qxl_object.c +1 -1
@@ -145,7 +145,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		return r;
 	}
 	if (pinned)
-		ttm_bo_pin(&bo->tbo);
+		qxl_bo_pin(bo);

I think this is now after ttm_bo_init, and at that point the object is visible to lru users and everything. So I do think you need to grab locks here instead of just incrementing the pin count alone.

It's also I think a bit racy, since ttm_bo_init drops the lock, so someone might have snuck in and evicted the object already.

I think what you need is to call ttm_bo_init_reserved, then ttm_bo_pin, then ttm_bo_unreserve, all explicitly.
-Daniel

Quoted 6 lines
drivers/gpu/drm/qxl/qxl_object.c +0 -0
 	*bo_ptr = bo;
 	return 0;
 }
Signature · 1 line
2.27.0
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
#6 lore raw

Re: [PATCH v2 4/4] drm/qxl: use qxl pin function

Am 29.09.20 um 12:53 schrieb Daniel Vetter:

Quoted 23 lines · Gerd Hoffmann
Quoted 13 lines

Otherwise ttm throws a WARN because we try to pin without a reservation.

Fixes 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
---
  drivers/gpu/drm/qxl/qxl_object.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_object.c +0 -0
index d3635e3e3267..eb45267d51db 100644

drivers/gpu/drm/qxl/qxl_object.c int qxl_bo_create(struct qxl_device *qdev, · line 148

Quoted 5 lines
drivers/gpu/drm/qxl/qxl_object.c +1 -1
@@ -145,7 +145,7 @@ int qxl_bo_create(struct qxl_device *qdev,
  		return r;
  	}
  	if (pinned)
-		ttm_bo_pin(&bo->tbo);
+		qxl_bo_pin(bo);

I think this is now after ttm_bo_init, and at that point the object is visible to lru users and everything. So I do think you need to grab locks here instead of just incrementing the pin count alone.

Quoted 5 lines

It's also I think a bit racy, since ttm_bo_init drops the lock, so someone might have snuck in and evicted the object already.

I think what you need is to call ttm_bo_init_reserved, then ttm_bo_pin, then ttm_bo_unreserve, all explicitly.

Ah, yes Daniel is right. I thought I've fixed that up, but looks like I only did that for VMWGFX.

Sorry for the noise, fix to correctly address this is underway.

Regards,
Christian.

Quoted 8 lines

-Daniel

Quoted 6 lines
drivers/gpu/drm/qxl/qxl_object.c +0 -0
  	*bo_ptr = bo;
  	return 0;
  }
Signature · 1 line
2.27.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel