Skip to contentSkip to conversation

drm/qxl: fix usage of ttm_bo_init

PATCH In review Christian König 3 participants 3 messages Sep 29, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/qxl: fix usage of ttm_bo_init

We need to use ttm_bo_init_reserved here to make sure that the BO is pinned before it becomes visible on the LRU.

---
 drivers/gpu/drm/qxl/qxl_object.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_object.c +5 -3
index d3635e3e3267..c8b67e7a3f02 100644
@@ -106,6 +106,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		  struct qxl_surface *surf,
 		  struct qxl_bo **bo_ptr)
 {
+	struct ttm_operation_ctx ctx = { !kernel, false };
 	struct qxl_bo *bo;
 	enum ttm_bo_type type;
 	int r;
@@ -134,9 +135,9 @@ int qxl_bo_create(struct qxl_device *qdev,
 
 	qxl_ttm_placement_from_domain(bo, domain);
 
-	r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
-			&bo->placement, 0, !kernel, size,
-			NULL, NULL, &qxl_ttm_bo_destroy);
+	r = ttm_bo_init_reserved(&qdev->mman.bdev, &bo->tbo, size, type,
+				 &bo->placement, 0, &ctx, size,
+				 NULL, NULL, &qxl_ttm_bo_destroy);
 	if (unlikely(r != 0)) {
 		if (r != -ERESTARTSYS)
 			dev_err(qdev->ddev.dev,
@@ -146,6 +147,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 	}
 	if (pinned)
 		ttm_bo_pin(&bo->tbo);
+	ttm_bo_unreserve(&bo->tbo);
 	*bo_ptr = bo;
 	return 0;
 }
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christian König

We need to use ttm_bo_init_reserved here to make sure that the BO is pinned before it becomes visible on the LRU.

But maybe let Gerd test this first before pushing :-) -Daniel

Quoted 40 lines
---
 drivers/gpu/drm/qxl/qxl_object.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_object.c +5 -3
index d3635e3e3267..c8b67e7a3f02 100644
@@ -106,6 +106,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 		  struct qxl_surface *surf,
 		  struct qxl_bo **bo_ptr)
 {
+	struct ttm_operation_ctx ctx = { !kernel, false };
 	struct qxl_bo *bo;
 	enum ttm_bo_type type;
 	int r;
@@ -134,9 +135,9 @@ int qxl_bo_create(struct qxl_device *qdev,
 
 	qxl_ttm_placement_from_domain(bo, domain);
 
-	r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
-			&bo->placement, 0, !kernel, size,
-			NULL, NULL, &qxl_ttm_bo_destroy);
+	r = ttm_bo_init_reserved(&qdev->mman.bdev, &bo->tbo, size, type,
+				 &bo->placement, 0, &ctx, size,
+				 NULL, NULL, &qxl_ttm_bo_destroy);
 	if (unlikely(r != 0)) {
 		if (r != -ERESTARTSYS)
 			dev_err(qdev->ddev.dev,
@@ -146,6 +147,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 	}
 	if (pinned)
 		ttm_bo_pin(&bo->tbo);
+	ttm_bo_unreserve(&bo->tbo);
 	*bo_ptr = bo;
 	return 0;
 }
Signature · 1 line
2.17.1
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
maintainer Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Christian König
Quoted 4 lines · Christian König

We need to use ttm_bo_init_reserved here to make sure that the BO is pinned before it becomes visible on the LRU.

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