Skip to contentSkip to conversation

drm/ttm: add default implementations for ttm_tt_(un)populate

PATCH In review Christian König 3 participants 12 messages Feb 22, 2018 – Feb 23, 2018

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

PATCH 1/8 drm/ttm: add default implementations for ttm_tt_(un)populate

Use ttm_pool_populate/ttm_pool_unpopulate if the driver doesn't provide a function.

---
 drivers/gpu/drm/ttm/ttm_tt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +8 -2
index 9fd7115a013a..65bf4eac184b 100644
@@ -410,7 +410,10 @@ int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
 	if (ttm->state != tt_unpopulated)
 		return 0;
 
-	ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	if (ttm->bdev->driver->ttm_tt_populate)
+		ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	else
+		ret = ttm_pool_populate(ttm, ctx);
 	if (!ret)
 		ttm_tt_add_mapping(ttm);
 	return ret;
@@ -436,5 +439,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
 		return;
 
 	ttm_tt_clear_mapping(ttm);
-	ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	if (ttm->bdev->driver->ttm_tt_unpopulate)
+		ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	else
+		ttm_pool_unpopulate(ttm);
 }
Signature · 6 lines
2.14.1

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

PATCH 2/8 drm/virtio: remove ttm_pool_* wrappers

TTM calls the default implementation now.

---
 drivers/gpu/drm/virtio/virtgpu_ttm.c | 16 ----------------
 1 file changed, 16 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ttm.c +0 -16
index 36655b709eb2..1cde060602aa 100644
@@ -324,20 +324,6 @@ static struct ttm_backend_func virtio_gpu_backend_func = {
 	.destroy = &virtio_gpu_ttm_backend_destroy,
 };
 
-static int virtio_gpu_ttm_tt_populate(struct ttm_tt *ttm,
-		struct ttm_operation_ctx *ctx)
-{
-	if (ttm->state != tt_unpopulated)
-		return 0;
-
-	return ttm_pool_populate(ttm, ctx);
-}
-
-static void virtio_gpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 static struct ttm_tt *virtio_gpu_ttm_tt_create(struct ttm_bo_device *bdev,
 					       unsigned long size,
 					       uint32_t page_flags,
@@ -421,8 +407,6 @@ static void virtio_gpu_bo_swap_notify(struct ttm_buffer_object *tbo)
 
 static struct ttm_bo_driver virtio_gpu_bo_driver = {
 	.ttm_tt_create = &virtio_gpu_ttm_tt_create,
-	.ttm_tt_populate = &virtio_gpu_ttm_tt_populate,
-	.ttm_tt_unpopulate = &virtio_gpu_ttm_tt_unpopulate,
 	.invalidate_caches = &virtio_gpu_invalidate_caches,
 	.init_mem_type = &virtio_gpu_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
Signature · 6 lines
2.14.1

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

PATCH 3/8 drm/mgag200: remove ttm_pool_* wrappers

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/gpu/drm/mgag200/mgag200_ttm.c +0 -13
index c97009bb77dd..26e5f14645c5 100644
@@ -216,21 +216,8 @@ static struct ttm_tt *mgag200_ttm_tt_create(struct ttm_bo_device *bdev,
 	return tt;
 }
 
-static int mgag200_ttm_tt_populate(struct ttm_tt *ttm,
-			struct ttm_operation_ctx *ctx)
-{
-	return ttm_pool_populate(ttm, ctx);
-}
-
-static void mgag200_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 struct ttm_bo_driver mgag200_bo_driver = {
 	.ttm_tt_create = mgag200_ttm_tt_create,
-	.ttm_tt_populate = mgag200_ttm_tt_populate,
-	.ttm_tt_unpopulate = mgag200_ttm_tt_unpopulate,
 	.init_mem_type = mgag200_bo_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = mgag200_bo_evict_flags,
Signature · 6 lines
2.14.1

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

PATCH 4/8 drm/hisilicon: remove ttm_pool_* wrappers

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +0 -13
index 8516e005643f..0c93349fbacf 100644
@@ -223,21 +223,8 @@ static struct ttm_tt *hibmc_ttm_tt_create(struct ttm_bo_device *bdev,
 	return tt;
 }
 
-static int hibmc_ttm_tt_populate(struct ttm_tt *ttm,
-		struct ttm_operation_ctx *ctx)
-{
-	return ttm_pool_populate(ttm, ctx);
-}
-
-static void hibmc_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 struct ttm_bo_driver hibmc_bo_driver = {
 	.ttm_tt_create		= hibmc_ttm_tt_create,
-	.ttm_tt_populate	= hibmc_ttm_tt_populate,
-	.ttm_tt_unpopulate	= hibmc_ttm_tt_unpopulate,
 	.init_mem_type		= hibmc_bo_init_mem_type,
 	.evict_flags		= hibmc_bo_evict_flags,
 	.move			= NULL,
Signature · 6 lines
2.14.1

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

PATCH 5/8 drm/ast: remove ttm_pool_* wrappers

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/ast/ast_ttm.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/gpu/drm/ast/ast_ttm.c +0 -13
index 7b784d91e258..68b9c5522eaa 100644
@@ -216,21 +216,8 @@ static struct ttm_tt *ast_ttm_tt_create(struct ttm_bo_device *bdev,
 	return tt;
 }
 
-static int ast_ttm_tt_populate(struct ttm_tt *ttm,
-			struct ttm_operation_ctx *ctx)
-{
-	return ttm_pool_populate(ttm, ctx);
-}
-
-static void ast_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 struct ttm_bo_driver ast_bo_driver = {
 	.ttm_tt_create = ast_ttm_tt_create,
-	.ttm_tt_populate = ast_ttm_tt_populate,
-	.ttm_tt_unpopulate = ast_ttm_tt_unpopulate,
 	.init_mem_type = ast_bo_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = ast_bo_evict_flags,
Signature · 6 lines
2.14.1

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

PATCH 6/8 drm/qxl: remove ttm_pool_* wrappers

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/qxl/qxl_ttm.c | 22 ----------------------
 1 file changed, 22 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +0 -22
index 59cd74c3f3af..07d4f3fde6c1 100644
@@ -291,26 +291,6 @@ static struct ttm_backend_func qxl_backend_func = {
 	.destroy = &qxl_ttm_backend_destroy,
 };
 
-static int qxl_ttm_tt_populate(struct ttm_tt *ttm,
-			struct ttm_operation_ctx *ctx)
-{
-	int r;
-
-	if (ttm->state != tt_unpopulated)
-		return 0;
-
-	r = ttm_pool_populate(ttm, ctx);
-	if (r)
-		return r;
-
-	return 0;
-}
-
-static void qxl_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 static struct ttm_tt *qxl_ttm_tt_create(struct ttm_bo_device *bdev,
 					unsigned long size, uint32_t page_flags,
 					struct page *dummy_read_page)
@@ -379,8 +359,6 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
 
 static struct ttm_bo_driver qxl_bo_driver = {
 	.ttm_tt_create = &qxl_ttm_tt_create,
-	.ttm_tt_populate = &qxl_ttm_tt_populate,
-	.ttm_tt_unpopulate = &qxl_ttm_tt_unpopulate,
 	.invalidate_caches = &qxl_invalidate_caches,
 	.init_mem_type = &qxl_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
Signature · 6 lines
2.14.1

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

PATCH 7/8 drm/cirrus: remove ttm_pool_* wrappers

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/cirrus/cirrus_ttm.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/gpu/drm/cirrus/cirrus_ttm.c +0 -13
index a8e31ea07382..33798c76a64b 100644
@@ -216,21 +216,8 @@ static struct ttm_tt *cirrus_ttm_tt_create(struct ttm_bo_device *bdev,
 	return tt;
 }
 
-static int cirrus_ttm_tt_populate(struct ttm_tt *ttm,
-		struct ttm_operation_ctx *ctx)
-{
-	return ttm_pool_populate(ttm, ctx);
-}
-
-static void cirrus_ttm_tt_unpopulate(struct ttm_tt *ttm)
-{
-	ttm_pool_unpopulate(ttm);
-}
-
 struct ttm_bo_driver cirrus_bo_driver = {
 	.ttm_tt_create = cirrus_ttm_tt_create,
-	.ttm_tt_populate = cirrus_ttm_tt_populate,
-	.ttm_tt_unpopulate = cirrus_ttm_tt_unpopulate,
 	.init_mem_type = cirrus_bo_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = cirrus_bo_evict_flags,
Signature · 6 lines
2.14.1

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

PATCH 8/8 drm/bochs: remove the default ttm_tt_populate callbacks

In reply to Christian König

TTM calls the default implementation now.

---
 drivers/gpu/drm/bochs/bochs_mm.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/bochs/bochs_mm.c +0 -2
index 704e879711e4..5525b6660340 100644
@@ -196,8 +196,6 @@ static struct ttm_tt *bochs_ttm_tt_create(struct ttm_bo_device *bdev,
 
 struct ttm_bo_driver bochs_bo_driver = {
 	.ttm_tt_create = bochs_ttm_tt_create,
-	.ttm_tt_populate = ttm_pool_populate,
-	.ttm_tt_unpopulate = ttm_pool_unpopulate,
 	.init_mem_type = bochs_bo_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = bochs_bo_evict_flags,
Signature · 6 lines
2.14.1

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

RE: [PATCH 8/8] drm/bochs: remove the default ttm_tt_populate callbacks

Series is: Reviewed-by: Roger He <[email protected]>

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Christian K?nig
Sent: Thursday, February 22, 2018 7:16 PM
To: [email protected]
Subject: [PATCH 8/8] drm/bochs: remove the default ttm_tt_populate callbacks

TTM calls the default implementation now.

---
 drivers/gpu/drm/bochs/bochs_mm.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/bochs/bochs_mm.c +0 -2
index 704e879711e4..5525b6660340 100644
@@ -196,8 +196,6 @@ static struct ttm_tt *bochs_ttm_tt_create(struct ttm_bo_device *bdev,
 
 struct ttm_bo_driver bochs_bo_driver = {
 	.ttm_tt_create = bochs_ttm_tt_create,
-	.ttm_tt_populate = ttm_pool_populate,
-	.ttm_tt_unpopulate = ttm_pool_unpopulate,
 	.init_mem_type = bochs_bo_init_mem_type,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = bochs_bo_evict_flags,
Signature · 10 lines
2.14.1

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

Use ttm_pool_populate/ttm_pool_unpopulate if the driver doesn't provide a function.

---
 drivers/gpu/drm/ttm/ttm_tt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +4 -1
index 9fd7115a013a..65bf4eac184b 100644
@@ -410,7 +410,10 @@ int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
 	if (ttm->state != tt_unpopulated)
 		return 0;
 
-	ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	if (ttm->bdev->driver->ttm_tt_populate)
+		ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	else
+		ret = ttm_pool_populate(ttm, ctx);
 	if (!ret)
 		ttm_tt_add_mapping(ttm);
 	return ret;

drivers/gpu/drm/ttm/ttm_tt.c void ttm_tt_unpopulate(struct ttm_tt *ttm) · line 446

Quoted 9 lines
drivers/gpu/drm/ttm/ttm_tt.c +4 -1
@@ -436,5 +439,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
 		return;
 
 	ttm_tt_clear_mapping(ttm);
-	ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	if (ttm->bdev->driver->ttm_tt_unpopulate)
+		ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	else
+		ttm_pool_unpopulate(ttm);
 }

Instead of the if/else, have you considered setting driver->ttm_tt_(un)populate = ttm_pool_(un)populate during initialization if they're NULL?

Either way, the series is

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

Am 22.02.2018 um 16:55 schrieb Michel Dänzer:

Quoted 28 lines · Christian König
Quoted 27 lines

Use ttm_pool_populate/ttm_pool_unpopulate if the driver doesn't provide a function.

---
  drivers/gpu/drm/ttm/ttm_tt.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +4 -1
index 9fd7115a013a..65bf4eac184b 100644
@@ -410,7 +410,10 @@ int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
  	if (ttm->state != tt_unpopulated)
  		return 0;
 
-	ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	if (ttm->bdev->driver->ttm_tt_populate)
+		ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+	else
+		ret = ttm_pool_populate(ttm, ctx);
  	if (!ret)
  		ttm_tt_add_mapping(ttm);
  	return ret;
@@ -436,5 +439,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
  		return;
 
Quoted 11 lines

drivers/gpu/drm/ttm/ttm_tt.c void ttm_tt_unpopulate(struct ttm_tt *ttm) · line 446

Quoted 8 lines
drivers/gpu/drm/ttm/ttm_tt.c +4 -1
  	ttm_tt_clear_mapping(ttm);
-	ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	if (ttm->bdev->driver->ttm_tt_unpopulate)
+		ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+	else
+		ttm_pool_unpopulate(ttm);
  }

Instead of the if/else, have you considered setting driver->ttm_tt_(un)populate = ttm_pool_(un)populate during initialization if they're NULL?

Mhm, also an interesting possibility. But shouldn't the function pointers be const?

Christian.

Quoted 7 lines

Either way, the series is

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

#11 lore raw
Quoted 40 lines · Christian König

Am 22.02.2018 um 16:55 schrieb Michel Dänzer:

Quoted 30 lines · Christian König
Quoted 29 lines

Use ttm_pool_populate/ttm_pool_unpopulate if the driver doesn't provide a function.

---
  drivers/gpu/drm/ttm/ttm_tt.c | 10 ++++++++--

  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +4 -0
index 9fd7115a013a..65bf4eac184b 100644
@@ -410,7 +410,10 @@ int ttm_tt_populate(struct ttm_tt *ttm, struct
 ttm_operation_ctx *ctx)
       if (ttm->state != tt_unpopulated)
           return 0;
   -    ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+    if (ttm->bdev->driver->ttm_tt_populate)
+        ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+    else
+        ret = ttm_pool_populate(ttm, ctx);
       if (!ret)
           ttm_tt_add_mapping(ttm);

      return ret;

drivers/gpu/drm/ttm/ttm_tt.c +1 -1
@@ -436,5 +439,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
           return;
         ttm_tt_clear_mapping(ttm);
-    ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+    if (ttm->bdev->driver->ttm_tt_unpopulate)
Quoted 8 lines

drivers/gpu/drm/ttm/ttm_tt.c void ttm_tt_unpopulate(struct ttm_tt *ttm)

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_tt.c +3 -0
+        ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+    else
+        ttm_pool_unpopulate(ttm);
   }
 

Instead of the if/else, have you considered setting driver->ttm_tt_(un)populate = ttm_pool_(un)populate during initialization if they're NULL?

Quoted 2 lines

Mhm, also an interesting possibility. But shouldn't the function pointers be const?

I guess that might be nice.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel