dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2)
@ 2020-08-04  2:55 Dave Airlie
  2020-08-04  2:55 ` [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate Dave Airlie
                   ` (60 more replies)
  0 siblings, 61 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

I've decided to repost the whole queue this time, it has a few driver
patches up front that are just cleanups.

I've reorodered things a little since the first posting, but not much.

misc core/driver cleanups
mem type manager debug callback cleanup (reordered)
new mem type manager init path
new mem type manager cleanup path
new wrapper to access managers
driver managed mem type allocations
cleanup after all of that
rename ttm_bo_manager to ttm_range_manager (new)
rename ttm_mem_type_manager to ttm_resource_manager (new)
rename ttm_mem_reg to ttm_resource (new)

I've marked most things with v2 that have changed, again I'd really
like to land this in drm-misc sooner rather than later, so it would be
good to get driver acks from qxl, vmwgfx and nouveau. (all cc'ed).

I've also commented on the list on any outstanding comments from previous
review that I disagree with or need more discussion.

Dave.


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  7:56   ` daniel
  2020-08-04  2:55 ` [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions Dave Airlie
                   ` (59 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

These two functions has the same code in them, create a common
helper function instead.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |  4 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c        | 60 ++--------------------
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 32 ++++++++++++
 3 files changed, 39 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 3596f3923ea3..b7c763713b4c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1023,6 +1023,10 @@ extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
 extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
 extern const struct vmw_sg_table *
 vmw_bo_sg_table(struct ttm_buffer_object *bo);
+extern int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
+				      unsigned long bo_size,
+				      struct ttm_buffer_object **bo_p);
+
 extern void vmw_piter_start(struct vmw_piter *viter,
 			    const struct vmw_sg_table *vsgt,
 			    unsigned long p_offs);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
index e8eb42933ca2..7f95ed6aa224 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
@@ -238,10 +238,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
 	unsigned long offset;
 	unsigned long bo_size;
 	struct vmw_otable *otables = batch->otables;
-	struct ttm_operation_ctx ctx = {
-		.interruptible = false,
-		.no_wait_gpu = false
-	};
 	SVGAOTableType i;
 	int ret;
 
@@ -255,24 +251,9 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
 		bo_size += otables[i].size;
 	}
 
-	ret = ttm_bo_create(&dev_priv->bdev, bo_size,
-			    ttm_bo_type_device,
-			    &vmw_sys_ne_placement,
-			    0, false, &batch->otable_bo);
-
-	if (unlikely(ret != 0))
-		goto out_no_bo;
-
-	ret = ttm_bo_reserve(batch->otable_bo, false, true, NULL);
-	BUG_ON(ret != 0);
-	ret = vmw_bo_driver.ttm_tt_populate(batch->otable_bo->ttm, &ctx);
-	if (unlikely(ret != 0))
-		goto out_unreserve;
-	ret = vmw_bo_map_dma(batch->otable_bo);
+	ret = vmw_bo_create_and_populate(dev_priv, bo_size, &batch->otable_bo);
 	if (unlikely(ret != 0))
-		goto out_unreserve;
-
-	ttm_bo_unreserve(batch->otable_bo);
+		return ret;
 
 	offset = 0;
 	for (i = 0; i < batch->num_otables; ++i) {
@@ -289,8 +270,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
 
 	return 0;
 
-out_unreserve:
-	ttm_bo_unreserve(batch->otable_bo);
 out_no_setup:
 	for (i = 0; i < batch->num_otables; ++i) {
 		if (batch->otables[i].enabled)
@@ -300,7 +279,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
 
 	ttm_bo_put(batch->otable_bo);
 	batch->otable_bo = NULL;
-out_no_bo:
 	return ret;
 }
 
@@ -432,41 +410,9 @@ struct vmw_mob *vmw_mob_create(unsigned long data_pages)
 static int vmw_mob_pt_populate(struct vmw_private *dev_priv,
 			       struct vmw_mob *mob)
 {
-	int ret;
-	struct ttm_operation_ctx ctx = {
-		.interruptible = false,
-		.no_wait_gpu = false
-	};
-
 	BUG_ON(mob->pt_bo != NULL);
 
-	ret = ttm_bo_create(&dev_priv->bdev, mob->num_pages * PAGE_SIZE,
-			    ttm_bo_type_device,
-			    &vmw_sys_ne_placement,
-			    0, false, &mob->pt_bo);
-	if (unlikely(ret != 0))
-		return ret;
-
-	ret = ttm_bo_reserve(mob->pt_bo, false, true, NULL);
-
-	BUG_ON(ret != 0);
-	ret = vmw_bo_driver.ttm_tt_populate(mob->pt_bo->ttm, &ctx);
-	if (unlikely(ret != 0))
-		goto out_unreserve;
-	ret = vmw_bo_map_dma(mob->pt_bo);
-	if (unlikely(ret != 0))
-		goto out_unreserve;
-
-	ttm_bo_unreserve(mob->pt_bo);
-
-	return 0;
-
-out_unreserve:
-	ttm_bo_unreserve(mob->pt_bo);
-	ttm_bo_put(mob->pt_bo);
-	mob->pt_bo = NULL;
-
-	return ret;
+	return vmw_bo_create_and_populate(dev_priv, mob->num_pages * PAGE_SIZE, &mob->pt_bo);
 }
 
 /**
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 2deaaed334e6..8e2a82ded900 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -817,3 +817,35 @@ struct ttm_bo_driver vmw_bo_driver = {
 	.swap_notify = vmw_swap_notify,
 	.io_mem_reserve = &vmw_ttm_io_mem_reserve,
 };
+
+int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
+			       unsigned long bo_size,
+			       struct ttm_buffer_object **bo_p)
+{
+	struct ttm_operation_ctx ctx = {
+		.interruptible = false,
+		.no_wait_gpu = false
+	};
+	struct ttm_buffer_object *bo;
+	int ret;
+
+	ret = ttm_bo_create(&dev_priv->bdev, bo_size,
+			    ttm_bo_type_device,
+			    &vmw_sys_ne_placement,
+			    0, false, &bo);
+
+	if (unlikely(ret != 0))
+		return ret;
+
+	ret = ttm_bo_reserve(bo, false, true, NULL);
+	BUG_ON(ret != 0);
+	ret = vmw_bo_driver.ttm_tt_populate(bo->ttm, &ctx);
+	if (likely(ret == 0))
+		ret = vmw_bo_map_dma(bo);
+
+	ttm_bo_unreserve(bo);
+
+	if (likely(ret == 0))
+		*bo_p = bo;
+	return ret;
+}
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
  2020-08-04  2:55 ` [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  7:59   ` daniel
  2020-08-04  2:55 ` [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2) Dave Airlie
                   ` (58 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The map one was used once, just inline it, and drop them both.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |  2 -
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 46 +++-------------------
 2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index b7c763713b4c..65c414f119c0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1019,8 +1019,6 @@ extern struct ttm_placement vmw_mob_placement;
 extern struct ttm_placement vmw_mob_ne_placement;
 extern struct ttm_placement vmw_nonfixed_placement;
 extern struct ttm_bo_driver vmw_bo_driver;
-extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
-extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
 extern const struct vmw_sg_table *
 vmw_bo_sg_table(struct ttm_buffer_object *bo);
 extern int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 8e2a82ded900..3a141a08d4bd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -519,43 +519,6 @@ static void vmw_ttm_unmap_dma(struct vmw_ttm_tt *vmw_tt)
 	vmw_tt->mapped = false;
 }
 
-
-/**
- * vmw_bo_map_dma - Make sure buffer object pages are visible to the device
- *
- * @bo: Pointer to a struct ttm_buffer_object
- *
- * Wrapper around vmw_ttm_map_dma, that takes a TTM buffer object pointer
- * instead of a pointer to a struct vmw_ttm_backend as argument.
- * Note that the buffer object must be either pinned or reserved before
- * calling this function.
- */
-int vmw_bo_map_dma(struct ttm_buffer_object *bo)
-{
-	struct vmw_ttm_tt *vmw_tt =
-		container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
-
-	return vmw_ttm_map_dma(vmw_tt);
-}
-
-
-/**
- * vmw_bo_unmap_dma - Make sure buffer object pages are visible to the device
- *
- * @bo: Pointer to a struct ttm_buffer_object
- *
- * Wrapper around vmw_ttm_unmap_dma, that takes a TTM buffer object pointer
- * instead of a pointer to a struct vmw_ttm_backend as argument.
- */
-void vmw_bo_unmap_dma(struct ttm_buffer_object *bo)
-{
-	struct vmw_ttm_tt *vmw_tt =
-		container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
-
-	vmw_ttm_unmap_dma(vmw_tt);
-}
-
-
 /**
  * vmw_bo_sg_table - Return a struct vmw_sg_table object for a
  * TTM buffer object
@@ -839,9 +802,12 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
 
 	ret = ttm_bo_reserve(bo, false, true, NULL);
 	BUG_ON(ret != 0);
-	ret = vmw_bo_driver.ttm_tt_populate(bo->ttm, &ctx);
-	if (likely(ret == 0))
-		ret = vmw_bo_map_dma(bo);
+	ret = vmw_ttm_populate(bo->ttm, &ctx);
+	if (likely(ret == 0)) {
+		struct vmw_ttm_tt *vmw_tt =
+			container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
+		ret = vmw_ttm_map_dma(vmw_tt);
+	}
 
 	ttm_bo_unreserve(bo);
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
  2020-08-04  2:55 ` [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate Dave Airlie
  2020-08-04  2:55 ` [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:32   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function Dave Airlie
                   ` (57 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Instead of rolling driver copies of them.

v2: cleanup return handling (Ben)
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 38 ++--------------------------
 1 file changed, 2 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 356c1aae327d..aebec45b8416 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1171,8 +1171,6 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
 	struct ttm_dma_tt *ttm_dma = (void *)ttm;
 	struct nouveau_drm *drm;
 	struct device *dev;
-	unsigned i;
-	int r;
 	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
 	if (ttm->state != tt_unpopulated)
@@ -1200,31 +1198,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
 		return ttm_dma_populate((void *)ttm, dev, ctx);
 	}
 #endif
-
-	r = ttm_pool_populate(ttm, ctx);
-	if (r) {
-		return r;
-	}
-
-	for (i = 0; i < ttm->num_pages; i++) {
-		dma_addr_t addr;
-
-		addr = dma_map_page(dev, ttm->pages[i], 0, PAGE_SIZE,
-				    DMA_BIDIRECTIONAL);
-
-		if (dma_mapping_error(dev, addr)) {
-			while (i--) {
-				dma_unmap_page(dev, ttm_dma->dma_address[i],
-					       PAGE_SIZE, DMA_BIDIRECTIONAL);
-				ttm_dma->dma_address[i] = 0;
-			}
-			ttm_pool_unpopulate(ttm);
-			return -EFAULT;
-		}
-
-		ttm_dma->dma_address[i] = addr;
-	}
-	return 0;
+	return ttm_populate_and_map_pages(dev, ttm_dma, ctx);
 }
 
 static void
@@ -1233,7 +1207,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
 	struct ttm_dma_tt *ttm_dma = (void *)ttm;
 	struct nouveau_drm *drm;
 	struct device *dev;
-	unsigned i;
 	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
 	if (slave)
@@ -1256,14 +1229,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
 	}
 #endif
 
-	for (i = 0; i < ttm->num_pages; i++) {
-		if (ttm_dma->dma_address[i]) {
-			dma_unmap_page(dev, ttm_dma->dma_address[i], PAGE_SIZE,
-				       DMA_BIDIRECTIONAL);
-		}
-	}
-
-	ttm_pool_unpopulate(ttm);
+	ttm_unmap_and_unpopulate_pages(dev, ttm_dma);
 }
 
 void
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (2 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:46   ` Gerd Hoffmann
  2020-08-04  2:55 ` [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths Dave Airlie
                   ` (56 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_cmd.c    | 2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c  | 2 +-
 drivers/gpu/drm/qxl/qxl_object.c | 4 ++--
 drivers/gpu/drm/qxl/qxl_object.h | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 798f9dd7ad75..54e3c3a97440 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -588,7 +588,7 @@ static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stal
 {
 	int ret;
 
-	ret = qxl_bo_reserve(surf, false);
+	ret = qxl_bo_reserve(surf);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 8f605d5cc149..5cea6eea72ab 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -322,7 +322,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 
 	qobj = gem_to_qxl_bo(gobj);
 
-	ret = qxl_bo_reserve(qobj, false);
+	ret = qxl_bo_reserve(qobj);
 	if (ret)
 		goto out;
 
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 80e7a17aaddd..f838b6d689aa 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -284,7 +284,7 @@ int qxl_bo_pin(struct qxl_bo *bo)
 {
 	int r;
 
-	r = qxl_bo_reserve(bo, false);
+	r = qxl_bo_reserve(bo);
 	if (r)
 		return r;
 
@@ -302,7 +302,7 @@ int qxl_bo_unpin(struct qxl_bo *bo)
 {
 	int r;
 
-	r = qxl_bo_reserve(bo, false);
+	r = qxl_bo_reserve(bo);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/qxl/qxl_object.h b/drivers/gpu/drm/qxl/qxl_object.h
index 21fa81048f4f..6b434e5ef795 100644
--- a/drivers/gpu/drm/qxl/qxl_object.h
+++ b/drivers/gpu/drm/qxl/qxl_object.h
@@ -27,11 +27,11 @@
 
 #include "qxl_drv.h"
 
-static inline int qxl_bo_reserve(struct qxl_bo *bo, bool no_wait)
+static inline int qxl_bo_reserve(struct qxl_bo *bo)
 {
 	int r;
 
-	r = ttm_bo_reserve(&bo->tbo, true, no_wait, NULL);
+	r = ttm_bo_reserve(&bo->tbo, true, false, NULL);
 	if (unlikely(r != 0)) {
 		if (r != -ERESTARTSYS) {
 			struct drm_device *ddev = bo->tbo.base.dev;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (3 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:33   ` Christian König
  2020-08-04  2:55 ` [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail Dave Airlie
                   ` (55 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Drop the WARN_ON and consolidate the two paths into one.

Use the consolidate slowpath in the execbuf utils code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 +-
 drivers/gpu/drm/ttm/ttm_execbuf_util.c     | 12 +--
 include/drm/ttm/ttm_bo_driver.h            | 91 ++++------------------
 3 files changed, 20 insertions(+), 85 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index afa5189dba7d..e01e8903741e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -160,7 +160,7 @@ static inline int amdgpu_bo_reserve(struct amdgpu_bo *bo, bool no_intr)
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 	int r;
 
-	r = __ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
+	r = ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
 	if (unlikely(r != 0)) {
 		if (r != -ERESTARTSYS)
 			dev_err(adev->dev, "%p reserve failed\n", bo);
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
index 1797f04c0534..8a8f1a6a83a6 100644
--- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
+++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
@@ -93,7 +93,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
 	list_for_each_entry(entry, list, head) {
 		struct ttm_buffer_object *bo = entry->bo;
 
-		ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
+		ret = ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
 		if (ret == -EALREADY && dups) {
 			struct ttm_validate_buffer *safe = entry;
 			entry = list_prev_entry(entry, head);
@@ -119,13 +119,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
 		ttm_eu_backoff_reservation_reverse(list, entry);
 
 		if (ret == -EDEADLK) {
-			if (intr) {
-				ret = dma_resv_lock_slow_interruptible(bo->base.resv,
-										 ticket);
-			} else {
-				dma_resv_lock_slow(bo->base.resv, ticket);
-				ret = 0;
-			}
+			ret = ttm_bo_reserve_slowpath(bo, intr, ticket);
 		}
 
 		if (!ret && entry->num_shared)
@@ -133,8 +127,6 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
 								entry->num_shared);
 
 		if (unlikely(ret != 0)) {
-			if (ret == -EINTR)
-				ret = -ERESTARTSYS;
 			if (ticket) {
 				ww_acquire_done(ticket);
 				ww_acquire_fini(ticket);
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 09211ecbf84f..c20fef4da1d3 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -588,29 +588,30 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible);
 void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
 
 /**
- * __ttm_bo_reserve:
+ * ttm_bo_reserve:
  *
  * @bo: A pointer to a struct ttm_buffer_object.
  * @interruptible: Sleep interruptible if waiting.
  * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY.
  * @ticket: ticket used to acquire the ww_mutex.
  *
- * Will not remove reserved buffers from the lru lists.
- * Otherwise identical to ttm_bo_reserve.
+ * Locks a buffer object for validation. (Or prevents other processes from
+ * locking it for validation), while taking a number of measures to prevent
+ * deadlocks.
  *
  * Returns:
  * -EDEADLK: The reservation may cause a deadlock.
  * Release all buffer reservations, wait for @bo to become unreserved and
- * try again. (only if use_sequence == 1).
+ * try again.
  * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
  * a signal. Release all buffer reservations and return to user-space.
  * -EBUSY: The function needed to sleep, but @no_wait was true
  * -EALREADY: Bo already reserved using @ticket. This error code will only
  * be returned if @use_ticket is set to true.
  */
-static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
-				   bool interruptible, bool no_wait,
-				   struct ww_acquire_ctx *ticket)
+static inline int ttm_bo_reserve(struct ttm_buffer_object *bo,
+				 bool interruptible, bool no_wait,
+				 struct ww_acquire_ctx *ticket)
 {
 	int ret = 0;
 
@@ -632,59 +633,6 @@ static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
 	return ret;
 }
 
-/**
- * ttm_bo_reserve:
- *
- * @bo: A pointer to a struct ttm_buffer_object.
- * @interruptible: Sleep interruptible if waiting.
- * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY.
- * @ticket: ticket used to acquire the ww_mutex.
- *
- * Locks a buffer object for validation. (Or prevents other processes from
- * locking it for validation) and removes it from lru lists, while taking
- * a number of measures to prevent deadlocks.
- *
- * Deadlocks may occur when two processes try to reserve multiple buffers in
- * different order, either by will or as a result of a buffer being evicted
- * to make room for a buffer already reserved. (Buffers are reserved before
- * they are evicted). The following algorithm prevents such deadlocks from
- * occurring:
- * Processes attempting to reserve multiple buffers other than for eviction,
- * (typically execbuf), should first obtain a unique 32-bit
- * validation sequence number,
- * and call this function with @use_ticket == 1 and @ticket->stamp == the unique
- * sequence number. If upon call of this function, the buffer object is already
- * reserved, the validation sequence is checked against the validation
- * sequence of the process currently reserving the buffer,
- * and if the current validation sequence is greater than that of the process
- * holding the reservation, the function returns -EDEADLK. Otherwise it sleeps
- * waiting for the buffer to become unreserved, after which it retries
- * reserving.
- * The caller should, when receiving an -EDEADLK error
- * release all its buffer reservations, wait for @bo to become unreserved, and
- * then rerun the validation with the same validation sequence. This procedure
- * will always guarantee that the process with the lowest validation sequence
- * will eventually succeed, preventing both deadlocks and starvation.
- *
- * Returns:
- * -EDEADLK: The reservation may cause a deadlock.
- * Release all buffer reservations, wait for @bo to become unreserved and
- * try again. (only if use_sequence == 1).
- * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
- * a signal. Release all buffer reservations and return to user-space.
- * -EBUSY: The function needed to sleep, but @no_wait was true
- * -EALREADY: Bo already reserved using @ticket. This error code will only
- * be returned if @use_ticket is set to true.
- */
-static inline int ttm_bo_reserve(struct ttm_buffer_object *bo,
-				 bool interruptible, bool no_wait,
-				 struct ww_acquire_ctx *ticket)
-{
-	WARN_ON(!kref_read(&bo->kref));
-
-	return __ttm_bo_reserve(bo, interruptible, no_wait, ticket);
-}
-
 /**
  * ttm_bo_reserve_slowpath:
  * @bo: A pointer to a struct ttm_buffer_object.
@@ -699,20 +647,15 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
 					  bool interruptible,
 					  struct ww_acquire_ctx *ticket)
 {
-	int ret = 0;
-
-	WARN_ON(!kref_read(&bo->kref));
-
-	if (interruptible)
-		ret = dma_resv_lock_slow_interruptible(bo->base.resv,
-								 ticket);
-	else
-		dma_resv_lock_slow(bo->base.resv, ticket);
-
-	if (ret == -EINTR)
-		ret = -ERESTARTSYS;
-
-	return ret;
+	if (interruptible) {
+		int ret = dma_resv_lock_slow_interruptible(bo->base.resv,
+							   ticket);
+		if (ret == -EINTR)
+			ret = -ERESTARTSYS;
+		return ret;
+	}
+	dma_resv_lock_slow(bo->base.resv, ticket);
+	return 0;
 }
 
 /**
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (4 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:34   ` Christian König
  2020-08-04  2:55 ` [PATCH 07/59] drm/vram-helper: remove populate/unpopulate Dave Airlie
                   ` (54 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The pattern was repeated a few times, just make an inline for it.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    |  8 ++------
 drivers/gpu/drm/ttm/ttm_bo_vm.c |  4 +---
 include/drm/ttm/ttm_bo_driver.h | 11 ++++++++---
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 721ff546bf47..2b49037231eb 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1103,9 +1103,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 
 error:
 	if (bo->mem.mem_type == TTM_PL_SYSTEM && !list_empty(&bo->lru)) {
-		spin_lock(&ttm_bo_glob.lru_lock);
-		ttm_bo_move_to_lru_tail(bo, NULL);
-		spin_unlock(&ttm_bo_glob.lru_lock);
+		ttm_bo_move_to_lru_tail_unlocked(bo);
 	}
 
 	return ret;
@@ -1320,9 +1318,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
 		return ret;
 	}
 
-	spin_lock(&ttm_bo_glob.lru_lock);
-	ttm_bo_move_to_lru_tail(bo, NULL);
-	spin_unlock(&ttm_bo_glob.lru_lock);
+	ttm_bo_move_to_lru_tail_unlocked(bo);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index d7a6537dd6ee..468a0eb9e632 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -308,9 +308,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 		}
 
 		if (bo->moving != moving) {
-			spin_lock(&ttm_bo_glob.lru_lock);
-			ttm_bo_move_to_lru_tail(bo, NULL);
-			spin_unlock(&ttm_bo_glob.lru_lock);
+			ttm_bo_move_to_lru_tail_unlocked(bo);
 		}
 		dma_fence_put(moving);
 	}
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index c20fef4da1d3..7958e411269a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -658,6 +658,13 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
 	return 0;
 }
 
+static inline void ttm_bo_move_to_lru_tail_unlocked(struct ttm_buffer_object *bo)
+{
+	spin_lock(&ttm_bo_glob.lru_lock);
+	ttm_bo_move_to_lru_tail(bo, NULL);
+	spin_unlock(&ttm_bo_glob.lru_lock);
+}
+
 /**
  * ttm_bo_unreserve
  *
@@ -667,9 +674,7 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
  */
 static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
 {
-	spin_lock(&ttm_bo_glob.lru_lock);
-	ttm_bo_move_to_lru_tail(bo, NULL);
-	spin_unlock(&ttm_bo_glob.lru_lock);
+	ttm_bo_move_to_lru_tail_unlocked(bo);
 	dma_resv_unlock(bo->base.resv);
 }
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 07/59] drm/vram-helper: remove populate/unpopulate
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (5 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04  6:54   ` Thomas Zimmermann
  2020-08-04  2:55 ` [PATCH 08/59] drm/ttm: export memory type debug entrypoint Dave Airlie
                   ` (53 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The default path for populate/unpopulate is already this.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 5f03c6137ef9..a93a00966f3a 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1061,8 +1061,6 @@ static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
 
 static struct ttm_bo_driver bo_driver = {
 	.ttm_tt_create = bo_driver_ttm_tt_create,
-	.ttm_tt_populate = ttm_pool_populate,
-	.ttm_tt_unpopulate = ttm_pool_unpopulate,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = bo_driver_evict_flags,
 	.move_notify = bo_driver_move_notify,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 08/59] drm/ttm: export memory type debug entrypoint.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (6 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 07/59] drm/vram-helper: remove populate/unpopulate Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:35   ` Christian König
  2020-08-04  2:55 ` [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback Dave Airlie
                   ` (52 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

As suggested on review, just export the memory type debug for
drivers to use, while also making the debug callback optional
(don't need to test for system as it won't init it).

rename it to be more consistent with object name for now.
(we may rename all the objects later.)

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 13 +++++++------
 include/drm/ttm/ttm_bo_driver.h |  8 ++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2b49037231eb..2ac70ec1f37d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -77,26 +77,26 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
 	return 0;
 }
 
-static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p,
-			       int mem_type)
+void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
+				struct drm_printer *p)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
-
 	drm_printf(p, "    has_type: %d\n", man->has_type);
 	drm_printf(p, "    use_type: %d\n", man->use_type);
 	drm_printf(p, "    use_tt: %d\n", man->use_tt);
 	drm_printf(p, "    size: %llu\n", man->size);
 	drm_printf(p, "    available_caching: 0x%08X\n", man->available_caching);
 	drm_printf(p, "    default_caching: 0x%08X\n", man->default_caching);
-	if (mem_type != TTM_PL_SYSTEM)
+	if (man->func && man->func->debug)
 		(*man->func->debug)(man, p);
 }
+EXPORT_SYMBOL(ttm_mem_type_manager_debug);
 
 static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
 					struct ttm_placement *placement)
 {
 	struct drm_printer p = drm_debug_printer(TTM_PFX);
 	int i, ret, mem_type;
+	struct ttm_mem_type_manager *man;
 
 	drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
 		   bo, bo->mem.num_pages, bo->mem.size >> 10,
@@ -108,7 +108,8 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
 			return;
 		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
 			   i, placement->placement[i].flags, mem_type);
-		ttm_mem_type_debug(bo->bdev, &p, mem_type);
+		man = &bo->bdev->man[mem_type];
+		ttm_mem_type_manager_debug(man, &p);
 	}
 }
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 7958e411269a..73f5d9c766cc 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -795,4 +795,12 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
 
 extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
 
+/**
+ * ttm_mem_type_manager_debug
+ *
+ * @man: manager type to dump.
+ * @p: printer to use for debug.
+ */
+void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
+				struct drm_printer *p);
 #endif
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (7 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 08/59] drm/ttm: export memory type debug entrypoint Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:34   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 10/59] drm/vmwgfx/gmrid: don't provide pointless " Dave Airlie
                   ` (51 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index b0012021ae12..6de762a0c229 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -49,12 +49,6 @@ nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
 	nouveau_mem_del(reg);
 }
 
-static void
-nouveau_manager_debug(struct ttm_mem_type_manager *man,
-		      struct drm_printer *printer)
-{
-}
-
 static int
 nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 			 struct ttm_buffer_object *bo,
@@ -86,7 +80,6 @@ const struct ttm_mem_type_manager_func nouveau_vram_manager = {
 	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_vram_manager_new,
 	.put_node = nouveau_manager_del,
-	.debug = nouveau_manager_debug,
 };
 
 static int
@@ -112,7 +105,6 @@ const struct ttm_mem_type_manager_func nouveau_gart_manager = {
 	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_gart_manager_new,
 	.put_node = nouveau_manager_del,
-	.debug = nouveau_manager_debug
 };
 
 static int
@@ -147,7 +139,6 @@ const struct ttm_mem_type_manager_func nv04_gart_manager = {
 	.takedown = nouveau_manager_fini,
 	.get_node = nv04_gart_manager_new,
 	.put_node = nouveau_manager_del,
-	.debug = nouveau_manager_debug
 };
 
 int
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 10/59] drm/vmwgfx/gmrid: don't provide pointless ttm debug callback
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (8 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04  2:55 ` [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2) Dave Airlie
                   ` (50 subsequent siblings)
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index 4a76fc7114ad..fb1bf4dd91d1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -137,16 +137,9 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man)
 	return 0;
 }
 
-static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
-				struct drm_printer *printer)
-{
-	drm_printf(printer, "No debug info available for the GMR id manager\n");
-}
-
 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
 	.init = vmw_gmrid_man_init,
 	.takedown = vmw_gmrid_man_takedown,
 	.get_node = vmw_gmrid_man_get_node,
 	.put_node = vmw_gmrid_man_put_node,
-	.debug = vmw_gmrid_man_debug
 };
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (9 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 10/59] drm/vmwgfx/gmrid: don't provide pointless " Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:48   ` Gerd Hoffmann
  2020-08-04  2:55 ` [PATCH 12/59] drm/vram-helper: call the ttm manager debug function Dave Airlie
                   ` (49 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

v2: use the new exported interface.
This code was poking inside a struct and assuming it was a drm_mm
at the start. Call the proper API.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 759c9d601072..3e664bb58764 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -279,12 +279,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)
 static int qxl_mm_dump_table(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	struct drm_mm *mm = (struct drm_mm *)node->info_ent->data;
+	struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data;
 	struct drm_printer p = drm_seq_file_printer(m);
 
-	spin_lock(&ttm_bo_glob.lru_lock);
-	drm_mm_print(mm, &p);
-	spin_unlock(&ttm_bo_glob.lru_lock);
+	ttm_mem_type_manager_debug(man, &p);
 	return 0;
 }
 #endif
@@ -305,9 +303,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev)
 		qxl_mem_types_list[i].show = &qxl_mm_dump_table;
 		qxl_mem_types_list[i].driver_features = 0;
 		if (i == 0)
-			qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
+			qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM];
 		else
-			qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV].priv;
+			qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV];
 
 	}
 	qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 12/59] drm/vram-helper: call the ttm manager debug function
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (10 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04  6:55   ` Thomas Zimmermann
  2020-08-04 10:48   ` Gerd Hoffmann
  2020-08-04  2:55 ` [PATCH 13/59] drm/ttm: split the mm manager init code (v2) Dave Airlie
                   ` (48 subsequent siblings)
  60 siblings, 2 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This code was assuming there was a drm_mm here, don't do
that call the correct API.

v2: use the new exported interface.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index a93a00966f3a..c20aee2fddf3 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1075,12 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
-	struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM].priv;
+	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
 	struct drm_printer p = drm_seq_file_printer(m);
 
-	spin_lock(&ttm_bo_glob.lru_lock);
-	drm_mm_print(mm, &p);
-	spin_unlock(&ttm_bo_glob.lru_lock);
+	ttm_mem_type_manager_debug(man, &p);
 	return 0;
 }
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 13/59] drm/ttm: split the mm manager init code (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (11 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 12/59] drm/vram-helper: call the ttm manager debug function Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 11:07   ` Christian König
  2020-08-04 11:10   ` Christian König
  2020-08-04  2:55 ` [PATCH 14/59] drm/ttm: provide a driver-led init path for range mm manager. (v2) Dave Airlie
                   ` (47 subsequent siblings)
  60 siblings, 2 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This will allow the driver to control the ordering here better.

Eventually the old path will be removed.

v2: add docs for new APIs.
rename new path to ttm_mem_type_manager_init/set_used(for now)

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 34 +++++++++++++++++++--------------
 include/drm/ttm/ttm_bo_api.h    | 15 +++++++++++++++
 include/drm/ttm/ttm_bo_driver.h | 15 +++++++++++++++
 3 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2ac70ec1f37d..300bcc10696a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1509,35 +1509,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 }
 EXPORT_SYMBOL(ttm_bo_evict_mm);
 
-int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
-			unsigned long p_size)
+void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
+			       struct ttm_mem_type_manager *man,
+			       unsigned long p_size)
 {
-	int ret;
-	struct ttm_mem_type_manager *man;
 	unsigned i;
 
-	BUG_ON(type >= TTM_NUM_MEM_TYPES);
-	man = &bdev->man[type];
 	BUG_ON(man->has_type);
 	man->use_io_reserve_lru = false;
 	mutex_init(&man->io_reserve_mutex);
 	spin_lock_init(&man->move_lock);
 	INIT_LIST_HEAD(&man->io_reserve_lru);
 	man->bdev = bdev;
-
-	if (type != TTM_PL_SYSTEM) {
-		ret = (*man->func->init)(man, p_size);
-		if (ret)
-			return ret;
-	}
-	man->has_type = true;
-	man->use_type = true;
 	man->size = p_size;
 
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
 		INIT_LIST_HEAD(&man->lru[i]);
 	man->move = NULL;
+}
+EXPORT_SYMBOL(ttm_mem_type_manager_init);
 
+int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
+			unsigned long p_size)
+{
+	int ret;
+	struct ttm_mem_type_manager *man;
+
+	BUG_ON(type >= TTM_NUM_MEM_TYPES);
+	ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
+
+	if (type != TTM_PL_SYSTEM) {
+		ret = (*man->func->init)(man, p_size);
+		if (ret)
+			return ret;
+	}
+	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
 EXPORT_SYMBOL(ttm_bo_init_mm);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index a9e13b252820..89053e761a69 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -54,6 +54,8 @@ struct ttm_place;
 
 struct ttm_lru_bulk_move;
 
+struct ttm_mem_type_manager;
+
 /**
  * struct ttm_bus_placement
  *
@@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
 		  uint32_t page_alignment, bool interruptible,
 		  struct ttm_buffer_object **p_bo);
 
+/**
+ * ttm_mem_type_manager_init
+ *
+ * @bdev: Pointer to a ttm_bo_device struct.
+ * @man: memory manager object to init
+ * @p_size: size managed area in pages.
+ *
+ * Initialise core parts of a a manager object.
+ */
+void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
+			       struct ttm_mem_type_manager *man,
+			       unsigned long p_size);
+
 /**
  * ttm_bo_init_mm
  *
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 73f5d9c766cc..6b49c0356343 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -678,6 +678,21 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
 	dma_resv_unlock(bo->base.resv);
 }
 
+/**
+ * ttm_mem_type_manager_set_used
+ *
+ * @man: A memory manager object.
+ * @used: usage state to set.
+ *
+ * Set the manager in use flag. If disabled the manager is no longer
+ * used for object placement.
+ */
+static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
+{
+	man->has_type = true;
+	man->use_type = used;
+}
+
 /*
  * ttm_bo_util.c
  */
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 14/59] drm/ttm: provide a driver-led init path for range mm manager. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (12 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 13/59] drm/ttm: split the mm manager init code (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04  2:55 ` [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side Dave Airlie
                   ` (46 subsequent siblings)
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This lets the generic range mm manager be initialised by the driver.

v2: add docs.
rename api to range_man_init for now.

v1-Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++---
 include/drm/ttm/ttm_bo_driver.h      | 14 ++++++++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index facd3049c3aa..eb86c8694f47 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static int ttm_bo_man_init(struct ttm_mem_type_manager *man,
-			   unsigned long p_size)
+static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,
+				   unsigned long p_size)
 {
 	struct ttm_range_manager *rman;
 
@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,
 	return 0;
 }
 
+int ttm_range_man_init(struct ttm_bo_device *bdev,
+		       struct ttm_mem_type_manager *man,
+		       unsigned long p_size)
+{
+	int ret;
+
+	man->func = &ttm_bo_manager_func;
+
+	ttm_mem_type_manager_init(bdev, man, p_size);
+	ret = ttm_bo_man_init_private(man, p_size);
+	if (ret)
+		return ret;
+	ttm_mem_type_manager_set_used(man, true);
+	return 0;
+}
+EXPORT_SYMBOL(ttm_range_man_init);
+
 static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
 {
 	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
@@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
-	.init = ttm_bo_man_init,
+	.init = ttm_bo_man_init_private,
 	.takedown = ttm_bo_man_takedown,
 	.get_node = ttm_bo_man_get_node,
 	.put_node = ttm_bo_man_put_node,
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 6b49c0356343..3672dea3edca 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -808,6 +808,20 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);
  */
 pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
 
+/**
+ * ttm_range_man_init
+ *
+ * @bdev: ttm device
+ * @man: the manager to initialise with the range manager.
+ * @p_size: size of area to be managed in pages.
+ *
+ * Initialise a generic range manager for the selected memory type.
+ * The range manager is installed for this device in the type slot.
+ */
+int ttm_range_man_init(struct ttm_bo_device *bdev,
+		       struct ttm_mem_type_manager *man,
+		       unsigned long p_size);
+
 extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
 
 /**
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (13 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 14/59] drm/ttm: provide a driver-led init path for range mm manager. (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 11:15   ` Christian König
  2020-08-04  2:55 ` [PATCH 16/59] drm/radeon: use new ttm man init path Dave Airlie
                   ` (45 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Use new init calls to unwrap manager init

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 19 ++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c      | 37 +++-----------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h      |  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 19 ++++++----
 4 files changed, 33 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 77fae40197ab..9d05e1ab2048 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -76,6 +76,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
 static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
 	           amdgpu_mem_info_gtt_used_show, NULL);
 
+static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
 /**
  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
  *
@@ -84,14 +85,20 @@ static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
  *
  * Allocate and initialize the GTT manager.
  */
-static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
-			       unsigned long p_size)
+int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
 	struct amdgpu_gtt_mgr *mgr;
 	uint64_t start, size;
 	int ret;
 
+	man->use_tt = true;
+	man->func = &amdgpu_gtt_mgr_func;
+	man->available_caching = TTM_PL_MASK_CACHING;
+	man->default_caching = TTM_PL_FLAG_CACHED;
+
+	ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
+
 	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
 	if (!mgr)
 		return -ENOMEM;
@@ -100,7 +107,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
 	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
 	drm_mm_init(&mgr->mm, start, size);
 	spin_lock_init(&mgr->lock);
-	atomic64_set(&mgr->available, p_size);
+	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
 	man->priv = mgr;
 
 	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
@@ -114,6 +121,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
 		return ret;
 	}
 
+	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
 
@@ -298,8 +306,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
 		   amdgpu_gtt_mgr_usage(man) >> 20);
 }
 
-const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
-	.init = amdgpu_gtt_mgr_init,
+static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
 	.takedown = amdgpu_gtt_mgr_fini,
 	.get_node = amdgpu_gtt_mgr_new,
 	.put_node = amdgpu_gtt_mgr_del,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index d3e3cad4d0cb..4a09a625e748 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -63,43 +63,16 @@
 
 #define AMDGPU_TTM_VRAM_MAX_DW_READ	(size_t)128
 
-static int amdgpu_ttm_init_vram(struct amdgpu_device *adev)
-{
-
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
-
-	man->func = &amdgpu_vram_mgr_func;
-	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-	man->default_caching = TTM_PL_FLAG_WC;
-
-	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
-			      adev->gmc.real_vram_size >> PAGE_SHIFT);
-}
-
-static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size)
-{
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
-
-	man->use_tt = true;
-	man->func = &amdgpu_gtt_mgr_func;
-	man->available_caching = TTM_PL_MASK_CACHING;
-	man->default_caching = TTM_PL_FLAG_CACHED;
-
-	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT,
-			      gtt_size >> PAGE_SHIFT);
-}
-
 static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
-				   unsigned int type,
-				   uint64_t size)
+				    unsigned int type,
+				    uint64_t size)
 {
 	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
 
-	man->func = &ttm_bo_manager_func;
 	man->available_caching = TTM_PL_FLAG_UNCACHED;
 	man->default_caching = TTM_PL_FLAG_UNCACHED;
 
-	return ttm_bo_init_mm(&adev->mman.bdev, type, size);
+	return ttm_range_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT);
 }
 
 /**
@@ -1915,7 +1888,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	adev->mman.bdev.no_retry = true;
 
 	/* Initialize VRAM pool with all of VRAM divided into pages */
-	r = amdgpu_ttm_init_vram(adev);
+	r = amdgpu_vram_mgr_init(adev);
 	if (r) {
 		DRM_ERROR("Failed initializing VRAM heap.\n");
 		return r;
@@ -1982,7 +1955,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		gtt_size = (uint64_t)amdgpu_gtt_size << 20;
 
 	/* Initialize GTT memory pool */
-	r = amdgpu_ttm_init_gtt(adev, gtt_size);
+	r = amdgpu_gtt_mgr_init(adev, gtt_size);
 	if (r) {
 		DRM_ERROR("Failed initializing GTT heap.\n");
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 17c8d0d7bcc3..fb45c0a323b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -67,8 +67,8 @@ struct amdgpu_copy_mem {
 	unsigned long			offset;
 };
 
-extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
-extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
+int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size);
+int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
 
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
 uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 134cc36e30c5..bef3497de2ae 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -158,6 +158,8 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
 	NULL
 };
 
+static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
+
 /**
  * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
  *
@@ -166,18 +168,23 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
  *
  * Allocate and initialize the VRAM manager.
  */
-static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
-				unsigned long p_size)
+int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
 	struct amdgpu_vram_mgr *mgr;
 	int ret;
 
+	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
+	man->default_caching = TTM_PL_FLAG_WC;
+
+	ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
+
+	man->func = &amdgpu_vram_mgr_func;
 	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
 	if (!mgr)
 		return -ENOMEM;
 
-	drm_mm_init(&mgr->mm, 0, p_size);
+	drm_mm_init(&mgr->mm, 0, man->size);
 	spin_lock_init(&mgr->lock);
 	man->priv = mgr;
 
@@ -186,6 +193,7 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
 	if (ret)
 		DRM_ERROR("Failed to register sysfs\n");
 
+	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
 
@@ -587,8 +595,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
 		   amdgpu_vram_mgr_vis_usage(man) >> 20);
 }
 
-const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
-	.init		= amdgpu_vram_mgr_init,
+static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
 	.takedown	= amdgpu_vram_mgr_fini,
 	.get_node	= amdgpu_vram_mgr_new,
 	.put_node	= amdgpu_vram_mgr_del,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 16/59] drm/radeon: use new ttm man init path
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (14 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 11:15   ` Christian König
  2020-08-04  2:55 ` [PATCH 17/59] drm/qxl/ttm: use new init path for manager Dave Airlie
                   ` (44 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Use the new common manager init path.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 0b07d8ed6edd..84c02b4529c0 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -70,19 +70,17 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev)
 {
 	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM];
 
-	man->func = &ttm_bo_manager_func;
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
 
-	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
-			      rdev->mc.real_vram_size >> PAGE_SHIFT);
+	return ttm_range_man_init(&rdev->mman.bdev, man,
+				  rdev->mc.real_vram_size >> PAGE_SHIFT);
 }
 
 static int radeon_ttm_init_gtt(struct radeon_device *rdev)
 {
 	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT];
 
-	man->func = &ttm_bo_manager_func;
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 	man->use_tt = true;
@@ -98,8 +96,8 @@ static int radeon_ttm_init_gtt(struct radeon_device *rdev)
 	}
 #endif
 
-	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
-			      rdev->mc.gtt_size >> PAGE_SHIFT);
+	return ttm_range_man_init(&rdev->mman.bdev, man,
+				  rdev->mc.gtt_size >> PAGE_SHIFT);
 }
 
 static void radeon_evict_flags(struct ttm_buffer_object *bo,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 17/59] drm/qxl/ttm: use new init path for manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (15 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 16/59] drm/radeon: use new ttm man init path Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 10:49   ` Gerd Hoffmann
  2020-08-04  2:55 ` [PATCH 18/59] drm/vram_helper: use new ttm manager init function Dave Airlie
                   ` (43 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 3e664bb58764..bfbd2c5c38a2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -221,11 +221,10 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
 {
 	struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type];
 
-	man->func = &ttm_bo_manager_func;
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	return ttm_bo_init_mm(&qdev->mman.bdev, type, size);
+	return ttm_range_man_init(&qdev->mman.bdev, man, size);
 }
 
 int qxl_ttm_init(struct qxl_device *qdev)
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 18/59] drm/vram_helper: use new ttm manager init function
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (16 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 17/59] drm/qxl/ttm: use new init path for manager Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04  6:58   ` Thomas Zimmermann
  2020-08-04 10:49   ` Gerd Hoffmann
  2020-08-04  2:55 ` [PATCH 19/59] drm/nouveau: use new memory manager init paths Dave Airlie
                   ` (42 subsequent siblings)
  60 siblings, 2 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index c20aee2fddf3..d7c0fdf82eb6 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1116,10 +1116,9 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	man->func = &ttm_bo_manager_func;
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
-	ret = ttm_bo_init_mm(&vmm->bdev, TTM_PL_VRAM, vram_size >> PAGE_SHIFT);
+	ret = ttm_range_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT);
 	if (ret)
 		return ret;
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 19/59] drm/nouveau: use new memory manager init paths
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (17 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 18/59] drm/vram_helper: use new ttm manager init function Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:40   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths Dave Airlie
                   ` (41 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 43 ++++++++++++---------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 6de762a0c229..cfcbecd332ef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -31,12 +31,6 @@
 
 #include <core/tegra.h>
 
-static int
-nouveau_manager_init(struct ttm_mem_type_manager *man, unsigned long psize)
-{
-	return 0;
-}
-
 static int
 nouveau_manager_fini(struct ttm_mem_type_manager *man)
 {
@@ -76,7 +70,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
-	.init = nouveau_manager_init,
 	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_vram_manager_new,
 	.put_node = nouveau_manager_del,
@@ -101,7 +94,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
-	.init = nouveau_manager_init,
 	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_gart_manager_new,
 	.put_node = nouveau_manager_del,
@@ -135,7 +127,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nv04_gart_manager = {
-	.init = nouveau_manager_init,
 	.takedown = nouveau_manager_fini,
 	.get_node = nv04_gart_manager_new,
 	.put_node = nouveau_manager_del,
@@ -191,27 +182,21 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 
 		man->func = &nouveau_vram_manager;
 		man->use_io_reserve_lru = true;
+		ttm_mem_type_manager_init(&drm->ttm.bdev, man,
+					  drm->gem.vram_available >> PAGE_SHIFT);
+		ttm_mem_type_manager_set_used(man, true);
+		return 0;
 	} else {
-		man->func = &ttm_bo_manager_func;
+		return ttm_range_man_init(&drm->ttm.bdev, man,
+					  drm->gem.vram_available >> PAGE_SHIFT);
 	}
-
-	return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
-			      drm->gem.vram_available >> PAGE_SHIFT);
 }
 
 static int
 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 {
 	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
-
-	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
-		man->func = &nouveau_gart_manager;
-	else
-	if (!drm->agp.bridge)
-		man->func = &nv04_gart_manager;
-	else
-		man->func = &ttm_bo_manager_func;
-
+	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
 	man->use_tt = true;
 	if (drm->agp.bridge) {
 		man->available_caching = TTM_PL_FLAG_UNCACHED |
@@ -222,8 +207,18 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 		man->default_caching = TTM_PL_FLAG_CACHED;
 	}
 
-	return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_TT,
-			      drm->gem.gart_available >> PAGE_SHIFT);
+	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
+		man->func = &nouveau_gart_manager;
+	else if (!drm->agp.bridge)
+		man->func = &nv04_gart_manager;
+	else
+		return ttm_range_man_init(&drm->ttm.bdev, man,
+					  size_pages);
+
+	ttm_mem_type_manager_init(&drm->ttm.bdev, man,
+				  size_pages);
+	ttm_mem_type_manager_set_used(man, true);
+	return 0;
 }
 
 int
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (18 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 19/59] drm/nouveau: use new memory manager init paths Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  8:57   ` daniel
  2020-08-04  2:55 ` [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths Dave Airlie
                   ` (40 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Split out the vram thp init path vs the range manager init.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 +++++++++++++++++++------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  4 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 12 ++++++++----
 3 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 1e4c2c6119c3..5a889df2de03 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -620,6 +620,23 @@ static int vmw_dma_masks(struct vmw_private *dev_priv)
 	return ret;
 }
 
+static int vmw_vram_manager_init(struct vmw_private *dev_priv)
+{
+	int ret;
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	ret = vmw_thp_init(dev_priv);
+#else
+	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
+
+	man->available_caching = TTM_PL_FLAG_CACHED;
+	man->default_caching = TTM_PL_FLAG_CACHED;
+
+	ret = ttm_range_man_init(&dev_priv->bdev, man,
+				 dev_priv->vram_size >> PAGE_SHIFT);
+#endif
+	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
+	return ret;
+}
 static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 {
 	struct vmw_private *dev_priv;
@@ -866,16 +883,12 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 	 * Enable VRAM, but initially don't use it until SVGA is enabled and
 	 * unhidden.
 	 */
-	dev_priv->bdev.man[TTM_PL_VRAM].func = &vmw_thp_func;
-	dev_priv->bdev.man[TTM_PL_VRAM].available_caching = TTM_PL_FLAG_CACHED;
-	dev_priv->bdev.man[TTM_PL_VRAM].default_caching = TTM_PL_FLAG_CACHED;
-	ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM,
-			     (dev_priv->vram_size >> PAGE_SHIFT));
+
+	ret = vmw_vram_manager_init(dev_priv);
 	if (unlikely(ret != 0)) {
 		DRM_ERROR("Failed initializing memory manager for VRAM.\n");
 		goto out_no_vram;
 	}
-	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
 
 	/*
 	 * "Guest Memory Regions" is an aperture like feature with
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 65c414f119c0..10b681725a53 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1520,9 +1520,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
 
 /* Transparent hugepage support - vmwgfx_thp.c */
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-extern const struct ttm_mem_type_manager_func vmw_thp_func;
-#else
-#define vmw_thp_func ttm_bo_manager_func
+extern int vmw_thp_init(struct vmw_private *dev_priv);
 #endif
 
 /**
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index b7c816ba7166..0292c931c265 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -115,18 +115,23 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static int vmw_thp_init(struct ttm_mem_type_manager *man,
-			unsigned long p_size)
+int vmw_thp_init(struct vmw_private *dev_priv)
 {
+	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
 	struct vmw_thp_manager *rman;
+	man->available_caching = TTM_PL_FLAG_CACHED;
+	man->default_caching = TTM_PL_FLAG_CACHED;
 
+	ttm_mem_type_manager_init(&dev_priv->bdev, man,
+				  dev_priv->vram_size >> PAGE_SHIFT);
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
 	if (!rman)
 		return -ENOMEM;
 
-	drm_mm_init(&rman->mm, 0, p_size);
+	drm_mm_init(&rman->mm, 0, man->size);
 	spin_lock_init(&rman->lock);
 	man->priv = rman;
+	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
 
@@ -158,7 +163,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func vmw_thp_func = {
-	.init = vmw_thp_init,
 	.takedown = vmw_thp_takedown,
 	.get_node = vmw_thp_get_node,
 	.put_node = vmw_thp_put_node,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (19 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  9:00   ` daniel
  2020-08-04  2:55 ` [PATCH 22/59] drm/ttm: convert system manager init to new code Dave Airlie
                   ` (39 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 17 ++++-----------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 21 ++++++++++++-------
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 5a889df2de03..364d5f3ff9a8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -896,14 +896,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 	 *  slots as well as the bo size.
 	 */
 	dev_priv->has_gmr = true;
-	dev_priv->bdev.man[VMW_PL_GMR].func = &vmw_gmrid_manager_func;
-	dev_priv->bdev.man[VMW_PL_GMR].available_caching = TTM_PL_FLAG_CACHED;
-	dev_priv->bdev.man[VMW_PL_GMR].default_caching = TTM_PL_FLAG_CACHED;
 	/* TODO: This is most likely not correct */
-	dev_priv->bdev.man[VMW_PL_GMR].use_tt = true;
 	if (((dev_priv->capabilities & (SVGA_CAP_GMR | SVGA_CAP_GMR2)) == 0) ||
-	    refuse_dma || ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_GMR,
-					 VMW_PL_GMR) != 0) {
+	    refuse_dma ||
+	    vmw_gmrid_man_init(dev_priv, VMW_PL_GMR) != 0) {
 		DRM_INFO("No GMR memory available. "
 			 "Graphics memory resources are very limited.\n");
 		dev_priv->has_gmr = false;
@@ -911,13 +907,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 
 	if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS && !refuse_dma) {
 		dev_priv->has_mob = true;
-		dev_priv->bdev.man[VMW_PL_MOB].func = &vmw_gmrid_manager_func;
-		dev_priv->bdev.man[VMW_PL_MOB].available_caching = TTM_PL_FLAG_CACHED;
-		dev_priv->bdev.man[VMW_PL_MOB].default_caching = TTM_PL_FLAG_CACHED;
-		/* TODO: This is most likely not correct */
-		dev_priv->bdev.man[VMW_PL_MOB].use_tt = true;
-		if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB,
-				   VMW_PL_MOB) != 0) {
+
+		if (vmw_gmrid_man_init(dev_priv, VMW_PL_MOB) != 0) {
 			DRM_INFO("No MOB memory available. "
 				 "3D will be disabled.\n");
 			dev_priv->has_mob = false;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 10b681725a53..8f319dd6cdb4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1221,7 +1221,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
  * GMR Id manager
  */
 
-extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
+int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type);
 
 /**
  * Prime - vmwgfx_prime.c
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index fb1bf4dd91d1..141fb14e3583 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -94,22 +94,28 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static int vmw_gmrid_man_init(struct ttm_mem_type_manager *man,
-			      unsigned long p_size)
+static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
+
+int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 {
-	struct vmw_private *dev_priv =
-		container_of(man->bdev, struct vmw_private, bdev);
+	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
 	struct vmwgfx_gmrid_man *gman =
 		kzalloc(sizeof(*gman), GFP_KERNEL);
 
 	if (unlikely(!gman))
 		return -ENOMEM;
 
+	man->func = &vmw_gmrid_manager_func;
+	man->available_caching = TTM_PL_FLAG_CACHED;
+	man->default_caching = TTM_PL_FLAG_CACHED;
+	/* TODO: This is most likely not correct */
+	man->use_tt = true;
+	ttm_mem_type_manager_init(&dev_priv->bdev, man, 0);
 	spin_lock_init(&gman->lock);
 	gman->used_gmr_pages = 0;
 	ida_init(&gman->gmr_ida);
 
-	switch (p_size) {
+	switch (type) {
 	case VMW_PL_GMR:
 		gman->max_gmr_ids = dev_priv->max_gmr_ids;
 		gman->max_gmr_pages = dev_priv->max_gmr_pages;
@@ -122,6 +128,8 @@ static int vmw_gmrid_man_init(struct ttm_mem_type_manager *man,
 		BUG();
 	}
 	man->priv = (void *) gman;
+
+	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
 
@@ -137,8 +145,7 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man)
 	return 0;
 }
 
-const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
-	.init = vmw_gmrid_man_init,
+static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
 	.takedown = vmw_gmrid_man_takedown,
 	.get_node = vmw_gmrid_man_get_node,
 	.put_node = vmw_gmrid_man_put_node,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 22/59] drm/ttm: convert system manager init to new code.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (20 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:40   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 23/59] drm/ttm: purge old manager init path Dave Airlie
                   ` (38 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Remove the exit path, since this can't fail now.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 300bcc10696a..c56cbc6c0ba8 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1650,6 +1650,22 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 }
 EXPORT_SYMBOL(ttm_bo_device_release);
 
+static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
+{
+	struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM];
+
+	/*
+	 * Initialize the system memory buffer type.
+	 * Other types need to be driver / IOCTL initialized.
+	 */
+	man->use_tt = true;
+	man->available_caching = TTM_PL_MASK_CACHING;
+	man->default_caching = TTM_PL_FLAG_CACHED;
+
+	ttm_mem_type_manager_init(bdev, man, 0);
+	ttm_mem_type_manager_set_used(man, true);
+}
+
 int ttm_bo_device_init(struct ttm_bo_device *bdev,
 		       struct ttm_bo_driver *driver,
 		       struct address_space *mapping,
@@ -1670,16 +1686,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 
 	memset(bdev->man, 0, sizeof(bdev->man));
 
-	/*
-	 * Initialize the system memory buffer type.
-	 * Other types need to be driver / IOCTL initialized.
-	 */
-	bdev->man[TTM_PL_SYSTEM].use_tt = true;
-	bdev->man[TTM_PL_SYSTEM].available_caching = TTM_PL_MASK_CACHING;
-	bdev->man[TTM_PL_SYSTEM].default_caching = TTM_PL_FLAG_CACHED;
-	ret = ttm_bo_init_mm(bdev, TTM_PL_SYSTEM, 0);
-	if (unlikely(ret != 0))
-		goto out_no_sys;
+	ttm_bo_init_sysman(bdev);
 
 	bdev->vma_manager = vma_manager;
 	INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
@@ -1691,9 +1698,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 	mutex_unlock(&ttm_global_mutex);
 
 	return 0;
-out_no_sys:
-	ttm_bo_global_release();
-	return ret;
 }
 EXPORT_SYMBOL(ttm_bo_device_init);
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 23/59] drm/ttm: purge old manager init path.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (21 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 22/59] drm/ttm: convert system manager init to new code Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:41   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places Dave Airlie
                   ` (37 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c         | 19 ------------------
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 29 ++++++++++------------------
 include/drm/ttm/ttm_bo_api.h         | 18 -----------------
 include/drm/ttm/ttm_bo_driver.h      | 15 --------------
 4 files changed, 10 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c56cbc6c0ba8..da88ea6cb814 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1529,25 +1529,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_mem_type_manager_init);
 
-int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
-			unsigned long p_size)
-{
-	int ret;
-	struct ttm_mem_type_manager *man;
-
-	BUG_ON(type >= TTM_NUM_MEM_TYPES);
-	ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
-
-	if (type != TTM_PL_SYSTEM) {
-		ret = (*man->func->init)(man, p_size);
-		if (ret)
-			return ret;
-	}
-	ttm_mem_type_manager_set_used(man, true);
-	return 0;
-}
-EXPORT_SYMBOL(ttm_bo_init_mm);
-
 static void ttm_bo_global_kobj_release(struct kobject *kobj)
 {
 	struct ttm_bo_global *glob =
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index eb86c8694f47..b56c6961b278 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -104,11 +104,18 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,
-				   unsigned long p_size)
+static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
+
+int ttm_range_man_init(struct ttm_bo_device *bdev,
+		       struct ttm_mem_type_manager *man,
+		       unsigned long p_size)
 {
 	struct ttm_range_manager *rman;
 
+	man->func = &ttm_bo_manager_func;
+
+	ttm_mem_type_manager_init(bdev, man, p_size);
+
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
 	if (!rman)
 		return -ENOMEM;
@@ -116,21 +123,7 @@ static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,
 	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
 	man->priv = rman;
-	return 0;
-}
 
-int ttm_range_man_init(struct ttm_bo_device *bdev,
-		       struct ttm_mem_type_manager *man,
-		       unsigned long p_size)
-{
-	int ret;
-
-	man->func = &ttm_bo_manager_func;
-
-	ttm_mem_type_manager_init(bdev, man, p_size);
-	ret = ttm_bo_man_init_private(man, p_size);
-	if (ret)
-		return ret;
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -163,11 +156,9 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 	spin_unlock(&rman->lock);
 }
 
-const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
-	.init = ttm_bo_man_init_private,
+static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
 	.takedown = ttm_bo_man_takedown,
 	.get_node = ttm_bo_man_get_node,
 	.put_node = ttm_bo_man_put_node,
 	.debug = ttm_bo_man_debug
 };
-EXPORT_SYMBOL(ttm_bo_manager_func);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 89053e761a69..2c84622faa44 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -546,24 +546,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
 			       struct ttm_mem_type_manager *man,
 			       unsigned long p_size);
 
-/**
- * ttm_bo_init_mm
- *
- * @bdev: Pointer to a ttm_bo_device struct.
- * @mem_type: The memory type.
- * @p_size: size managed area in pages.
- *
- * Initialize a manager for a given memory type.
- * Note: if part of driver firstopen, it must be protected from a
- * potentially racing lastclose.
- * Returns:
- * -EINVAL: invalid size or memory type.
- * -ENOMEM: Not enough memory.
- * May also return driver-specified errors.
- */
-int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
-		   unsigned long p_size);
-
 /**
  * ttm_bo_clean_mm
  *
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 3672dea3edca..548c27294c64 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -48,19 +48,6 @@
 struct ttm_mem_type_manager;
 
 struct ttm_mem_type_manager_func {
-	/**
-	 * struct ttm_mem_type_manager member init
-	 *
-	 * @man: Pointer to a memory type manager.
-	 * @p_size: Implementation dependent, but typically the size of the
-	 * range to be managed in pages.
-	 *
-	 * Called to initialize a private range manager. The function is
-	 * expected to initialize the man::priv member.
-	 * Returns 0 on success, negative error code on failure.
-	 */
-	int  (*init)(struct ttm_mem_type_manager *man, unsigned long p_size);
-
 	/**
 	 * struct ttm_mem_type_manager member takedown
 	 *
@@ -822,8 +809,6 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       struct ttm_mem_type_manager *man,
 		       unsigned long p_size);
 
-extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
-
 /**
  * ttm_mem_type_manager_debug
  *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (22 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 23/59] drm/ttm: purge old manager init path Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-05  5:42   ` Ben Skeggs
  2020-08-04  2:55 ` [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2) Dave Airlie
                   ` (36 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This makes it easier to cleanup things

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index da88ea6cb814..af1b1c3f6ed2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -769,13 +769,12 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
 }
 
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
-			       uint32_t mem_type,
+			       struct ttm_mem_type_manager *man,
 			       const struct ttm_place *place,
 			       struct ttm_operation_ctx *ctx,
 			       struct ww_acquire_ctx *ticket)
 {
 	struct ttm_buffer_object *bo = NULL, *busy_bo = NULL;
-	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
 	bool locked = false;
 	unsigned i;
 	int ret;
@@ -924,7 +923,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 			break;
 		if (unlikely(ret != -ENOSPC))
 			return ret;
-		ret = ttm_mem_evict_first(bdev, mem->mem_type, place, ctx,
+		ret = ttm_mem_evict_first(bdev, man, place, ctx,
 					  ticket);
 		if (unlikely(ret != 0))
 			return ret;
@@ -1409,14 +1408,13 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
 EXPORT_SYMBOL(ttm_bo_create);
 
 static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
-				   unsigned mem_type)
+				   struct ttm_mem_type_manager *man)
 {
 	struct ttm_operation_ctx ctx = {
 		.interruptible = false,
 		.no_wait_gpu = false,
 		.flags = TTM_OPT_FLAG_FORCE_ALLOC
 	};
-	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
 	struct ttm_bo_global *glob = &ttm_bo_glob;
 	struct dma_fence *fence;
 	int ret;
@@ -1430,7 +1428,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		while (!list_empty(&man->lru[i])) {
 			spin_unlock(&glob->lru_lock);
-			ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx,
+			ret = ttm_mem_evict_first(bdev, man, NULL, &ctx,
 						  NULL);
 			if (ret)
 				return ret;
@@ -1475,7 +1473,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 
 	ret = 0;
 	if (mem_type > 0) {
-		ret = ttm_bo_force_list_clean(bdev, mem_type);
+		ret = ttm_bo_force_list_clean(bdev, man);
 		if (ret) {
 			pr_err("Cleanup eviction failed\n");
 			return ret;
@@ -1505,7 +1503,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return 0;
 	}
 
-	return ttm_bo_force_list_clean(bdev, mem_type);
+	return ttm_bo_force_list_clean(bdev, man);
 }
 EXPORT_SYMBOL(ttm_bo_evict_mm);
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (23 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 11:18   ` Christian König
  2020-08-04  2:55 ` [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2) Dave Airlie
                   ` (35 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The disable path is just temporary for now, it will be dropped once has_type
is gone in a later patch.

v2: add docs.
rename to ttm_mem_type_manager namespace

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
 include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index af1b1c3f6ed2..127a0b62bf98 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1468,8 +1468,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return ret;
 	}
 
-	man->use_type = false;
-	man->has_type = false;
+	ttm_mem_type_manager_disable(man);
 
 	ret = 0;
 	if (mem_type > 0) {
@@ -1482,8 +1481,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		ret = (*man->func->takedown)(man);
 	}
 
-	dma_fence_put(man->move);
-	man->move = NULL;
+	ttm_mem_type_manager_cleanup(man);
 
 	return ret;
 }
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 548c27294c64..41bfa514c29d 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -680,6 +680,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
 	man->use_type = used;
 }
 
+/**
+ * ttm_mem_type_manager_disable.
+ *
+ * @man: A memory manager object.
+ *
+ * Indicate the manager is not to be used and deregistered. (temporary during rework).
+ */
+static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
+{
+	man->has_type = false;
+	man->use_type = false;
+}
+
+/**
+ * ttm_mem_type_manager_cleanup
+ *
+ * @man: A memory manager object.
+ *
+ * Cleanup the move fences from the memory manager object.
+ */
+static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
+{
+	dma_fence_put(man->move);
+	man->move = NULL;
+}
+
 /*
  * ttm_bo_util.c
  */
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (24 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2) Dave Airlie
@ 2020-08-04  2:55 ` Dave Airlie
  2020-08-04 11:20   ` Christian König
  2020-08-04  2:56 ` [PATCH 27/59] drm/amdgpu/ttm: use new takedown path Dave Airlie
                   ` (34 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:55 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Allow the takedown path callback to be optional as well.

v2: use fini for range manager
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c         | 12 +++++++-----
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++--
 include/drm/ttm/ttm_bo_driver.h      | 24 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 127a0b62bf98..a45038c74de6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1407,8 +1407,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_create);
 
-static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
-				   struct ttm_mem_type_manager *man)
+int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
+					  struct ttm_mem_type_manager *man)
 {
 	struct ttm_operation_ctx ctx = {
 		.interruptible = false,
@@ -1450,6 +1450,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
 
 	return 0;
 }
+EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
 
 int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 {
@@ -1472,13 +1473,14 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 
 	ret = 0;
 	if (mem_type > 0) {
-		ret = ttm_bo_force_list_clean(bdev, man);
+		ret = ttm_mem_type_manager_force_list_clean(bdev, man);
 		if (ret) {
 			pr_err("Cleanup eviction failed\n");
 			return ret;
 		}
 
-		ret = (*man->func->takedown)(man);
+		if (man->func->takedown)
+			ret = (*man->func->takedown)(man);
 	}
 
 	ttm_mem_type_manager_cleanup(man);
@@ -1501,7 +1503,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return 0;
 	}
 
-	return ttm_bo_force_list_clean(bdev, man);
+	return ttm_mem_type_manager_force_list_clean(bdev, man);
 }
 EXPORT_SYMBOL(ttm_bo_evict_mm);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index b56c6961b278..96da22be672b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -129,7 +129,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_range_man_init);
 
-static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
+static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
 {
 	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
 	struct drm_mm *mm = &rman->mm;
@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
 	return -EBUSY;
 }
 
+int ttm_range_man_fini(struct ttm_bo_device *bdev,
+		       struct ttm_mem_type_manager *man)
+{
+	int ret;
+
+	ttm_mem_type_manager_disable(man);
+
+	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
+	if (ret)
+		return ret;
+
+	ttm_bo_man_takedown_private(man);
+	ttm_mem_type_manager_cleanup(man);
+	return 0;
+}
+EXPORT_SYMBOL(ttm_range_man_fini);
+
 static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 			     struct drm_printer *printer)
 {
@@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 }
 
 static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
-	.takedown = ttm_bo_man_takedown,
+	.takedown = ttm_bo_man_takedown_private,
 	.get_node = ttm_bo_man_get_node,
 	.put_node = ttm_bo_man_put_node,
 	.debug = ttm_bo_man_debug
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 41bfa514c29d..9b4c22abc22c 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -706,6 +706,18 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
 	man->move = NULL;
 }
 
+/*
+ * ttm_mem_type_manager_force_list_clean
+ *
+ * @bdev - device to use
+ * @man - manager to use
+ *
+ * Force all the objects out of a memory manager until clean.
+ * Part of memory manager cleanup sequence.
+ */
+int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
+					  struct ttm_mem_type_manager *man);
+
 /*
  * ttm_bo_util.c
  */
@@ -835,6 +847,17 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       struct ttm_mem_type_manager *man,
 		       unsigned long p_size);
 
+/**
+ * ttm_range_man_fini
+ *
+ * @bdev: ttm device
+ * @type: memory manager type
+ *
+ * Remove the generic range manager from a slot and tear it down.
+ */
+int ttm_range_man_fini(struct ttm_bo_device *bdev,
+		       struct ttm_mem_type_manager *man);
+
 /**
  * ttm_mem_type_manager_debug
  *
@@ -843,4 +866,5 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
  */
 void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
 				struct drm_printer *p);
+
 #endif
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 27/59] drm/amdgpu/ttm: use new takedown path
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (25 preceding siblings ...)
  2020-08-04  2:55 ` [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2) Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04  2:56 ` [PATCH 28/59] drm/vmwgfx: takedown vram manager Dave Airlie
                   ` (33 subsequent siblings)
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 15 +++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c      | 10 +++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 15 +++++++++++----
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9d05e1ab2048..28056d12b199 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -133,10 +133,18 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
  * Destroy and free the GTT manager, returns -EBUSY if ranges are still
  * allocated inside it.
  */
-static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)
+void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
 	struct amdgpu_gtt_mgr *mgr = man->priv;
+	int ret;
+
+	ttm_mem_type_manager_disable(man);
+
+	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
+	if (ret)
+		return;
+
 	spin_lock(&mgr->lock);
 	drm_mm_takedown(&mgr->mm);
 	spin_unlock(&mgr->lock);
@@ -146,7 +154,7 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
 
-	return 0;
+	ttm_mem_type_manager_cleanup(man);
 }
 
 /**
@@ -307,7 +315,6 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
 }
 
 static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
-	.takedown = amdgpu_gtt_mgr_fini,
 	.get_node = amdgpu_gtt_mgr_new,
 	.put_node = amdgpu_gtt_mgr_del,
 	.debug = amdgpu_gtt_mgr_debug
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 4a09a625e748..d7516144bb0a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2012,11 +2012,11 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 		iounmap(adev->mman.aper_base_kaddr);
 	adev->mman.aper_base_kaddr = NULL;
 
-	ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);
-	ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);
-	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
-	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
-	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
+	amdgpu_vram_mgr_fini(adev);
+	amdgpu_gtt_mgr_fini(adev);
+	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS]);
+	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS]);
+	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA]);
 	ttm_bo_device_release(&adev->mman.bdev);
 	adev->mman.initialized = false;
 	DRM_INFO("amdgpu: ttm finalized\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index fb45c0a323b0..c01fdb3f0458 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -68,7 +68,9 @@ struct amdgpu_copy_mem {
 };
 
 int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size);
+void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev);
 int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
+void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
 uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index bef3497de2ae..c3bc9ddd437e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -205,10 +205,17 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
  * Destroy and free the VRAM manager, returns -EBUSY if ranges are still
  * allocated inside it.
  */
-static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
+void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
 	struct amdgpu_vram_mgr *mgr = man->priv;
+	int ret;
+
+	ttm_mem_type_manager_disable(man);
+
+	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
+	if (ret)
+		return;
 
 	spin_lock(&mgr->lock);
 	drm_mm_takedown(&mgr->mm);
@@ -216,7 +223,8 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
 	kfree(mgr);
 	man->priv = NULL;
 	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
-	return 0;
+
+	ttm_mem_type_manager_cleanup(man);
 }
 
 /**
@@ -596,7 +604,6 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
 }
 
 static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
-	.takedown	= amdgpu_vram_mgr_fini,
 	.get_node	= amdgpu_vram_mgr_new,
 	.put_node	= amdgpu_vram_mgr_del,
 	.debug		= amdgpu_vram_mgr_debug
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 28/59] drm/vmwgfx: takedown vram manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (26 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 27/59] drm/amdgpu/ttm: use new takedown path Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  9:19   ` daniel
  2020-08-04  2:56 ` [PATCH 29/59] drm/vram_helper: call explicit mm takedown Dave Airlie
                   ` (32 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Don't bother returning EBUSY, nobody cares enough,
if the driver has a problem, it should deal with it.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++++++++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 23 +++++++++++++----------
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 364d5f3ff9a8..4f4d22bac477 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -637,6 +637,17 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
 	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
 	return ret;
 }
+
+static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
+{
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	vmw_thp_fini(dev_priv);
+#else
+	ttm_bo_man_fini(&dev_priv->bdev,
+			    &dev_priv->bdev.man[TTM_PL_VRAM]);
+#endif
+}
+
 static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 {
 	struct vmw_private *dev_priv;
@@ -988,7 +999,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
 	if (dev_priv->has_gmr)
 		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
-	(void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
+	vmw_vram_manager_fini(dev_priv);
 out_no_vram:
 	(void)ttm_bo_device_release(&dev_priv->bdev);
 out_no_bdev:
@@ -1042,6 +1053,7 @@ static void vmw_driver_unload(struct drm_device *dev)
 	vmw_release_device_early(dev_priv);
 	if (dev_priv->has_mob)
 		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
+	vmw_vram_manager_fini(dev_priv);
 	(void) ttm_bo_device_release(&dev_priv->bdev);
 	drm_vma_offset_manager_destroy(&dev_priv->vma_manager);
 	vmw_release_device_late(dev_priv);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 8f319dd6cdb4..c6530d7b6d51 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1521,6 +1521,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
 /* Transparent hugepage support - vmwgfx_thp.c */
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern int vmw_thp_init(struct vmw_private *dev_priv);
+void vmw_thp_fini(struct vmw_private *dev_priv);
 #endif
 
 /**
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 0292c931c265..548f152b9963 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -135,21 +135,25 @@ int vmw_thp_init(struct vmw_private *dev_priv)
 	return 0;
 }
 
-static int vmw_thp_takedown(struct ttm_mem_type_manager *man)
+void vmw_thp_fini(struct vmw_private *dev_priv)
 {
+	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
 	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
 	struct drm_mm *mm = &rman->mm;
+	int ret;
+
+	ttm_mem_type_manager_disable(man);
 
+	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
+	if (ret)
+		return;
 	spin_lock(&rman->lock);
-	if (drm_mm_clean(mm)) {
-		drm_mm_takedown(mm);
-		spin_unlock(&rman->lock);
-		kfree(rman);
-		man->priv = NULL;
-		return 0;
-	}
+	drm_mm_clean(mm);
+	drm_mm_takedown(mm);
 	spin_unlock(&rman->lock);
-	return -EBUSY;
+	kfree(rman);
+	man->priv = NULL;
+	ttm_mem_type_manager_cleanup(man);
 }
 
 static void vmw_thp_debug(struct ttm_mem_type_manager *man,
@@ -163,7 +167,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func vmw_thp_func = {
-	.takedown = vmw_thp_takedown,
 	.get_node = vmw_thp_get_node,
 	.put_node = vmw_thp_put_node,
 	.debug = vmw_thp_debug
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 29/59] drm/vram_helper: call explicit mm takedown
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (27 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 28/59] drm/vmwgfx: takedown vram manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04  6:59   ` Thomas Zimmermann
  2020-08-04  2:56 ` [PATCH 30/59] drm/nouveau: use new cleanup paths Dave Airlie
                   ` (31 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index d7c0fdf82eb6..2099851c017e 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1127,6 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 
 static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
 {
+	ttm_range_man_fini(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]);
 	ttm_bo_device_release(&vmm->bdev);
 }
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 30/59] drm/nouveau: use new cleanup paths
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (28 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 29/59] drm/vram_helper: call explicit mm takedown Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:44   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 31/59] drm/radeon/ttm: use new takedown paths Dave Airlie
                   ` (30 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index cfcbecd332ef..bb310719e3f5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -31,12 +31,6 @@
 
 #include <core/tegra.h>
 
-static int
-nouveau_manager_fini(struct ttm_mem_type_manager *man)
-{
-	return 0;
-}
-
 static void
 nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
 {
@@ -70,7 +64,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
-	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_vram_manager_new,
 	.put_node = nouveau_manager_del,
 };
@@ -94,7 +87,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
-	.takedown = nouveau_manager_fini,
 	.get_node = nouveau_gart_manager_new,
 	.put_node = nouveau_manager_del,
 };
@@ -127,7 +119,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
 }
 
 const struct ttm_mem_type_manager_func nv04_gart_manager = {
-	.takedown = nouveau_manager_fini,
 	.get_node = nv04_gart_manager_new,
 	.put_node = nouveau_manager_del,
 };
@@ -192,6 +183,19 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 	}
 }
 
+static void
+nouveau_ttm_fini_vram(struct nouveau_drm *drm)
+{
+	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
+
+	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+		ttm_mem_type_manager_disable(man);
+		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
+		ttm_mem_type_manager_cleanup(man);
+	} else
+		ttm_range_man_fini(&drm->ttm.bdev, man);
+}
+
 static int
 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 {
@@ -221,6 +225,21 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	return 0;
 }
 
+static void
+nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
+{
+	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
+
+	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
+	    drm->agp.bridge)
+		ttm_range_man_fini(&drm->ttm.bdev, man);
+	else {
+		ttm_mem_type_manager_disable(man);
+		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
+		ttm_mem_type_manager_cleanup(man);
+	}
+}
+
 int
 nouveau_ttm_init(struct nouveau_drm *drm)
 {
@@ -310,8 +329,8 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
 {
 	struct nvkm_device *device = nvxx_device(&drm->client.device);
 
-	ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM);
-	ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT);
+	nouveau_ttm_fini_vram(drm);
+	nouveau_ttm_fini_gtt(drm);
 
 	ttm_bo_device_release(&drm->ttm.bdev);
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 31/59] drm/radeon/ttm: use new takedown paths
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (29 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 30/59] drm/nouveau: use new cleanup paths Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04  2:56 ` [PATCH 32/59] drm/qxl/ttm: use new takedown path Dave Airlie
                   ` (29 subsequent siblings)
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 84c02b4529c0..76b409af9476 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -825,8 +825,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 		}
 		radeon_bo_unref(&rdev->stolen_vga_memory);
 	}
-	ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_VRAM);
-	ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_TT);
+	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM]);
+	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT]);
 	ttm_bo_device_release(&rdev->mman.bdev);
 	radeon_gart_fini(rdev);
 	rdev->mman.initialized = false;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 32/59] drm/qxl/ttm: use new takedown path
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (30 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 31/59] drm/radeon/ttm: use new takedown paths Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 10:50   ` Gerd Hoffmann
  2020-08-04  2:56 ` [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface Dave Airlie
                   ` (28 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index bfbd2c5c38a2..0f7071829056 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -266,8 +266,8 @@ int qxl_ttm_init(struct qxl_device *qdev)
 
 void qxl_ttm_fini(struct qxl_device *qdev)
 {
-	ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_VRAM);
-	ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_PRIV);
+	ttm_range_man_fini(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM]);
+	ttm_range_man_fini(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV]);
 	ttm_bo_device_release(&qdev->mman.bdev);
 	DRM_INFO("qxl: ttm finalized\n");
 }
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (31 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 32/59] drm/qxl/ttm: use new takedown path Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  9:21   ` daniel
  2020-08-04  2:56 ` [PATCH 34/59] drm/ttm: remove range manager legacy takedown path Dave Airlie
                   ` (27 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           |  9 ++++-----
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 11 ++++++++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 4f4d22bac477..f368a9cc0c2a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -996,9 +996,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 	vmw_kms_close(dev_priv);
 out_no_kms:
 	if (dev_priv->has_mob)
-		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
+		vmw_gmrid_man_fini(dev_priv, VMW_PL_MOB);
 	if (dev_priv->has_gmr)
-		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
+		vmw_gmrid_man_fini(dev_priv, VMW_PL_GMR);
 	vmw_vram_manager_fini(dev_priv);
 out_no_vram:
 	(void)ttm_bo_device_release(&dev_priv->bdev);
@@ -1047,12 +1047,11 @@ static void vmw_driver_unload(struct drm_device *dev)
 	vmw_overlay_close(dev_priv);
 
 	if (dev_priv->has_gmr)
-		(void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
-	(void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
+		vmw_gmrid_man_fini(dev_priv, VMW_PL_GMR);
 
 	vmw_release_device_early(dev_priv);
 	if (dev_priv->has_mob)
-		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
+		vmw_gmrid_man_fini(dev_priv, VMW_PL_MOB);
 	vmw_vram_manager_fini(dev_priv);
 	(void) ttm_bo_device_release(&dev_priv->bdev);
 	drm_vma_offset_manager_destroy(&dev_priv->vma_manager);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index c6530d7b6d51..aa763c6b1146 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1222,6 +1222,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
  */
 
 int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type);
+void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type);
 
 /**
  * Prime - vmwgfx_prime.c
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index 141fb14e3583..ec1b5bb01a93 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -133,20 +133,25 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 	return 0;
 }
 
-static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man)
+void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 {
+	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
 	struct vmwgfx_gmrid_man *gman =
 		(struct vmwgfx_gmrid_man *)man->priv;
 
+	ttm_mem_type_manager_disable(man);
+
+	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
+
 	if (gman) {
 		ida_destroy(&gman->gmr_ida);
 		kfree(gman);
 	}
-	return 0;
+
+	ttm_mem_type_manager_cleanup(man);
 }
 
 static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
-	.takedown = vmw_gmrid_man_takedown,
 	.get_node = vmw_gmrid_man_get_node,
 	.put_node = vmw_gmrid_man_put_node,
 };
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 34/59] drm/ttm: remove range manager legacy takedown path
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (32 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:45   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only Dave Airlie
                   ` (26 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Now all drivers have been converted, drop the non-driver path.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 96da22be672b..86bf5e71e959 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -129,26 +129,11 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_range_man_init);
 
-static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
-{
-	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
-	struct drm_mm *mm = &rman->mm;
-
-	spin_lock(&rman->lock);
-	if (drm_mm_clean(mm)) {
-		drm_mm_takedown(mm);
-		spin_unlock(&rman->lock);
-		kfree(rman);
-		man->priv = NULL;
-		return 0;
-	}
-	spin_unlock(&rman->lock);
-	return -EBUSY;
-}
-
 int ttm_range_man_fini(struct ttm_bo_device *bdev,
 		       struct ttm_mem_type_manager *man)
 {
+	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
+	struct drm_mm *mm = &rman->mm;
 	int ret;
 
 	ttm_mem_type_manager_disable(man);
@@ -157,7 +142,13 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 	if (ret)
 		return ret;
 
-	ttm_bo_man_takedown_private(man);
+	spin_lock(&rman->lock);
+	drm_mm_clean(mm);
+	drm_mm_takedown(mm);
+	spin_unlock(&rman->lock);
+	kfree(rman);
+	man->priv = NULL;
+
 	ttm_mem_type_manager_cleanup(man);
 	return 0;
 }
@@ -174,7 +165,6 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 }
 
 static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
-	.takedown = ttm_bo_man_takedown_private,
 	.get_node = ttm_bo_man_get_node,
 	.put_node = ttm_bo_man_put_node,
 	.debug = ttm_bo_man_debug
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (33 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 34/59] drm/ttm: remove range manager legacy takedown path Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:46   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev Dave Airlie
                   ` (25 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Drivers should all be cleaning up their memory managers
themselves now, so let the core just clean the system one up.

Remove the legacy cleaning interface.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 54 +++------------------------------
 include/drm/ttm/ttm_bo_api.h    | 28 -----------------
 include/drm/ttm/ttm_bo_driver.h | 10 ------
 3 files changed, 4 insertions(+), 88 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index a45038c74de6..ebecb796dd49 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1452,42 +1452,6 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
 
-int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
-{
-	struct ttm_mem_type_manager *man;
-	int ret = -EINVAL;
-
-	if (mem_type >= TTM_NUM_MEM_TYPES) {
-		pr_err("Illegal memory type %d\n", mem_type);
-		return ret;
-	}
-	man = &bdev->man[mem_type];
-
-	if (!man->has_type) {
-		pr_err("Trying to take down uninitialized memory manager type %u\n",
-		       mem_type);
-		return ret;
-	}
-
-	ttm_mem_type_manager_disable(man);
-
-	ret = 0;
-	if (mem_type > 0) {
-		ret = ttm_mem_type_manager_force_list_clean(bdev, man);
-		if (ret) {
-			pr_err("Cleanup eviction failed\n");
-			return ret;
-		}
-
-		if (man->func->takedown)
-			ret = (*man->func->takedown)(man);
-	}
-
-	ttm_mem_type_manager_cleanup(man);
-
-	return ret;
-}
-EXPORT_SYMBOL(ttm_bo_clean_mm);
 
 int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 {
@@ -1591,21 +1555,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 {
 	struct ttm_bo_global *glob = &ttm_bo_glob;
 	int ret = 0;
-	unsigned i = TTM_NUM_MEM_TYPES;
+	unsigned i;
 	struct ttm_mem_type_manager *man;
 
-	while (i--) {
-		man = &bdev->man[i];
-		if (man->has_type) {
-			man->use_type = false;
-			if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) {
-				ret = -EBUSY;
-				pr_err("DRM memory manager type %d is not clean\n",
-				       i);
-			}
-			man->has_type = false;
-		}
-	}
+	man = &bdev->man[TTM_PL_SYSTEM];
+	ttm_mem_type_manager_disable(man);
 
 	mutex_lock(&ttm_global_mutex);
 	list_del(&bdev->device_list);
@@ -1618,7 +1572,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 
 	spin_lock(&glob->lru_lock);
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
-		if (list_empty(&bdev->man[0].lru[0]))
+		if (list_empty(&man->lru[0]))
 			pr_debug("Swap list %d was clean\n", i);
 	spin_unlock(&glob->lru_lock);
 
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 2c84622faa44..9c55eafd0e7d 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -546,34 +546,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
 			       struct ttm_mem_type_manager *man,
 			       unsigned long p_size);
 
-/**
- * ttm_bo_clean_mm
- *
- * @bdev: Pointer to a ttm_bo_device struct.
- * @mem_type: The memory type.
- *
- * Take down a manager for a given memory type after first walking
- * the LRU list to evict any buffers left alive.
- *
- * Normally, this function is part of lastclose() or unload(), and at that
- * point there shouldn't be any buffers left created by user-space, since
- * there should've been removed by the file descriptor release() method.
- * However, before this function is run, make sure to signal all sync objects,
- * and verify that the delayed delete queue is empty. The driver must also
- * make sure that there are no NO_EVICT buffers present in this memory type
- * when the call is made.
- *
- * If this function is part of a VT switch, the caller must make sure that
- * there are no appications currently validating buffers before this
- * function is called. The caller can do that by first taking the
- * struct ttm_bo_device::ttm_lock in write mode.
- *
- * Returns:
- * -EINVAL: invalid or uninitialized memory type.
- * -EBUSY: There are still buffers left in this memory type.
- */
-int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
-
 /**
  * ttm_bo_evict_mm
  *
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 9b4c22abc22c..8cc39cd55a14 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -48,16 +48,6 @@
 struct ttm_mem_type_manager;
 
 struct ttm_mem_type_manager_func {
-	/**
-	 * struct ttm_mem_type_manager member takedown
-	 *
-	 * @man: Pointer to a memory type manager.
-	 *
-	 * Called to undo the setup done in init. All allocated resources
-	 * should be freed.
-	 */
-	int  (*takedown)(struct ttm_mem_type_manager *man);
-
 	/**
 	 * struct ttm_mem_type_manager member get_node
 	 *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (34 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:25   ` Christian König
  2020-08-04  2:56 ` [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers Dave Airlie
                   ` (24 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This will allow different abstractions later.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c      | 34 +++++++++++++++----------------
 drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++---------
 drivers/gpu/drm/ttm/ttm_bo_vm.c   |  2 +-
 include/drm/ttm/ttm_bo_driver.h   |  6 ++++++
 4 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index ebecb796dd49..8777c323e7de 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
 			return;
 		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
 			   i, placement->placement[i].flags, mem_type);
-		man = &bo->bdev->man[mem_type];
+		man = ttm_manager_type(bo->bdev, mem_type);
 		ttm_mem_type_manager_debug(man, &p);
 	}
 }
@@ -157,7 +157,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
 	if (mem->placement & TTM_PL_FLAG_NO_EVICT)
 		return;
 
-	man = &bdev->man[mem->mem_type];
+	man = ttm_manager_type(bdev, mem->mem_type);
 	list_add_tail(&bo->lru, &man->lru[bo->priority]);
 
 	if (man->use_tt && bo->ttm &&
@@ -232,7 +232,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
 		dma_resv_assert_held(pos->first->base.resv);
 		dma_resv_assert_held(pos->last->base.resv);
 
-		man = &pos->first->bdev->man[TTM_PL_TT];
+		man = ttm_manager_type(pos->first->bdev, TTM_PL_TT);
 		list_bulk_move_tail(&man->lru[i], &pos->first->lru,
 				    &pos->last->lru);
 	}
@@ -247,7 +247,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
 		dma_resv_assert_held(pos->first->base.resv);
 		dma_resv_assert_held(pos->last->base.resv);
 
-		man = &pos->first->bdev->man[TTM_PL_VRAM];
+		man = ttm_manager_type(pos->first->bdev, TTM_PL_VRAM);
 		list_bulk_move_tail(&man->lru[i], &pos->first->lru,
 				    &pos->last->lru);
 	}
@@ -273,8 +273,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type];
-	struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
+	struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 
 	ret = ttm_mem_io_lock(old_man, true);
@@ -340,7 +340,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 	return 0;
 
 out_err:
-	new_man = &bdev->man[bo->mem.mem_type];
+	new_man = ttm_manager_type(bdev, bo->mem.mem_type);
 	if (!new_man->use_tt) {
 		ttm_tt_destroy(bo->ttm);
 		bo->ttm = NULL;
@@ -552,7 +552,7 @@ static void ttm_bo_release(struct kref *kref)
 	struct ttm_buffer_object *bo =
 	    container_of(kref, struct ttm_buffer_object, kref);
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
 	size_t acc_size = bo->acc_size;
 	int ret;
 
@@ -844,7 +844,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 			  const struct ttm_place *place,
 			  struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
 	mem->mm_node = NULL;
 	if (!man->func || !man->func->get_node)
@@ -855,7 +855,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 
 void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
 	if (!man->func || !man->func->put_node)
 		return;
@@ -912,7 +912,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	struct ww_acquire_ctx *ticket;
 	int ret;
 
@@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 	if (ret)
 		return ret;
 
-	man = &bdev->man[mem_type];
+	man = ttm_manager_type(bdev, mem_type);
 	if (!man->has_type || !man->use_type)
 		return -EBUSY;
 
@@ -1065,7 +1065,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 		if (unlikely(ret))
 			goto error;
 
-		man = &bdev->man[mem->mem_type];
+		man = ttm_manager_type(bdev, mem->mem_type);
 		ret = ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
 		if (unlikely(ret)) {
 			ttm_bo_mem_put(bo, mem);
@@ -1455,7 +1455,7 @@ EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
 
 int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
 
 	if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
 		pr_err("Illegal memory manager memory type %u\n", mem_type);
@@ -1558,7 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 	unsigned i;
 	struct ttm_mem_type_manager *man;
 
-	man = &bdev->man[TTM_PL_SYSTEM];
+	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
 	ttm_mem_type_manager_disable(man);
 
 	mutex_lock(&ttm_global_mutex);
@@ -1585,7 +1585,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
 
 static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
 
 	/*
 	 * Initialize the system memory buffer type.
@@ -1649,7 +1649,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
 void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
 
 	ttm_mem_io_lock(man, false);
 	ttm_bo_unmap_virtual_locked(bo);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 1f502be0b646..879c8ded0cd8 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
 		       struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 
 	if (mem->bus.io_reserved_count++)
@@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
 
 int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
 {
-	struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
 	struct ttm_mem_reg *mem = &bo->mem;
 	int ret;
 
@@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
 			       struct ttm_mem_reg *mem,
 			       void **virtual)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 	void *addr;
 
@@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
 {
 	struct ttm_mem_type_manager *man;
 
-	man = &bdev->man[mem->mem_type];
+	man = ttm_manager_type(bdev, mem->mem_type);
 
 	if (virtual && mem->bus.addr == NULL)
 		iounmap(virtual);
@@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 		       struct ttm_mem_reg *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
 	struct ttm_tt *ttm = bo->ttm;
 	struct ttm_mem_reg *old_mem = &bo->mem;
 	struct ttm_mem_reg old_copy = *old_mem;
@@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
 		struct ttm_bo_kmap_obj *map)
 {
 	struct ttm_mem_type_manager *man =
-		&bo->bdev->man[bo->mem.mem_type];
+		ttm_manager_type(bo->bdev, bo->mem.mem_type);
 	unsigned long offset, size;
 	int ret;
 
@@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
 {
 	struct ttm_buffer_object *bo = map->bo;
 	struct ttm_mem_type_manager *man =
-		&bo->bdev->man[bo->mem.mem_type];
+		ttm_manager_type(bo->bdev, bo->mem.mem_type);
 
 	if (!map->virtual)
 		return;
@@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 			      struct ttm_mem_reg *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
 	struct ttm_mem_reg *old_mem = &bo->mem;
 	int ret;
 	struct ttm_buffer_object *ghost_obj;
@@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
 	struct ttm_bo_device *bdev = bo->bdev;
 	struct ttm_mem_reg *old_mem = &bo->mem;
 
-	struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type];
-	struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type];
+	struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
+	struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
 
 	int ret;
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 468a0eb9e632..5ae679184eb5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	unsigned long address = vmf->address;
 	struct ttm_mem_type_manager *man =
-		&bdev->man[bo->mem.mem_type];
+		ttm_manager_type(bdev, bo->mem.mem_type);
 
 	/*
 	 * Refuse to fault imported pages. This should be handled
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 8cc39cd55a14..e80deee3ae99 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -444,6 +444,12 @@ struct ttm_bo_device {
 	bool no_retry;
 };
 
+static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
+							    int mem_type)
+{
+	return &bdev->man[mem_type];
+}
+
 /**
  * struct ttm_lru_bulk_move_pos
  *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (35 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:26   ` Christian König
  2020-08-04  2:56 ` [PATCH 38/59] drm/vram-helper: use wrapper to access " Dave Airlie
                   ` (23 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c       |  6 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |  5 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 12 +++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c      | 21 +++++++++++---------
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c      | 12 +++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 12 +++++------
 8 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 1b865fed74ca..e24f421e5553 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -517,8 +517,9 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
 uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 
-	return amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+	return amdgpu_vram_mgr_usage(vram_man);
 }
 
 uint64_t amdgpu_amdkfd_get_hive_id(struct kgd_dev *kgd)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index a512ccbc4dea..9829640e1769 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
 {
 	s64 time_us, increment_us;
 	u64 free_vram, total_vram, used_vram;
-
+	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	/* Allow a maximum of 200 accumulated ms. This is basically per-IB
 	 * throttling.
 	 *
@@ -316,7 +316,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
 	}
 
 	total_vram = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size);
-	used_vram = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+	used_vram = amdgpu_vram_mgr_usage(vram_man);
 	free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram;
 
 	spin_lock(&adev->mm_stats.lock);
@@ -363,7 +363,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
 	if (!amdgpu_gmc_vram_full_visible(&adev->gmc)) {
 		u64 total_vis_vram = adev->gmc.visible_vram_size;
 		u64 used_vis_vram =
-			amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+		  amdgpu_vram_mgr_vis_usage(vram_man);
 
 		if (used_vis_vram < total_vis_vram) {
 			u64 free_vis_vram = total_vis_vram - used_vis_vram;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index aa5b54e5a1d7..d551e7c5e69d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3880,7 +3880,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
 
 	amdgpu_virt_init_data_exchange(adev);
 	/* we need recover gart prior to run SMC/CP/SDMA resume */
-	amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]);
+	amdgpu_gtt_mgr_recover(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
 
 	r = amdgpu_device_fw_loading(adev);
 	if (r)
@@ -4079,8 +4079,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 					amdgpu_inc_vram_lost(tmp_adev);
 				}
 
-				r = amdgpu_gtt_mgr_recover(
-					&tmp_adev->mman.bdev.man[TTM_PL_TT]);
+				r = amdgpu_gtt_mgr_recover(ttm_manager_type(&tmp_adev->mman.bdev, TTM_PL_TT));
 				if (r)
 					goto out;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 28056d12b199..f0b78e88bb55 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -48,9 +48,9 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
-			(adev->mman.bdev.man[TTM_PL_TT].size) * PAGE_SIZE);
+			man->size * PAGE_SIZE);
 }
 
 /**
@@ -66,9 +66,9 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
-			amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]));
+			amdgpu_gtt_mgr_usage(man));
 }
 
 static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
@@ -87,7 +87,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
  */
 int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	struct amdgpu_gtt_mgr *mgr;
 	uint64_t start, size;
 	int ret;
@@ -135,7 +135,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
  */
 void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	struct amdgpu_gtt_mgr *mgr = man->priv;
 	int ret;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index a8c47aecd342..594687cc99ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -594,13 +594,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 		ui64 = atomic64_read(&adev->num_vram_cpu_page_faults);
 		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
 	case AMDGPU_INFO_VRAM_USAGE:
-		ui64 = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+		ui64 = amdgpu_vram_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM));
 		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
 	case AMDGPU_INFO_VIS_VRAM_USAGE:
-		ui64 = amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+		ui64 = amdgpu_vram_mgr_vis_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM));
 		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
 	case AMDGPU_INFO_GTT_USAGE:
-		ui64 = amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]);
+		ui64 = amdgpu_gtt_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
 		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
 	case AMDGPU_INFO_GDS_CONFIG: {
 		struct drm_amdgpu_info_gds gds_info;
@@ -623,7 +623,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 			min(adev->gmc.visible_vram_size -
 			    atomic64_read(&adev->visible_pin_size),
 			    vram_gtt.vram_size);
-		vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size;
+		vram_gtt.gtt_size = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT)->size;
 		vram_gtt.gtt_size *= PAGE_SIZE;
 		vram_gtt.gtt_size -= atomic64_read(&adev->gart_pin_size);
 		return copy_to_user(out, &vram_gtt,
@@ -631,14 +631,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 	}
 	case AMDGPU_INFO_MEMORY: {
 		struct drm_amdgpu_memory_info mem;
-
+		struct ttm_mem_type_manager *vram_man =
+			ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+		struct ttm_mem_type_manager *gtt_man =
+			ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 		memset(&mem, 0, sizeof(mem));
 		mem.vram.total_heap_size = adev->gmc.real_vram_size;
 		mem.vram.usable_heap_size = adev->gmc.real_vram_size -
 			atomic64_read(&adev->vram_pin_size) -
 			AMDGPU_VM_RESERVED_VRAM;
 		mem.vram.heap_usage =
-			amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+			amdgpu_vram_mgr_usage(vram_man);
 		mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4;
 
 		mem.cpu_accessible_vram.total_heap_size =
@@ -648,16 +651,16 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 			    atomic64_read(&adev->visible_pin_size),
 			    mem.vram.usable_heap_size);
 		mem.cpu_accessible_vram.heap_usage =
-			amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+			amdgpu_vram_mgr_vis_usage(vram_man);
 		mem.cpu_accessible_vram.max_allocation =
 			mem.cpu_accessible_vram.usable_heap_size * 3 / 4;
 
-		mem.gtt.total_heap_size = adev->mman.bdev.man[TTM_PL_TT].size;
+		mem.gtt.total_heap_size = gtt_man->size;
 		mem.gtt.total_heap_size *= PAGE_SIZE;
 		mem.gtt.usable_heap_size = mem.gtt.total_heap_size -
 			atomic64_read(&adev->gart_pin_size);
 		mem.gtt.heap_usage =
-			amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]);
+			amdgpu_gtt_mgr_usage(gtt_man);
 		mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4;
 
 		return copy_to_user(out, &mem,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5ac7b5561475..ced418cba2f7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -449,7 +449,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
 	 * allow fall back to GTT
 	 */
 	if (domain & AMDGPU_GEM_DOMAIN_GTT) {
-		man = &adev->mman.bdev.man[TTM_PL_TT];
+		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 
 		if (size < (man->size << PAGE_SHIFT))
 			return true;
@@ -458,7 +458,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
 	}
 
 	if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
-		man = &adev->mman.bdev.man[TTM_PL_VRAM];
+		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 
 		if (size < (man->size << PAGE_SHIFT))
 			return true;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index d7516144bb0a..1bd860877f1e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -67,7 +67,7 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
 				    unsigned int type,
 				    uint64_t size)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type);
 
 	man->available_caching = TTM_PL_FLAG_UNCACHED;
 	man->default_caching = TTM_PL_FLAG_UNCACHED;
@@ -2014,9 +2014,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
 	amdgpu_vram_mgr_fini(adev);
 	amdgpu_gtt_mgr_fini(adev);
-	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS]);
-	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS]);
-	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA]);
+	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS));
+	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS));
+	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA));
 	ttm_bo_device_release(&adev->mman.bdev);
 	adev->mman.initialized = false;
 	DRM_INFO("amdgpu: ttm finalized\n");
@@ -2033,7 +2033,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	uint64_t size;
 	int r;
 
@@ -2255,7 +2255,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
 	unsigned ttm_pl = (uintptr_t)node->info_ent->data;
 	struct drm_device *dev = node->minor->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	man->func->debug(man, &p);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index c3bc9ddd437e..bc776b8f1063 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -82,9 +82,9 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
-		amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]));
+			amdgpu_vram_mgr_usage(man));
 }
 
 /**
@@ -100,9 +100,9 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
-		amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]));
+			amdgpu_vram_mgr_vis_usage(man));
 }
 
 static ssize_t amdgpu_mem_info_vram_vendor(struct device *dev,
@@ -170,7 +170,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
  */
 int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	struct amdgpu_vram_mgr *mgr;
 	int ret;
 
@@ -207,7 +207,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
  */
 void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	struct amdgpu_vram_mgr *mgr = man->priv;
 	int ret;
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 38/59] drm/vram-helper: use wrapper to access memory managers
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (36 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04  7:00   ` Thomas Zimmermann
  2020-08-04  2:56 ` [PATCH 39/59] drm/nouveau/ttm: " Dave Airlie
                   ` (22 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 2099851c017e..a01768adb96d 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1075,7 +1075,7 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
-	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	ttm_mem_type_manager_debug(man, &p);
@@ -1103,7 +1103,7 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
 static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 			    uint64_t vram_base, size_t vram_size)
 {
-	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
 	int ret;
 
 	vmm->vram_base = vram_base;
@@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 
 static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
 {
-	ttm_range_man_fini(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]);
+	ttm_range_man_fini(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM));
 	ttm_bo_device_release(&vmm->bdev);
 }
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 39/59] drm/nouveau/ttm: use wrapper to access memory managers
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (37 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 38/59] drm/vram-helper: use wrapper to access " Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:48   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager Dave Airlie
                   ` (21 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index bb310719e3f5..cc6cf04553dd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -156,7 +156,7 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
 static int
 nouveau_ttm_init_vram(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 	struct nvif_mmu *mmu = &drm->client.mmu;
 
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
@@ -186,7 +186,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 static void
 nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
 		ttm_mem_type_manager_disable(man);
@@ -199,7 +199,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 static int
 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
 	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
 	man->use_tt = true;
 	if (drm->agp.bridge) {
@@ -228,7 +228,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 static void
 nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
 
 	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
 	    drm->agp.bridge)
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (38 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 39/59] drm/nouveau/ttm: " Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 10:50   ` Gerd Hoffmann
  2020-08-04  2:56 ` [PATCH 41/59] drm/radeon/ttm: " Dave Airlie
                   ` (20 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 0f7071829056..57c96f7271db 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -219,7 +219,7 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
 				 unsigned int type,
 				 uint64_t size)
 {
-	struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type);
 
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
@@ -266,8 +266,9 @@ int qxl_ttm_init(struct qxl_device *qdev)
 
 void qxl_ttm_fini(struct qxl_device *qdev)
 {
-	ttm_range_man_fini(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM]);
-	ttm_range_man_fini(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV]);
+
+	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM));
+	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV));
 	ttm_bo_device_release(&qdev->mman.bdev);
 	DRM_INFO("qxl: ttm finalized\n");
 }
@@ -302,9 +303,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev)
 		qxl_mem_types_list[i].show = &qxl_mm_dump_table;
 		qxl_mem_types_list[i].driver_features = 0;
 		if (i == 0)
-			qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM];
+			qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM);
 		else
-			qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV];
+			qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV);
 
 	}
 	qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 41/59] drm/radeon/ttm: use wrapper to access memory manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (39 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:29   ` Christian König
  2020-08-04  2:56 ` [PATCH 42/59] drm/vmwgfx/ttm: " Dave Airlie
                   ` (19 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_gem.c |  2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 44157ada9b0e..3ec028dba739 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -226,7 +226,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
 	struct drm_radeon_gem_info *args = data;
 	struct ttm_mem_type_manager *man;
 
-	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
+	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
 
 	args->vram_size = (u64)man->size << PAGE_SHIFT;
 	args->vram_visible = rdev->mc.visible_vram_size;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 76b409af9476..03c0a24e74c4 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -68,7 +68,7 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 
 static int radeon_ttm_init_vram(struct radeon_device *rdev)
 {
-	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
 
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
@@ -79,7 +79,7 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev)
 
 static int radeon_ttm_init_gtt(struct radeon_device *rdev)
 {
-	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT);
 
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
@@ -825,8 +825,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 		}
 		radeon_bo_unref(&rdev->stolen_vga_memory);
 	}
-	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM]);
-	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT]);
+	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM));
+	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT));
 	ttm_bo_device_release(&rdev->mman.bdev);
 	radeon_gart_fini(rdev);
 	rdev->mman.initialized = false;
@@ -842,7 +842,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
 	if (!rdev->mman.initialized)
 		return;
 
-	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
+	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
 	/* this just adjusts TTM size idea, which sets lpfn to the correct value */
 	man->size = size >> PAGE_SHIFT;
 }
@@ -896,7 +896,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
 	unsigned ttm_pl = *(int*)node->info_ent->data;
 	struct drm_device *dev = node->minor->dev;
 	struct radeon_device *rdev = dev->dev_private;
-	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	man->func->debug(man, &p);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 42/59] drm/vmwgfx/ttm: use wrapper to access memory manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (40 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 41/59] drm/radeon/ttm: " Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  9:22   ` daniel
  2020-08-04  2:56 ` [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used Dave Airlie
                   ` (18 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 23 +++++++++++--------
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  4 ++--
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index f368a9cc0c2a..6ed92f38b54b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -634,7 +634,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
 	ret = ttm_range_man_init(&dev_priv->bdev, man,
 				 dev_priv->vram_size >> PAGE_SHIFT);
 #endif
-	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
+	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
 	return ret;
 }
 
@@ -644,7 +644,7 @@ static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
 	vmw_thp_fini(dev_priv);
 #else
 	ttm_bo_man_fini(&dev_priv->bdev,
-			    &dev_priv->bdev.man[TTM_PL_VRAM]);
+			ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM));
 #endif
 }
 
@@ -887,7 +887,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 		DRM_ERROR("Failed initializing TTM buffer object driver.\n");
 		goto out_no_bdev;
 	}
-	dev_priv->bdev.man[TTM_PL_SYSTEM].available_caching =
+	ttm_manager_type(&dev_priv->bdev, TTM_PL_SYSTEM)->available_caching =
 		TTM_PL_FLAG_CACHED;
 
 	/*
@@ -1194,10 +1194,12 @@ static void vmw_master_drop(struct drm_device *dev,
  */
 static void __vmw_svga_enable(struct vmw_private *dev_priv)
 {
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+
 	spin_lock(&dev_priv->svga_lock);
-	if (!dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
+	if (!man->use_type) {
 		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
-		dev_priv->bdev.man[TTM_PL_VRAM].use_type = true;
+		man->use_type = true;
 	}
 	spin_unlock(&dev_priv->svga_lock);
 }
@@ -1223,9 +1225,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)
  */
 static void __vmw_svga_disable(struct vmw_private *dev_priv)
 {
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+
 	spin_lock(&dev_priv->svga_lock);
-	if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
-		dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
+	if (man->use_type) {
+		man->use_type = false;
 		vmw_write(dev_priv, SVGA_REG_ENABLE,
 			  SVGA_REG_ENABLE_HIDE |
 			  SVGA_REG_ENABLE_ENABLE);
@@ -1242,6 +1246,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
  */
 void vmw_svga_disable(struct vmw_private *dev_priv)
 {
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 	/*
 	 * Disabling SVGA will turn off device modesetting capabilities, so
 	 * notify KMS about that so that it doesn't cache atomic state that
@@ -1257,8 +1262,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
 	vmw_kms_lost_device(dev_priv->dev);
 	ttm_write_lock(&dev_priv->reservation_sem, false);
 	spin_lock(&dev_priv->svga_lock);
-	if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
-		dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
+	if (man->use_type) {
+		man->use_type = false;
 		spin_unlock(&dev_priv->svga_lock);
 		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
 			DRM_ERROR("Failed evicting VRAM buffers.\n");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index ec1b5bb01a93..54c85a59dd8b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -98,7 +98,7 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
 
 int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 {
-	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
 	struct vmwgfx_gmrid_man *gman =
 		kzalloc(sizeof(*gman), GFP_KERNEL);
 
@@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 
 void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 {
-	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
 	struct vmwgfx_gmrid_man *gman =
 		(struct vmwgfx_gmrid_man *)man->priv;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 548f152b9963..720a24214c74 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -117,7 +117,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
 
 int vmw_thp_init(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 	struct vmw_thp_manager *rman;
 	man->available_caching = TTM_PL_FLAG_CACHED;
 	man->default_caching = TTM_PL_FLAG_CACHED;
@@ -137,7 +137,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
 
 void vmw_thp_fini(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
+	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
 	struct drm_mm *mm = &rman->mm;
 	int ret;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (41 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 42/59] drm/vmwgfx/ttm: " Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:29   ` Christian König
  2020-08-04  2:56 ` [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses Dave Airlie
                   ` (17 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Other users of this should notice this change and switch to wrapper.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 2 +-
 include/drm/ttm/ttm_bo_driver.h | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8777c323e7de..3a3a4dfb0fff 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1617,7 +1617,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 
 	bdev->driver = driver;
 
-	memset(bdev->man, 0, sizeof(bdev->man));
+	memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
 
 	ttm_bo_init_sysman(bdev);
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index e80deee3ae99..03b253d14e6a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -415,7 +415,10 @@ struct ttm_bo_device {
 	 */
 	struct list_head device_list;
 	struct ttm_bo_driver *driver;
-	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
+	/*
+	 * access via ttm_manager_type.
+	 */
+	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
 
 	/*
 	 * Protected by internal locks.
@@ -447,7 +450,7 @@ struct ttm_bo_device {
 static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
-	return &bdev->man[mem_type];
+	return &bdev->man_priv[mem_type];
 }
 
 /**
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (42 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:30   ` Christian König
  2020-08-04  2:56 ` [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs Dave Airlie
                   ` (16 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This will get removed eventually and all drivers will use this.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 03b253d14e6a..6940d85a531a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -419,7 +419,7 @@ struct ttm_bo_device {
 	 * access via ttm_manager_type.
 	 */
 	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
-
+	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
 	/*
 	 * Protected by internal locks.
 	 */
@@ -450,9 +450,18 @@ struct ttm_bo_device {
 static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
+	if (bdev->man_drv[mem_type])
+		return bdev->man_drv[mem_type];
 	return &bdev->man_priv[mem_type];
 }
 
+static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
+					  int type,
+					  struct ttm_mem_type_manager *manager)
+{
+	bdev->man_drv[type] = manager;
+}
+
 /**
  * struct ttm_lru_bulk_move_pos
  *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (43 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:32   ` Christian König
  2020-08-04  2:56 ` [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args Dave Airlie
                   ` (15 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 35 +++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 36 +++++++++++++-------
 2 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index f0b78e88bb55..b664c5cb13ce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -25,11 +25,17 @@
 #include "amdgpu.h"
 
 struct amdgpu_gtt_mgr {
+	struct ttm_mem_type_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 	atomic64_t available;
 };
 
+static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man)
+{
+	return container_of(man, struct amdgpu_gtt_mgr, manager);
+}
+
 struct amdgpu_gtt_node {
 	struct drm_mm_node node;
 	struct ttm_buffer_object *tbo;
@@ -87,11 +93,16 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
  */
 int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
+	struct ttm_mem_type_manager *man;
 	struct amdgpu_gtt_mgr *mgr;
 	uint64_t start, size;
 	int ret;
 
+	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
+	if (!mgr)
+		return -ENOMEM;
+
+	man = &mgr->manager;
 	man->use_tt = true;
 	man->func = &amdgpu_gtt_mgr_func;
 	man->available_caching = TTM_PL_MASK_CACHING;
@@ -99,16 +110,11 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 
 	ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
 
-	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
-	if (!mgr)
-		return -ENOMEM;
-
 	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
 	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
 	drm_mm_init(&mgr->mm, start, size);
 	spin_lock_init(&mgr->lock);
 	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
-	man->priv = mgr;
 
 	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
 	if (ret) {
@@ -121,6 +127,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 		return ret;
 	}
 
+	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -136,7 +143,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 {
 	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	int ret;
 
 	ttm_mem_type_manager_disable(man);
@@ -148,13 +155,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 	spin_lock(&mgr->lock);
 	drm_mm_takedown(&mgr->mm);
 	spin_unlock(&mgr->lock);
-	kfree(mgr);
-	man->priv = NULL;
 
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
 
 	ttm_mem_type_manager_cleanup(man);
+	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
+	kfree(mgr);
 }
 
 /**
@@ -184,7 +191,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
 			      const struct ttm_place *place,
 			      struct ttm_mem_reg *mem)
 {
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node;
 	int r;
 
@@ -245,7 +252,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
 static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
 			       struct ttm_mem_reg *mem)
 {
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node = mem->mm_node;
 
 	if (node) {
@@ -267,7 +274,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
  */
 uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
 {
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	s64 result = man->size - atomic64_read(&mgr->available);
 
 	return (result > 0 ? result : 0) * PAGE_SIZE;
@@ -275,7 +282,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
 
 int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
 {
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node;
 	struct drm_mm_node *mm_node;
 	int r = 0;
@@ -303,7 +310,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
 static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
 				 struct drm_printer *printer)
 {
-	struct amdgpu_gtt_mgr *mgr = man->priv;
+	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 
 	spin_lock(&mgr->lock);
 	drm_mm_print(&mgr->mm, printer);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index bc776b8f1063..2b37f4266dcb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -29,12 +29,18 @@
 #include "atom.h"
 
 struct amdgpu_vram_mgr {
+	struct ttm_mem_type_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 	atomic64_t usage;
 	atomic64_t vis_usage;
 };
 
+static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
+{
+	return container_of(man, struct amdgpu_vram_mgr, manager);
+}
+
 /**
  * DOC: mem_info_vram_total
  *
@@ -170,29 +176,32 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
  */
 int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_mem_type_manager *man;
 	struct amdgpu_vram_mgr *mgr;
 	int ret;
 
+	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
+	if (!mgr)
+		return -ENOMEM;
+
+	man = &mgr->manager;
+
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
 
 	ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
 
 	man->func = &amdgpu_vram_mgr_func;
-	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
-	if (!mgr)
-		return -ENOMEM;
 
 	drm_mm_init(&mgr->mm, 0, man->size);
 	spin_lock_init(&mgr->lock);
-	man->priv = mgr;
 
 	/* Add the two VRAM-related sysfs files */
 	ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
 	if (ret)
 		DRM_ERROR("Failed to register sysfs\n");
 
+	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -208,7 +217,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 {
 	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	int ret;
 
 	ttm_mem_type_manager_disable(man);
@@ -220,11 +229,12 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 	spin_lock(&mgr->lock);
 	drm_mm_takedown(&mgr->mm);
 	spin_unlock(&mgr->lock);
-	kfree(mgr);
-	man->priv = NULL;
+
 	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
 
 	ttm_mem_type_manager_cleanup(man);
+	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
+	kfree(mgr);
 }
 
 /**
@@ -314,7 +324,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
 			       struct ttm_mem_reg *mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	struct drm_mm *mm = &mgr->mm;
 	struct drm_mm_node *nodes;
 	enum drm_mm_insert_mode mode;
@@ -430,7 +440,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
 				struct ttm_mem_reg *mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	struct drm_mm_node *nodes = mem->mm_node;
 	uint64_t usage = 0, vis_usage = 0;
 	unsigned pages = mem->num_pages;
@@ -562,7 +572,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
  */
 uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
 {
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 
 	return atomic64_read(&mgr->usage);
 }
@@ -576,7 +586,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
  */
 uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
 {
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 
 	return atomic64_read(&mgr->vis_usage);
 }
@@ -592,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
 static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
 				  struct drm_printer *printer)
 {
-	struct amdgpu_vram_mgr *mgr = man->priv;
+	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 
 	spin_lock(&mgr->lock);
 	drm_mm_print(&mgr->mm, printer);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (44 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:35   ` Christian König
  2020-08-04  2:56 ` [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation Dave Airlie
                   ` (14 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This makes it easier to move these to a driver allocated system

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++-------
 drivers/gpu/drm/drm_gem_vram_helper.c   | 10 ++++----
 drivers/gpu/drm/nouveau/nouveau_ttm.c   | 22 +++++++++++-------
 drivers/gpu/drm/qxl/qxl_ttm.c           | 13 ++++-------
 drivers/gpu/drm/radeon/radeon_ttm.c     | 31 ++++++++++++-------------
 drivers/gpu/drm/ttm/ttm_bo_manager.c    | 19 +++++++++++----
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c     | 13 ++++-------
 include/drm/ttm/ttm_bo_driver.h         | 12 +++++++---
 8 files changed, 70 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 1bd860877f1e..b190d50dc9bb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
 				    unsigned int type,
 				    uint64_t size)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type);
-
-	man->available_caching = TTM_PL_FLAG_UNCACHED;
-	man->default_caching = TTM_PL_FLAG_UNCACHED;
-
-	return ttm_range_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT);
+	return ttm_range_man_init(&adev->mman.bdev, type,
+				  TTM_PL_FLAG_UNCACHED, TTM_PL_FLAG_UNCACHED,
+				  false, size >> PAGE_SHIFT);
 }
 
 /**
@@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
 	amdgpu_vram_mgr_fini(adev);
 	amdgpu_gtt_mgr_fini(adev);
-	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS));
-	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS));
-	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA));
+	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GDS);
+	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GWS);
+	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_OA);
 	ttm_bo_device_release(&adev->mman.bdev);
 	adev->mman.initialized = false;
 	DRM_INFO("amdgpu: ttm finalized\n");
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index a01768adb96d..2187787f397e 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
 static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 			    uint64_t vram_base, size_t vram_size)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
 	int ret;
 
 	vmm->vram_base = vram_base;
@@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-	man->default_caching = TTM_PL_FLAG_WC;
-	ret = ttm_range_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT);
+	ret = ttm_range_man_init(&vmm->bdev, TTM_PL_VRAM,
+				 TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
+				 TTM_PL_FLAG_WC, false,
+				 vram_size >> PAGE_SHIFT);
 	if (ret)
 		return ret;
 
@@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 
 static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
 {
-	ttm_range_man_fini(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM));
+	ttm_range_man_fini(&vmm->bdev, TTM_PL_VRAM);
 	ttm_bo_device_release(&vmm->bdev);
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index cc6cf04553dd..1c636723823c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
 static int
 nouveau_ttm_init_vram(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 	struct nvif_mmu *mmu = &drm->client.mmu;
 
-	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-	man->default_caching = TTM_PL_FLAG_WC;
-
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+		struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
+
 		/* Some BARs do not support being ioremapped WC */
 		const u8 type = mmu->type[drm->ttm.type_vram].type;
 
+		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
+		man->default_caching = TTM_PL_FLAG_WC;
+
 		if (type & NVIF_MEM_UNCACHED) {
 			man->available_caching = TTM_PL_FLAG_UNCACHED;
 			man->default_caching = TTM_PL_FLAG_UNCACHED;
@@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 		ttm_mem_type_manager_set_used(man, true);
 		return 0;
 	} else {
-		return ttm_range_man_init(&drm->ttm.bdev, man,
+		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
+					  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
+					  TTM_PL_FLAG_WC, false,
 					  drm->gem.vram_available >> PAGE_SHIFT);
 	}
 }
@@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
 		ttm_mem_type_manager_cleanup(man);
 	} else
-		ttm_range_man_fini(&drm->ttm.bdev, man);
+		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
 }
 
 static int
@@ -216,9 +219,10 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	else if (!drm->agp.bridge)
 		man->func = &nv04_gart_manager;
 	else
-		return ttm_range_man_init(&drm->ttm.bdev, man,
+		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
+					  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
+					  TTM_PL_FLAG_WC, true,
 					  size_pages);
-
 	ttm_mem_type_manager_init(&drm->ttm.bdev, man,
 				  size_pages);
 	ttm_mem_type_manager_set_used(man, true);
@@ -232,7 +236,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 
 	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
 	    drm->agp.bridge)
-		ttm_range_man_fini(&drm->ttm.bdev, man);
+		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
 	else {
 		ttm_mem_type_manager_disable(man);
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 57c96f7271db..b7365b2e4c7f 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
 				 unsigned int type,
 				 uint64_t size)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type);
-
-	man->available_caching = TTM_PL_MASK_CACHING;
-	man->default_caching = TTM_PL_FLAG_CACHED;
-
-	return ttm_range_man_init(&qdev->mman.bdev, man, size);
+	return ttm_range_man_init(&qdev->mman.bdev, type, TTM_PL_MASK_CACHING,
+				  TTM_PL_FLAG_CACHED, false, size);
 }
 
 int qxl_ttm_init(struct qxl_device *qdev)
@@ -266,9 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev)
 
 void qxl_ttm_fini(struct qxl_device *qdev)
 {
-
-	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM));
-	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV));
+	ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_VRAM);
+	ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_PRIV);
 	ttm_bo_device_release(&qdev->mman.bdev);
 	DRM_INFO("qxl: ttm finalized\n");
 }
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 03c0a24e74c4..474d2161da1e 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -68,35 +68,34 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 
 static int radeon_ttm_init_vram(struct radeon_device *rdev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
-
-	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-	man->default_caching = TTM_PL_FLAG_WC;
-
-	return ttm_range_man_init(&rdev->mman.bdev, man,
+	return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_VRAM,
+				  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
+				  TTM_PL_FLAG_WC, false,
 				  rdev->mc.real_vram_size >> PAGE_SHIFT);
 }
 
 static int radeon_ttm_init_gtt(struct radeon_device *rdev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT);
+	uint32_t available_caching, default_caching;
+
+	available_caching = TTM_PL_MASK_CACHING;
+	default_caching = TTM_PL_FLAG_CACHED;
 
-	man->available_caching = TTM_PL_MASK_CACHING;
-	man->default_caching = TTM_PL_FLAG_CACHED;
-	man->use_tt = true;
 #if IS_ENABLED(CONFIG_AGP)
 	if (rdev->flags & RADEON_IS_AGP) {
 		if (!rdev->ddev->agp) {
 			DRM_ERROR("AGP is not enabled\n");
 			return -EINVAL;
 		}
-		man->available_caching = TTM_PL_FLAG_UNCACHED |
-					 TTM_PL_FLAG_WC;
-		man->default_caching = TTM_PL_FLAG_WC;
+		available_caching = TTM_PL_FLAG_UNCACHED |
+			TTM_PL_FLAG_WC;
+		default_caching = TTM_PL_FLAG_WC;
 	}
 #endif
 
-	return ttm_range_man_init(&rdev->mman.bdev, man,
+	return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_TT,
+				  available_caching,
+				  default_caching, true,
 				  rdev->mc.gtt_size >> PAGE_SHIFT);
 }
 
@@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 		}
 		radeon_bo_unref(&rdev->stolen_vga_memory);
 	}
-	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM));
-	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT));
+	ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_VRAM);
+	ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_TT);
 	ttm_bo_device_release(&rdev->mman.bdev);
 	radeon_gart_fini(rdev);
 	rdev->mman.initialized = false;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 86bf5e71e959..d83cb967a107 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
 
 int ttm_range_man_init(struct ttm_bo_device *bdev,
-		       struct ttm_mem_type_manager *man,
+		       unsigned type,
+		       uint32_t available_caching,
+		       uint32_t default_caching,
+		       bool use_tt,
 		       unsigned long p_size)
 {
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
 	struct ttm_range_manager *rman;
 
-	man->func = &ttm_bo_manager_func;
-
-	ttm_mem_type_manager_init(bdev, man, p_size);
+	man->available_caching = available_caching;
+	man->default_caching = default_caching;
+	man->use_tt = use_tt;
 
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
 	if (!rman)
 		return -ENOMEM;
 
+	man->func = &ttm_bo_manager_func;
+
+	ttm_mem_type_manager_init(bdev, man, p_size);
+
 	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
 	man->priv = rman;
@@ -130,8 +138,9 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 EXPORT_SYMBOL(ttm_range_man_init);
 
 int ttm_range_man_fini(struct ttm_bo_device *bdev,
-		       struct ttm_mem_type_manager *man)
+		       unsigned type)
 {
+	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
 	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
 	struct drm_mm *mm = &rman->mm;
 	int ret;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 6ed92f38b54b..7168403fb4f8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -626,13 +626,9 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	ret = vmw_thp_init(dev_priv);
 #else
-	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
-
-	man->available_caching = TTM_PL_FLAG_CACHED;
-	man->default_caching = TTM_PL_FLAG_CACHED;
-
-	ret = ttm_range_man_init(&dev_priv->bdev, man,
-				 dev_priv->vram_size >> PAGE_SHIFT);
+	ret = ttm_range_man_init(&dev_priv->bdev, TTM_PL_VRAM,
+				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
+				 false, dev_priv->vram_size >> PAGE_SHIFT);
 #endif
 	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
 	return ret;
@@ -643,8 +639,7 @@ static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	vmw_thp_fini(dev_priv);
 #else
-	ttm_bo_man_fini(&dev_priv->bdev,
-			ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM));
+	ttm_bo_man_fini(&dev_priv->bdev, TTM_PL_VRAM);
 #endif
 }
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 6940d85a531a..789c1eb26859 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -845,14 +845,20 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
  * ttm_range_man_init
  *
  * @bdev: ttm device
- * @man: the manager to initialise with the range manager.
+ * @type: memory manager type
+ * @available_caching: TTM_PL_FLAG_* for allowed caching modes
+ * @default_caching: default caching mode
+ * @use_tt: if the memory manager uses tt
  * @p_size: size of area to be managed in pages.
  *
  * Initialise a generic range manager for the selected memory type.
  * The range manager is installed for this device in the type slot.
  */
 int ttm_range_man_init(struct ttm_bo_device *bdev,
-		       struct ttm_mem_type_manager *man,
+		       unsigned type,
+		       uint32_t available_caching,
+		       uint32_t default_caching,
+		       bool use_tt,
 		       unsigned long p_size);
 
 /**
@@ -864,7 +870,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
  * Remove the generic range manager from a slot and tear it down.
  */
 int ttm_range_man_fini(struct ttm_bo_device *bdev,
-		       struct ttm_mem_type_manager *man);
+		       unsigned type);
 
 /**
  * ttm_mem_type_manager_debug
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (45 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:52   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed Dave Airlie
                   ` (13 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 31 +++++++++++++++++-----------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index d83cb967a107..01d41c6f2f7b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -44,16 +44,22 @@
  */
 
 struct ttm_range_manager {
+	struct ttm_mem_type_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 };
 
+static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man)
+{
+	return container_of(man, struct ttm_range_manager, manager);
+}
+
 static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
 			       struct ttm_buffer_object *bo,
 			       const struct ttm_place *place,
 			       struct ttm_mem_reg *mem)
 {
-	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
+	struct ttm_range_manager *rman = to_range_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	struct drm_mm_node *node;
 	enum drm_mm_insert_mode mode;
@@ -92,7 +98,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
 static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 				struct ttm_mem_reg *mem)
 {
-	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
+	struct ttm_range_manager *rman = to_range_manager(man);
 
 	if (mem->mm_node) {
 		spin_lock(&rman->lock);
@@ -113,25 +119,26 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       bool use_tt,
 		       unsigned long p_size)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
+	struct ttm_mem_type_manager *man;
 	struct ttm_range_manager *rman;
 
-	man->available_caching = available_caching;
-	man->default_caching = default_caching;
-	man->use_tt = use_tt;
-
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
 	if (!rman)
 		return -ENOMEM;
 
+	man = &rman->manager;
+	man->available_caching = available_caching;
+	man->default_caching = default_caching;
+	man->use_tt = use_tt;
+
 	man->func = &ttm_bo_manager_func;
 
 	ttm_mem_type_manager_init(bdev, man, p_size);
 
 	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
-	man->priv = rman;
 
+	ttm_set_driver_manager(bdev, type, &rman->manager);
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -141,7 +148,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 		       unsigned type)
 {
 	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
-	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
+	struct ttm_range_manager *rman = to_range_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
@@ -155,10 +162,10 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 	drm_mm_clean(mm);
 	drm_mm_takedown(mm);
 	spin_unlock(&rman->lock);
-	kfree(rman);
-	man->priv = NULL;
 
 	ttm_mem_type_manager_cleanup(man);
+	ttm_set_driver_manager(bdev, type, NULL);
+	kfree(rman);
 	return 0;
 }
 EXPORT_SYMBOL(ttm_range_man_fini);
@@ -166,7 +173,7 @@ EXPORT_SYMBOL(ttm_range_man_fini);
 static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 			     struct drm_printer *printer)
 {
-	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
+	struct ttm_range_manager *rman = to_range_manager(man);
 
 	spin_lock(&rman->lock);
 	drm_mm_print(&rman->mm, printer);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (46 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  9:24   ` daniel
  2020-08-04  2:56 ` [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation Dave Airlie
                   ` (12 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 32 +++++++++++++++++++----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 720a24214c74..1cefd9c1e8ea 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -16,10 +16,16 @@
  * @lock: Manager lock.
  */
 struct vmw_thp_manager {
+	struct ttm_mem_type_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 };
 
+static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man)
+{
+	return container_of(man, struct vmw_thp_manager, manager);
+}
+
 static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
 				  unsigned long align_pages,
 				  const struct ttm_place *place,
@@ -43,7 +49,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
 			    const struct ttm_place *place,
 			    struct ttm_mem_reg *mem)
 {
-	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
+	struct vmw_thp_manager *rman = to_thp_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	struct drm_mm_node *node;
 	unsigned long align_pages;
@@ -103,7 +109,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
 static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
 			     struct ttm_mem_reg *mem)
 {
-	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
+	struct vmw_thp_manager *rman = to_thp_manager(man);
 
 	if (mem->mm_node) {
 		spin_lock(&rman->lock);
@@ -117,20 +123,24 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
 
 int vmw_thp_init(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+	struct ttm_mem_type_manager *man;
 	struct vmw_thp_manager *rman;
+
+	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
+	if (!rman)
+		return -ENOMEM;
+
+	man = &rman->manager;
 	man->available_caching = TTM_PL_FLAG_CACHED;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
 	ttm_mem_type_manager_init(&dev_priv->bdev, man,
 				  dev_priv->vram_size >> PAGE_SHIFT);
-	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
-	if (!rman)
-		return -ENOMEM;
 
 	drm_mm_init(&rman->mm, 0, man->size);
 	spin_lock_init(&rman->lock);
-	man->priv = rman;
+
+	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -138,7 +148,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
 void vmw_thp_fini(struct vmw_private *dev_priv)
 {
 	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
-	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
+	struct vmw_thp_manager *rman = to_thp_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
@@ -151,15 +161,15 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
 	drm_mm_clean(mm);
 	drm_mm_takedown(mm);
 	spin_unlock(&rman->lock);
-	kfree(rman);
-	man->priv = NULL;
 	ttm_mem_type_manager_cleanup(man);
+	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
+	kfree(rman);
 }
 
 static void vmw_thp_debug(struct ttm_mem_type_manager *man,
 			  struct drm_printer *printer)
 {
-	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
+	struct vmw_thp_manager *rman = to_thp_manager(man);
 
 	spin_lock(&rman->lock);
 	drm_mm_print(&rman->mm, printer);
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (47 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  9:26   ` daniel
  2020-08-04  2:56 ` [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager Dave Airlie
                   ` (11 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 32 +++++++++++--------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index 54c85a59dd8b..bc51b7773084 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -37,6 +37,7 @@
 #include <linux/kernel.h>
 
 struct vmwgfx_gmrid_man {
+	struct ttm_mem_type_manager manager;
 	spinlock_t lock;
 	struct ida gmr_ida;
 	uint32_t max_gmr_ids;
@@ -44,13 +45,17 @@ struct vmwgfx_gmrid_man {
 	uint32_t used_gmr_pages;
 };
 
+static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man)
+{
+	return container_of(man, struct vmwgfx_gmrid_man, manager);
+}
+
 static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
 				  struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
 				  struct ttm_mem_reg *mem)
 {
-	struct vmwgfx_gmrid_man *gman =
-		(struct vmwgfx_gmrid_man *)man->priv;
+	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 	int id;
 
 	id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL);
@@ -82,8 +87,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
 static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
 				   struct ttm_mem_reg *mem)
 {
-	struct vmwgfx_gmrid_man *gman =
-		(struct vmwgfx_gmrid_man *)man->priv;
+	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 
 	if (mem->mm_node) {
 		ida_free(&gman->gmr_ida, mem->start);
@@ -98,13 +102,15 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
 
 int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
+	struct ttm_mem_type_manager *man;
 	struct vmwgfx_gmrid_man *gman =
 		kzalloc(sizeof(*gman), GFP_KERNEL);
 
 	if (unlikely(!gman))
 		return -ENOMEM;
 
+	man = &gman->manager;
+
 	man->func = &vmw_gmrid_manager_func;
 	man->available_caching = TTM_PL_FLAG_CACHED;
 	man->default_caching = TTM_PL_FLAG_CACHED;
@@ -127,8 +133,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 	default:
 		BUG();
 	}
-	man->priv = (void *) gman;
-
+	ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager);
 	ttm_mem_type_manager_set_used(man, true);
 	return 0;
 }
@@ -136,19 +141,18 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 {
 	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
-	struct vmwgfx_gmrid_man *gman =
-		(struct vmwgfx_gmrid_man *)man->priv;
+	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 
 	ttm_mem_type_manager_disable(man);
 
 	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
 
-	if (gman) {
-		ida_destroy(&gman->gmr_ida);
-		kfree(gman);
-	}
-
 	ttm_mem_type_manager_cleanup(man);
+
+	ttm_set_driver_manager(&dev_priv->bdev, type, NULL);
+	ida_destroy(&gman->gmr_ida);
+	kfree(gman);
+
 }
 
 static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (48 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:53   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 51/59] drm/ttm: drop priv pointer in memory manager Dave Airlie
                   ` (10 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 45 +++++++++++++++++++--------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 1c636723823c..58d9bd708e95 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -157,12 +157,12 @@ static int
 nouveau_ttm_init_vram(struct nouveau_drm *drm)
 {
 	struct nvif_mmu *mmu = &drm->client.mmu;
-
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
-		struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
-
 		/* Some BARs do not support being ioremapped WC */
 		const u8 type = mmu->type[drm->ttm.type_vram].type;
+		struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
+		if (!man)
+			return -ENOMEM;
 
 		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 		man->default_caching = TTM_PL_FLAG_WC;
@@ -174,8 +174,10 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 
 		man->func = &nouveau_vram_manager;
 		man->use_io_reserve_lru = true;
+
 		ttm_mem_type_manager_init(&drm->ttm.bdev, man,
 					  drm->gem.vram_available >> PAGE_SHIFT);
+		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
 		ttm_mem_type_manager_set_used(man, true);
 		return 0;
 	} else {
@@ -195,6 +197,8 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 		ttm_mem_type_manager_disable(man);
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
 		ttm_mem_type_manager_cleanup(man);
+		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
+		kfree(man);
 	} else
 		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
 }
@@ -202,30 +206,43 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 static int
 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
+	struct ttm_mem_type_manager *man;
 	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
-	man->use_tt = true;
+	unsigned available_caching, default_caching;
+	const struct ttm_mem_type_manager_func *func = NULL;
 	if (drm->agp.bridge) {
-		man->available_caching = TTM_PL_FLAG_UNCACHED |
+		available_caching = TTM_PL_FLAG_UNCACHED |
 			TTM_PL_FLAG_WC;
-		man->default_caching = TTM_PL_FLAG_WC;
+		default_caching = TTM_PL_FLAG_WC;
 	} else {
-		man->available_caching = TTM_PL_MASK_CACHING;
-		man->default_caching = TTM_PL_FLAG_CACHED;
+		available_caching = TTM_PL_MASK_CACHING;
+		default_caching = TTM_PL_FLAG_CACHED;
 	}
 
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
-		man->func = &nouveau_gart_manager;
+		func = &nouveau_gart_manager;
 	else if (!drm->agp.bridge)
-		man->func = &nv04_gart_manager;
+		func = &nv04_gart_manager;
 	else
 		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
-					  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
-					  TTM_PL_FLAG_WC, true,
+					  available_caching, default_caching,
+					  true,
 					  size_pages);
+
+	man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
+	if (!man)
+		return -ENOMEM;
+
+	man->func = func;
+	man->available_caching = available_caching;
+	man->default_caching = default_caching;
+	man->use_tt = true;
 	ttm_mem_type_manager_init(&drm->ttm.bdev, man,
 				  size_pages);
+
+	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
 	ttm_mem_type_manager_set_used(man, true);
+
 	return 0;
 }
 
@@ -241,6 +258,8 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 		ttm_mem_type_manager_disable(man);
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
 		ttm_mem_type_manager_cleanup(man);
+		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
+		kfree(man);
 	}
 }
 
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 51/59] drm/ttm: drop priv pointer in memory manager
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (49 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:54   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 52/59] drm/amdgpu/ttm: remove man->bdev references Dave Airlie
                   ` (9 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This isn't needed anymore by any drivers.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 include/drm/ttm/ttm_bo_driver.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 789c1eb26859..b477c1ad5c3e 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -123,7 +123,6 @@ struct ttm_mem_type_manager_func {
  * @default_caching: The default caching policy used for a buffer object
  * placed in this memory type if the user doesn't provide one.
  * @func: structure pointer implementing the range manager. See above
- * @priv: Driver private closure for @func.
  * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures
  * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions
  * reserved by the TTM vm system.
@@ -152,7 +151,6 @@ struct ttm_mem_type_manager {
 	uint32_t available_caching;
 	uint32_t default_caching;
 	const struct ttm_mem_type_manager_func *func;
-	void *priv;
 	struct mutex io_reserve_mutex;
 	bool use_io_reserve_lru;
 	spinlock_t move_lock;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 52/59] drm/amdgpu/ttm: remove man->bdev references.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (50 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 51/59] drm/ttm: drop priv pointer in memory manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04  2:56 ` [PATCH 53/59] drm/ttm: drop man->bdev link Dave Airlie
                   ` (8 subsequent siblings)
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

Just store the device in the private so the link
can be removed from the manager

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 2b37f4266dcb..bbc528c0ed3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -34,6 +34,7 @@ struct amdgpu_vram_mgr {
 	spinlock_t lock;
 	atomic64_t usage;
 	atomic64_t vis_usage;
+	struct amdgpu_device *adev;
 };
 
 static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
@@ -196,6 +197,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 	drm_mm_init(&mgr->mm, 0, man->size);
 	spin_lock_init(&mgr->lock);
 
+	mgr->adev = adev;
+
 	/* Add the two VRAM-related sysfs files */
 	ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
 	if (ret)
@@ -323,8 +326,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
 			       const struct ttm_place *place,
 			       struct ttm_mem_reg *mem)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
+	struct amdgpu_device *adev = mgr->adev;
 	struct drm_mm *mm = &mgr->mm;
 	struct drm_mm_node *nodes;
 	enum drm_mm_insert_mode mode;
@@ -439,8 +442,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
 static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
 				struct ttm_mem_reg *mem)
 {
-	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
+	struct amdgpu_device *adev = mgr->adev;
 	struct drm_mm_node *nodes = mem->mm_node;
 	uint64_t usage = 0, vis_usage = 0;
 	unsigned pages = mem->num_pages;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 53/59] drm/ttm: drop man->bdev link.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (51 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 52/59] drm/amdgpu/ttm: remove man->bdev references Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-05  5:54   ` Ben Skeggs
  2020-08-04  2:56 ` [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2) Dave Airlie
                   ` (7 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This link isn't needed anymore, drop it from the init interface.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         | 6 ++----
 drivers/gpu/drm/ttm/ttm_bo.c                  | 6 ++----
 drivers/gpu/drm/ttm/ttm_bo_manager.c          | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           | 2 +-
 include/drm/ttm/ttm_bo_api.h                  | 6 ++----
 include/drm/ttm/ttm_bo_driver.h               | 2 --
 9 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index b664c5cb13ce..9fc3d876ed38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
+	ttm_mem_type_manager_init(man, gtt_size >> PAGE_SHIFT);
 
 	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
 	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index bbc528c0ed3e..684698cdf772 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
 
-	ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
+	ttm_mem_type_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
 
 	man->func = &amdgpu_vram_mgr_func;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 58d9bd708e95..d408e1485cce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -175,7 +175,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 		man->func = &nouveau_vram_manager;
 		man->use_io_reserve_lru = true;
 
-		ttm_mem_type_manager_init(&drm->ttm.bdev, man,
+		ttm_mem_type_manager_init(man,
 					  drm->gem.vram_available >> PAGE_SHIFT);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
 		ttm_mem_type_manager_set_used(man, true);
@@ -237,9 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	man->available_caching = available_caching;
 	man->default_caching = default_caching;
 	man->use_tt = true;
-	ttm_mem_type_manager_init(&drm->ttm.bdev, man,
-				  size_pages);
-
+	ttm_mem_type_manager_init(man, size_pages);
 	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
 	ttm_mem_type_manager_set_used(man, true);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3a3a4dfb0fff..78b72443a9ef 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1471,8 +1471,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 }
 EXPORT_SYMBOL(ttm_bo_evict_mm);
 
-void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
-			       struct ttm_mem_type_manager *man,
+void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
 			       unsigned long p_size)
 {
 	unsigned i;
@@ -1482,7 +1481,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
 	mutex_init(&man->io_reserve_mutex);
 	spin_lock_init(&man->move_lock);
 	INIT_LIST_HEAD(&man->io_reserve_lru);
-	man->bdev = bdev;
 	man->size = p_size;
 
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
@@ -1595,7 +1593,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(bdev, man, 0);
+	ttm_mem_type_manager_init(man, 0);
 	ttm_mem_type_manager_set_used(man, true);
 }
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 01d41c6f2f7b..1b7245ce3356 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -133,7 +133,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 
 	man->func = &ttm_bo_manager_func;
 
-	ttm_mem_type_manager_init(bdev, man, p_size);
+	ttm_mem_type_manager_init(man, p_size);
 
 	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index bc51b7773084..c3fa25161fd0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 	man->default_caching = TTM_PL_FLAG_CACHED;
 	/* TODO: This is most likely not correct */
 	man->use_tt = true;
-	ttm_mem_type_manager_init(&dev_priv->bdev, man, 0);
+	ttm_mem_type_manager_init(man, 0);
 	spin_lock_init(&gman->lock);
 	gman->used_gmr_pages = 0;
 	ida_init(&gman->gmr_ida);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 1cefd9c1e8ea..0b9c29249393 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -134,7 +134,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
 	man->available_caching = TTM_PL_FLAG_CACHED;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(&dev_priv->bdev, man,
+	ttm_mem_type_manager_init(man,
 				  dev_priv->vram_size >> PAGE_SHIFT);
 
 	drm_mm_init(&rman->mm, 0, man->size);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 9c55eafd0e7d..eb465e9ca0c1 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -536,14 +536,12 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
 /**
  * ttm_mem_type_manager_init
  *
- * @bdev: Pointer to a ttm_bo_device struct.
  * @man: memory manager object to init
  * @p_size: size managed area in pages.
  *
- * Initialise core parts of a a manager object.
+ * Initialise core parts of a manager object.
  */
-void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
-			       struct ttm_mem_type_manager *man,
+void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
 			       unsigned long p_size);
 
 /**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index b477c1ad5c3e..bfd19400372f 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -138,8 +138,6 @@ struct ttm_mem_type_manager_func {
 
 
 struct ttm_mem_type_manager {
-	struct ttm_bo_device *bdev;
-
 	/*
 	 * No protection. Constant from start.
 	 */
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (52 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 53/59] drm/ttm: drop man->bdev link Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:37   ` Christian König
  2020-08-04  2:56 ` [PATCH 55/59] drm/ttm: drop type manager has_type Dave Airlie
                   ` (6 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The driver now controls these, the core just controls the system
memory one.

v2: init sysman explicitly and assign it as a driver manager
to simplify the lookup sequence.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 6 +++---
 include/drm/ttm/ttm_bo_driver.h | 6 ++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 78b72443a9ef..12abe46bfbc1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1558,6 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 
 	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
 	ttm_mem_type_manager_disable(man);
+	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
 
 	mutex_lock(&ttm_global_mutex);
 	list_del(&bdev->device_list);
@@ -1583,7 +1584,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
 
 static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
+	struct ttm_mem_type_manager *man = &bdev->sysman;
 
 	/*
 	 * Initialize the system memory buffer type.
@@ -1594,6 +1595,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
 	ttm_mem_type_manager_init(man, 0);
+	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
 	ttm_mem_type_manager_set_used(man, true);
 }
 
@@ -1615,8 +1617,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 
 	bdev->driver = driver;
 
-	memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
-
 	ttm_bo_init_sysman(bdev);
 
 	bdev->vma_manager = vma_manager;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index bfd19400372f..d5646d7cac60 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -414,7 +414,7 @@ struct ttm_bo_device {
 	/*
 	 * access via ttm_manager_type.
 	 */
-	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
+	struct ttm_mem_type_manager sysman;
 	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
 	/*
 	 * Protected by internal locks.
@@ -446,9 +446,7 @@ struct ttm_bo_device {
 static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
-	if (bdev->man_drv[mem_type])
-		return bdev->man_drv[mem_type];
-	return &bdev->man_priv[mem_type];
+	return bdev->man_drv[mem_type];
 }
 
 static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 55/59] drm/ttm: drop type manager has_type
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (53 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2) Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:37   ` Christian König
  2020-08-04  2:56 ` [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use Dave Airlie
                   ` (5 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

under driver control, this flag isn't needed anymore,
remove the API that used to access it, and consoldiate
with the used api.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |  2 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 ++--
 drivers/gpu/drm/ttm/ttm_bo.c                  |  8 +++-----
 drivers/gpu/drm/ttm/ttm_bo_manager.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  2 +-
 include/drm/ttm/ttm_bo_driver.h               | 17 -----------------
 8 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9fc3d876ed38..71461d652fcc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	int ret;
 
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 
 	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
 	if (ret)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 684698cdf772..8cc44c3d2fdd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	int ret;
 
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 
 	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
 	if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index d408e1485cce..22185a8dcfa1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -194,7 +194,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
-		ttm_mem_type_manager_disable(man);
+		ttm_mem_type_manager_set_used(man, false);
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
 		ttm_mem_type_manager_cleanup(man);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
@@ -253,7 +253,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 	    drm->agp.bridge)
 		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
 	else {
-		ttm_mem_type_manager_disable(man);
+		ttm_mem_type_manager_set_used(man, false);
 		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
 		ttm_mem_type_manager_cleanup(man);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 12abe46bfbc1..cda33b4af681 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -80,7 +80,6 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
 void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
 				struct drm_printer *p)
 {
-	drm_printf(p, "    has_type: %d\n", man->has_type);
 	drm_printf(p, "    use_type: %d\n", man->use_type);
 	drm_printf(p, "    use_tt: %d\n", man->use_tt);
 	drm_printf(p, "    size: %llu\n", man->size);
@@ -1003,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 		return ret;
 
 	man = ttm_manager_type(bdev, mem_type);
-	if (!man->has_type || !man->use_type)
+	if (!man || !man->use_type)
 		return -EBUSY;
 
 	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
@@ -1462,7 +1461,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return -EINVAL;
 	}
 
-	if (!man->has_type) {
+	if (!man) {
 		pr_err("Memory type %u has not been initialized\n", mem_type);
 		return 0;
 	}
@@ -1476,7 +1475,6 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
 {
 	unsigned i;
 
-	BUG_ON(man->has_type);
 	man->use_io_reserve_lru = false;
 	mutex_init(&man->io_reserve_mutex);
 	spin_lock_init(&man->move_lock);
@@ -1557,7 +1555,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 	struct ttm_mem_type_manager *man;
 
 	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
 
 	mutex_lock(&ttm_global_mutex);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 1b7245ce3356..6679dc11934f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -152,7 +152,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 
 	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
 	if (ret)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index c3fa25161fd0..ca5037184814 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -143,7 +143,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 
 	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 0b9c29249393..4110e8309188 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -152,7 +152,7 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
-	ttm_mem_type_manager_disable(man);
+	ttm_mem_type_manager_set_used(man, false);
 
 	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
 	if (ret)
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index d5646d7cac60..300934289e64 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -111,7 +111,6 @@ struct ttm_mem_type_manager_func {
 /**
  * struct ttm_mem_type_manager
  *
- * @has_type: The memory type has been initialized.
  * @use_type: The memory type is enabled.
  * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
  * managed by this memory type.
@@ -141,8 +140,6 @@ struct ttm_mem_type_manager {
 	/*
 	 * No protection. Constant from start.
 	 */
-
-	bool has_type;
 	bool use_type;
 	bool use_tt;
 	uint64_t size;
@@ -678,23 +675,9 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
  */
 static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
 {
-	man->has_type = true;
 	man->use_type = used;
 }
 
-/**
- * ttm_mem_type_manager_disable.
- *
- * @man: A memory manager object.
- *
- * Indicate the manager is not to be used and deregistered. (temporary during rework).
- */
-static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
-{
-	man->has_type = false;
-	man->use_type = false;
-}
-
 /**
  * ttm_mem_type_manager_cleanup
  *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (54 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 55/59] drm/ttm: drop type manager has_type Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:38   ` Christian König
  2020-08-05  9:04   ` daniel
  2020-08-04  2:56 ` [PATCH 57/59] drm/ttm: rename bo manager to range manager Dave Airlie
                   ` (4 subsequent siblings)
  60 siblings, 2 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This converts vmwgfx over to using an interface to set the
in use and check the in use flag.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_ttm.c |  1 -
 drivers/gpu/drm/ttm/ttm_bo.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 14 +++++++-------
 include/drm/ttm/ttm_bo_driver.h       | 14 ++++++++++++++
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 22185a8dcfa1..38a0e4bd16f7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	ttm_mem_type_manager_init(man, size_pages);
 	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
 	ttm_mem_type_manager_set_used(man, true);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cda33b4af681..7d10abae9a60 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 		return ret;
 
 	man = ttm_manager_type(bdev, mem_type);
-	if (!man || !man->use_type)
+	if (!man || !ttm_mem_type_manager_used(man))
 		return -EBUSY;
 
 	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 7168403fb4f8..b2f1e7a3b048 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
 				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
 				 false, dev_priv->vram_size >> PAGE_SHIFT);
 #endif
-	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
+	ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
 	return ret;
 }
 
@@ -1192,9 +1192,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)
 	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 
 	spin_lock(&dev_priv->svga_lock);
-	if (!man->use_type) {
+	if (!ttm_mem_type_manager_used(man)) {
 		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
-		man->use_type = true;
+		ttm_mem_type_manager_set_used(man, true);
 	}
 	spin_unlock(&dev_priv->svga_lock);
 }
@@ -1223,8 +1223,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
 	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 
 	spin_lock(&dev_priv->svga_lock);
-	if (man->use_type) {
-		man->use_type = false;
+	if (ttm_mem_type_manager_used(man)) {
+		ttm_mem_type_manager_set_used(man, false);
 		vmw_write(dev_priv, SVGA_REG_ENABLE,
 			  SVGA_REG_ENABLE_HIDE |
 			  SVGA_REG_ENABLE_ENABLE);
@@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
 	vmw_kms_lost_device(dev_priv->dev);
 	ttm_write_lock(&dev_priv->reservation_sem, false);
 	spin_lock(&dev_priv->svga_lock);
-	if (man->use_type) {
-		man->use_type = false;
+	if (ttm_mem_type_manager_used(man)) {
+		ttm_mem_type_manager_set_used(man, false);
 		spin_unlock(&dev_priv->svga_lock);
 		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
 			DRM_ERROR("Failed evicting VRAM buffers.\n");
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 300934289e64..f231fe34e744 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -678,6 +678,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
 	man->use_type = used;
 }
 
+/**
+ * ttm_mem_type_manager_used
+ *
+ * @man: Manager to get used state for
+ *
+ * Get the in use flag for a manager.
+ * Returns:
+ * true is used, false if not.
+ */
+static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
+{
+	return man->use_type;
+}
+
 /**
  * ttm_mem_type_manager_cleanup
  *
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 57/59] drm/ttm: rename bo manager to range manager.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (55 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:40   ` Christian König
  2020-08-04  2:56 ` [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager Dave Airlie
                   ` (3 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

The generic manager is called the range manager now, rename
the file and some internals.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/Makefile                  |  2 +-
 .../{ttm_bo_manager.c => ttm_range_manager.c} | 26 +++++++++----------
 2 files changed, 14 insertions(+), 14 deletions(-)
 rename drivers/gpu/drm/ttm/{ttm_bo_manager.c => ttm_range_manager.c} (88%)

diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
index caea2a099496..e54326e6cea4 100644
--- a/drivers/gpu/drm/ttm/Makefile
+++ b/drivers/gpu/drm/ttm/Makefile
@@ -4,7 +4,7 @@
 
 ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
 	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
-	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
+	ttm_execbuf_util.o ttm_page_alloc.o ttm_range_manager.o
 ttm-$(CONFIG_AGP) += ttm_agp_backend.o
 ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
similarity index 88%
rename from drivers/gpu/drm/ttm/ttm_bo_manager.c
rename to drivers/gpu/drm/ttm/ttm_range_manager.c
index 6679dc11934f..52d9a0ed7165 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
@@ -54,10 +54,10 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_man
 	return container_of(man, struct ttm_range_manager, manager);
 }
 
-static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
-			       struct ttm_buffer_object *bo,
-			       const struct ttm_place *place,
-			       struct ttm_mem_reg *mem)
+static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
+				  struct ttm_buffer_object *bo,
+				  const struct ttm_place *place,
+				  struct ttm_mem_reg *mem)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
 	struct drm_mm *mm = &rman->mm;
@@ -95,8 +95,8 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
 	return ret;
 }
 
-static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
-				struct ttm_mem_reg *mem)
+static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
+				   struct ttm_mem_reg *mem)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
 
@@ -110,7 +110,7 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
+static const struct ttm_mem_type_manager_func ttm_range_manager_func;
 
 int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       unsigned type,
@@ -131,7 +131,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 	man->default_caching = default_caching;
 	man->use_tt = use_tt;
 
-	man->func = &ttm_bo_manager_func;
+	man->func = &ttm_range_manager_func;
 
 	ttm_mem_type_manager_init(man, p_size);
 
@@ -170,7 +170,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_range_man_fini);
 
-static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
+static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
 			     struct drm_printer *printer)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
@@ -180,8 +180,8 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
 	spin_unlock(&rman->lock);
 }
 
-static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
-	.get_node = ttm_bo_man_get_node,
-	.put_node = ttm_bo_man_put_node,
-	.debug = ttm_bo_man_debug
+static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
+	.get_node = ttm_range_man_get_node,
+	.put_node = ttm_range_man_put_node,
+	.debug = ttm_range_man_debug
 };
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (56 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 57/59] drm/ttm: rename bo manager to range manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:41   ` Christian König
  2020-08-04  2:56 ` [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource Dave Airlie
                   ` (2 subsequent siblings)
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This name makes a lot more sense, since these are about managing
driver resources rather than just memory ranges.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   | 36 +++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       |  8 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 36 +++++-----
 drivers/gpu/drm/drm_gem_vram_helper.c         |  4 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         | 46 ++++++-------
 drivers/gpu/drm/nouveau/nouveau_ttm.h         |  6 +-
 drivers/gpu/drm/qxl/qxl_ttm.c                 |  4 +-
 drivers/gpu/drm/radeon/radeon_gem.c           |  2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c           |  4 +-
 drivers/gpu/drm/ttm/ttm_bo.c                  | 66 +++++++++----------
 drivers/gpu/drm/ttm/ttm_bo_util.c             | 26 ++++----
 drivers/gpu/drm/ttm/ttm_bo_vm.c               |  2 +-
 drivers/gpu/drm/ttm/ttm_range_manager.c       | 28 ++++----
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 20 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 26 ++++----
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           | 26 ++++----
 include/drm/ttm/ttm_bo_api.h                  |  6 +-
 include/drm/ttm/ttm_bo_driver.h               | 60 ++++++++---------
 23 files changed, 210 insertions(+), 210 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index e24f421e5553..478f67498a17 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -517,7 +517,7 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
 uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 
 	return amdgpu_vram_mgr_usage(vram_man);
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 9829640e1769..ecd051976bce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
 {
 	s64 time_us, increment_us;
 	u64 free_vram, total_vram, used_vram;
-	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	/* Allow a maximum of 200 accumulated ms. This is basically per-IB
 	 * throttling.
 	 *
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 71461d652fcc..8b600b804f34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -25,13 +25,13 @@
 #include "amdgpu.h"
 
 struct amdgpu_gtt_mgr {
-	struct ttm_mem_type_manager manager;
+	struct ttm_resource_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 	atomic64_t available;
 };
 
-static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man)
+static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_resource_manager *man)
 {
 	return container_of(man, struct amdgpu_gtt_mgr, manager);
 }
@@ -54,7 +54,7 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
 			man->size * PAGE_SIZE);
 }
@@ -72,7 +72,7 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
 			amdgpu_gtt_mgr_usage(man));
 }
@@ -82,7 +82,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
 static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
 	           amdgpu_mem_info_gtt_used_show, NULL);
 
-static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
+static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
 /**
  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
  *
@@ -93,7 +93,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
  */
 int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	struct amdgpu_gtt_mgr *mgr;
 	uint64_t start, size;
 	int ret;
@@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(man, gtt_size >> PAGE_SHIFT);
+	ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
 
 	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
 	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
@@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 	}
 
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 
@@ -142,13 +142,13 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
  */
 void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	int ret;
 
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 
-	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
+	ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
 	if (ret)
 		return;
 
@@ -159,7 +159,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
 	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
 
-	ttm_mem_type_manager_cleanup(man);
+	ttm_resource_manager_cleanup(man);
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
 	kfree(mgr);
 }
@@ -186,7 +186,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
  *
  * Dummy, allocate the node but no space for it yet.
  */
-static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
+static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 			      struct ttm_buffer_object *tbo,
 			      const struct ttm_place *place,
 			      struct ttm_mem_reg *mem)
@@ -249,7 +249,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
  *
  * Free the allocated GTT again.
  */
-static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
+static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
 			       struct ttm_mem_reg *mem)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
@@ -272,7 +272,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
  *
  * Return how many bytes are used in the GTT domain
  */
-uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
+uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	s64 result = man->size - atomic64_read(&mgr->available);
@@ -280,7 +280,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
 	return (result > 0 ? result : 0) * PAGE_SIZE;
 }
 
-int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
+int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node;
@@ -307,7 +307,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
  *
  * Dump the table content using printk.
  */
-static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
+static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
 				 struct drm_printer *printer)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
@@ -321,7 +321,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
 		   amdgpu_gtt_mgr_usage(man) >> 20);
 }
 
-static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
+static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
 	.get_node = amdgpu_gtt_mgr_new,
 	.put_node = amdgpu_gtt_mgr_del,
 	.debug = amdgpu_gtt_mgr_debug
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 594687cc99ac..2763bca163e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -631,9 +631,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 	}
 	case AMDGPU_INFO_MEMORY: {
 		struct drm_amdgpu_memory_info mem;
-		struct ttm_mem_type_manager *vram_man =
+		struct ttm_resource_manager *vram_man =
 			ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
-		struct ttm_mem_type_manager *gtt_man =
+		struct ttm_resource_manager *gtt_man =
 			ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
 		memset(&mem, 0, sizeof(mem));
 		mem.vram.total_heap_size = adev->gmc.real_vram_size;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index ced418cba2f7..ce98df5b0c21 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -442,7 +442,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
 static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
 					  unsigned long size, u32 domain)
 {
-	struct ttm_mem_type_manager *man = NULL;
+	struct ttm_resource_manager *man = NULL;
 
 	/*
 	 * If GTT is part of requested domains the check must succeed to
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index b190d50dc9bb..cae7eada7215 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2030,7 +2030,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	uint64_t size;
 	int r;
 
@@ -2252,7 +2252,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
 	unsigned ttm_pl = (uintptr_t)node->info_ent->data;
 	struct drm_device *dev = node->minor->dev;
 	struct amdgpu_device *adev = dev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	man->func->debug(man, &p);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index c01fdb3f0458..3db29ae1f802 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -73,8 +73,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
 void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
-uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
-int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man);
+uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
+int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
 
 u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
 int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
@@ -86,8 +86,8 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
 			      struct device *dev,
 			      enum dma_data_direction dir,
 			      struct sg_table *sgt);
-uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
-uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man);
+uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man);
+uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man);
 
 int amdgpu_ttm_init(struct amdgpu_device *adev);
 void amdgpu_ttm_late_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 8cc44c3d2fdd..b227e380094f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -29,7 +29,7 @@
 #include "atom.h"
 
 struct amdgpu_vram_mgr {
-	struct ttm_mem_type_manager manager;
+	struct ttm_resource_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 	atomic64_t usage;
@@ -37,7 +37,7 @@ struct amdgpu_vram_mgr {
 	struct amdgpu_device *adev;
 };
 
-static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
+static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_resource_manager *man)
 {
 	return container_of(man, struct amdgpu_vram_mgr, manager);
 }
@@ -89,7 +89,7 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
 			amdgpu_vram_mgr_usage(man));
 }
@@ -107,7 +107,7 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev,
 {
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = ddev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	return snprintf(buf, PAGE_SIZE, "%llu\n",
 			amdgpu_vram_mgr_vis_usage(man));
 }
@@ -165,7 +165,7 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
 	NULL
 };
 
-static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
+static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
 
 /**
  * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
@@ -177,7 +177,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
  */
 int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	struct amdgpu_vram_mgr *mgr;
 	int ret;
 
@@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
 	man->default_caching = TTM_PL_FLAG_WC;
 
-	ttm_mem_type_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
+	ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
 
 	man->func = &amdgpu_vram_mgr_func;
 
@@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 		DRM_ERROR("Failed to register sysfs\n");
 
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 
@@ -219,13 +219,13 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
  */
 void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	int ret;
 
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 
-	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
+	ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
 	if (ret)
 		return;
 
@@ -235,7 +235,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 
 	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
 
-	ttm_mem_type_manager_cleanup(man);
+	ttm_resource_manager_cleanup(man);
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
 	kfree(mgr);
 }
@@ -321,7 +321,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
  *
  * Allocate VRAM for the given BO.
  */
-static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
+static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
 			       struct ttm_buffer_object *tbo,
 			       const struct ttm_place *place,
 			       struct ttm_mem_reg *mem)
@@ -439,7 +439,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
  *
  * Free the allocated VRAM again.
  */
-static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
+static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
 				struct ttm_mem_reg *mem)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
@@ -573,7 +573,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
  *
  * Returns how many bytes are used in this domain.
  */
-uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
+uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 
@@ -587,7 +587,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
  *
  * Returns how many bytes are used in the visible part of VRAM
  */
-uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
+uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 
@@ -602,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
  *
  * Dump the table content using printk.
  */
-static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
+static void amdgpu_vram_mgr_debug(struct ttm_resource_manager *man,
 				  struct drm_printer *printer)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
@@ -616,7 +616,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
 		   amdgpu_vram_mgr_vis_usage(man) >> 20);
 }
 
-static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
+static const struct ttm_resource_manager_func amdgpu_vram_mgr_func = {
 	.get_node	= amdgpu_vram_mgr_new,
 	.put_node	= amdgpu_vram_mgr_del,
 	.debug		= amdgpu_vram_mgr_debug
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 2187787f397e..e3660d00987d 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1075,10 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
 	struct drm_printer p = drm_seq_file_printer(m);
 
-	ttm_mem_type_manager_debug(man, &p);
+	ttm_resource_manager_debug(man, &p);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 38a0e4bd16f7..d6ad0977dc7d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -32,13 +32,13 @@
 #include <core/tegra.h>
 
 static void
-nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
+nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
 {
 	nouveau_mem_del(reg);
 }
 
 static int
-nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
+nouveau_vram_manager_new(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
 			 struct ttm_mem_reg *reg)
@@ -63,13 +63,13 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
 	return 0;
 }
 
-const struct ttm_mem_type_manager_func nouveau_vram_manager = {
+const struct ttm_resource_manager_func nouveau_vram_manager = {
 	.get_node = nouveau_vram_manager_new,
 	.put_node = nouveau_manager_del,
 };
 
 static int
-nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
+nouveau_gart_manager_new(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
 			 struct ttm_mem_reg *reg)
@@ -86,13 +86,13 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
 	return 0;
 }
 
-const struct ttm_mem_type_manager_func nouveau_gart_manager = {
+const struct ttm_resource_manager_func nouveau_gart_manager = {
 	.get_node = nouveau_gart_manager_new,
 	.put_node = nouveau_manager_del,
 };
 
 static int
-nv04_gart_manager_new(struct ttm_mem_type_manager *man,
+nv04_gart_manager_new(struct ttm_resource_manager *man,
 		      struct ttm_buffer_object *bo,
 		      const struct ttm_place *place,
 		      struct ttm_mem_reg *reg)
@@ -118,7 +118,7 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
 	return 0;
 }
 
-const struct ttm_mem_type_manager_func nv04_gart_manager = {
+const struct ttm_resource_manager_func nv04_gart_manager = {
 	.get_node = nv04_gart_manager_new,
 	.put_node = nouveau_manager_del,
 };
@@ -160,7 +160,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
 		/* Some BARs do not support being ioremapped WC */
 		const u8 type = mmu->type[drm->ttm.type_vram].type;
-		struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
+		struct ttm_resource_manager *man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
 		if (!man)
 			return -ENOMEM;
 
@@ -175,10 +175,10 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 		man->func = &nouveau_vram_manager;
 		man->use_io_reserve_lru = true;
 
-		ttm_mem_type_manager_init(man,
+		ttm_resource_manager_init(man,
 					  drm->gem.vram_available >> PAGE_SHIFT);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
-		ttm_mem_type_manager_set_used(man, true);
+		ttm_resource_manager_set_used(man, true);
 		return 0;
 	} else {
 		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
@@ -191,12 +191,12 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 static void
 nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
 
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
-		ttm_mem_type_manager_set_used(man, false);
-		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
-		ttm_mem_type_manager_cleanup(man);
+		ttm_resource_manager_set_used(man, false);
+		ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
+		ttm_resource_manager_cleanup(man);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
 		kfree(man);
 	} else
@@ -206,10 +206,10 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
 static int
 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
 	unsigned available_caching, default_caching;
-	const struct ttm_mem_type_manager_func *func = NULL;
+	const struct ttm_resource_manager_func *func = NULL;
 	if (drm->agp.bridge) {
 		available_caching = TTM_PL_FLAG_UNCACHED |
 			TTM_PL_FLAG_WC;
@@ -229,7 +229,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 					  true,
 					  size_pages);
 
-	man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
+	man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
 	if (!man)
 		return -ENOMEM;
 
@@ -237,24 +237,24 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
 	man->available_caching = available_caching;
 	man->default_caching = default_caching;
 	man->use_tt = true;
-	ttm_mem_type_manager_init(man, size_pages);
+	ttm_resource_manager_init(man, size_pages);
 	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 
 static void
 nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
+	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
 
 	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
 	    drm->agp.bridge)
 		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
 	else {
-		ttm_mem_type_manager_set_used(man, false);
-		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
-		ttm_mem_type_manager_cleanup(man);
+		ttm_resource_manager_set_used(man, false);
+		ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
+		ttm_resource_manager_cleanup(man);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
 		kfree(man);
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.h b/drivers/gpu/drm/nouveau/nouveau_ttm.h
index 085280754b3e..eaf25461cd91 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.h
@@ -8,9 +8,9 @@ nouveau_bdev(struct ttm_bo_device *bd)
 	return container_of(bd, struct nouveau_drm, ttm.bdev);
 }
 
-extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
-extern const struct ttm_mem_type_manager_func nouveau_gart_manager;
-extern const struct ttm_mem_type_manager_func nv04_gart_manager;
+extern const struct ttm_resource_manager_func nouveau_vram_manager;
+extern const struct ttm_resource_manager_func nouveau_gart_manager;
+extern const struct ttm_resource_manager_func nv04_gart_manager;
 
 struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo,
 					u32 page_flags);
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index b7365b2e4c7f..1c06fe780815 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -274,10 +274,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)
 static int qxl_mm_dump_table(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data;
+	struct ttm_resource_manager *man = (struct ttm_resource_manager *)node->info_ent->data;
 	struct drm_printer p = drm_seq_file_printer(m);
 
-	ttm_mem_type_manager_debug(man, &p);
+	ttm_resource_manager_debug(man, &p);
 	return 0;
 }
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 3ec028dba739..7f5dfe04789e 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -224,7 +224,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
 {
 	struct radeon_device *rdev = dev->dev_private;
 	struct drm_radeon_gem_info *args = data;
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
 
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 474d2161da1e..05b5f29f2b61 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -836,7 +836,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
  * isn't running */
 void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	if (!rdev->mman.initialized)
 		return;
@@ -895,7 +895,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
 	unsigned ttm_pl = *(int*)node->info_ent->data;
 	struct drm_device *dev = node->minor->dev;
 	struct radeon_device *rdev = dev->dev_private;
-	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
+	struct ttm_resource_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	man->func->debug(man, &p);
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 7d10abae9a60..48840a3cf4c4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -77,7 +77,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
 	return 0;
 }
 
-void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
+void ttm_resource_manager_debug(struct ttm_resource_manager *man,
 				struct drm_printer *p)
 {
 	drm_printf(p, "    use_type: %d\n", man->use_type);
@@ -88,14 +88,14 @@ void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
 	if (man->func && man->func->debug)
 		(*man->func->debug)(man, p);
 }
-EXPORT_SYMBOL(ttm_mem_type_manager_debug);
+EXPORT_SYMBOL(ttm_resource_manager_debug);
 
 static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
 					struct ttm_placement *placement)
 {
 	struct drm_printer p = drm_debug_printer(TTM_PFX);
 	int i, ret, mem_type;
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
 		   bo, bo->mem.num_pages, bo->mem.size >> 10,
@@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
 		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
 			   i, placement->placement[i].flags, mem_type);
 		man = ttm_manager_type(bo->bdev, mem_type);
-		ttm_mem_type_manager_debug(man, &p);
+		ttm_resource_manager_debug(man, &p);
 	}
 }
 
@@ -148,7 +148,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
 				  struct ttm_mem_reg *mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	if (!list_empty(&bo->lru))
 		return;
@@ -223,7 +223,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
 
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i];
-		struct ttm_mem_type_manager *man;
+		struct ttm_resource_manager *man;
 
 		if (!pos->first)
 			continue;
@@ -238,7 +238,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
 
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i];
-		struct ttm_mem_type_manager *man;
+		struct ttm_resource_manager *man;
 
 		if (!pos->first)
 			continue;
@@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
-	struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
+	struct ttm_resource_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
+	struct ttm_resource_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 
 	ret = ttm_mem_io_lock(old_man, true);
@@ -551,7 +551,7 @@ static void ttm_bo_release(struct kref *kref)
 	struct ttm_buffer_object *bo =
 	    container_of(kref, struct ttm_buffer_object, kref);
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
 	size_t acc_size = bo->acc_size;
 	int ret;
 
@@ -768,7 +768,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
 }
 
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
-			       struct ttm_mem_type_manager *man,
+			       struct ttm_resource_manager *man,
 			       const struct ttm_place *place,
 			       struct ttm_operation_ctx *ctx,
 			       struct ww_acquire_ctx *ticket)
@@ -843,7 +843,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 			  const struct ttm_place *place,
 			  struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
 	mem->mm_node = NULL;
 	if (!man->func || !man->func->get_node)
@@ -854,7 +854,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 
 void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
 	if (!man->func || !man->func->put_node)
 		return;
@@ -869,7 +869,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
  * Add the last move fence to the BO and reserve a new shared slot.
  */
 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
-				 struct ttm_mem_type_manager *man,
+				 struct ttm_resource_manager *man,
 				 struct ttm_mem_reg *mem,
 				 bool no_wait_gpu)
 {
@@ -911,7 +911,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	struct ww_acquire_ctx *ticket;
 	int ret;
 
@@ -931,7 +931,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 	return ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
 }
 
-static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
+static uint32_t ttm_bo_select_caching(struct ttm_resource_manager *man,
 				      uint32_t cur_placement,
 				      uint32_t proposed_placement)
 {
@@ -956,7 +956,7 @@ static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
 	return result;
 }
 
-static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
+static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
 				 uint32_t mem_type,
 				 const struct ttm_place *place,
 				 uint32_t *masked_placement)
@@ -993,7 +993,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 	uint32_t mem_type = TTM_PL_SYSTEM;
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	uint32_t cur_flags = 0;
 	int ret;
 
@@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 		return ret;
 
 	man = ttm_manager_type(bdev, mem_type);
-	if (!man || !ttm_mem_type_manager_used(man))
+	if (!man || !ttm_resource_manager_used(man))
 		return -EBUSY;
 
 	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
@@ -1049,7 +1049,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 
 	for (i = 0; i < placement->num_placement; ++i) {
 		const struct ttm_place *place = &placement->placement[i];
-		struct ttm_mem_type_manager *man;
+		struct ttm_resource_manager *man;
 
 		ret = ttm_bo_mem_placement(bo, place, mem, ctx);
 		if (ret == -EBUSY)
@@ -1406,8 +1406,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_create);
 
-int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
-					  struct ttm_mem_type_manager *man)
+int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
+					  struct ttm_resource_manager *man)
 {
 	struct ttm_operation_ctx ctx = {
 		.interruptible = false,
@@ -1449,12 +1449,12 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
 
 	return 0;
 }
-EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
+EXPORT_SYMBOL(ttm_resource_manager_force_list_clean);
 
 
 int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem_type);
 
 	if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
 		pr_err("Illegal memory manager memory type %u\n", mem_type);
@@ -1466,11 +1466,11 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return 0;
 	}
 
-	return ttm_mem_type_manager_force_list_clean(bdev, man);
+	return ttm_resource_manager_force_list_clean(bdev, man);
 }
 EXPORT_SYMBOL(ttm_bo_evict_mm);
 
-void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
+void ttm_resource_manager_init(struct ttm_resource_manager *man,
 			       unsigned long p_size)
 {
 	unsigned i;
@@ -1485,7 +1485,7 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
 		INIT_LIST_HEAD(&man->lru[i]);
 	man->move = NULL;
 }
-EXPORT_SYMBOL(ttm_mem_type_manager_init);
+EXPORT_SYMBOL(ttm_resource_manager_init);
 
 static void ttm_bo_global_kobj_release(struct kobject *kobj)
 {
@@ -1552,10 +1552,10 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 	struct ttm_bo_global *glob = &ttm_bo_glob;
 	int ret = 0;
 	unsigned i;
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
 
 	mutex_lock(&ttm_global_mutex);
@@ -1582,7 +1582,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
 
 static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 {
-	struct ttm_mem_type_manager *man = &bdev->sysman;
+	struct ttm_resource_manager *man = &bdev->sysman;
 
 	/*
 	 * Initialize the system memory buffer type.
@@ -1592,9 +1592,9 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 	man->available_caching = TTM_PL_MASK_CACHING;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(man, 0);
+	ttm_resource_manager_init(man, 0);
 	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 }
 
 int ttm_bo_device_init(struct ttm_bo_device *bdev,
@@ -1645,7 +1645,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
 void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
 
 	ttm_mem_io_lock(man, false);
 	ttm_bo_unmap_virtual_locked(bo);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 879c8ded0cd8..8ef0de8e36c5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -91,7 +91,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_move_ttm);
 
-int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
+int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible)
 {
 	if (likely(!man->use_io_reserve_lru))
 		return 0;
@@ -103,7 +103,7 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
 	return 0;
 }
 
-void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
+void ttm_mem_io_unlock(struct ttm_resource_manager *man)
 {
 	if (likely(!man->use_io_reserve_lru))
 		return;
@@ -111,7 +111,7 @@ void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
 	mutex_unlock(&man->io_reserve_mutex);
 }
 
-static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
+static int ttm_mem_io_evict(struct ttm_resource_manager *man)
 {
 	struct ttm_buffer_object *bo;
 
@@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
 		       struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 
 	if (mem->bus.io_reserved_count++)
@@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
 
 int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
 	struct ttm_mem_reg *mem = &bo->mem;
 	int ret;
 
@@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
 			       struct ttm_mem_reg *mem,
 			       void **virtual)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
 	void *addr;
 
@@ -230,7 +230,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
 				struct ttm_mem_reg *mem,
 				void *virtual)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 
 	man = ttm_manager_type(bdev, mem->mem_type);
 
@@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 		       struct ttm_mem_reg *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
 	struct ttm_tt *ttm = bo->ttm;
 	struct ttm_mem_reg *old_mem = &bo->mem;
 	struct ttm_mem_reg old_copy = *old_mem;
@@ -570,7 +570,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
 		unsigned long start_page, unsigned long num_pages,
 		struct ttm_bo_kmap_obj *map)
 {
-	struct ttm_mem_type_manager *man =
+	struct ttm_resource_manager *man =
 		ttm_manager_type(bo->bdev, bo->mem.mem_type);
 	unsigned long offset, size;
 	int ret;
@@ -600,7 +600,7 @@ EXPORT_SYMBOL(ttm_bo_kmap);
 void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
 {
 	struct ttm_buffer_object *bo = map->bo;
-	struct ttm_mem_type_manager *man =
+	struct ttm_resource_manager *man =
 		ttm_manager_type(bo->bdev, bo->mem.mem_type);
 
 	if (!map->virtual)
@@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 			      struct ttm_mem_reg *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
 	struct ttm_mem_reg *old_mem = &bo->mem;
 	int ret;
 	struct ttm_buffer_object *ghost_obj;
@@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
 	struct ttm_bo_device *bdev = bo->bdev;
 	struct ttm_mem_reg *old_mem = &bo->mem;
 
-	struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
-	struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
+	struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
+	struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
 
 	int ret;
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 5ae679184eb5..c8efceef015d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -281,7 +281,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 	pgoff_t i;
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	unsigned long address = vmf->address;
-	struct ttm_mem_type_manager *man =
+	struct ttm_resource_manager *man =
 		ttm_manager_type(bdev, bo->mem.mem_type);
 
 	/*
diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
index 52d9a0ed7165..22de9f209449 100644
--- a/drivers/gpu/drm/ttm/ttm_range_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
@@ -44,17 +44,17 @@
  */
 
 struct ttm_range_manager {
-	struct ttm_mem_type_manager manager;
+	struct ttm_resource_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 };
 
-static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man)
+static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_manager *man)
 {
 	return container_of(man, struct ttm_range_manager, manager);
 }
 
-static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
+static int ttm_range_man_get_node(struct ttm_resource_manager *man,
 				  struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
 				  struct ttm_mem_reg *mem)
@@ -95,7 +95,7 @@ static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
 	return ret;
 }
 
-static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
+static void ttm_range_man_put_node(struct ttm_resource_manager *man,
 				   struct ttm_mem_reg *mem)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
@@ -110,7 +110,7 @@ static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static const struct ttm_mem_type_manager_func ttm_range_manager_func;
+static const struct ttm_resource_manager_func ttm_range_manager_func;
 
 int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       unsigned type,
@@ -119,7 +119,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 		       bool use_tt,
 		       unsigned long p_size)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	struct ttm_range_manager *rman;
 
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
@@ -133,13 +133,13 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
 
 	man->func = &ttm_range_manager_func;
 
-	ttm_mem_type_manager_init(man, p_size);
+	ttm_resource_manager_init(man, p_size);
 
 	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
 
 	ttm_set_driver_manager(bdev, type, &rman->manager);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 EXPORT_SYMBOL(ttm_range_man_init);
@@ -147,14 +147,14 @@ EXPORT_SYMBOL(ttm_range_man_init);
 int ttm_range_man_fini(struct ttm_bo_device *bdev,
 		       unsigned type)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
+	struct ttm_resource_manager *man = ttm_manager_type(bdev, type);
 	struct ttm_range_manager *rman = to_range_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 
-	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
+	ret = ttm_resource_manager_force_list_clean(bdev, man);
 	if (ret)
 		return ret;
 
@@ -163,14 +163,14 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 	drm_mm_takedown(mm);
 	spin_unlock(&rman->lock);
 
-	ttm_mem_type_manager_cleanup(man);
+	ttm_resource_manager_cleanup(man);
 	ttm_set_driver_manager(bdev, type, NULL);
 	kfree(rman);
 	return 0;
 }
 EXPORT_SYMBOL(ttm_range_man_fini);
 
-static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
+static void ttm_range_man_debug(struct ttm_resource_manager *man,
 			     struct drm_printer *printer)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
@@ -180,7 +180,7 @@ static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
 	spin_unlock(&rman->lock);
 }
 
-static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
+static const struct ttm_resource_manager_func ttm_range_manager_func = {
 	.get_node = ttm_range_man_get_node,
 	.put_node = ttm_range_man_put_node,
 	.debug = ttm_range_man_debug
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index b2f1e7a3b048..7645d67aa6b6 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
 				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
 				 false, dev_priv->vram_size >> PAGE_SHIFT);
 #endif
-	ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
+	ttm_resource_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
 	return ret;
 }
 
@@ -1189,12 +1189,12 @@ static void vmw_master_drop(struct drm_device *dev,
  */
 static void __vmw_svga_enable(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 
 	spin_lock(&dev_priv->svga_lock);
-	if (!ttm_mem_type_manager_used(man)) {
+	if (!ttm_resource_manager_used(man)) {
 		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
-		ttm_mem_type_manager_set_used(man, true);
+		ttm_resource_manager_set_used(man, true);
 	}
 	spin_unlock(&dev_priv->svga_lock);
 }
@@ -1220,11 +1220,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)
  */
 static void __vmw_svga_disable(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 
 	spin_lock(&dev_priv->svga_lock);
-	if (ttm_mem_type_manager_used(man)) {
-		ttm_mem_type_manager_set_used(man, false);
+	if (ttm_resource_manager_used(man)) {
+		ttm_resource_manager_set_used(man, false);
 		vmw_write(dev_priv, SVGA_REG_ENABLE,
 			  SVGA_REG_ENABLE_HIDE |
 			  SVGA_REG_ENABLE_ENABLE);
@@ -1241,7 +1241,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
  */
 void vmw_svga_disable(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 	/*
 	 * Disabling SVGA will turn off device modesetting capabilities, so
 	 * notify KMS about that so that it doesn't cache atomic state that
@@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
 	vmw_kms_lost_device(dev_priv->dev);
 	ttm_write_lock(&dev_priv->reservation_sem, false);
 	spin_lock(&dev_priv->svga_lock);
-	if (ttm_mem_type_manager_used(man)) {
-		ttm_mem_type_manager_set_used(man, false);
+	if (ttm_resource_manager_used(man)) {
+		ttm_resource_manager_set_used(man, false);
 		spin_unlock(&dev_priv->svga_lock);
 		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
 			DRM_ERROR("Failed evicting VRAM buffers.\n");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index ca5037184814..c8fe6e9cf092 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -37,7 +37,7 @@
 #include <linux/kernel.h>
 
 struct vmwgfx_gmrid_man {
-	struct ttm_mem_type_manager manager;
+	struct ttm_resource_manager manager;
 	spinlock_t lock;
 	struct ida gmr_ida;
 	uint32_t max_gmr_ids;
@@ -45,12 +45,12 @@ struct vmwgfx_gmrid_man {
 	uint32_t used_gmr_pages;
 };
 
-static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man)
+static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *man)
 {
 	return container_of(man, struct vmwgfx_gmrid_man, manager);
 }
 
-static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
+static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
 				  struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
 				  struct ttm_mem_reg *mem)
@@ -84,7 +84,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
 	return -ENOSPC;
 }
 
-static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
+static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
 				   struct ttm_mem_reg *mem)
 {
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
@@ -98,11 +98,11 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
 	}
 }
 
-static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
+static const struct ttm_resource_manager_func vmw_gmrid_manager_func;
 
 int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	struct vmwgfx_gmrid_man *gman =
 		kzalloc(sizeof(*gman), GFP_KERNEL);
 
@@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 	man->default_caching = TTM_PL_FLAG_CACHED;
 	/* TODO: This is most likely not correct */
 	man->use_tt = true;
-	ttm_mem_type_manager_init(man, 0);
+	ttm_resource_manager_init(man, 0);
 	spin_lock_init(&gman->lock);
 	gman->used_gmr_pages = 0;
 	ida_init(&gman->gmr_ida);
@@ -134,20 +134,20 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
 		BUG();
 	}
 	ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 
 void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
+	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, type);
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 
-	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
+	ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
 
-	ttm_mem_type_manager_cleanup(man);
+	ttm_resource_manager_cleanup(man);
 
 	ttm_set_driver_manager(&dev_priv->bdev, type, NULL);
 	ida_destroy(&gman->gmr_ida);
@@ -155,7 +155,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
 
 }
 
-static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
+static const struct ttm_resource_manager_func vmw_gmrid_manager_func = {
 	.get_node = vmw_gmrid_man_get_node,
 	.put_node = vmw_gmrid_man_put_node,
 };
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 4110e8309188..6cac7b091205 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -16,12 +16,12 @@
  * @lock: Manager lock.
  */
 struct vmw_thp_manager {
-	struct ttm_mem_type_manager manager;
+	struct ttm_resource_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
 };
 
-static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man)
+static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
 {
 	return container_of(man, struct vmw_thp_manager, manager);
 }
@@ -44,7 +44,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
 	return -ENOSPC;
 }
 
-static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
+static int vmw_thp_get_node(struct ttm_resource_manager *man,
 			    struct ttm_buffer_object *bo,
 			    const struct ttm_place *place,
 			    struct ttm_mem_reg *mem)
@@ -106,7 +106,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
 
 
 
-static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
+static void vmw_thp_put_node(struct ttm_resource_manager *man,
 			     struct ttm_mem_reg *mem)
 {
 	struct vmw_thp_manager *rman = to_thp_manager(man);
@@ -123,7 +123,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
 
 int vmw_thp_init(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man;
+	struct ttm_resource_manager *man;
 	struct vmw_thp_manager *rman;
 
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
@@ -134,39 +134,39 @@ int vmw_thp_init(struct vmw_private *dev_priv)
 	man->available_caching = TTM_PL_FLAG_CACHED;
 	man->default_caching = TTM_PL_FLAG_CACHED;
 
-	ttm_mem_type_manager_init(man,
+	ttm_resource_manager_init(man,
 				  dev_priv->vram_size >> PAGE_SHIFT);
 
 	drm_mm_init(&rman->mm, 0, man->size);
 	spin_lock_init(&rman->lock);
 
 	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
-	ttm_mem_type_manager_set_used(man, true);
+	ttm_resource_manager_set_used(man, true);
 	return 0;
 }
 
 void vmw_thp_fini(struct vmw_private *dev_priv)
 {
-	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
+	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
 	struct vmw_thp_manager *rman = to_thp_manager(man);
 	struct drm_mm *mm = &rman->mm;
 	int ret;
 
-	ttm_mem_type_manager_set_used(man, false);
+	ttm_resource_manager_set_used(man, false);
 
-	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
+	ret = ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
 	if (ret)
 		return;
 	spin_lock(&rman->lock);
 	drm_mm_clean(mm);
 	drm_mm_takedown(mm);
 	spin_unlock(&rman->lock);
-	ttm_mem_type_manager_cleanup(man);
+	ttm_resource_manager_cleanup(man);
 	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
 	kfree(rman);
 }
 
-static void vmw_thp_debug(struct ttm_mem_type_manager *man,
+static void vmw_thp_debug(struct ttm_resource_manager *man,
 			  struct drm_printer *printer)
 {
 	struct vmw_thp_manager *rman = to_thp_manager(man);
@@ -176,7 +176,7 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
 	spin_unlock(&rman->lock);
 }
 
-const struct ttm_mem_type_manager_func vmw_thp_func = {
+const struct ttm_resource_manager_func vmw_thp_func = {
 	.get_node = vmw_thp_get_node,
 	.put_node = vmw_thp_put_node,
 	.debug = vmw_thp_debug
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index eb465e9ca0c1..15958dff11d2 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -54,7 +54,7 @@ struct ttm_place;
 
 struct ttm_lru_bulk_move;
 
-struct ttm_mem_type_manager;
+struct ttm_resource_manager;
 
 /**
  * struct ttm_bus_placement
@@ -534,14 +534,14 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
 		  struct ttm_buffer_object **p_bo);
 
 /**
- * ttm_mem_type_manager_init
+ * ttm_resource_manager_init
  *
  * @man: memory manager object to init
  * @p_size: size managed area in pages.
  *
  * Initialise core parts of a manager object.
  */
-void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
+void ttm_resource_manager_init(struct ttm_resource_manager *man,
 			       unsigned long p_size);
 
 /**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index f231fe34e744..d1eff7de4fa3 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -45,11 +45,11 @@
 
 #define TTM_MAX_BO_PRIORITY	4U
 
-struct ttm_mem_type_manager;
+struct ttm_resource_manager;
 
-struct ttm_mem_type_manager_func {
+struct ttm_resource_manager_func {
 	/**
-	 * struct ttm_mem_type_manager member get_node
+	 * struct ttm_resource_manager member get_node
 	 *
 	 * @man: Pointer to a memory type manager.
 	 * @bo: Pointer to the buffer object we're allocating space for.
@@ -69,20 +69,20 @@ struct ttm_mem_type_manager_func {
 	 * the function should return a negative error code.
 	 *
 	 * Note that @mem::mm_node will only be dereferenced by
-	 * struct ttm_mem_type_manager functions and optionally by the driver,
+	 * struct ttm_resource_manager functions and optionally by the driver,
 	 * which has knowledge of the underlying type.
 	 *
 	 * This function may not be called from within atomic context, so
 	 * an implementation can and must use either a mutex or a spinlock to
 	 * protect any data structures managing the space.
 	 */
-	int  (*get_node)(struct ttm_mem_type_manager *man,
+	int  (*get_node)(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
 			 struct ttm_mem_reg *mem);
 
 	/**
-	 * struct ttm_mem_type_manager member put_node
+	 * struct ttm_resource_manager member put_node
 	 *
 	 * @man: Pointer to a memory type manager.
 	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
@@ -91,11 +91,11 @@ struct ttm_mem_type_manager_func {
 	 * and that are identified by @mem::mm_node and @mem::start. May not
 	 * be called from within atomic context.
 	 */
-	void (*put_node)(struct ttm_mem_type_manager *man,
+	void (*put_node)(struct ttm_resource_manager *man,
 			 struct ttm_mem_reg *mem);
 
 	/**
-	 * struct ttm_mem_type_manager member debug
+	 * struct ttm_resource_manager member debug
 	 *
 	 * @man: Pointer to a memory type manager.
 	 * @printer: Prefix to be used in printout to identify the caller.
@@ -104,12 +104,12 @@ struct ttm_mem_type_manager_func {
 	 * type manager to aid debugging of out-of-memory conditions.
 	 * It may not be called from within atomic context.
 	 */
-	void (*debug)(struct ttm_mem_type_manager *man,
+	void (*debug)(struct ttm_resource_manager *man,
 		      struct drm_printer *printer);
 };
 
 /**
- * struct ttm_mem_type_manager
+ * struct ttm_resource_manager
  *
  * @use_type: The memory type is enabled.
  * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
@@ -136,7 +136,7 @@ struct ttm_mem_type_manager_func {
 
 
 
-struct ttm_mem_type_manager {
+struct ttm_resource_manager {
 	/*
 	 * No protection. Constant from start.
 	 */
@@ -145,7 +145,7 @@ struct ttm_mem_type_manager {
 	uint64_t size;
 	uint32_t available_caching;
 	uint32_t default_caching;
-	const struct ttm_mem_type_manager_func *func;
+	const struct ttm_resource_manager_func *func;
 	struct mutex io_reserve_mutex;
 	bool use_io_reserve_lru;
 	spinlock_t move_lock;
@@ -390,7 +390,7 @@ extern struct ttm_bo_global {
  * struct ttm_bo_device - Buffer object driver device-specific data.
  *
  * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
- * @man: An array of mem_type_managers.
+ * @man: An array of resource_managers.
  * @vma_manager: Address space manager (pointer)
  * lru_lock: Spinlock that protects the buffer+device lru lists and
  * ddestroy lists.
@@ -411,8 +411,8 @@ struct ttm_bo_device {
 	/*
 	 * access via ttm_manager_type.
 	 */
-	struct ttm_mem_type_manager sysman;
-	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
+	struct ttm_resource_manager sysman;
+	struct ttm_resource_manager *man_drv[TTM_NUM_MEM_TYPES];
 	/*
 	 * Protected by internal locks.
 	 */
@@ -440,7 +440,7 @@ struct ttm_bo_device {
 	bool no_retry;
 };
 
-static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
+static inline struct ttm_resource_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
 	return bdev->man_drv[mem_type];
@@ -448,7 +448,7 @@ static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device
 
 static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
 					  int type,
-					  struct ttm_mem_type_manager *manager)
+					  struct ttm_resource_manager *manager)
 {
 	bdev->man_drv[type] = manager;
 }
@@ -570,8 +570,8 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo);
 
 int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo);
 void ttm_mem_io_free_vm(struct ttm_buffer_object *bo);
-int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible);
-void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
+int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible);
+void ttm_mem_io_unlock(struct ttm_resource_manager *man);
 
 /**
  * ttm_bo_reserve:
@@ -665,7 +665,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
 }
 
 /**
- * ttm_mem_type_manager_set_used
+ * ttm_resource_manager_set_used
  *
  * @man: A memory manager object.
  * @used: usage state to set.
@@ -673,13 +673,13 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
  * Set the manager in use flag. If disabled the manager is no longer
  * used for object placement.
  */
-static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
+static inline void ttm_resource_manager_set_used(struct ttm_resource_manager *man, bool used)
 {
 	man->use_type = used;
 }
 
 /**
- * ttm_mem_type_manager_used
+ * ttm_resource_manager_used
  *
  * @man: Manager to get used state for
  *
@@ -687,26 +687,26 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
  * Returns:
  * true is used, false if not.
  */
-static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
+static inline bool ttm_resource_manager_used(struct ttm_resource_manager *man)
 {
 	return man->use_type;
 }
 
 /**
- * ttm_mem_type_manager_cleanup
+ * ttm_resource_manager_cleanup
  *
  * @man: A memory manager object.
  *
  * Cleanup the move fences from the memory manager object.
  */
-static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
+static inline void ttm_resource_manager_cleanup(struct ttm_resource_manager *man)
 {
 	dma_fence_put(man->move);
 	man->move = NULL;
 }
 
 /*
- * ttm_mem_type_manager_force_list_clean
+ * ttm_resource_manager_force_list_clean
  *
  * @bdev - device to use
  * @man - manager to use
@@ -714,8 +714,8 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
  * Force all the objects out of a memory manager until clean.
  * Part of memory manager cleanup sequence.
  */
-int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
-					  struct ttm_mem_type_manager *man);
+int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
+					  struct ttm_resource_manager *man);
 
 /*
  * ttm_bo_util.c
@@ -864,12 +864,12 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
 		       unsigned type);
 
 /**
- * ttm_mem_type_manager_debug
+ * ttm_resource_manager_debug
  *
  * @man: manager type to dump.
  * @p: printer to use for debug.
  */
-void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
+void ttm_resource_manager_debug(struct ttm_resource_manager *man,
 				struct drm_printer *p);
 
 #endif
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource.
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (57 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager Dave Airlie
@ 2020-08-04  2:56 ` Dave Airlie
  2020-08-04 11:41   ` Christian König
  2020-08-04  3:01 ` [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
  2020-08-05 11:55 ` Christian König
  60 siblings, 1 reply; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  2:56 UTC (permalink / raw)
  To: dri-devel
  Cc: sroland, christian.koenig, linux-graphics-maintainer, bskeggs, kraxel

From: Dave Airlie <airlied@redhat.com>

This name better reflects what the object does. I didn't rename
all the pointers it seemed too messy.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       | 46 +++++++++----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       | 10 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 12 ++---
 drivers/gpu/drm/drm_gem_vram_helper.c         |  6 +--
 drivers/gpu/drm/nouveau/nouveau_bo.c          | 28 +++++------
 drivers/gpu/drm/nouveau/nouveau_bo.h          | 14 +++---
 drivers/gpu/drm/nouveau/nouveau_bo0039.c      |  4 +-
 drivers/gpu/drm/nouveau/nouveau_bo5039.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo74c1.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo85b5.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo9039.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo90b5.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_boa0b5.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 +-
 drivers/gpu/drm/nouveau/nouveau_mem.c         |  8 ++--
 drivers/gpu/drm/nouveau/nouveau_mem.h         | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_sgdma.c       |  4 +-
 drivers/gpu/drm/nouveau/nouveau_ttm.c         |  8 ++--
 drivers/gpu/drm/nouveau/nv17_fence.c          |  2 +-
 drivers/gpu/drm/nouveau/nv50_fence.c          |  2 +-
 drivers/gpu/drm/qxl/qxl_drv.h                 |  2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c                 | 14 +++---
 drivers/gpu/drm/radeon/radeon.h               |  2 +-
 drivers/gpu/drm/radeon/radeon_object.c        |  2 +-
 drivers/gpu/drm/radeon/radeon_object.h        |  2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c           | 28 +++++------
 drivers/gpu/drm/radeon/radeon_vm.c            |  2 +-
 drivers/gpu/drm/ttm/ttm_agp_backend.c         |  2 +-
 drivers/gpu/drm/ttm/ttm_bo.c                  | 26 +++++------
 drivers/gpu/drm/ttm/ttm_bo_util.c             | 46 +++++++++----------
 drivers/gpu/drm/ttm/ttm_range_manager.c       |  4 +-
 drivers/gpu/drm/ttm/ttm_tt.c                  |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c            |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c      |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  6 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c    |  8 ++--
 include/drm/ttm/ttm_bo_api.h                  | 10 ++--
 include/drm/ttm/ttm_bo_driver.h               | 42 ++++++++---------
 include/drm/ttm/ttm_tt.h                      | 10 ++--
 45 files changed, 202 insertions(+), 202 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 8b600b804f34..fb1415488579 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -171,7 +171,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
  *
  * Check if a mem object has already address space allocated.
  */
-bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
+bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem)
 {
 	return mem->mm_node != NULL;
 }
@@ -189,7 +189,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
 static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 			      struct ttm_buffer_object *tbo,
 			      const struct ttm_place *place,
-			      struct ttm_mem_reg *mem)
+			      struct ttm_resource *mem)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node;
@@ -250,7 +250,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
  * Free the allocated GTT again.
  */
 static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
-			       struct ttm_mem_reg *mem)
+			       struct ttm_resource *mem)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
 	struct amdgpu_gtt_node *node = mem->mm_node;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index ce98df5b0c21..43f4966331dd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1268,11 +1268,11 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
  */
 void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
 			   bool evict,
-			   struct ttm_mem_reg *new_mem)
+			   struct ttm_resource *new_mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 	struct amdgpu_bo *abo;
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 
 	if (!amdgpu_bo_is_amdgpu_bo(bo))
 		return;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index e01e8903741e..5ddb6cf96030 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,7 +283,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
 			   uint64_t *flags);
 void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
 			   bool evict,
-			   struct ttm_mem_reg *new_mem);
+			   struct ttm_resource *new_mem);
 void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
 int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
 void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index cae7eada7215..682172d59f60 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -183,9 +183,9 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
  * Assign the memory from new_mem to the memory of the buffer object bo.
  */
 static void amdgpu_move_null(struct ttm_buffer_object *bo,
-			     struct ttm_mem_reg *new_mem)
+			     struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 
 	BUG_ON(old_mem->mm_node != NULL);
 	*old_mem = *new_mem;
@@ -202,7 +202,7 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo,
  */
 static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
 				    struct drm_mm_node *mm_node,
-				    struct ttm_mem_reg *mem)
+				    struct ttm_resource *mem)
 {
 	uint64_t addr = 0;
 
@@ -222,7 +222,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
  * @offset: The offset that drm_mm_node is used for finding.
  *
  */
-static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
+static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_resource *mem,
 					       uint64_t *offset)
 {
 	struct drm_mm_node *mm_node = mem->mm_node;
@@ -250,7 +250,7 @@ static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
  * the physical address for local memory.
  */
 static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
-				 struct ttm_mem_reg *mem,
+				 struct ttm_resource *mem,
 				 struct drm_mm_node *mm_node,
 				 unsigned num_pages, uint64_t offset,
 				 unsigned window, struct amdgpu_ring *ring,
@@ -474,8 +474,8 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
  */
 static int amdgpu_move_blit(struct ttm_buffer_object *bo,
 			    bool evict, bool no_wait_gpu,
-			    struct ttm_mem_reg *new_mem,
-			    struct ttm_mem_reg *old_mem)
+			    struct ttm_resource *new_mem,
+			    struct ttm_resource *old_mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
@@ -534,10 +534,10 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
  */
 static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
 				struct ttm_operation_ctx *ctx,
-				struct ttm_mem_reg *new_mem)
+				struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
-	struct ttm_mem_reg tmp_mem;
+	struct ttm_resource *old_mem = &bo->mem;
+	struct ttm_resource tmp_mem;
 	struct ttm_place placements;
 	struct ttm_placement placement;
 	int r;
@@ -590,10 +590,10 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
  */
 static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
 				struct ttm_operation_ctx *ctx,
-				struct ttm_mem_reg *new_mem)
+				struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
-	struct ttm_mem_reg tmp_mem;
+	struct ttm_resource *old_mem = &bo->mem;
+	struct ttm_resource tmp_mem;
 	struct ttm_placement placement;
 	struct ttm_place placements;
 	int r;
@@ -636,7 +636,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
  * Called by amdgpu_bo_move()
  */
 static bool amdgpu_mem_visible(struct amdgpu_device *adev,
-			       struct ttm_mem_reg *mem)
+			       struct ttm_resource *mem)
 {
 	struct drm_mm_node *nodes = mem->mm_node;
 
@@ -646,7 +646,7 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
 	if (mem->mem_type != TTM_PL_VRAM)
 		return false;
 
-	/* ttm_mem_reg_ioremap only supports contiguous memory */
+	/* ttm_resource_ioremap only supports contiguous memory */
 	if (nodes->size != mem->num_pages)
 		return false;
 
@@ -661,11 +661,11 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
  */
 static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 			  struct ttm_operation_ctx *ctx,
-			  struct ttm_mem_reg *new_mem)
+			  struct ttm_resource *new_mem)
 {
 	struct amdgpu_device *adev;
 	struct amdgpu_bo *abo;
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 	int r;
 
 	/* Can't move a pinned BO */
@@ -747,7 +747,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
  *
  * Called by ttm_mem_io_reserve() ultimately via ttm_bo_vm_fault()
  */
-static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
+static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
 	struct drm_mm_node *mm_node = mem->mm_node;
@@ -771,7 +771,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
 			return -EINVAL;
 		/* Only physically contiguous buffers apply. In a contiguous
 		 * buffer, size of the first mm_node would match the number of
-		 * pages in ttm_mem_reg.
+		 * pages in ttm_resource.
 		 */
 		if (adev->mman.aper_base_kaddr &&
 		    (mm_node->size == mem->num_pages))
@@ -1116,7 +1116,7 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  * This handles binding GTT memory to the device address space.
  */
 static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
-				   struct ttm_mem_reg *bo_mem)
+				   struct ttm_resource *bo_mem)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
 	struct amdgpu_ttm_tt *gtt = (void*)ttm;
@@ -1167,7 +1167,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 	struct ttm_operation_ctx ctx = { false, false };
 	struct amdgpu_ttm_tt *gtt = (void*)bo->ttm;
-	struct ttm_mem_reg tmp;
+	struct ttm_resource tmp;
 	struct ttm_placement placement;
 	struct ttm_place placements;
 	uint64_t addr, flags;
@@ -1507,7 +1507,7 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm)
  *
  * Figure out the flags to use for a VM PDE (Page Directory Entry).
  */
-uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
+uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem)
 {
 	uint64_t flags = 0;
 
@@ -1533,7 +1533,7 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
  * Figure out the flags to use for a VM PTE (Page Table Entry).
  */
 uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
-				 struct ttm_mem_reg *mem)
+				 struct ttm_resource *mem)
 {
 	uint64_t flags = amdgpu_ttm_tt_pde_flags(ttm, mem);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 3db29ae1f802..36b024fd077e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -63,7 +63,7 @@ struct amdgpu_mman {
 
 struct amdgpu_copy_mem {
 	struct ttm_buffer_object	*bo;
-	struct ttm_mem_reg		*mem;
+	struct ttm_resource		*mem;
 	unsigned long			offset;
 };
 
@@ -72,13 +72,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev);
 int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
 void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
-bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
+bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
 uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
 int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
 
 u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
 int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
-			      struct ttm_mem_reg *mem,
+			      struct ttm_resource *mem,
 			      struct device *dev,
 			      enum dma_data_direction dir,
 			      struct sg_table **sgt);
@@ -142,9 +142,9 @@ bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm,
 				       int *last_invalidated);
 bool amdgpu_ttm_tt_is_userptr(struct ttm_tt *ttm);
 bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm);
-uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem);
+uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem);
 uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
-				 struct ttm_mem_reg *mem);
+				 struct ttm_resource *mem);
 
 int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 71e005cf2952..8bc2253939be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1765,7 +1765,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 	struct amdgpu_vm *vm = bo_va->base.vm;
 	struct amdgpu_bo_va_mapping *mapping;
 	dma_addr_t *pages_addr = NULL;
-	struct ttm_mem_reg *mem;
+	struct ttm_resource *mem;
 	struct drm_mm_node *nodes;
 	struct dma_fence **last_update;
 	struct dma_resv *resv;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index b227e380094f..44f20b30420e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -272,7 +272,7 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,
 u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-	struct ttm_mem_reg *mem = &bo->tbo.mem;
+	struct ttm_resource *mem = &bo->tbo.mem;
 	struct drm_mm_node *nodes = mem->mm_node;
 	unsigned pages = mem->num_pages;
 	u64 usage;
@@ -292,13 +292,13 @@ u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
 /**
  * amdgpu_vram_mgr_virt_start - update virtual start address
  *
- * @mem: ttm_mem_reg to update
+ * @mem: ttm_resource to update
  * @node: just allocated node
  *
  * Calculate a virtual BO start address to easily check if everything is CPU
  * accessible.
  */
-static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
+static void amdgpu_vram_mgr_virt_start(struct ttm_resource *mem,
 				       struct drm_mm_node *node)
 {
 	unsigned long start;
@@ -324,7 +324,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
 static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
 			       struct ttm_buffer_object *tbo,
 			       const struct ttm_place *place,
-			       struct ttm_mem_reg *mem)
+			       struct ttm_resource *mem)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	struct amdgpu_device *adev = mgr->adev;
@@ -440,7 +440,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
  * Free the allocated VRAM again.
  */
 static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
-				struct ttm_mem_reg *mem)
+				struct ttm_resource *mem)
 {
 	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
 	struct amdgpu_device *adev = mgr->adev;
@@ -480,7 +480,7 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
  * Allocate and fill a sg table from a VRAM allocation.
  */
 int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
-			      struct ttm_mem_reg *mem,
+			      struct ttm_resource *mem,
 			      struct device *dev,
 			      enum dma_data_direction dir,
 			      struct sg_table **sgt)
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index e3660d00987d..b410930d94a0 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -653,7 +653,7 @@ static void drm_gem_vram_bo_driver_evict_flags(struct drm_gem_vram_object *gbo,
 
 static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
 					       bool evict,
-					       struct ttm_mem_reg *new_mem)
+					       struct ttm_resource *new_mem)
 {
 	struct ttm_bo_kmap_obj *kmap = &gbo->kmap;
 
@@ -1020,7 +1020,7 @@ static void bo_driver_evict_flags(struct ttm_buffer_object *bo,
 
 static void bo_driver_move_notify(struct ttm_buffer_object *bo,
 				  bool evict,
-				  struct ttm_mem_reg *new_mem)
+				  struct ttm_resource *new_mem)
 {
 	struct drm_gem_vram_object *gbo;
 
@@ -1034,7 +1034,7 @@ static void bo_driver_move_notify(struct ttm_buffer_object *bo,
 }
 
 static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
-				    struct ttm_mem_reg *mem)
+				    struct ttm_resource *mem)
 {
 	struct drm_vram_mm *vmm = drm_vram_mm_of_bdev(bdev);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index aebec45b8416..80d22a98950b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -666,7 +666,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
 
 static int
 nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
-		     struct ttm_mem_reg *reg)
+		     struct ttm_resource *reg)
 {
 	struct nouveau_mem *old_mem = nouveau_mem(&bo->mem);
 	struct nouveau_mem *new_mem = nouveau_mem(reg);
@@ -698,7 +698,7 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
 
 static int
 nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
-		     bool no_wait_gpu, struct ttm_mem_reg *new_reg)
+		     bool no_wait_gpu, struct ttm_resource *new_reg)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	struct nouveau_channel *chan = drm->ttm.chan;
@@ -708,7 +708,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
 
 	/* create temporary vmas for the transfer and attach them to the
 	 * old nvkm_mem node, these will get cleaned up after ttm has
-	 * destroyed the ttm_mem_reg
+	 * destroyed the ttm_resource
 	 */
 	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
 		ret = nouveau_bo_move_prep(drm, bo, new_reg);
@@ -744,7 +744,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
 		s32 oclass;
 		int (*exec)(struct nouveau_channel *,
 			    struct ttm_buffer_object *,
-			    struct ttm_mem_reg *, struct ttm_mem_reg *);
+			    struct ttm_resource *, struct ttm_resource *);
 		int (*init)(struct nouveau_channel *, u32 handle);
 	} _methods[] = {
 		{  "COPY", 4, 0xc5b5, nve0_bo_move_copy, nve0_bo_move_init },
@@ -805,7 +805,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
 
 static int
 nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
-		      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
+		      bool no_wait_gpu, struct ttm_resource *new_reg)
 {
 	struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
 	struct ttm_place placement_memtype = {
@@ -814,7 +814,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
 		.flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
 	};
 	struct ttm_placement placement;
-	struct ttm_mem_reg tmp_reg;
+	struct ttm_resource tmp_reg;
 	int ret;
 
 	placement.num_placement = placement.num_busy_placement = 1;
@@ -842,7 +842,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
 
 static int
 nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
-		      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
+		      bool no_wait_gpu, struct ttm_resource *new_reg)
 {
 	struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
 	struct ttm_place placement_memtype = {
@@ -851,7 +851,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
 		.flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
 	};
 	struct ttm_placement placement;
-	struct ttm_mem_reg tmp_reg;
+	struct ttm_resource tmp_reg;
 	int ret;
 
 	placement.num_placement = placement.num_busy_placement = 1;
@@ -878,7 +878,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
 
 static void
 nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
-		     struct ttm_mem_reg *new_reg)
+		     struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = new_reg ? nouveau_mem(new_reg) : NULL;
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
@@ -910,7 +910,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
 }
 
 static int
-nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_reg,
+nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_resource *new_reg,
 		   struct nouveau_drm_tile **new_tile)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
@@ -946,11 +946,11 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
 static int
 nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
 		struct ttm_operation_ctx *ctx,
-		struct ttm_mem_reg *new_reg)
+		struct ttm_resource *new_reg)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
-	struct ttm_mem_reg *old_reg = &bo->mem;
+	struct ttm_resource *old_reg = &bo->mem;
 	struct nouveau_drm_tile *new_tile = NULL;
 	int ret = 0;
 
@@ -1019,7 +1019,7 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
 }
 
 static int
-nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
+nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bdev);
 	struct nvkm_device *device = nvxx_device(&drm->client.device);
@@ -1099,7 +1099,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
 }
 
 static void
-nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
+nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_resource *reg)
 {
 	struct nouveau_drm *drm = nouveau_bdev(bdev);
 	struct nouveau_mem *mem = nouveau_mem(reg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h
index 52489ce7d029..aecb7481df0d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -139,28 +139,28 @@ nouveau_bo_new_pin_map(struct nouveau_cli *cli, u64 size, int align, u32 flags,
 
 int nv04_bo_move_init(struct nouveau_channel *, u32);
 int nv04_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nv50_bo_move_init(struct nouveau_channel *, u32);
 int nv50_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nv84_bo_move_exec(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nva3_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nvc0_bo_move_init(struct nouveau_channel *, u32);
 int nvc0_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nvc0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 int nve0_bo_move_init(struct nouveau_channel *, u32);
 int nve0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
-		      struct ttm_mem_reg *, struct ttm_mem_reg *);
+		      struct ttm_resource *, struct ttm_resource *);
 
 #define NVBO_WR32_(b,o,dr,f) nouveau_bo_wr32((b), (o)/4 + (dr), (f))
 #define NVBO_RD32_(b,o,dr)   nouveau_bo_rd32((b), (o)/4 + (dr))
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
index bf7ae2cecaf6..7390132129fe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
@@ -36,7 +36,7 @@
 
 static inline uint32_t
 nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
-		      struct nouveau_channel *chan, struct ttm_mem_reg *reg)
+		      struct nouveau_channel *chan, struct ttm_resource *reg)
 {
 	if (reg->mem_type == TTM_PL_TT)
 		return NvDmaTT;
@@ -45,7 +45,7 @@ nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
 
 int
 nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nvif_push *push = chan->chan.push;
 	u32 src_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, old_reg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
index f9b9b85abe44..4c75c7b3804c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
@@ -37,7 +37,7 @@
 
 int
 nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	struct nvif_push *push = chan->chan.push;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
index 1b5fd78ddcba..ed6c09d67840 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
@@ -34,7 +34,7 @@
 
 int
 nv84_bo_move_exec(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	struct nvif_push *push = chan->chan.push;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
index f0df172b029e..dec29b2d8bb2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
@@ -38,7 +38,7 @@
 
 int
 nva3_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	struct nvif_push *push = chan->chan.push;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo9039.c b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
index 52fefb37064c..776b04976cdf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo9039.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
@@ -36,7 +36,7 @@
 
 int
 nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nvif_push *push = chan->chan.push;
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
index 34b79d561c7f..8499f58213e3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
@@ -31,7 +31,7 @@
 
 int
 nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	struct nvif_push *push = chan->chan.push;
diff --git a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
index 394e29012e50..575212472e7a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
+++ b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
@@ -36,7 +36,7 @@
 
 int
 nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
-		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
+		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(old_reg);
 	struct nvif_push *push = chan->chan.push;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index ae76a5865a5a..f63ac72aa556 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -157,7 +157,7 @@ struct nouveau_drm {
 		atomic_t validate_sequence;
 		int (*move)(struct nouveau_channel *,
 			    struct ttm_buffer_object *,
-			    struct ttm_mem_reg *, struct ttm_mem_reg *);
+			    struct ttm_resource *, struct ttm_resource *);
 		struct nouveau_channel *chan;
 		struct nvif_object copy;
 		int mtrr;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index b1bb542d3115..269d8707acc3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -92,7 +92,7 @@ nouveau_mem_fini(struct nouveau_mem *mem)
 }
 
 int
-nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
+nouveau_mem_host(struct ttm_resource *reg, struct ttm_dma_tt *tt)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_cli *cli = mem->cli;
@@ -130,7 +130,7 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
 }
 
 int
-nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
+nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	struct nouveau_cli *cli = mem->cli;
@@ -173,7 +173,7 @@ nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
 }
 
 void
-nouveau_mem_del(struct ttm_mem_reg *reg)
+nouveau_mem_del(struct ttm_resource *reg)
 {
 	struct nouveau_mem *mem = nouveau_mem(reg);
 	nouveau_mem_fini(mem);
@@ -183,7 +183,7 @@ nouveau_mem_del(struct ttm_mem_reg *reg)
 
 int
 nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
-		struct ttm_mem_reg *reg)
+		struct ttm_resource *reg)
 {
 	struct nouveau_mem *mem;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.h b/drivers/gpu/drm/nouveau/nouveau_mem.h
index f6d039e73812..3fe1cfed57a1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.h
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.h
@@ -7,7 +7,7 @@ struct ttm_dma_tt;
 #include <nvif/vmm.h>
 
 static inline struct nouveau_mem *
-nouveau_mem(struct ttm_mem_reg *reg)
+nouveau_mem(struct ttm_resource *reg)
 {
 	return reg->mm_node;
 }
@@ -21,10 +21,10 @@ struct nouveau_mem {
 };
 
 int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
-		    struct ttm_mem_reg *);
-void nouveau_mem_del(struct ttm_mem_reg *);
-int nouveau_mem_vram(struct ttm_mem_reg *, bool contig, u8 page);
-int nouveau_mem_host(struct ttm_mem_reg *, struct ttm_dma_tt *);
+		    struct ttm_resource *);
+void nouveau_mem_del(struct ttm_resource *);
+int nouveau_mem_vram(struct ttm_resource *, bool contig, u8 page);
+int nouveau_mem_host(struct ttm_resource *, struct ttm_dma_tt *);
 void nouveau_mem_fini(struct nouveau_mem *);
 int nouveau_mem_map(struct nouveau_mem *, struct nvif_vmm *, struct nvif_vma *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index c3ccf661b7a6..eef75c53a197 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -26,7 +26,7 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm)
 }
 
 static int
-nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
+nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
 {
 	struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
 	struct nouveau_mem *mem = nouveau_mem(reg);
@@ -60,7 +60,7 @@ static struct ttm_backend_func nv04_sgdma_backend = {
 };
 
 static int
-nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
+nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
 {
 	struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
 	struct nouveau_mem *mem = nouveau_mem(reg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index d6ad0977dc7d..9e96b6ff24cf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -32,7 +32,7 @@
 #include <core/tegra.h>
 
 static void
-nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
+nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_resource *reg)
 {
 	nouveau_mem_del(reg);
 }
@@ -41,7 +41,7 @@ static int
 nouveau_vram_manager_new(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
-			 struct ttm_mem_reg *reg)
+			 struct ttm_resource *reg)
 {
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
@@ -72,7 +72,7 @@ static int
 nouveau_gart_manager_new(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
-			 struct ttm_mem_reg *reg)
+			 struct ttm_resource *reg)
 {
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
@@ -95,7 +95,7 @@ static int
 nv04_gart_manager_new(struct ttm_resource_manager *man,
 		      struct ttm_buffer_object *bo,
 		      const struct ttm_place *place,
-		      struct ttm_mem_reg *reg)
+		      struct ttm_resource *reg)
 {
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index cd1e87a528a4..6b697ee6bc0e 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -78,7 +78,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
 {
 	struct nv10_fence_priv *priv = chan->drm->fence;
 	struct nv10_fence_chan *fctx;
-	struct ttm_mem_reg *reg = &priv->bo->bo.mem;
+	struct ttm_resource *reg = &priv->bo->bo.mem;
 	u32 start = reg->start * PAGE_SIZE;
 	u32 limit = start + reg->size - 1;
 	int ret = 0;
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index ebb740686b44..49b46f51073c 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -37,7 +37,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
 {
 	struct nv10_fence_priv *priv = chan->drm->fence;
 	struct nv10_fence_chan *fctx;
-	struct ttm_mem_reg *reg = &priv->bo->bo.mem;
+	struct ttm_resource *reg = &priv->bo->bo.mem;
 	u32 start = reg->start * PAGE_SIZE;
 	u32 limit = start + reg->size - 1;
 	int ret;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 9691449aefdb..aae90a9ee1db 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -350,7 +350,7 @@ int qxl_mode_dumb_mmap(struct drm_file *filp,
 int qxl_ttm_init(struct qxl_device *qdev);
 void qxl_ttm_fini(struct qxl_device *qdev);
 int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
-			   struct ttm_mem_reg *mem);
+			   struct ttm_resource *mem);
 
 /* qxl image */
 
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 1c06fe780815..dc31f3fea33c 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -71,7 +71,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
 }
 
 int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
-			   struct ttm_mem_reg *mem)
+			   struct ttm_resource *mem)
 {
 	struct qxl_device *qdev = qxl_get_qdev(bdev);
 
@@ -111,7 +111,7 @@ struct qxl_ttm_tt {
 };
 
 static int qxl_ttm_backend_bind(struct ttm_tt *ttm,
-				struct ttm_mem_reg *bo_mem)
+				struct ttm_resource *bo_mem)
 {
 	struct qxl_ttm_tt *gtt = (void *)ttm;
 
@@ -163,9 +163,9 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
 }
 
 static void qxl_move_null(struct ttm_buffer_object *bo,
-			     struct ttm_mem_reg *new_mem)
+			     struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 
 	BUG_ON(old_mem->mm_node != NULL);
 	*old_mem = *new_mem;
@@ -174,9 +174,9 @@ static void qxl_move_null(struct ttm_buffer_object *bo,
 
 static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
 		       struct ttm_operation_ctx *ctx,
-		       struct ttm_mem_reg *new_mem)
+		       struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 	int ret;
 
 	ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
@@ -192,7 +192,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
 
 static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
 			       bool evict,
-			       struct ttm_mem_reg *new_mem)
+			       struct ttm_resource *new_mem)
 {
 	struct qxl_bo *qbo;
 	struct qxl_device *qdev;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index b7c3fb2bfb54..cc4f58d16589 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2857,7 +2857,7 @@ int radeon_vm_clear_invalids(struct radeon_device *rdev,
 			     struct radeon_vm *vm);
 int radeon_vm_bo_update(struct radeon_device *rdev,
 			struct radeon_bo_va *bo_va,
-			struct ttm_mem_reg *mem);
+			struct ttm_resource *mem);
 void radeon_vm_bo_invalidate(struct radeon_device *rdev,
 			     struct radeon_bo *bo);
 struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index f3dee01250da..bb7582afd803 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -775,7 +775,7 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
 
 void radeon_bo_move_notify(struct ttm_buffer_object *bo,
 			   bool evict,
-			   struct ttm_mem_reg *new_mem)
+			   struct ttm_resource *new_mem)
 {
 	struct radeon_bo *rbo;
 
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index 60275b822f79..44b47241ee42 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -165,7 +165,7 @@ extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
 				bool force_drop);
 extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
 				  bool evict,
-				  struct ttm_mem_reg *new_mem);
+				  struct ttm_resource *new_mem);
 extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
 extern int radeon_bo_get_surface_reg(struct radeon_bo *bo);
 extern void radeon_bo_fence(struct radeon_bo *bo, struct radeon_fence *fence,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 05b5f29f2b61..a068d6960c23 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -166,9 +166,9 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
 }
 
 static void radeon_move_null(struct ttm_buffer_object *bo,
-			     struct ttm_mem_reg *new_mem)
+			     struct ttm_resource *new_mem)
 {
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 
 	BUG_ON(old_mem->mm_node != NULL);
 	*old_mem = *new_mem;
@@ -177,8 +177,8 @@ static void radeon_move_null(struct ttm_buffer_object *bo,
 
 static int radeon_move_blit(struct ttm_buffer_object *bo,
 			bool evict, bool no_wait_gpu,
-			struct ttm_mem_reg *new_mem,
-			struct ttm_mem_reg *old_mem)
+			struct ttm_resource *new_mem,
+			struct ttm_resource *old_mem)
 {
 	struct radeon_device *rdev;
 	uint64_t old_start, new_start;
@@ -233,11 +233,11 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
 static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
 				bool evict, bool interruptible,
 				bool no_wait_gpu,
-				struct ttm_mem_reg *new_mem)
+				struct ttm_resource *new_mem)
 {
 	struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
-	struct ttm_mem_reg *old_mem = &bo->mem;
-	struct ttm_mem_reg tmp_mem;
+	struct ttm_resource *old_mem = &bo->mem;
+	struct ttm_resource tmp_mem;
 	struct ttm_place placements;
 	struct ttm_placement placement;
 	int r;
@@ -278,11 +278,11 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
 static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
 				bool evict, bool interruptible,
 				bool no_wait_gpu,
-				struct ttm_mem_reg *new_mem)
+				struct ttm_resource *new_mem)
 {
 	struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
-	struct ttm_mem_reg *old_mem = &bo->mem;
-	struct ttm_mem_reg tmp_mem;
+	struct ttm_resource *old_mem = &bo->mem;
+	struct ttm_resource tmp_mem;
 	struct ttm_placement placement;
 	struct ttm_place placements;
 	int r;
@@ -315,11 +315,11 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
 
 static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 			  struct ttm_operation_ctx *ctx,
-			  struct ttm_mem_reg *new_mem)
+			  struct ttm_resource *new_mem)
 {
 	struct radeon_device *rdev;
 	struct radeon_bo *rbo;
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 	int r;
 
 	r = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
@@ -376,7 +376,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 	return 0;
 }
 
-static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
+static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
 {
 	struct radeon_device *rdev = radeon_get_rdev(bdev);
 
@@ -544,7 +544,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 }
 
 static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
-				   struct ttm_mem_reg *bo_mem)
+				   struct ttm_resource *bo_mem)
 {
 	struct radeon_ttm_tt *gtt = (void*)ttm;
 	uint32_t flags = RADEON_GART_PAGE_VALID | RADEON_GART_PAGE_READ |
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index f60fae0aed11..71e2c3785ab9 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -911,7 +911,7 @@ static void radeon_vm_fence_pts(struct radeon_vm *vm,
  */
 int radeon_vm_bo_update(struct radeon_device *rdev,
 			struct radeon_bo_va *bo_va,
-			struct ttm_mem_reg *mem)
+			struct ttm_resource *mem)
 {
 	struct radeon_vm *vm = bo_va->vm;
 	struct radeon_ib ib;
diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
index 38f1351140e2..09fe80e215c5 100644
--- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
+++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
@@ -48,7 +48,7 @@ struct ttm_agp_backend {
 	struct agp_bridge_data *bridge;
 };
 
-static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
+static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
 {
 	struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
 	struct page *dummy_read_page = ttm_bo_glob.dummy_read_page;
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 48840a3cf4c4..1ea5de976ec3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -145,7 +145,7 @@ static inline uint32_t ttm_bo_type_flags(unsigned type)
 }
 
 static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
-				  struct ttm_mem_reg *mem)
+				  struct ttm_resource *mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 	struct ttm_resource_manager *man;
@@ -268,7 +268,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
 EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
 
 static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
-				  struct ttm_mem_reg *mem, bool evict,
+				  struct ttm_resource *mem, bool evict,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
@@ -642,7 +642,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
 			struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_reg evict_mem;
+	struct ttm_resource evict_mem;
 	struct ttm_placement placement;
 	int ret = 0;
 
@@ -841,7 +841,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
 
 static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 			  const struct ttm_place *place,
-			  struct ttm_mem_reg *mem)
+			  struct ttm_resource *mem)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
@@ -852,7 +852,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
 	return man->func->get_node(man, bo, place, mem);
 }
 
-void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
+void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
 
@@ -870,7 +870,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
  */
 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 				 struct ttm_resource_manager *man,
-				 struct ttm_mem_reg *mem,
+				 struct ttm_resource *mem,
 				 bool no_wait_gpu)
 {
 	struct dma_fence *fence;
@@ -907,7 +907,7 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
  */
 static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
-				  struct ttm_mem_reg *mem,
+				  struct ttm_resource *mem,
 				  struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
@@ -988,7 +988,7 @@ static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
  */
 static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
 				const struct ttm_place *place,
-				struct ttm_mem_reg *mem,
+				struct ttm_resource *mem,
 				struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
@@ -1036,7 +1036,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
  */
 int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 			struct ttm_placement *placement,
-			struct ttm_mem_reg *mem,
+			struct ttm_resource *mem,
 			struct ttm_operation_ctx *ctx)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
@@ -1114,7 +1114,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
 			      struct ttm_operation_ctx *ctx)
 {
 	int ret = 0;
-	struct ttm_mem_reg mem;
+	struct ttm_resource mem;
 
 	dma_resv_assert_held(bo->base.resv);
 
@@ -1140,7 +1140,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
 
 static bool ttm_bo_places_compat(const struct ttm_place *places,
 				 unsigned num_placement,
-				 struct ttm_mem_reg *mem,
+				 struct ttm_resource *mem,
 				 uint32_t *new_flags)
 {
 	unsigned i;
@@ -1163,7 +1163,7 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
 }
 
 bool ttm_bo_mem_compat(struct ttm_placement *placement,
-		       struct ttm_mem_reg *mem,
+		       struct ttm_resource *mem,
 		       uint32_t *new_flags)
 {
 	if (ttm_bo_places_compat(placement->placement, placement->num_placement,
@@ -1732,7 +1732,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
 	if (bo->mem.mem_type != TTM_PL_SYSTEM ||
 	    bo->ttm->caching_state != tt_cached) {
 		struct ttm_operation_ctx ctx = { false, false };
-		struct ttm_mem_reg evict_mem;
+		struct ttm_resource evict_mem;
 
 		evict_mem = bo->mem;
 		evict_mem.mm_node = NULL;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 8ef0de8e36c5..496158acd5b9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -52,10 +52,10 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
 
 int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 		   struct ttm_operation_ctx *ctx,
-		    struct ttm_mem_reg *new_mem)
+		    struct ttm_resource *new_mem)
 {
 	struct ttm_tt *ttm = bo->ttm;
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 	int ret;
 
 	if (old_mem->mem_type != TTM_PL_SYSTEM) {
@@ -127,7 +127,7 @@ static int ttm_mem_io_evict(struct ttm_resource_manager *man)
 }
 
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
-		       struct ttm_mem_reg *mem)
+		       struct ttm_resource *mem)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
 	int ret;
@@ -149,7 +149,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
 }
 
 void ttm_mem_io_free(struct ttm_bo_device *bdev,
-		     struct ttm_mem_reg *mem)
+		     struct ttm_resource *mem)
 {
 	if (--mem->bus.io_reserved_count)
 		return;
@@ -163,7 +163,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
 int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
-	struct ttm_mem_reg *mem = &bo->mem;
+	struct ttm_resource *mem = &bo->mem;
 	int ret;
 
 	if (mem->bus.io_reserved_vm)
@@ -181,7 +181,7 @@ int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
 
 void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
 {
-	struct ttm_mem_reg *mem = &bo->mem;
+	struct ttm_resource *mem = &bo->mem;
 
 	if (!mem->bus.io_reserved_vm)
 		return;
@@ -191,8 +191,8 @@ void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
 	ttm_mem_io_free(bo->bdev, mem);
 }
 
-static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
-			       struct ttm_mem_reg *mem,
+static int ttm_resource_ioremap(struct ttm_bo_device *bdev,
+			       struct ttm_resource *mem,
 			       void **virtual)
 {
 	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
@@ -226,8 +226,8 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
 	return 0;
 }
 
-static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
-				struct ttm_mem_reg *mem,
+static void ttm_resource_iounmap(struct ttm_bo_device *bdev,
+				struct ttm_resource *mem,
 				void *virtual)
 {
 	struct ttm_resource_manager *man;
@@ -300,13 +300,13 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 
 int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 		       struct ttm_operation_ctx *ctx,
-		       struct ttm_mem_reg *new_mem)
+		       struct ttm_resource *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
 	struct ttm_tt *ttm = bo->ttm;
-	struct ttm_mem_reg *old_mem = &bo->mem;
-	struct ttm_mem_reg old_copy = *old_mem;
+	struct ttm_resource *old_mem = &bo->mem;
+	struct ttm_resource old_copy = *old_mem;
 	void *old_iomap;
 	void *new_iomap;
 	int ret;
@@ -319,10 +319,10 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 	if (ret)
 		return ret;
 
-	ret = ttm_mem_reg_ioremap(bdev, old_mem, &old_iomap);
+	ret = ttm_resource_ioremap(bdev, old_mem, &old_iomap);
 	if (ret)
 		return ret;
-	ret = ttm_mem_reg_ioremap(bdev, new_mem, &new_iomap);
+	ret = ttm_resource_ioremap(bdev, new_mem, &new_iomap);
 	if (ret)
 		goto out;
 
@@ -390,9 +390,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 	}
 
 out1:
-	ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
+	ttm_resource_iounmap(bdev, old_mem, new_iomap);
 out:
-	ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
+	ttm_resource_iounmap(bdev, &old_copy, old_iomap);
 
 	/*
 	 * On error, keep the mm node!
@@ -502,7 +502,7 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo,
 			  unsigned long size,
 			  struct ttm_bo_kmap_obj *map)
 {
-	struct ttm_mem_reg *mem = &bo->mem;
+	struct ttm_resource *mem = &bo->mem;
 
 	if (bo->mem.bus.addr) {
 		map->bo_kmap_type = ttm_bo_map_premapped;
@@ -526,7 +526,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
 			   unsigned long num_pages,
 			   struct ttm_bo_kmap_obj *map)
 {
-	struct ttm_mem_reg *mem = &bo->mem;
+	struct ttm_resource *mem = &bo->mem;
 	struct ttm_operation_ctx ctx = {
 		.interruptible = false,
 		.no_wait_gpu = false
@@ -631,11 +631,11 @@ EXPORT_SYMBOL(ttm_bo_kunmap);
 int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 			      struct dma_fence *fence,
 			      bool evict,
-			      struct ttm_mem_reg *new_mem)
+			      struct ttm_resource *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 	int ret;
 	struct ttm_buffer_object *ghost_obj;
 
@@ -692,10 +692,10 @@ EXPORT_SYMBOL(ttm_bo_move_accel_cleanup);
 
 int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
 			 struct dma_fence *fence, bool evict,
-			 struct ttm_mem_reg *new_mem)
+			 struct ttm_resource *new_mem)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_reg *old_mem = &bo->mem;
+	struct ttm_resource *old_mem = &bo->mem;
 
 	struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
 	struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
index 22de9f209449..7442d811f867 100644
--- a/drivers/gpu/drm/ttm/ttm_range_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
@@ -57,7 +57,7 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_man
 static int ttm_range_man_get_node(struct ttm_resource_manager *man,
 				  struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
-				  struct ttm_mem_reg *mem)
+				  struct ttm_resource *mem)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
 	struct drm_mm *mm = &rman->mm;
@@ -96,7 +96,7 @@ static int ttm_range_man_get_node(struct ttm_resource_manager *man,
 }
 
 static void ttm_range_man_put_node(struct ttm_resource_manager *man,
-				   struct ttm_mem_reg *mem)
+				   struct ttm_resource *mem)
 {
 	struct ttm_range_manager *rman = to_range_manager(man);
 
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 9d1c7177384c..1ccf1ef050d6 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -316,7 +316,7 @@ void ttm_tt_unbind(struct ttm_tt *ttm)
 	}
 }
 
-int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
+int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
 		struct ttm_operation_ctx *ctx)
 {
 	int ret = 0;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
index 1e59c019affa..3229451d0706 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -1135,14 +1135,14 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
  * vmw_bo_move_notify - TTM move_notify_callback
  *
  * @bo: The TTM buffer object about to move.
- * @mem: The struct ttm_mem_reg indicating to what memory
+ * @mem: The struct ttm_resource indicating to what memory
  *       region the move is taking place.
  *
  * Detaches cached maps and device bindings that require that the
  * buffer doesn't move.
  */
 void vmw_bo_move_notify(struct ttm_buffer_object *bo,
-			struct ttm_mem_reg *mem)
+			struct ttm_resource *mem)
 {
 	struct vmw_buffer_object *vbo;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index aa763c6b1146..871ad738dadb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -793,7 +793,7 @@ extern void vmw_resource_unreserve(struct vmw_resource *res,
 				   struct vmw_buffer_object *new_backup,
 				   unsigned long new_backup_offset);
 extern void vmw_query_move_notify(struct ttm_buffer_object *bo,
-				  struct ttm_mem_reg *mem);
+				  struct ttm_resource *mem);
 extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob);
 extern void vmw_resource_evict_all(struct vmw_private *dev_priv);
 extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo);
@@ -878,7 +878,7 @@ extern void vmw_bo_fence_single(struct ttm_buffer_object *bo,
 extern void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo);
 extern void vmw_bo_unmap(struct vmw_buffer_object *vbo);
 extern void vmw_bo_move_notify(struct ttm_buffer_object *bo,
-			       struct ttm_mem_reg *mem);
+			       struct ttm_resource *mem);
 extern void vmw_bo_swap_notify(struct ttm_buffer_object *bo);
 extern struct vmw_buffer_object *
 vmw_user_bo_noref_lookup(struct ttm_object_file *tfile, u32 handle);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index c8fe6e9cf092..3fea7a6c7cfa 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -53,7 +53,7 @@ static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *ma
 static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
 				  struct ttm_buffer_object *bo,
 				  const struct ttm_place *place,
-				  struct ttm_mem_reg *mem)
+				  struct ttm_resource *mem)
 {
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 	int id;
@@ -85,7 +85,7 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
 }
 
 static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
-				   struct ttm_mem_reg *mem)
+				   struct ttm_resource *mem)
 {
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index c8441030637a..c0f156078dda 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -855,7 +855,7 @@ int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob)
  * states from the device.
  */
 void vmw_query_move_notify(struct ttm_buffer_object *bo,
-			   struct ttm_mem_reg *mem)
+			   struct ttm_resource *mem)
 {
 	struct vmw_buffer_object *dx_query_mob;
 	struct ttm_bo_device *bdev = bo->bdev;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index 6cac7b091205..f594e2e6ab7e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -29,7 +29,7 @@ static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
 static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
 				  unsigned long align_pages,
 				  const struct ttm_place *place,
-				  struct ttm_mem_reg *mem,
+				  struct ttm_resource *mem,
 				  unsigned long lpfn,
 				  enum drm_mm_insert_mode mode)
 {
@@ -47,7 +47,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
 static int vmw_thp_get_node(struct ttm_resource_manager *man,
 			    struct ttm_buffer_object *bo,
 			    const struct ttm_place *place,
-			    struct ttm_mem_reg *mem)
+			    struct ttm_resource *mem)
 {
 	struct vmw_thp_manager *rman = to_thp_manager(man);
 	struct drm_mm *mm = &rman->mm;
@@ -107,7 +107,7 @@ static int vmw_thp_get_node(struct ttm_resource_manager *man,
 
 
 static void vmw_thp_put_node(struct ttm_resource_manager *man,
-			     struct ttm_mem_reg *mem)
+			     struct ttm_resource *mem)
 {
 	struct vmw_thp_manager *rman = to_thp_manager(man);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 3a141a08d4bd..7247347a9bca 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -539,7 +539,7 @@ const struct vmw_sg_table *vmw_bo_sg_table(struct ttm_buffer_object *bo)
 }
 
 
-static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
+static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
 {
 	struct vmw_ttm_tt *vmw_be =
 		container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm);
@@ -711,7 +711,7 @@ static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp)
 	return vmw_user_bo_verify_access(bo, tfile);
 }
 
-static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
+static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
 {
 	struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev);
 
@@ -741,7 +741,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
  * vmw_move_notify - TTM move_notify_callback
  *
  * @bo: The TTM buffer object about to move.
- * @mem: The struct ttm_mem_reg indicating to what memory
+ * @mem: The struct ttm_resource indicating to what memory
  *       region the move is taking place.
  *
  * Calls move_notify for all subsystems needing it.
@@ -749,7 +749,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
  */
 static void vmw_move_notify(struct ttm_buffer_object *bo,
 			    bool evict,
-			    struct ttm_mem_reg *mem)
+			    struct ttm_resource *mem)
 {
 	vmw_bo_move_notify(bo, mem);
 	vmw_query_move_notify(bo, mem);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 15958dff11d2..247d4f803443 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -81,7 +81,7 @@ struct ttm_bus_placement {
 
 
 /**
- * struct ttm_mem_reg
+ * struct ttm_resource
  *
  * @mm_node: Memory manager node.
  * @size: Requested size of memory region.
@@ -94,7 +94,7 @@ struct ttm_bus_placement {
  * buffer object.
  */
 
-struct ttm_mem_reg {
+struct ttm_resource {
 	void *mm_node;
 	unsigned long start;
 	unsigned long size;
@@ -187,7 +187,7 @@ struct ttm_buffer_object {
 	 * Members protected by the bo::resv::reserved lock.
 	 */
 
-	struct ttm_mem_reg mem;
+	struct ttm_resource mem;
 	struct file *persistent_swap_storage;
 	struct ttm_tt *ttm;
 	bool evicted;
@@ -316,12 +316,12 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait);
  * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo
  *
  * @placement:  Return immediately if buffer is busy.
- * @mem:  The struct ttm_mem_reg indicating the region where the bo resides
+ * @mem:  The struct ttm_resource indicating the region where the bo resides
  * @new_flags: Describes compatible placement found
  *
  * Returns true if the placement is compatible
  */
-bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_mem_reg *mem,
+bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_resource *mem,
 		       uint32_t *new_flags);
 
 /**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index d1eff7de4fa3..576c91c85a6b 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -55,7 +55,7 @@ struct ttm_resource_manager_func {
 	 * @bo: Pointer to the buffer object we're allocating space for.
 	 * @placement: Placement details.
 	 * @flags: Additional placement flags.
-	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
+	 * @mem: Pointer to a struct ttm_resource to be filled in.
 	 *
 	 * This function should allocate space in the memory type managed
 	 * by @man. Placement details if
@@ -79,20 +79,20 @@ struct ttm_resource_manager_func {
 	int  (*get_node)(struct ttm_resource_manager *man,
 			 struct ttm_buffer_object *bo,
 			 const struct ttm_place *place,
-			 struct ttm_mem_reg *mem);
+			 struct ttm_resource *mem);
 
 	/**
 	 * struct ttm_resource_manager member put_node
 	 *
 	 * @man: Pointer to a memory type manager.
-	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
+	 * @mem: Pointer to a struct ttm_resource to be filled in.
 	 *
 	 * This function frees memory type resources previously allocated
 	 * and that are identified by @mem::mm_node and @mem::start. May not
 	 * be called from within atomic context.
 	 */
 	void (*put_node)(struct ttm_resource_manager *man,
-			 struct ttm_mem_reg *mem);
+			 struct ttm_resource *mem);
 
 	/**
 	 * struct ttm_resource_manager member debug
@@ -251,7 +251,7 @@ struct ttm_bo_driver {
 	 */
 	int (*move)(struct ttm_buffer_object *bo, bool evict,
 		    struct ttm_operation_ctx *ctx,
-		    struct ttm_mem_reg *new_mem);
+		    struct ttm_resource *new_mem);
 
 	/**
 	 * struct ttm_bo_driver_member verify_access
@@ -277,7 +277,7 @@ struct ttm_bo_driver {
 	 */
 	void (*move_notify)(struct ttm_buffer_object *bo,
 			    bool evict,
-			    struct ttm_mem_reg *new_mem);
+			    struct ttm_resource *new_mem);
 	/* notify the driver we are taking a fault on this BO
 	 * and have reserved it */
 	int (*fault_reserve_notify)(struct ttm_buffer_object *bo);
@@ -294,9 +294,9 @@ struct ttm_bo_driver {
 	 * are balanced.
 	 */
 	int (*io_mem_reserve)(struct ttm_bo_device *bdev,
-			      struct ttm_mem_reg *mem);
+			      struct ttm_resource *mem);
 	void (*io_mem_free)(struct ttm_bo_device *bdev,
-			    struct ttm_mem_reg *mem);
+			    struct ttm_resource *mem);
 
 	/**
 	 * Return the pfn for a given page_offset inside the BO.
@@ -508,7 +508,7 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
  * @bo: Pointer to a struct ttm_buffer_object. the data of which
  * we want to allocate space for.
  * @proposed_placement: Proposed new placement for the buffer object.
- * @mem: A struct ttm_mem_reg.
+ * @mem: A struct ttm_resource.
  * @interruptible: Sleep interruptible when sliping.
  * @no_wait_gpu: Return immediately if the GPU is busy.
  *
@@ -523,10 +523,10 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
  */
 int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 		     struct ttm_placement *placement,
-		     struct ttm_mem_reg *mem,
+		     struct ttm_resource *mem,
 		     struct ttm_operation_ctx *ctx);
 
-void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);
+void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem);
 
 int ttm_bo_device_release(struct ttm_bo_device *bdev);
 
@@ -722,16 +722,16 @@ int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
  */
 
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
-		       struct ttm_mem_reg *mem);
+		       struct ttm_resource *mem);
 void ttm_mem_io_free(struct ttm_bo_device *bdev,
-		     struct ttm_mem_reg *mem);
+		     struct ttm_resource *mem);
 /**
  * ttm_bo_move_ttm
  *
  * @bo: A pointer to a struct ttm_buffer_object.
  * @interruptible: Sleep interruptible if waiting.
  * @no_wait_gpu: Return immediately if the GPU is busy.
- * @new_mem: struct ttm_mem_reg indicating where to move.
+ * @new_mem: struct ttm_resource indicating where to move.
  *
  * Optimized move function for a buffer object with both old and
  * new placement backed by a TTM. The function will, if successful,
@@ -745,7 +745,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
 
 int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 		    struct ttm_operation_ctx *ctx,
-		    struct ttm_mem_reg *new_mem);
+		    struct ttm_resource *new_mem);
 
 /**
  * ttm_bo_move_memcpy
@@ -753,7 +753,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
  * @bo: A pointer to a struct ttm_buffer_object.
  * @interruptible: Sleep interruptible if waiting.
  * @no_wait_gpu: Return immediately if the GPU is busy.
- * @new_mem: struct ttm_mem_reg indicating where to move.
+ * @new_mem: struct ttm_resource indicating where to move.
  *
  * Fallback move function for a mappable buffer object in mappable memory.
  * The function will, if successful,
@@ -767,7 +767,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 
 int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 		       struct ttm_operation_ctx *ctx,
-		       struct ttm_mem_reg *new_mem);
+		       struct ttm_resource *new_mem);
 
 /**
  * ttm_bo_free_old_node
@@ -784,7 +784,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
  * @bo: A pointer to a struct ttm_buffer_object.
  * @fence: A fence object that signals when moving is complete.
  * @evict: This is an evict move. Don't return until the buffer is idle.
- * @new_mem: struct ttm_mem_reg indicating where to move.
+ * @new_mem: struct ttm_resource indicating where to move.
  *
  * Accelerated move function to be called when an accelerated move
  * has been scheduled. The function will create a new temporary buffer object
@@ -795,7 +795,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
  */
 int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 			      struct dma_fence *fence, bool evict,
-			      struct ttm_mem_reg *new_mem);
+			      struct ttm_resource *new_mem);
 
 /**
  * ttm_bo_pipeline_move.
@@ -803,14 +803,14 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
  * @bo: A pointer to a struct ttm_buffer_object.
  * @fence: A fence object that signals when moving is complete.
  * @evict: This is an evict move. Don't return until the buffer is idle.
- * @new_mem: struct ttm_mem_reg indicating where to move.
+ * @new_mem: struct ttm_resource indicating where to move.
  *
  * Function for pipelining accelerated moves. Either free the memory
  * immediately or hang it on a temporary buffer object.
  */
 int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
 			 struct dma_fence *fence, bool evict,
-			 struct ttm_mem_reg *new_mem);
+			 struct ttm_resource *new_mem);
 
 /**
  * ttm_bo_pipeline_gutting.
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
index 5e2393fe42c6..241cc40839ed 100644
--- a/include/drm/ttm/ttm_tt.h
+++ b/include/drm/ttm/ttm_tt.h
@@ -30,7 +30,7 @@
 #include <linux/types.h>
 
 struct ttm_tt;
-struct ttm_mem_reg;
+struct ttm_resource;
 struct ttm_buffer_object;
 struct ttm_operation_ctx;
 
@@ -53,14 +53,14 @@ struct ttm_backend_func {
 	 * struct ttm_backend_func member bind
 	 *
 	 * @ttm: Pointer to a struct ttm_tt.
-	 * @bo_mem: Pointer to a struct ttm_mem_reg describing the
+	 * @bo_mem: Pointer to a struct ttm_resource describing the
 	 * memory type and location for binding.
 	 *
 	 * Bind the backend pages into the aperture in the location
 	 * indicated by @bo_mem. This function should be able to handle
 	 * differences between aperture and system page sizes.
 	 */
-	int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
+	int (*bind) (struct ttm_tt *ttm, struct ttm_resource *bo_mem);
 
 	/**
 	 * struct ttm_backend_func member unbind
@@ -179,11 +179,11 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
  * ttm_ttm_bind:
  *
  * @ttm: The struct ttm_tt containing backing pages.
- * @bo_mem: The struct ttm_mem_reg identifying the binding location.
+ * @bo_mem: The struct ttm_resource identifying the binding location.
  *
  * Bind the pages of @ttm to an aperture location identified by @bo_mem
  */
-int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
+int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
 		struct ttm_operation_ctx *ctx);
 
 /**
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 136+ messages in thread

* Re: [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (58 preceding siblings ...)
  2020-08-04  2:56 ` [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource Dave Airlie
@ 2020-08-04  3:01 ` Dave Airlie
  2020-08-05 11:55 ` Christian König
  60 siblings, 0 replies; 136+ messages in thread
From: Dave Airlie @ 2020-08-04  3:01 UTC (permalink / raw)
  To: dri-devel
  Cc: Linux-graphics-maintainer, Gerd Hoffmann, Roland Scheidegger,
	Koenig, Christian, Ben Skeggs

On Tue, 4 Aug 2020 at 12:56, Dave Airlie <airlied@gmail.com> wrote:
>
> I've decided to repost the whole queue this time, it has a few driver
> patches up front that are just cleanups.

Sample branch is

https://cgit.freedesktop.org/~airlied/linux/log/?h=ttm-refactor-mem-manager-rename

Dave.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 07/59] drm/vram-helper: remove populate/unpopulate
  2020-08-04  2:55 ` [PATCH 07/59] drm/vram-helper: remove populate/unpopulate Dave Airlie
@ 2020-08-04  6:54   ` Thomas Zimmermann
  0 siblings, 0 replies; 136+ messages in thread
From: Thomas Zimmermann @ 2020-08-04  6:54 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: linux-graphics-maintainer, kraxel, sroland, christian.koenig, bskeggs


[-- Attachment #1.1.1: Type: text/plain, Size: 1212 bytes --]



Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> The default path for populate/unpopulate is already this.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 5f03c6137ef9..a93a00966f3a 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1061,8 +1061,6 @@ static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
>  
>  static struct ttm_bo_driver bo_driver = {
>  	.ttm_tt_create = bo_driver_ttm_tt_create,
> -	.ttm_tt_populate = ttm_pool_populate,
> -	.ttm_tt_unpopulate = ttm_pool_unpopulate,
>  	.eviction_valuable = ttm_bo_eviction_valuable,
>  	.evict_flags = bo_driver_evict_flags,
>  	.move_notify = bo_driver_move_notify,
> 

-- 
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: 516 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] 136+ messages in thread

* Re: [PATCH 12/59] drm/vram-helper: call the ttm manager debug function
  2020-08-04  2:55 ` [PATCH 12/59] drm/vram-helper: call the ttm manager debug function Dave Airlie
@ 2020-08-04  6:55   ` Thomas Zimmermann
  2020-08-04 10:48   ` Gerd Hoffmann
  1 sibling, 0 replies; 136+ messages in thread
From: Thomas Zimmermann @ 2020-08-04  6:55 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: linux-graphics-maintainer, kraxel, sroland, christian.koenig, bskeggs


[-- Attachment #1.1.1: Type: text/plain, Size: 1475 bytes --]



Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> This code was assuming there was a drm_mm here, don't do
> that call the correct API.
> 
> v2: use the new exported interface.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index a93a00966f3a..c20aee2fddf3 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1075,12 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
>  	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
> -	struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM].priv;
> +	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
>  	struct drm_printer p = drm_seq_file_printer(m);
>  
> -	spin_lock(&ttm_bo_glob.lru_lock);
> -	drm_mm_print(mm, &p);
> -	spin_unlock(&ttm_bo_glob.lru_lock);
> +	ttm_mem_type_manager_debug(man, &p);
>  	return 0;
>  }
>  
> 

-- 
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: 516 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] 136+ messages in thread

* Re: [PATCH 18/59] drm/vram_helper: use new ttm manager init function
  2020-08-04  2:55 ` [PATCH 18/59] drm/vram_helper: use new ttm manager init function Dave Airlie
@ 2020-08-04  6:58   ` Thomas Zimmermann
  2020-08-04 10:49   ` Gerd Hoffmann
  1 sibling, 0 replies; 136+ messages in thread
From: Thomas Zimmermann @ 2020-08-04  6:58 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: linux-graphics-maintainer, kraxel, sroland, christian.koenig, bskeggs


[-- Attachment #1.1.1: Type: text/plain, Size: 1228 bytes --]



Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index c20aee2fddf3..d7c0fdf82eb6 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1116,10 +1116,9 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	man->func = &ttm_bo_manager_func;
>  	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>  	man->default_caching = TTM_PL_FLAG_WC;
> -	ret = ttm_bo_init_mm(&vmm->bdev, TTM_PL_VRAM, vram_size >> PAGE_SHIFT);
> +	ret = ttm_range_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT);
>  	if (ret)
>  		return ret;
>  
> 

-- 
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: 516 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] 136+ messages in thread

* Re: [PATCH 29/59] drm/vram_helper: call explicit mm takedown
  2020-08-04  2:56 ` [PATCH 29/59] drm/vram_helper: call explicit mm takedown Dave Airlie
@ 2020-08-04  6:59   ` Thomas Zimmermann
  0 siblings, 0 replies; 136+ messages in thread
From: Thomas Zimmermann @ 2020-08-04  6:59 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: linux-graphics-maintainer, kraxel, sroland, christian.koenig, bskeggs


[-- Attachment #1.1.1: Type: text/plain, Size: 1022 bytes --]



Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index d7c0fdf82eb6..2099851c017e 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1127,6 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>  
>  static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
>  {
> +	ttm_range_man_fini(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]);
>  	ttm_bo_device_release(&vmm->bdev);
>  }
>  
> 

-- 
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: 516 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] 136+ messages in thread

* Re: [PATCH 38/59] drm/vram-helper: use wrapper to access memory managers
  2020-08-04  2:56 ` [PATCH 38/59] drm/vram-helper: use wrapper to access " Dave Airlie
@ 2020-08-04  7:00   ` Thomas Zimmermann
  0 siblings, 0 replies; 136+ messages in thread
From: Thomas Zimmermann @ 2020-08-04  7:00 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: linux-graphics-maintainer, kraxel, sroland, christian.koenig, bskeggs


[-- Attachment #1.1.1: Type: text/plain, Size: 2005 bytes --]



Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 2099851c017e..a01768adb96d 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1075,7 +1075,7 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
>  	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
> -	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
>  	struct drm_printer p = drm_seq_file_printer(m);
>  
>  	ttm_mem_type_manager_debug(man, &p);
> @@ -1103,7 +1103,7 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
>  static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>  			    uint64_t vram_base, size_t vram_size)
>  {
> -	struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
>  	int ret;
>  
>  	vmm->vram_base = vram_base;
> @@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>  
>  static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
>  {
> -	ttm_range_man_fini(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]);
> +	ttm_range_man_fini(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM));
>  	ttm_bo_device_release(&vmm->bdev);
>  }
>  
> 

-- 
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: 516 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] 136+ messages in thread

* Re: [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths
  2020-08-04  2:55 ` [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths Dave Airlie
@ 2020-08-04 10:33   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 10:33 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Drop the WARN_ON and consolidate the two paths into one.
>
> Use the consolidate slowpath in the execbuf utils code.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 +-
>   drivers/gpu/drm/ttm/ttm_execbuf_util.c     | 12 +--
>   include/drm/ttm/ttm_bo_driver.h            | 91 ++++------------------
>   3 files changed, 20 insertions(+), 85 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index afa5189dba7d..e01e8903741e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -160,7 +160,7 @@ static inline int amdgpu_bo_reserve(struct amdgpu_bo *bo, bool no_intr)
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
>   	int r;
>   
> -	r = __ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
> +	r = ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
>   	if (unlikely(r != 0)) {
>   		if (r != -ERESTARTSYS)
>   			dev_err(adev->dev, "%p reserve failed\n", bo);
> diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> index 1797f04c0534..8a8f1a6a83a6 100644
> --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> @@ -93,7 +93,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
>   	list_for_each_entry(entry, list, head) {
>   		struct ttm_buffer_object *bo = entry->bo;
>   
> -		ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
> +		ret = ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
>   		if (ret == -EALREADY && dups) {
>   			struct ttm_validate_buffer *safe = entry;
>   			entry = list_prev_entry(entry, head);
> @@ -119,13 +119,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
>   		ttm_eu_backoff_reservation_reverse(list, entry);
>   
>   		if (ret == -EDEADLK) {
> -			if (intr) {
> -				ret = dma_resv_lock_slow_interruptible(bo->base.resv,
> -										 ticket);
> -			} else {
> -				dma_resv_lock_slow(bo->base.resv, ticket);
> -				ret = 0;
> -			}
> +			ret = ttm_bo_reserve_slowpath(bo, intr, ticket);
>   		}
>   
>   		if (!ret && entry->num_shared)
> @@ -133,8 +127,6 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
>   								entry->num_shared);
>   
>   		if (unlikely(ret != 0)) {
> -			if (ret == -EINTR)
> -				ret = -ERESTARTSYS;
>   			if (ticket) {
>   				ww_acquire_done(ticket);
>   				ww_acquire_fini(ticket);
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 09211ecbf84f..c20fef4da1d3 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -588,29 +588,30 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible);
>   void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
>   
>   /**
> - * __ttm_bo_reserve:
> + * ttm_bo_reserve:
>    *
>    * @bo: A pointer to a struct ttm_buffer_object.
>    * @interruptible: Sleep interruptible if waiting.
>    * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY.
>    * @ticket: ticket used to acquire the ww_mutex.
>    *
> - * Will not remove reserved buffers from the lru lists.
> - * Otherwise identical to ttm_bo_reserve.
> + * Locks a buffer object for validation. (Or prevents other processes from
> + * locking it for validation), while taking a number of measures to prevent
> + * deadlocks.
>    *
>    * Returns:
>    * -EDEADLK: The reservation may cause a deadlock.
>    * Release all buffer reservations, wait for @bo to become unreserved and
> - * try again. (only if use_sequence == 1).
> + * try again.
>    * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
>    * a signal. Release all buffer reservations and return to user-space.
>    * -EBUSY: The function needed to sleep, but @no_wait was true
>    * -EALREADY: Bo already reserved using @ticket. This error code will only
>    * be returned if @use_ticket is set to true.
>    */
> -static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
> -				   bool interruptible, bool no_wait,
> -				   struct ww_acquire_ctx *ticket)
> +static inline int ttm_bo_reserve(struct ttm_buffer_object *bo,
> +				 bool interruptible, bool no_wait,
> +				 struct ww_acquire_ctx *ticket)
>   {
>   	int ret = 0;
>   
> @@ -632,59 +633,6 @@ static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
>   	return ret;
>   }
>   
> -/**
> - * ttm_bo_reserve:
> - *
> - * @bo: A pointer to a struct ttm_buffer_object.
> - * @interruptible: Sleep interruptible if waiting.
> - * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY.
> - * @ticket: ticket used to acquire the ww_mutex.
> - *
> - * Locks a buffer object for validation. (Or prevents other processes from
> - * locking it for validation) and removes it from lru lists, while taking
> - * a number of measures to prevent deadlocks.
> - *
> - * Deadlocks may occur when two processes try to reserve multiple buffers in
> - * different order, either by will or as a result of a buffer being evicted
> - * to make room for a buffer already reserved. (Buffers are reserved before
> - * they are evicted). The following algorithm prevents such deadlocks from
> - * occurring:
> - * Processes attempting to reserve multiple buffers other than for eviction,
> - * (typically execbuf), should first obtain a unique 32-bit
> - * validation sequence number,
> - * and call this function with @use_ticket == 1 and @ticket->stamp == the unique
> - * sequence number. If upon call of this function, the buffer object is already
> - * reserved, the validation sequence is checked against the validation
> - * sequence of the process currently reserving the buffer,
> - * and if the current validation sequence is greater than that of the process
> - * holding the reservation, the function returns -EDEADLK. Otherwise it sleeps
> - * waiting for the buffer to become unreserved, after which it retries
> - * reserving.
> - * The caller should, when receiving an -EDEADLK error
> - * release all its buffer reservations, wait for @bo to become unreserved, and
> - * then rerun the validation with the same validation sequence. This procedure
> - * will always guarantee that the process with the lowest validation sequence
> - * will eventually succeed, preventing both deadlocks and starvation.
> - *
> - * Returns:
> - * -EDEADLK: The reservation may cause a deadlock.
> - * Release all buffer reservations, wait for @bo to become unreserved and
> - * try again. (only if use_sequence == 1).
> - * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
> - * a signal. Release all buffer reservations and return to user-space.
> - * -EBUSY: The function needed to sleep, but @no_wait was true
> - * -EALREADY: Bo already reserved using @ticket. This error code will only
> - * be returned if @use_ticket is set to true.
> - */
> -static inline int ttm_bo_reserve(struct ttm_buffer_object *bo,
> -				 bool interruptible, bool no_wait,
> -				 struct ww_acquire_ctx *ticket)
> -{
> -	WARN_ON(!kref_read(&bo->kref));
> -
> -	return __ttm_bo_reserve(bo, interruptible, no_wait, ticket);
> -}
> -
>   /**
>    * ttm_bo_reserve_slowpath:
>    * @bo: A pointer to a struct ttm_buffer_object.
> @@ -699,20 +647,15 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
>   					  bool interruptible,
>   					  struct ww_acquire_ctx *ticket)
>   {
> -	int ret = 0;
> -
> -	WARN_ON(!kref_read(&bo->kref));
> -
> -	if (interruptible)
> -		ret = dma_resv_lock_slow_interruptible(bo->base.resv,
> -								 ticket);
> -	else
> -		dma_resv_lock_slow(bo->base.resv, ticket);
> -
> -	if (ret == -EINTR)
> -		ret = -ERESTARTSYS;
> -
> -	return ret;
> +	if (interruptible) {
> +		int ret = dma_resv_lock_slow_interruptible(bo->base.resv,
> +							   ticket);
> +		if (ret == -EINTR)
> +			ret = -ERESTARTSYS;
> +		return ret;
> +	}
> +	dma_resv_lock_slow(bo->base.resv, ticket);
> +	return 0;
>   }
>   
>   /**

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail
  2020-08-04  2:55 ` [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail Dave Airlie
@ 2020-08-04 10:34   ` Christian König
  2020-08-05  5:32     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 10:34 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The pattern was repeated a few times, just make an inline for it.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    |  8 ++------
>   drivers/gpu/drm/ttm/ttm_bo_vm.c |  4 +---
>   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++---
>   3 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 721ff546bf47..2b49037231eb 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1103,9 +1103,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   
>   error:
>   	if (bo->mem.mem_type == TTM_PL_SYSTEM && !list_empty(&bo->lru)) {
> -		spin_lock(&ttm_bo_glob.lru_lock);
> -		ttm_bo_move_to_lru_tail(bo, NULL);
> -		spin_unlock(&ttm_bo_glob.lru_lock);
> +		ttm_bo_move_to_lru_tail_unlocked(bo);
>   	}
>   
>   	return ret;
> @@ -1320,9 +1318,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
>   		return ret;
>   	}
>   
> -	spin_lock(&ttm_bo_glob.lru_lock);
> -	ttm_bo_move_to_lru_tail(bo, NULL);
> -	spin_unlock(&ttm_bo_glob.lru_lock);
> +	ttm_bo_move_to_lru_tail_unlocked(bo);
>   
>   	return ret;
>   }
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index d7a6537dd6ee..468a0eb9e632 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -308,9 +308,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>   		}
>   
>   		if (bo->moving != moving) {
> -			spin_lock(&ttm_bo_glob.lru_lock);
> -			ttm_bo_move_to_lru_tail(bo, NULL);
> -			spin_unlock(&ttm_bo_glob.lru_lock);
> +			ttm_bo_move_to_lru_tail_unlocked(bo);
>   		}
>   		dma_fence_put(moving);
>   	}
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index c20fef4da1d3..7958e411269a 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -658,6 +658,13 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
>   	return 0;
>   }
>   
> +static inline void ttm_bo_move_to_lru_tail_unlocked(struct ttm_buffer_object *bo)
> +{
> +	spin_lock(&ttm_bo_glob.lru_lock);
> +	ttm_bo_move_to_lru_tail(bo, NULL);
> +	spin_unlock(&ttm_bo_glob.lru_lock);
> +}
> +
>   /**
>    * ttm_bo_unreserve
>    *
> @@ -667,9 +674,7 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
>    */
>   static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>   {
> -	spin_lock(&ttm_bo_glob.lru_lock);
> -	ttm_bo_move_to_lru_tail(bo, NULL);
> -	spin_unlock(&ttm_bo_glob.lru_lock);
> +	ttm_bo_move_to_lru_tail_unlocked(bo);
>   	dma_resv_unlock(bo->base.resv);
>   }
>   

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 08/59] drm/ttm: export memory type debug entrypoint.
  2020-08-04  2:55 ` [PATCH 08/59] drm/ttm: export memory type debug entrypoint Dave Airlie
@ 2020-08-04 10:35   ` Christian König
  2020-08-05  5:34     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 10:35 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> As suggested on review, just export the memory type debug for
> drivers to use, while also making the debug callback optional
> (don't need to test for system as it won't init it).
>
> rename it to be more consistent with object name for now.
> (we may rename all the objects later.)
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 13 +++++++------
>   include/drm/ttm/ttm_bo_driver.h |  8 ++++++++
>   2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 2b49037231eb..2ac70ec1f37d 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -77,26 +77,26 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
>   	return 0;
>   }
>   
> -static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p,
> -			       int mem_type)
> +void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> +				struct drm_printer *p)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
> -
>   	drm_printf(p, "    has_type: %d\n", man->has_type);
>   	drm_printf(p, "    use_type: %d\n", man->use_type);
>   	drm_printf(p, "    use_tt: %d\n", man->use_tt);
>   	drm_printf(p, "    size: %llu\n", man->size);
>   	drm_printf(p, "    available_caching: 0x%08X\n", man->available_caching);
>   	drm_printf(p, "    default_caching: 0x%08X\n", man->default_caching);
> -	if (mem_type != TTM_PL_SYSTEM)
> +	if (man->func && man->func->debug)
>   		(*man->func->debug)(man, p);
>   }
> +EXPORT_SYMBOL(ttm_mem_type_manager_debug);
>   
>   static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
>   					struct ttm_placement *placement)
>   {
>   	struct drm_printer p = drm_debug_printer(TTM_PFX);
>   	int i, ret, mem_type;
> +	struct ttm_mem_type_manager *man;
>   
>   	drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
>   		   bo, bo->mem.num_pages, bo->mem.size >> 10,
> @@ -108,7 +108,8 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
>   			return;
>   		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
>   			   i, placement->placement[i].flags, mem_type);
> -		ttm_mem_type_debug(bo->bdev, &p, mem_type);
> +		man = &bo->bdev->man[mem_type];
> +		ttm_mem_type_manager_debug(man, &p);
>   	}
>   }
>   
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 7958e411269a..73f5d9c766cc 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -795,4 +795,12 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
>   
>   extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
>   
> +/**
> + * ttm_mem_type_manager_debug
> + *
> + * @man: manager type to dump.
> + * @p: printer to use for debug.
> + */
> +void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> +				struct drm_printer *p);
>   #endif

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function
  2020-08-04  2:55 ` [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function Dave Airlie
@ 2020-08-04 10:46   ` Gerd Hoffmann
  0 siblings, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:46 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:55:37PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2)
  2020-08-04  2:55 ` [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2) Dave Airlie
@ 2020-08-04 10:48   ` Gerd Hoffmann
  0 siblings, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:48 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:55:44PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> v2: use the new exported interface.
> This code was poking inside a struct and assuming it was a drm_mm
> at the start. Call the proper API.

[ also adds some debug info about the ttm manager to the file ]

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 12/59] drm/vram-helper: call the ttm manager debug function
  2020-08-04  2:55 ` [PATCH 12/59] drm/vram-helper: call the ttm manager debug function Dave Airlie
  2020-08-04  6:55   ` Thomas Zimmermann
@ 2020-08-04 10:48   ` Gerd Hoffmann
  1 sibling, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:48 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:55:45PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This code was assuming there was a drm_mm here, don't do
> that call the correct API.
> 
> v2: use the new exported interface.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 17/59] drm/qxl/ttm: use new init path for manager
  2020-08-04  2:55 ` [PATCH 17/59] drm/qxl/ttm: use new init path for manager Dave Airlie
@ 2020-08-04 10:49   ` Gerd Hoffmann
  0 siblings, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:49 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:55:50PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 18/59] drm/vram_helper: use new ttm manager init function
  2020-08-04  2:55 ` [PATCH 18/59] drm/vram_helper: use new ttm manager init function Dave Airlie
  2020-08-04  6:58   ` Thomas Zimmermann
@ 2020-08-04 10:49   ` Gerd Hoffmann
  1 sibling, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:49 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:55:51PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 32/59] drm/qxl/ttm: use new takedown path
  2020-08-04  2:56 ` [PATCH 32/59] drm/qxl/ttm: use new takedown path Dave Airlie
@ 2020-08-04 10:50   ` Gerd Hoffmann
  0 siblings, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:50 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:56:05PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager
  2020-08-04  2:56 ` [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager Dave Airlie
@ 2020-08-04 10:50   ` Gerd Hoffmann
  0 siblings, 0 replies; 136+ messages in thread
From: Gerd Hoffmann @ 2020-08-04 10:50 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, linux-graphics-maintainer, bskeggs, dri-devel, christian.koenig

On Tue, Aug 04, 2020 at 12:56:13PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 13/59] drm/ttm: split the mm manager init code (v2)
  2020-08-04  2:55 ` [PATCH 13/59] drm/ttm: split the mm manager init code (v2) Dave Airlie
@ 2020-08-04 11:07   ` Christian König
  2020-08-04 13:08     ` Christian König
  2020-08-04 11:10   ` Christian König
  1 sibling, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:07 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will allow the driver to control the ordering here better.
>
> Eventually the old path will be removed.
>
> v2: add docs for new APIs.
> rename new path to ttm_mem_type_manager_init/set_used(for now)
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 34 +++++++++++++++++++--------------
>   include/drm/ttm/ttm_bo_api.h    | 15 +++++++++++++++
>   include/drm/ttm/ttm_bo_driver.h | 15 +++++++++++++++
>   3 files changed, 50 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 2ac70ec1f37d..300bcc10696a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1509,35 +1509,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   }
>   EXPORT_SYMBOL(ttm_bo_evict_mm);
>   
> -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> -			unsigned long p_size)
> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> +			       struct ttm_mem_type_manager *man,
> +			       unsigned long p_size)
>   {
> -	int ret;
> -	struct ttm_mem_type_manager *man;
>   	unsigned i;
>   
> -	BUG_ON(type >= TTM_NUM_MEM_TYPES);
> -	man = &bdev->man[type];
>   	BUG_ON(man->has_type);
>   	man->use_io_reserve_lru = false;
>   	mutex_init(&man->io_reserve_mutex);
>   	spin_lock_init(&man->move_lock);
>   	INIT_LIST_HEAD(&man->io_reserve_lru);
>   	man->bdev = bdev;
> -
> -	if (type != TTM_PL_SYSTEM) {
> -		ret = (*man->func->init)(man, p_size);
> -		if (ret)
> -			return ret;
> -	}
> -	man->has_type = true;
> -	man->use_type = true;
>   	man->size = p_size;
>   
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
>   		INIT_LIST_HEAD(&man->lru[i]);
>   	man->move = NULL;
> +}
> +EXPORT_SYMBOL(ttm_mem_type_manager_init);
>   
> +int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> +			unsigned long p_size)
> +{
> +	int ret;
> +	struct ttm_mem_type_manager *man;
> +
> +	BUG_ON(type >= TTM_NUM_MEM_TYPES);
> +	ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
> +
> +	if (type != TTM_PL_SYSTEM) {
> +		ret = (*man->func->init)(man, p_size);
> +		if (ret)
> +			return ret;
> +	}
> +	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
>   EXPORT_SYMBOL(ttm_bo_init_mm);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index a9e13b252820..89053e761a69 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -54,6 +54,8 @@ struct ttm_place;
>   
>   struct ttm_lru_bulk_move;
>   
> +struct ttm_mem_type_manager;
> +
>   /**
>    * struct ttm_bus_placement
>    *
> @@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
>   		  uint32_t page_alignment, bool interruptible,
>   		  struct ttm_buffer_object **p_bo);
>   
> +/**
> + * ttm_mem_type_manager_init
> + *
> + * @bdev: Pointer to a ttm_bo_device struct.
> + * @man: memory manager object to init
> + * @p_size: size managed area in pages.
> + *
> + * Initialise core parts of a a manager object.
> + */
> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> +			       struct ttm_mem_type_manager *man,
> +			       unsigned long p_size);
> +
>   /**
>    * ttm_bo_init_mm
>    *
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 73f5d9c766cc..6b49c0356343 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -678,6 +678,21 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>   	dma_resv_unlock(bo->base.resv);
>   }
>   
> +/**
> + * ttm_mem_type_manager_set_used
> + *
> + * @man: A memory manager object.
> + * @used: usage state to set.
> + *
> + * Set the manager in use flag. If disabled the manager is no longer
> + * used for object placement.
> + */
> +static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
> +{
> +	man->has_type = true;
> +	man->use_type = used;
> +}
> +
>   /*
>    * ttm_bo_util.c
>    */

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 13/59] drm/ttm: split the mm manager init code (v2)
  2020-08-04  2:55 ` [PATCH 13/59] drm/ttm: split the mm manager init code (v2) Dave Airlie
  2020-08-04 11:07   ` Christian König
@ 2020-08-04 11:10   ` Christian König
  1 sibling, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:10 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will allow the driver to control the ordering here better.
>
> Eventually the old path will be removed.
>
> v2: add docs for new APIs.
> rename new path to ttm_mem_type_manager_init/set_used(for now)
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 34 +++++++++++++++++++--------------
>   include/drm/ttm/ttm_bo_api.h    | 15 +++++++++++++++
>   include/drm/ttm/ttm_bo_driver.h | 15 +++++++++++++++
>   3 files changed, 50 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 2ac70ec1f37d..300bcc10696a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1509,35 +1509,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   }
>   EXPORT_SYMBOL(ttm_bo_evict_mm);
>   
> -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> -			unsigned long p_size)
> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> +			       struct ttm_mem_type_manager *man,
> +			       unsigned long p_size)
>   {
> -	int ret;
> -	struct ttm_mem_type_manager *man;
>   	unsigned i;
>   
> -	BUG_ON(type >= TTM_NUM_MEM_TYPES);
> -	man = &bdev->man[type];
>   	BUG_ON(man->has_type);
>   	man->use_io_reserve_lru = false;
>   	mutex_init(&man->io_reserve_mutex);
>   	spin_lock_init(&man->move_lock);
>   	INIT_LIST_HEAD(&man->io_reserve_lru);
>   	man->bdev = bdev;
> -
> -	if (type != TTM_PL_SYSTEM) {
> -		ret = (*man->func->init)(man, p_size);
> -		if (ret)
> -			return ret;
> -	}
> -	man->has_type = true;
> -	man->use_type = true;
>   	man->size = p_size;
>   
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
>   		INIT_LIST_HEAD(&man->lru[i]);
>   	man->move = NULL;
> +}
> +EXPORT_SYMBOL(ttm_mem_type_manager_init);
>   
> +int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> +			unsigned long p_size)
> +{
> +	int ret;
> +	struct ttm_mem_type_manager *man;
> +
> +	BUG_ON(type >= TTM_NUM_MEM_TYPES);
> +	ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
> +
> +	if (type != TTM_PL_SYSTEM) {
> +		ret = (*man->func->init)(man, p_size);
> +		if (ret)
> +			return ret;
> +	}
> +	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
>   EXPORT_SYMBOL(ttm_bo_init_mm);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index a9e13b252820..89053e761a69 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -54,6 +54,8 @@ struct ttm_place;
>   
>   struct ttm_lru_bulk_move;
>   
> +struct ttm_mem_type_manager;
> +
>   /**
>    * struct ttm_bus_placement
>    *
> @@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
>   		  uint32_t page_alignment, bool interruptible,
>   		  struct ttm_buffer_object **p_bo);
>   
> +/**
> + * ttm_mem_type_manager_init
> + *
> + * @bdev: Pointer to a ttm_bo_device struct.
> + * @man: memory manager object to init
> + * @p_size: size managed area in pages.
> + *
> + * Initialise core parts of a a manager object.
> + */

As far as I know we usually have the documentation on the function 
instead of the prototype in the Linux kernel.

Christian.

> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> +			       struct ttm_mem_type_manager *man,
> +			       unsigned long p_size);
> +
>   /**
>    * ttm_bo_init_mm
>    *
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 73f5d9c766cc..6b49c0356343 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -678,6 +678,21 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>   	dma_resv_unlock(bo->base.resv);
>   }
>   
> +/**
> + * ttm_mem_type_manager_set_used
> + *
> + * @man: A memory manager object.
> + * @used: usage state to set.
> + *
> + * Set the manager in use flag. If disabled the manager is no longer
> + * used for object placement.
> + */
> +static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
> +{
> +	man->has_type = true;
> +	man->use_type = used;
> +}
> +
>   /*
>    * ttm_bo_util.c
>    */

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side.
  2020-08-04  2:55 ` [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side Dave Airlie
@ 2020-08-04 11:15   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:15 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Use new init calls to unwrap manager init
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 19 ++++++----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c      | 37 +++-----------------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h      |  4 +--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 19 ++++++----
>   4 files changed, 33 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 77fae40197ab..9d05e1ab2048 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -76,6 +76,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
>   static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
>   	           amdgpu_mem_info_gtt_used_show, NULL);
>   
> +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
>   /**
>    * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
>    *
> @@ -84,14 +85,20 @@ static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
>    *
>    * Allocate and initialize the GTT manager.
>    */
> -static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
> -			       unsigned long p_size)
> +int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   {
> -	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
> +	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
>   	struct amdgpu_gtt_mgr *mgr;
>   	uint64_t start, size;
>   	int ret;
>   
> +	man->use_tt = true;
> +	man->func = &amdgpu_gtt_mgr_func;
> +	man->available_caching = TTM_PL_MASK_CACHING;
> +	man->default_caching = TTM_PL_FLAG_CACHED;
> +
> +	ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
> +
>   	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
>   	if (!mgr)
>   		return -ENOMEM;
> @@ -100,7 +107,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
>   	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
>   	drm_mm_init(&mgr->mm, start, size);
>   	spin_lock_init(&mgr->lock);
> -	atomic64_set(&mgr->available, p_size);
> +	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
>   	man->priv = mgr;
>   
>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
> @@ -114,6 +121,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,
>   		return ret;
>   	}
>   
> +	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
>   
> @@ -298,8 +306,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
>   		   amdgpu_gtt_mgr_usage(man) >> 20);
>   }
>   
> -const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
> -	.init = amdgpu_gtt_mgr_init,
> +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
>   	.takedown = amdgpu_gtt_mgr_fini,
>   	.get_node = amdgpu_gtt_mgr_new,
>   	.put_node = amdgpu_gtt_mgr_del,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index d3e3cad4d0cb..4a09a625e748 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -63,43 +63,16 @@
>   
>   #define AMDGPU_TTM_VRAM_MAX_DW_READ	(size_t)128
>   
> -static int amdgpu_ttm_init_vram(struct amdgpu_device *adev)
> -{
> -
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
> -
> -	man->func = &amdgpu_vram_mgr_func;
> -	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> -	man->default_caching = TTM_PL_FLAG_WC;
> -
> -	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
> -			      adev->gmc.real_vram_size >> PAGE_SHIFT);
> -}
> -
> -static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size)
> -{
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
> -
> -	man->use_tt = true;
> -	man->func = &amdgpu_gtt_mgr_func;
> -	man->available_caching = TTM_PL_MASK_CACHING;
> -	man->default_caching = TTM_PL_FLAG_CACHED;
> -
> -	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT,
> -			      gtt_size >> PAGE_SHIFT);
> -}
> -
>   static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
> -				   unsigned int type,
> -				   uint64_t size)
> +				    unsigned int type,
> +				    uint64_t size)
>   {
>   	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
>   
> -	man->func = &ttm_bo_manager_func;
>   	man->available_caching = TTM_PL_FLAG_UNCACHED;
>   	man->default_caching = TTM_PL_FLAG_UNCACHED;
>   
> -	return ttm_bo_init_mm(&adev->mman.bdev, type, size);
> +	return ttm_range_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT);
>   }
>   
>   /**
> @@ -1915,7 +1888,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
>   	adev->mman.bdev.no_retry = true;
>   
>   	/* Initialize VRAM pool with all of VRAM divided into pages */
> -	r = amdgpu_ttm_init_vram(adev);
> +	r = amdgpu_vram_mgr_init(adev);
>   	if (r) {
>   		DRM_ERROR("Failed initializing VRAM heap.\n");
>   		return r;
> @@ -1982,7 +1955,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
>   		gtt_size = (uint64_t)amdgpu_gtt_size << 20;
>   
>   	/* Initialize GTT memory pool */
> -	r = amdgpu_ttm_init_gtt(adev, gtt_size);
> +	r = amdgpu_gtt_mgr_init(adev, gtt_size);
>   	if (r) {
>   		DRM_ERROR("Failed initializing GTT heap.\n");
>   		return r;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> index 17c8d0d7bcc3..fb45c0a323b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> @@ -67,8 +67,8 @@ struct amdgpu_copy_mem {
>   	unsigned long			offset;
>   };
>   
> -extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
> -extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
> +int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size);
> +int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
>   
>   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
>   uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 134cc36e30c5..bef3497de2ae 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -158,6 +158,8 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
>   	NULL
>   };
>   
> +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
> +
>   /**
>    * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
>    *
> @@ -166,18 +168,23 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
>    *
>    * Allocate and initialize the VRAM manager.
>    */
> -static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
> -				unsigned long p_size)
> +int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   {
> -	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
> +	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
>   	struct amdgpu_vram_mgr *mgr;
>   	int ret;
>   
> +	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> +	man->default_caching = TTM_PL_FLAG_WC;
> +
> +	ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> +
> +	man->func = &amdgpu_vram_mgr_func;
>   	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
>   	if (!mgr)
>   		return -ENOMEM;
>   
> -	drm_mm_init(&mgr->mm, 0, p_size);
> +	drm_mm_init(&mgr->mm, 0, man->size);
>   	spin_lock_init(&mgr->lock);
>   	man->priv = mgr;
>   
> @@ -186,6 +193,7 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
>   	if (ret)
>   		DRM_ERROR("Failed to register sysfs\n");
>   
> +	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
>   
> @@ -587,8 +595,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
>   		   amdgpu_vram_mgr_vis_usage(man) >> 20);
>   }
>   
> -const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
> -	.init		= amdgpu_vram_mgr_init,
> +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
>   	.takedown	= amdgpu_vram_mgr_fini,
>   	.get_node	= amdgpu_vram_mgr_new,
>   	.put_node	= amdgpu_vram_mgr_del,

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 16/59] drm/radeon: use new ttm man init path
  2020-08-04  2:55 ` [PATCH 16/59] drm/radeon: use new ttm man init path Dave Airlie
@ 2020-08-04 11:15   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:15 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Use the new common manager init path.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon_ttm.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 0b07d8ed6edd..84c02b4529c0 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -70,19 +70,17 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev)
>   {
>   	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM];
>   
> -	man->func = &ttm_bo_manager_func;
>   	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>   	man->default_caching = TTM_PL_FLAG_WC;
>   
> -	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
> -			      rdev->mc.real_vram_size >> PAGE_SHIFT);
> +	return ttm_range_man_init(&rdev->mman.bdev, man,
> +				  rdev->mc.real_vram_size >> PAGE_SHIFT);
>   }
>   
>   static int radeon_ttm_init_gtt(struct radeon_device *rdev)
>   {
>   	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT];
>   
> -	man->func = &ttm_bo_manager_func;
>   	man->available_caching = TTM_PL_MASK_CACHING;
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   	man->use_tt = true;
> @@ -98,8 +96,8 @@ static int radeon_ttm_init_gtt(struct radeon_device *rdev)
>   	}
>   #endif
>   
> -	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
> -			      rdev->mc.gtt_size >> PAGE_SHIFT);
> +	return ttm_range_man_init(&rdev->mman.bdev, man,
> +				  rdev->mc.gtt_size >> PAGE_SHIFT);
>   }
>   
>   static void radeon_evict_flags(struct ttm_buffer_object *bo,

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2)
  2020-08-04  2:55 ` [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2) Dave Airlie
@ 2020-08-04 11:18   ` Christian König
  2020-08-05  5:42     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:18 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The disable path is just temporary for now, it will be dropped once has_type
> is gone in a later patch.
>
> v2: add docs.
> rename to ttm_mem_type_manager namespace
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
>   include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
>   2 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index af1b1c3f6ed2..127a0b62bf98 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1468,8 +1468,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		return ret;
>   	}
>   
> -	man->use_type = false;
> -	man->has_type = false;
> +	ttm_mem_type_manager_disable(man);
>   
>   	ret = 0;
>   	if (mem_type > 0) {
> @@ -1482,8 +1481,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		ret = (*man->func->takedown)(man);
>   	}
>   
> -	dma_fence_put(man->move);
> -	man->move = NULL;
> +	ttm_mem_type_manager_cleanup(man);
>   
>   	return ret;
>   }
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 548c27294c64..41bfa514c29d 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -680,6 +680,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
>   	man->use_type = used;
>   }
>   
> +/**
> + * ttm_mem_type_manager_disable.
> + *
> + * @man: A memory manager object.
> + *
> + * Indicate the manager is not to be used and deregistered. (temporary during rework).
> + */
> +static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> +{
> +	man->has_type = false;
> +	man->use_type = false;
> +}
> +
> +/**
> + * ttm_mem_type_manager_cleanup
> + *
> + * @man: A memory manager object.
> + *
> + * Cleanup the move fences from the memory manager object.
> + */
> +static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> +{
> +	dma_fence_put(man->move);
> +	man->move = NULL;
> +}
> +
>   /*
>    * ttm_bo_util.c
>    */

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2)
  2020-08-04  2:55 ` [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2) Dave Airlie
@ 2020-08-04 11:20   ` Christian König
  2020-08-05  5:43     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:20 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Allow the takedown path callback to be optional as well.
>
> v2: use fini for range manager
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c         | 12 +++++++-----
>   drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++--
>   include/drm/ttm/ttm_bo_driver.h      | 24 ++++++++++++++++++++++++
>   3 files changed, 50 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 127a0b62bf98..a45038c74de6 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1407,8 +1407,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
>   }
>   EXPORT_SYMBOL(ttm_bo_create);
>   
> -static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
> -				   struct ttm_mem_type_manager *man)
> +int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> +					  struct ttm_mem_type_manager *man)
>   {
>   	struct ttm_operation_ctx ctx = {
>   		.interruptible = false,
> @@ -1450,6 +1450,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
>   
>   	return 0;
>   }
> +EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
>   
>   int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   {
> @@ -1472,13 +1473,14 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   
>   	ret = 0;
>   	if (mem_type > 0) {
> -		ret = ttm_bo_force_list_clean(bdev, man);
> +		ret = ttm_mem_type_manager_force_list_clean(bdev, man);
>   		if (ret) {
>   			pr_err("Cleanup eviction failed\n");
>   			return ret;
>   		}
>   
> -		ret = (*man->func->takedown)(man);
> +		if (man->func->takedown)
> +			ret = (*man->func->takedown)(man);
>   	}
>   
>   	ttm_mem_type_manager_cleanup(man);
> @@ -1501,7 +1503,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		return 0;
>   	}
>   
> -	return ttm_bo_force_list_clean(bdev, man);
> +	return ttm_mem_type_manager_force_list_clean(bdev, man);
>   }
>   EXPORT_SYMBOL(ttm_bo_evict_mm);
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index b56c6961b278..96da22be672b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -129,7 +129,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   }
>   EXPORT_SYMBOL(ttm_range_man_init);
>   
> -static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
> +static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
>   {
>   	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
>   	struct drm_mm *mm = &rman->mm;
> @@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
>   	return -EBUSY;
>   }
>   
> +int ttm_range_man_fini(struct ttm_bo_device *bdev,
> +		       struct ttm_mem_type_manager *man)
> +{
> +	int ret;
> +
> +	ttm_mem_type_manager_disable(man);
> +
> +	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> +	if (ret)
> +		return ret;
> +
> +	ttm_bo_man_takedown_private(man);
> +	ttm_mem_type_manager_cleanup(man);
> +	return 0;
> +}
> +EXPORT_SYMBOL(ttm_range_man_fini);
> +
>   static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>   			     struct drm_printer *printer)
>   {
> @@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>   }
>   
>   static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> -	.takedown = ttm_bo_man_takedown,
> +	.takedown = ttm_bo_man_takedown_private,
>   	.get_node = ttm_bo_man_get_node,
>   	.put_node = ttm_bo_man_put_node,
>   	.debug = ttm_bo_man_debug
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 41bfa514c29d..9b4c22abc22c 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -706,6 +706,18 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
>   	man->move = NULL;
>   }
>   
> +/*
> + * ttm_mem_type_manager_force_list_clean
> + *
> + * @bdev - device to use
> + * @man - manager to use
> + *
> + * Force all the objects out of a memory manager until clean.
> + * Part of memory manager cleanup sequence.
> + */
> +int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> +					  struct ttm_mem_type_manager *man);
> +
>   /*
>    * ttm_bo_util.c
>    */
> @@ -835,6 +847,17 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   		       struct ttm_mem_type_manager *man,
>   		       unsigned long p_size);
>   
> +/**
> + * ttm_range_man_fini
> + *
> + * @bdev: ttm device
> + * @type: memory manager type
> + *
> + * Remove the generic range manager from a slot and tear it down.
> + */
> +int ttm_range_man_fini(struct ttm_bo_device *bdev,
> +		       struct ttm_mem_type_manager *man);
> +
>   /**
>    * ttm_mem_type_manager_debug
>    *
> @@ -843,4 +866,5 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>    */
>   void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
>   				struct drm_printer *p);
> +
>   #endif

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev.
  2020-08-04  2:56 ` [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev Dave Airlie
@ 2020-08-04 11:25   ` Christian König
  2020-08-05  5:47     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:25 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will allow different abstractions later.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c      | 34 +++++++++++++++----------------
>   drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++---------
>   drivers/gpu/drm/ttm/ttm_bo_vm.c   |  2 +-
>   include/drm/ttm/ttm_bo_driver.h   |  6 ++++++
>   4 files changed, 34 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index ebecb796dd49..8777c323e7de 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
>   			return;
>   		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
>   			   i, placement->placement[i].flags, mem_type);
> -		man = &bo->bdev->man[mem_type];
> +		man = ttm_manager_type(bo->bdev, mem_type);
>   		ttm_mem_type_manager_debug(man, &p);
>   	}
>   }
> @@ -157,7 +157,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
>   	if (mem->placement & TTM_PL_FLAG_NO_EVICT)
>   		return;
>   
> -	man = &bdev->man[mem->mem_type];
> +	man = ttm_manager_type(bdev, mem->mem_type);
>   	list_add_tail(&bo->lru, &man->lru[bo->priority]);
>   
>   	if (man->use_tt && bo->ttm &&
> @@ -232,7 +232,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
>   		dma_resv_assert_held(pos->first->base.resv);
>   		dma_resv_assert_held(pos->last->base.resv);
>   
> -		man = &pos->first->bdev->man[TTM_PL_TT];
> +		man = ttm_manager_type(pos->first->bdev, TTM_PL_TT);
>   		list_bulk_move_tail(&man->lru[i], &pos->first->lru,
>   				    &pos->last->lru);
>   	}
> @@ -247,7 +247,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
>   		dma_resv_assert_held(pos->first->base.resv);
>   		dma_resv_assert_held(pos->last->base.resv);
>   
> -		man = &pos->first->bdev->man[TTM_PL_VRAM];
> +		man = ttm_manager_type(pos->first->bdev, TTM_PL_VRAM);
>   		list_bulk_move_tail(&man->lru[i], &pos->first->lru,
>   				    &pos->last->lru);
>   	}
> @@ -273,8 +273,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type];
> -	struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> +	struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   
>   	ret = ttm_mem_io_lock(old_man, true);
> @@ -340,7 +340,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
>   	return 0;
>   
>   out_err:
> -	new_man = &bdev->man[bo->mem.mem_type];
> +	new_man = ttm_manager_type(bdev, bo->mem.mem_type);
>   	if (!new_man->use_tt) {
>   		ttm_tt_destroy(bo->ttm);
>   		bo->ttm = NULL;
> @@ -552,7 +552,7 @@ static void ttm_bo_release(struct kref *kref)
>   	struct ttm_buffer_object *bo =
>   	    container_of(kref, struct ttm_buffer_object, kref);
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
>   	size_t acc_size = bo->acc_size;
>   	int ret;
>   
> @@ -844,7 +844,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   			  const struct ttm_place *place,
>   			  struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
>   	mem->mm_node = NULL;
>   	if (!man->func || !man->func->get_node)
> @@ -855,7 +855,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   
>   void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
>   	if (!man->func || !man->func->put_node)
>   		return;
> @@ -912,7 +912,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	struct ww_acquire_ctx *ticket;
>   	int ret;
>   
> @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   	if (ret)
>   		return ret;
>   
> -	man = &bdev->man[mem_type];
> +	man = ttm_manager_type(bdev, mem_type);
>   	if (!man->has_type || !man->use_type)
>   		return -EBUSY;
>   
> @@ -1065,7 +1065,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   		if (unlikely(ret))
>   			goto error;
>   
> -		man = &bdev->man[mem->mem_type];
> +		man = ttm_manager_type(bdev, mem->mem_type);
>   		ret = ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
>   		if (unlikely(ret)) {
>   			ttm_bo_mem_put(bo, mem);
> @@ -1455,7 +1455,7 @@ EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
>   
>   int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->man[mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
>   
>   	if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
>   		pr_err("Illegal memory manager memory type %u\n", mem_type);
> @@ -1558,7 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>   	unsigned i;
>   	struct ttm_mem_type_manager *man;
>   
> -	man = &bdev->man[TTM_PL_SYSTEM];
> +	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
>   	ttm_mem_type_manager_disable(man);
>   
>   	mutex_lock(&ttm_global_mutex);
> @@ -1585,7 +1585,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
>   
>   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
>   
>   	/*
>   	 * Initialize the system memory buffer type.
> @@ -1649,7 +1649,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
>   void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
>   
>   	ttm_mem_io_lock(man, false);
>   	ttm_bo_unmap_virtual_locked(bo);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 1f502be0b646..879c8ded0cd8 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
>   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
>   		       struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   
>   	if (mem->bus.io_reserved_count++)
> @@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
>   
>   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
>   {
> -	struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   	struct ttm_mem_reg *mem = &bo->mem;
>   	int ret;
>   
> @@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
>   			       struct ttm_mem_reg *mem,
>   			       void **virtual)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   	void *addr;
>   
> @@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
>   {
>   	struct ttm_mem_type_manager *man;
>   
> -	man = &bdev->man[mem->mem_type];
> +	man = ttm_manager_type(bdev, mem->mem_type);
>   
>   	if (virtual && mem->bus.addr == NULL)
>   		iounmap(virtual);
> @@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   		       struct ttm_mem_reg *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
>   	struct ttm_tt *ttm = bo->ttm;
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   	struct ttm_mem_reg old_copy = *old_mem;
> @@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
>   		struct ttm_bo_kmap_obj *map)
>   {
>   	struct ttm_mem_type_manager *man =
> -		&bo->bdev->man[bo->mem.mem_type];
> +		ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   	unsigned long offset, size;
>   	int ret;
>   
> @@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
>   {
>   	struct ttm_buffer_object *bo = map->bo;
>   	struct ttm_mem_type_manager *man =
> -		&bo->bdev->man[bo->mem.mem_type];
> +		ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   
>   	if (!map->virtual)
>   		return;
> @@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
>   			      struct ttm_mem_reg *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   	int ret;
>   	struct ttm_buffer_object *ghost_obj;
> @@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   
> -	struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type];
> -	struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type];
> +	struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> +	struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
>   
>   	int ret;
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 468a0eb9e632..5ae679184eb5 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>   	vm_fault_t ret = VM_FAULT_NOPAGE;
>   	unsigned long address = vmf->address;
>   	struct ttm_mem_type_manager *man =
> -		&bdev->man[bo->mem.mem_type];
> +		ttm_manager_type(bdev, bo->mem.mem_type);
>   
>   	/*
>   	 * Refuse to fault imported pages. This should be handled
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 8cc39cd55a14..e80deee3ae99 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -444,6 +444,12 @@ struct ttm_bo_device {
>   	bool no_retry;
>   };
>   
> +static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> +							    int mem_type)
> +{
> +	return &bdev->man[mem_type];
> +}
> +
>   /**
>    * struct ttm_lru_bulk_move_pos
>    *

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers
  2020-08-04  2:56 ` [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers Dave Airlie
@ 2020-08-04 11:26   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:26 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c   |  3 ++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c       |  6 +++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |  5 ++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 12 +++++------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c      | 21 +++++++++++---------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c   |  4 ++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c      | 12 +++++------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 12 +++++------
>   8 files changed, 39 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index 1b865fed74ca..e24f421e5553 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -517,8 +517,9 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
>   uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
>   {
>   	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
> +	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   
> -	return amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +	return amdgpu_vram_mgr_usage(vram_man);
>   }
>   
>   uint64_t amdgpu_amdkfd_get_hive_id(struct kgd_dev *kgd)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index a512ccbc4dea..9829640e1769 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
>   {
>   	s64 time_us, increment_us;
>   	u64 free_vram, total_vram, used_vram;
> -
> +	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	/* Allow a maximum of 200 accumulated ms. This is basically per-IB
>   	 * throttling.
>   	 *
> @@ -316,7 +316,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
>   	}
>   
>   	total_vram = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size);
> -	used_vram = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +	used_vram = amdgpu_vram_mgr_usage(vram_man);
>   	free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram;
>   
>   	spin_lock(&adev->mm_stats.lock);
> @@ -363,7 +363,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
>   	if (!amdgpu_gmc_vram_full_visible(&adev->gmc)) {
>   		u64 total_vis_vram = adev->gmc.visible_vram_size;
>   		u64 used_vis_vram =
> -			amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +		  amdgpu_vram_mgr_vis_usage(vram_man);
>   
>   		if (used_vis_vram < total_vis_vram) {
>   			u64 free_vis_vram = total_vis_vram - used_vis_vram;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index aa5b54e5a1d7..d551e7c5e69d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3880,7 +3880,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
>   
>   	amdgpu_virt_init_data_exchange(adev);
>   	/* we need recover gart prior to run SMC/CP/SDMA resume */
> -	amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]);
> +	amdgpu_gtt_mgr_recover(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
>   
>   	r = amdgpu_device_fw_loading(adev);
>   	if (r)
> @@ -4079,8 +4079,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
>   					amdgpu_inc_vram_lost(tmp_adev);
>   				}
>   
> -				r = amdgpu_gtt_mgr_recover(
> -					&tmp_adev->mman.bdev.man[TTM_PL_TT]);
> +				r = amdgpu_gtt_mgr_recover(ttm_manager_type(&tmp_adev->mman.bdev, TTM_PL_TT));
>   				if (r)
>   					goto out;
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 28056d12b199..f0b78e88bb55 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -48,9 +48,9 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
> -			(adev->mman.bdev.man[TTM_PL_TT].size) * PAGE_SIZE);
> +			man->size * PAGE_SIZE);
>   }
>   
>   /**
> @@ -66,9 +66,9 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
> -			amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]));
> +			amdgpu_gtt_mgr_usage(man));
>   }
>   
>   static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
> @@ -87,7 +87,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
>    */
>   int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	struct amdgpu_gtt_mgr *mgr;
>   	uint64_t start, size;
>   	int ret;
> @@ -135,7 +135,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>    */
>   void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	struct amdgpu_gtt_mgr *mgr = man->priv;
>   	int ret;
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index a8c47aecd342..594687cc99ac 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -594,13 +594,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   		ui64 = atomic64_read(&adev->num_vram_cpu_page_faults);
>   		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
>   	case AMDGPU_INFO_VRAM_USAGE:
> -		ui64 = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +		ui64 = amdgpu_vram_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM));
>   		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
>   	case AMDGPU_INFO_VIS_VRAM_USAGE:
> -		ui64 = amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +		ui64 = amdgpu_vram_mgr_vis_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM));
>   		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
>   	case AMDGPU_INFO_GTT_USAGE:
> -		ui64 = amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]);
> +		ui64 = amdgpu_gtt_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
>   		return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
>   	case AMDGPU_INFO_GDS_CONFIG: {
>   		struct drm_amdgpu_info_gds gds_info;
> @@ -623,7 +623,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   			min(adev->gmc.visible_vram_size -
>   			    atomic64_read(&adev->visible_pin_size),
>   			    vram_gtt.vram_size);
> -		vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size;
> +		vram_gtt.gtt_size = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT)->size;
>   		vram_gtt.gtt_size *= PAGE_SIZE;
>   		vram_gtt.gtt_size -= atomic64_read(&adev->gart_pin_size);
>   		return copy_to_user(out, &vram_gtt,
> @@ -631,14 +631,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   	}
>   	case AMDGPU_INFO_MEMORY: {
>   		struct drm_amdgpu_memory_info mem;
> -
> +		struct ttm_mem_type_manager *vram_man =
> +			ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +		struct ttm_mem_type_manager *gtt_man =
> +			ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   		memset(&mem, 0, sizeof(mem));
>   		mem.vram.total_heap_size = adev->gmc.real_vram_size;
>   		mem.vram.usable_heap_size = adev->gmc.real_vram_size -
>   			atomic64_read(&adev->vram_pin_size) -
>   			AMDGPU_VM_RESERVED_VRAM;
>   		mem.vram.heap_usage =
> -			amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +			amdgpu_vram_mgr_usage(vram_man);
>   		mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4;
>   
>   		mem.cpu_accessible_vram.total_heap_size =
> @@ -648,16 +651,16 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   			    atomic64_read(&adev->visible_pin_size),
>   			    mem.vram.usable_heap_size);
>   		mem.cpu_accessible_vram.heap_usage =
> -			amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
> +			amdgpu_vram_mgr_vis_usage(vram_man);
>   		mem.cpu_accessible_vram.max_allocation =
>   			mem.cpu_accessible_vram.usable_heap_size * 3 / 4;
>   
> -		mem.gtt.total_heap_size = adev->mman.bdev.man[TTM_PL_TT].size;
> +		mem.gtt.total_heap_size = gtt_man->size;
>   		mem.gtt.total_heap_size *= PAGE_SIZE;
>   		mem.gtt.usable_heap_size = mem.gtt.total_heap_size -
>   			atomic64_read(&adev->gart_pin_size);
>   		mem.gtt.heap_usage =
> -			amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]);
> +			amdgpu_gtt_mgr_usage(gtt_man);
>   		mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4;
>   
>   		return copy_to_user(out, &mem,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 5ac7b5561475..ced418cba2f7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -449,7 +449,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
>   	 * allow fall back to GTT
>   	 */
>   	if (domain & AMDGPU_GEM_DOMAIN_GTT) {
> -		man = &adev->mman.bdev.man[TTM_PL_TT];
> +		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   
>   		if (size < (man->size << PAGE_SHIFT))
>   			return true;
> @@ -458,7 +458,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
>   	}
>   
>   	if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
> -		man = &adev->mman.bdev.man[TTM_PL_VRAM];
> +		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   
>   		if (size < (man->size << PAGE_SHIFT))
>   			return true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index d7516144bb0a..1bd860877f1e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -67,7 +67,7 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
>   				    unsigned int type,
>   				    uint64_t size)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type);
>   
>   	man->available_caching = TTM_PL_FLAG_UNCACHED;
>   	man->default_caching = TTM_PL_FLAG_UNCACHED;
> @@ -2014,9 +2014,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
>   
>   	amdgpu_vram_mgr_fini(adev);
>   	amdgpu_gtt_mgr_fini(adev);
> -	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS]);
> -	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS]);
> -	ttm_range_man_fini(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA]);
> +	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS));
> +	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS));
> +	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA));
>   	ttm_bo_device_release(&adev->mman.bdev);
>   	adev->mman.initialized = false;
>   	DRM_INFO("amdgpu: ttm finalized\n");
> @@ -2033,7 +2033,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
>    */
>   void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	uint64_t size;
>   	int r;
>   
> @@ -2255,7 +2255,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
>   	unsigned ttm_pl = (uintptr_t)node->info_ent->data;
>   	struct drm_device *dev = node->minor->dev;
>   	struct amdgpu_device *adev = dev->dev_private;
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
>   	man->func->debug(man, &p);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index c3bc9ddd437e..bc776b8f1063 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -82,9 +82,9 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
> -		amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]));
> +			amdgpu_vram_mgr_usage(man));
>   }
>   
>   /**
> @@ -100,9 +100,9 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
> -		amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]));
> +			amdgpu_vram_mgr_vis_usage(man));
>   }
>   
>   static ssize_t amdgpu_mem_info_vram_vendor(struct device *dev,
> @@ -170,7 +170,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
>    */
>   int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	struct amdgpu_vram_mgr *mgr;
>   	int ret;
>   
> @@ -207,7 +207,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>    */
>   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	struct amdgpu_vram_mgr *mgr = man->priv;
>   	int ret;
>   

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 41/59] drm/radeon/ttm: use wrapper to access memory manager
  2020-08-04  2:56 ` [PATCH 41/59] drm/radeon/ttm: " Dave Airlie
@ 2020-08-04 11:29   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:29 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon_gem.c |  2 +-
>   drivers/gpu/drm/radeon/radeon_ttm.c | 12 ++++++------
>   2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index 44157ada9b0e..3ec028dba739 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -226,7 +226,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
>   	struct drm_radeon_gem_info *args = data;
>   	struct ttm_mem_type_manager *man;
>   
> -	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
> +	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
>   
>   	args->vram_size = (u64)man->size << PAGE_SHIFT;
>   	args->vram_visible = rdev->mc.visible_vram_size;
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 76b409af9476..03c0a24e74c4 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -68,7 +68,7 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
>   
>   static int radeon_ttm_init_vram(struct radeon_device *rdev)
>   {
> -	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
>   
>   	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>   	man->default_caching = TTM_PL_FLAG_WC;
> @@ -79,7 +79,7 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev)
>   
>   static int radeon_ttm_init_gtt(struct radeon_device *rdev)
>   {
> -	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT);
>   
>   	man->available_caching = TTM_PL_MASK_CACHING;
>   	man->default_caching = TTM_PL_FLAG_CACHED;
> @@ -825,8 +825,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
>   		}
>   		radeon_bo_unref(&rdev->stolen_vga_memory);
>   	}
> -	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM]);
> -	ttm_range_man_fini(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT]);
> +	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM));
> +	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT));
>   	ttm_bo_device_release(&rdev->mman.bdev);
>   	radeon_gart_fini(rdev);
>   	rdev->mman.initialized = false;
> @@ -842,7 +842,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
>   	if (!rdev->mman.initialized)
>   		return;
>   
> -	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
> +	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
>   	/* this just adjusts TTM size idea, which sets lpfn to the correct value */
>   	man->size = size >> PAGE_SHIFT;
>   }
> @@ -896,7 +896,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
>   	unsigned ttm_pl = *(int*)node->info_ent->data;
>   	struct drm_device *dev = node->minor->dev;
>   	struct radeon_device *rdev = dev->dev_private;
> -	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
>   	man->func->debug(man, &p);

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used.
  2020-08-04  2:56 ` [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used Dave Airlie
@ 2020-08-04 11:29   ` Christian König
  2020-08-05  5:49     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:29 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Other users of this should notice this change and switch to wrapper.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 2 +-
>   include/drm/ttm/ttm_bo_driver.h | 7 +++++--
>   2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 8777c323e7de..3a3a4dfb0fff 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1617,7 +1617,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>   
>   	bdev->driver = driver;
>   
> -	memset(bdev->man, 0, sizeof(bdev->man));
> +	memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
>   
>   	ttm_bo_init_sysman(bdev);
>   
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index e80deee3ae99..03b253d14e6a 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -415,7 +415,10 @@ struct ttm_bo_device {
>   	 */
>   	struct list_head device_list;
>   	struct ttm_bo_driver *driver;
> -	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> +	/*
> +	 * access via ttm_manager_type.
> +	 */
> +	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
>   
>   	/*
>   	 * Protected by internal locks.
> @@ -447,7 +450,7 @@ struct ttm_bo_device {
>   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
> -	return &bdev->man[mem_type];
> +	return &bdev->man_priv[mem_type];
>   }
>   
>   /**

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses
  2020-08-04  2:56 ` [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses Dave Airlie
@ 2020-08-04 11:30   ` Christian König
  2020-08-05  5:49     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:30 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will get removed eventually and all drivers will use this.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 03b253d14e6a..6940d85a531a 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -419,7 +419,7 @@ struct ttm_bo_device {
>   	 * access via ttm_manager_type.
>   	 */
>   	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> -
> +	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
>   	/*
>   	 * Protected by internal locks.
>   	 */
> @@ -450,9 +450,18 @@ struct ttm_bo_device {
>   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
> +	if (bdev->man_drv[mem_type])
> +		return bdev->man_drv[mem_type];
>   	return &bdev->man_priv[mem_type];
>   }
>   
> +static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
> +					  int type,
> +					  struct ttm_mem_type_manager *manager)
> +{
> +	bdev->man_drv[type] = manager;
> +}
> +
>   /**
>    * struct ttm_lru_bulk_move_pos
>    *

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs
  2020-08-04  2:56 ` [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs Dave Airlie
@ 2020-08-04 11:32   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 11:32 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

This one is already reviewed and can stay like this, but I had one more 
idea for further cleanups, see below.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  | 35 +++++++++++--------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 36 +++++++++++++-------
>   2 files changed, 44 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index f0b78e88bb55..b664c5cb13ce 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -25,11 +25,17 @@
>   #include "amdgpu.h"
>   
>   struct amdgpu_gtt_mgr {
> +	struct ttm_mem_type_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   	atomic64_t available;
>   };
>   
> +static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man)
> +{
> +	return container_of(man, struct amdgpu_gtt_mgr, manager);
> +}
> +
>   struct amdgpu_gtt_node {
>   	struct drm_mm_node node;
>   	struct ttm_buffer_object *tbo;
> @@ -87,11 +93,16 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
>    */
>   int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> +	struct ttm_mem_type_manager *man;
>   	struct amdgpu_gtt_mgr *mgr;
>   	uint64_t start, size;
>   	int ret;
>   
> +	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);

Why do we even kzalloc that here any more? We could just embed the 
structure in struct amdgpu_mman.

Same for all other drivers as well,
Christian.

> +	if (!mgr)
> +		return -ENOMEM;
> +
> +	man = &mgr->manager;
>   	man->use_tt = true;
>   	man->func = &amdgpu_gtt_mgr_func;
>   	man->available_caching = TTM_PL_MASK_CACHING;
> @@ -99,16 +110,11 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   
>   	ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
>   
> -	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
> -	if (!mgr)
> -		return -ENOMEM;
> -
>   	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
>   	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
>   	drm_mm_init(&mgr->mm, start, size);
>   	spin_lock_init(&mgr->lock);
>   	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
> -	man->priv = mgr;
>   
>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
>   	if (ret) {
> @@ -121,6 +127,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   		return ret;
>   	}
>   
> +	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
>   	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
> @@ -136,7 +143,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   {
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	int ret;
>   
>   	ttm_mem_type_manager_disable(man);
> @@ -148,13 +155,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   	spin_lock(&mgr->lock);
>   	drm_mm_takedown(&mgr->mm);
>   	spin_unlock(&mgr->lock);
> -	kfree(mgr);
> -	man->priv = NULL;
>   
>   	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
>   	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
>   
>   	ttm_mem_type_manager_cleanup(man);
> +	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
> +	kfree(mgr);
>   }
>   
>   /**
> @@ -184,7 +191,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
>   			      const struct ttm_place *place,
>   			      struct ttm_mem_reg *mem)
>   {
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node;
>   	int r;
>   
> @@ -245,7 +252,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
>   static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>   			       struct ttm_mem_reg *mem)
>   {
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node = mem->mm_node;
>   
>   	if (node) {
> @@ -267,7 +274,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>    */
>   uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
>   {
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	s64 result = man->size - atomic64_read(&mgr->available);
>   
>   	return (result > 0 ? result : 0) * PAGE_SIZE;
> @@ -275,7 +282,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
>   
>   int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
>   {
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node;
>   	struct drm_mm_node *mm_node;
>   	int r = 0;
> @@ -303,7 +310,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
>   static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
>   				 struct drm_printer *printer)
>   {
> -	struct amdgpu_gtt_mgr *mgr = man->priv;
> +	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   
>   	spin_lock(&mgr->lock);
>   	drm_mm_print(&mgr->mm, printer);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index bc776b8f1063..2b37f4266dcb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -29,12 +29,18 @@
>   #include "atom.h"
>   
>   struct amdgpu_vram_mgr {
> +	struct ttm_mem_type_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   	atomic64_t usage;
>   	atomic64_t vis_usage;
>   };
>   
> +static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
> +{
> +	return container_of(man, struct amdgpu_vram_mgr, manager);
> +}
> +
>   /**
>    * DOC: mem_info_vram_total
>    *
> @@ -170,29 +176,32 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
>    */
>   int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_mem_type_manager *man;
>   	struct amdgpu_vram_mgr *mgr;
>   	int ret;
>   
> +	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
> +	if (!mgr)
> +		return -ENOMEM;
> +
> +	man = &mgr->manager;
> +
>   	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>   	man->default_caching = TTM_PL_FLAG_WC;
>   
>   	ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
>   
>   	man->func = &amdgpu_vram_mgr_func;
> -	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
> -	if (!mgr)
> -		return -ENOMEM;
>   
>   	drm_mm_init(&mgr->mm, 0, man->size);
>   	spin_lock_init(&mgr->lock);
> -	man->priv = mgr;
>   
>   	/* Add the two VRAM-related sysfs files */
>   	ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
>   	if (ret)
>   		DRM_ERROR("Failed to register sysfs\n");
>   
> +	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
>   	ttm_mem_type_manager_set_used(man, true);
>   	return 0;
>   }
> @@ -208,7 +217,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   {
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	int ret;
>   
>   	ttm_mem_type_manager_disable(man);
> @@ -220,11 +229,12 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   	spin_lock(&mgr->lock);
>   	drm_mm_takedown(&mgr->mm);
>   	spin_unlock(&mgr->lock);
> -	kfree(mgr);
> -	man->priv = NULL;
> +
>   	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
>   
>   	ttm_mem_type_manager_cleanup(man);
> +	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
> +	kfree(mgr);
>   }
>   
>   /**
> @@ -314,7 +324,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
>   			       struct ttm_mem_reg *mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	struct drm_mm *mm = &mgr->mm;
>   	struct drm_mm_node *nodes;
>   	enum drm_mm_insert_mode mode;
> @@ -430,7 +440,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
>   				struct ttm_mem_reg *mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	struct drm_mm_node *nodes = mem->mm_node;
>   	uint64_t usage = 0, vis_usage = 0;
>   	unsigned pages = mem->num_pages;
> @@ -562,7 +572,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
>    */
>   uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
>   {
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   
>   	return atomic64_read(&mgr->usage);
>   }
> @@ -576,7 +586,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
>    */
>   uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
>   {
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   
>   	return atomic64_read(&mgr->vis_usage);
>   }
> @@ -592,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
>   static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
>   				  struct drm_printer *printer)
>   {
> -	struct amdgpu_vram_mgr *mgr = man->priv;
> +	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   
>   	spin_lock(&mgr->lock);
>   	drm_mm_print(&mgr->mm, printer);

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args
  2020-08-04  2:56 ` [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args Dave Airlie
@ 2020-08-04 11:35   ` Christian König
  2020-08-05  5:51     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:35 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This makes it easier to move these to a driver allocated system
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++-------
>   drivers/gpu/drm/drm_gem_vram_helper.c   | 10 ++++----
>   drivers/gpu/drm/nouveau/nouveau_ttm.c   | 22 +++++++++++-------
>   drivers/gpu/drm/qxl/qxl_ttm.c           | 13 ++++-------
>   drivers/gpu/drm/radeon/radeon_ttm.c     | 31 ++++++++++++-------------
>   drivers/gpu/drm/ttm/ttm_bo_manager.c    | 19 +++++++++++----
>   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c     | 13 ++++-------
>   include/drm/ttm/ttm_bo_driver.h         | 12 +++++++---
>   8 files changed, 70 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 1bd860877f1e..b190d50dc9bb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
>   				    unsigned int type,
>   				    uint64_t size)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type);
> -
> -	man->available_caching = TTM_PL_FLAG_UNCACHED;
> -	man->default_caching = TTM_PL_FLAG_UNCACHED;
> -
> -	return ttm_range_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT);
> +	return ttm_range_man_init(&adev->mman.bdev, type,
> +				  TTM_PL_FLAG_UNCACHED, TTM_PL_FLAG_UNCACHED,
> +				  false, size >> PAGE_SHIFT);
>   }
>   
>   /**
> @@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
>   
>   	amdgpu_vram_mgr_fini(adev);
>   	amdgpu_gtt_mgr_fini(adev);
> -	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS));
> -	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS));
> -	ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA));
> +	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GDS);
> +	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GWS);
> +	ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_OA);
>   	ttm_bo_device_release(&adev->mman.bdev);
>   	adev->mman.initialized = false;
>   	DRM_INFO("amdgpu: ttm finalized\n");
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index a01768adb96d..2187787f397e 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
>   static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>   			    uint64_t vram_base, size_t vram_size)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
>   	int ret;
>   
>   	vmm->vram_base = vram_base;
> @@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>   	if (ret)
>   		return ret;
>   
> -	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> -	man->default_caching = TTM_PL_FLAG_WC;
> -	ret = ttm_range_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT);
> +	ret = ttm_range_man_init(&vmm->bdev, TTM_PL_VRAM,
> +				 TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> +				 TTM_PL_FLAG_WC, false,
> +				 vram_size >> PAGE_SHIFT);
>   	if (ret)
>   		return ret;
>   
> @@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
>   
>   static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
>   {
> -	ttm_range_man_fini(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM));
> +	ttm_range_man_fini(&vmm->bdev, TTM_PL_VRAM);
>   	ttm_bo_device_release(&vmm->bdev);
>   }
>   
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index cc6cf04553dd..1c636723823c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
>   static int
>   nouveau_ttm_init_vram(struct nouveau_drm *drm)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
>   	struct nvif_mmu *mmu = &drm->client.mmu;
>   
> -	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> -	man->default_caching = TTM_PL_FLAG_WC;
> -
>   	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> +		struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> +
>   		/* Some BARs do not support being ioremapped WC */
>   		const u8 type = mmu->type[drm->ttm.type_vram].type;
>   
> +		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> +		man->default_caching = TTM_PL_FLAG_WC;
> +
>   		if (type & NVIF_MEM_UNCACHED) {
>   			man->available_caching = TTM_PL_FLAG_UNCACHED;
>   			man->default_caching = TTM_PL_FLAG_UNCACHED;
> @@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>   		ttm_mem_type_manager_set_used(man, true);
>   		return 0;
>   	} else {
> -		return ttm_range_man_init(&drm->ttm.bdev, man,
> +		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
> +					  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> +					  TTM_PL_FLAG_WC, false,
>   					  drm->gem.vram_available >> PAGE_SHIFT);
>   	}
>   }
> @@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>   		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
>   		ttm_mem_type_manager_cleanup(man);
>   	} else
> -		ttm_range_man_fini(&drm->ttm.bdev, man);
> +		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
>   }
>   
>   static int
> @@ -216,9 +219,10 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>   	else if (!drm->agp.bridge)
>   		man->func = &nv04_gart_manager;
>   	else
> -		return ttm_range_man_init(&drm->ttm.bdev, man,
> +		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
> +					  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> +					  TTM_PL_FLAG_WC, true,
>   					  size_pages);
> -
>   	ttm_mem_type_manager_init(&drm->ttm.bdev, man,
>   				  size_pages);
>   	ttm_mem_type_manager_set_used(man, true);
> @@ -232,7 +236,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
>   
>   	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
>   	    drm->agp.bridge)
> -		ttm_range_man_fini(&drm->ttm.bdev, man);
> +		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
>   	else {
>   		ttm_mem_type_manager_disable(man);
>   		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 57c96f7271db..b7365b2e4c7f 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
>   				 unsigned int type,
>   				 uint64_t size)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type);
> -
> -	man->available_caching = TTM_PL_MASK_CACHING;
> -	man->default_caching = TTM_PL_FLAG_CACHED;
> -
> -	return ttm_range_man_init(&qdev->mman.bdev, man, size);
> +	return ttm_range_man_init(&qdev->mman.bdev, type, TTM_PL_MASK_CACHING,
> +				  TTM_PL_FLAG_CACHED, false, size);
>   }
>   
>   int qxl_ttm_init(struct qxl_device *qdev)
> @@ -266,9 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev)
>   
>   void qxl_ttm_fini(struct qxl_device *qdev)
>   {
> -
> -	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM));
> -	ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV));
> +	ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_VRAM);
> +	ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_PRIV);
>   	ttm_bo_device_release(&qdev->mman.bdev);
>   	DRM_INFO("qxl: ttm finalized\n");
>   }
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 03c0a24e74c4..474d2161da1e 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -68,35 +68,34 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
>   
>   static int radeon_ttm_init_vram(struct radeon_device *rdev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
> -
> -	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> -	man->default_caching = TTM_PL_FLAG_WC;
> -
> -	return ttm_range_man_init(&rdev->mman.bdev, man,
> +	return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_VRAM,
> +				  TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> +				  TTM_PL_FLAG_WC, false,
>   				  rdev->mc.real_vram_size >> PAGE_SHIFT);
>   }
>   
>   static int radeon_ttm_init_gtt(struct radeon_device *rdev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT);
> +	uint32_t available_caching, default_caching;
> +
> +	available_caching = TTM_PL_MASK_CACHING;
> +	default_caching = TTM_PL_FLAG_CACHED;
>   
> -	man->available_caching = TTM_PL_MASK_CACHING;
> -	man->default_caching = TTM_PL_FLAG_CACHED;
> -	man->use_tt = true;
>   #if IS_ENABLED(CONFIG_AGP)
>   	if (rdev->flags & RADEON_IS_AGP) {
>   		if (!rdev->ddev->agp) {
>   			DRM_ERROR("AGP is not enabled\n");
>   			return -EINVAL;
>   		}
> -		man->available_caching = TTM_PL_FLAG_UNCACHED |
> -					 TTM_PL_FLAG_WC;
> -		man->default_caching = TTM_PL_FLAG_WC;
> +		available_caching = TTM_PL_FLAG_UNCACHED |
> +			TTM_PL_FLAG_WC;
> +		default_caching = TTM_PL_FLAG_WC;
>   	}
>   #endif
>   
> -	return ttm_range_man_init(&rdev->mman.bdev, man,
> +	return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_TT,
> +				  available_caching,
> +				  default_caching, true,
>   				  rdev->mc.gtt_size >> PAGE_SHIFT);
>   }
>   
> @@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
>   		}
>   		radeon_bo_unref(&rdev->stolen_vga_memory);
>   	}
> -	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM));
> -	ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT));
> +	ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_VRAM);
> +	ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_TT);
>   	ttm_bo_device_release(&rdev->mman.bdev);
>   	radeon_gart_fini(rdev);
>   	rdev->mman.initialized = false;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index 86bf5e71e959..d83cb967a107 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
>   static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
>   
>   int ttm_range_man_init(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_type_manager *man,
> +		       unsigned type,
> +		       uint32_t available_caching,
> +		       uint32_t default_caching,
> +		       bool use_tt,
>   		       unsigned long p_size)
>   {
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
>   	struct ttm_range_manager *rman;
>   
> -	man->func = &ttm_bo_manager_func;
> -
> -	ttm_mem_type_manager_init(bdev, man, p_size);
> +	man->available_caching = available_caching;
> +	man->default_caching = default_caching;
> +	man->use_tt = use_tt;
>   
>   	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
>   	if (!rman)
>   		return -ENOMEM;
>   
> +	man->func = &ttm_bo_manager_func;
> +
> +	ttm_mem_type_manager_init(bdev, man, p_size);
> +
>   	drm_mm_init(&rman->mm, 0, p_size);
>   	spin_lock_init(&rman->lock);
>   	man->priv = rman;
> @@ -130,8 +138,9 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   EXPORT_SYMBOL(ttm_range_man_init);
>   
>   int ttm_range_man_fini(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_type_manager *man)
> +		       unsigned type)
>   {
> +	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
>   	struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
>   	struct drm_mm *mm = &rman->mm;
>   	int ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 6ed92f38b54b..7168403fb4f8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -626,13 +626,9 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>   #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>   	ret = vmw_thp_init(dev_priv);
>   #else
> -	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
> -
> -	man->available_caching = TTM_PL_FLAG_CACHED;
> -	man->default_caching = TTM_PL_FLAG_CACHED;
> -
> -	ret = ttm_range_man_init(&dev_priv->bdev, man,
> -				 dev_priv->vram_size >> PAGE_SHIFT);
> +	ret = ttm_range_man_init(&dev_priv->bdev, TTM_PL_VRAM,
> +				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
> +				 false, dev_priv->vram_size >> PAGE_SHIFT);
>   #endif
>   	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
>   	return ret;
> @@ -643,8 +639,7 @@ static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
>   #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>   	vmw_thp_fini(dev_priv);
>   #else
> -	ttm_bo_man_fini(&dev_priv->bdev,
> -			ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM));
> +	ttm_bo_man_fini(&dev_priv->bdev, TTM_PL_VRAM);
>   #endif
>   }
>   
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 6940d85a531a..789c1eb26859 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -845,14 +845,20 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
>    * ttm_range_man_init
>    *
>    * @bdev: ttm device
> - * @man: the manager to initialise with the range manager.
> + * @type: memory manager type
> + * @available_caching: TTM_PL_FLAG_* for allowed caching modes
> + * @default_caching: default caching mode
> + * @use_tt: if the memory manager uses tt
>    * @p_size: size of area to be managed in pages.
>    *
>    * Initialise a generic range manager for the selected memory type.
>    * The range manager is installed for this device in the type slot.
>    */
>   int ttm_range_man_init(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_type_manager *man,
> +		       unsigned type,
> +		       uint32_t available_caching,
> +		       uint32_t default_caching,
> +		       bool use_tt,
>   		       unsigned long p_size);
>   
>   /**
> @@ -864,7 +870,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>    * Remove the generic range manager from a slot and tear it down.
>    */
>   int ttm_range_man_fini(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_type_manager *man);
> +		       unsigned type);
>   
>   /**
>    * ttm_mem_type_manager_debug

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2)
  2020-08-04  2:56 ` [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2) Dave Airlie
@ 2020-08-04 11:37   ` Christian König
  2020-08-05  5:55     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:37 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The driver now controls these, the core just controls the system
> memory one.
>
> v2: init sysman explicitly and assign it as a driver manager
> to simplify the lookup sequence.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 6 +++---
>   include/drm/ttm/ttm_bo_driver.h | 6 ++----
>   2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 78b72443a9ef..12abe46bfbc1 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1558,6 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>   
>   	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
>   	ttm_mem_type_manager_disable(man);
> +	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
>   
>   	mutex_lock(&ttm_global_mutex);
>   	list_del(&bdev->device_list);
> @@ -1583,7 +1584,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
>   
>   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> +	struct ttm_mem_type_manager *man = &bdev->sysman;
>   
>   	/*
>   	 * Initialize the system memory buffer type.
> @@ -1594,6 +1595,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   
>   	ttm_mem_type_manager_init(man, 0);
> +	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
>   	ttm_mem_type_manager_set_used(man, true);
>   }
>   
> @@ -1615,8 +1617,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>   
>   	bdev->driver = driver;
>   
> -	memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
> -
>   	ttm_bo_init_sysman(bdev);
>   
>   	bdev->vma_manager = vma_manager;
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index bfd19400372f..d5646d7cac60 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -414,7 +414,7 @@ struct ttm_bo_device {
>   	/*
>   	 * access via ttm_manager_type.
>   	 */
> -	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> +	struct ttm_mem_type_manager sysman;
>   	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
>   	/*
>   	 * Protected by internal locks.
> @@ -446,9 +446,7 @@ struct ttm_bo_device {
>   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
> -	if (bdev->man_drv[mem_type])
> -		return bdev->man_drv[mem_type];
> -	return &bdev->man_priv[mem_type];
> +	return bdev->man_drv[mem_type];
>   }
>   
>   static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 55/59] drm/ttm: drop type manager has_type
  2020-08-04  2:56 ` [PATCH 55/59] drm/ttm: drop type manager has_type Dave Airlie
@ 2020-08-04 11:37   ` Christian König
  2020-08-05  5:55     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:37 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> under driver control, this flag isn't needed anymore,
> remove the API that used to access it, and consoldiate
> with the used api.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 ++--
>   drivers/gpu/drm/ttm/ttm_bo.c                  |  8 +++-----
>   drivers/gpu/drm/ttm/ttm_bo_manager.c          |  2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  2 +-
>   include/drm/ttm/ttm_bo_driver.h               | 17 -----------------
>   8 files changed, 10 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 9fc3d876ed38..71461d652fcc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	int ret;
>   
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   
>   	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
>   	if (ret)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 684698cdf772..8cc44c3d2fdd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	int ret;
>   
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   
>   	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
>   	if (ret)
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index d408e1485cce..22185a8dcfa1 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -194,7 +194,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
>   
>   	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> -		ttm_mem_type_manager_disable(man);
> +		ttm_mem_type_manager_set_used(man, false);
>   		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
>   		ttm_mem_type_manager_cleanup(man);
>   		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
> @@ -253,7 +253,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
>   	    drm->agp.bridge)
>   		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
>   	else {
> -		ttm_mem_type_manager_disable(man);
> +		ttm_mem_type_manager_set_used(man, false);
>   		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
>   		ttm_mem_type_manager_cleanup(man);
>   		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 12abe46bfbc1..cda33b4af681 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -80,7 +80,6 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
>   void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
>   				struct drm_printer *p)
>   {
> -	drm_printf(p, "    has_type: %d\n", man->has_type);
>   	drm_printf(p, "    use_type: %d\n", man->use_type);
>   	drm_printf(p, "    use_tt: %d\n", man->use_tt);
>   	drm_printf(p, "    size: %llu\n", man->size);
> @@ -1003,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   		return ret;
>   
>   	man = ttm_manager_type(bdev, mem_type);
> -	if (!man->has_type || !man->use_type)
> +	if (!man || !man->use_type)
>   		return -EBUSY;
>   
>   	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> @@ -1462,7 +1461,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		return -EINVAL;
>   	}
>   
> -	if (!man->has_type) {
> +	if (!man) {
>   		pr_err("Memory type %u has not been initialized\n", mem_type);
>   		return 0;
>   	}
> @@ -1476,7 +1475,6 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
>   {
>   	unsigned i;
>   
> -	BUG_ON(man->has_type);
>   	man->use_io_reserve_lru = false;
>   	mutex_init(&man->io_reserve_mutex);
>   	spin_lock_init(&man->move_lock);
> @@ -1557,7 +1555,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>   	struct ttm_mem_type_manager *man;
>   
>   	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
>   
>   	mutex_lock(&ttm_global_mutex);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index 1b7245ce3356..6679dc11934f 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -152,7 +152,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>   	struct drm_mm *mm = &rman->mm;
>   	int ret;
>   
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   
>   	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
>   	if (ret)
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index c3fa25161fd0..ca5037184814 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -143,7 +143,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
>   	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>   
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   
>   	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
>   
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 0b9c29249393..4110e8309188 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -152,7 +152,7 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
>   	struct drm_mm *mm = &rman->mm;
>   	int ret;
>   
> -	ttm_mem_type_manager_disable(man);
> +	ttm_mem_type_manager_set_used(man, false);
>   
>   	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
>   	if (ret)
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index d5646d7cac60..300934289e64 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -111,7 +111,6 @@ struct ttm_mem_type_manager_func {
>   /**
>    * struct ttm_mem_type_manager
>    *
> - * @has_type: The memory type has been initialized.
>    * @use_type: The memory type is enabled.
>    * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
>    * managed by this memory type.
> @@ -141,8 +140,6 @@ struct ttm_mem_type_manager {
>   	/*
>   	 * No protection. Constant from start.
>   	 */
> -
> -	bool has_type;
>   	bool use_type;
>   	bool use_tt;
>   	uint64_t size;
> @@ -678,23 +675,9 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>    */
>   static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
>   {
> -	man->has_type = true;
>   	man->use_type = used;
>   }
>   
> -/**
> - * ttm_mem_type_manager_disable.
> - *
> - * @man: A memory manager object.
> - *
> - * Indicate the manager is not to be used and deregistered. (temporary during rework).
> - */
> -static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> -{
> -	man->has_type = false;
> -	man->use_type = false;
> -}
> -
>   /**
>    * ttm_mem_type_manager_cleanup
>    *

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use
  2020-08-04  2:56 ` [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use Dave Airlie
@ 2020-08-04 11:38   ` Christian König
  2020-08-05  5:56     ` Ben Skeggs
  2020-08-05  9:04   ` daniel
  1 sibling, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:38 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This converts vmwgfx over to using an interface to set the
> in use and check the in use flag.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/nouveau/nouveau_ttm.c |  1 -
>   drivers/gpu/drm/ttm/ttm_bo.c          |  2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 14 +++++++-------
>   include/drm/ttm/ttm_bo_driver.h       | 14 ++++++++++++++
>   4 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 22185a8dcfa1..38a0e4bd16f7 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>   	ttm_mem_type_manager_init(man, size_pages);
>   	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
>   	ttm_mem_type_manager_set_used(man, true);
> -
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index cda33b4af681..7d10abae9a60 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   		return ret;
>   
>   	man = ttm_manager_type(bdev, mem_type);
> -	if (!man || !man->use_type)
> +	if (!man || !ttm_mem_type_manager_used(man))
>   		return -EBUSY;
>   
>   	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 7168403fb4f8..b2f1e7a3b048 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>   				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
>   				 false, dev_priv->vram_size >> PAGE_SHIFT);
>   #endif
> -	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
> +	ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
>   	return ret;
>   }
>   
> @@ -1192,9 +1192,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   
>   	spin_lock(&dev_priv->svga_lock);
> -	if (!man->use_type) {
> +	if (!ttm_mem_type_manager_used(man)) {
>   		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> -		man->use_type = true;
> +		ttm_mem_type_manager_set_used(man, true);
>   	}
>   	spin_unlock(&dev_priv->svga_lock);
>   }
> @@ -1223,8 +1223,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
>   	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   
>   	spin_lock(&dev_priv->svga_lock);
> -	if (man->use_type) {
> -		man->use_type = false;
> +	if (ttm_mem_type_manager_used(man)) {
> +		ttm_mem_type_manager_set_used(man, false);
>   		vmw_write(dev_priv, SVGA_REG_ENABLE,
>   			  SVGA_REG_ENABLE_HIDE |
>   			  SVGA_REG_ENABLE_ENABLE);
> @@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
>   	vmw_kms_lost_device(dev_priv->dev);
>   	ttm_write_lock(&dev_priv->reservation_sem, false);
>   	spin_lock(&dev_priv->svga_lock);
> -	if (man->use_type) {
> -		man->use_type = false;
> +	if (ttm_mem_type_manager_used(man)) {
> +		ttm_mem_type_manager_set_used(man, false);
>   		spin_unlock(&dev_priv->svga_lock);
>   		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
>   			DRM_ERROR("Failed evicting VRAM buffers.\n");
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 300934289e64..f231fe34e744 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -678,6 +678,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
>   	man->use_type = used;
>   }
>   
> +/**
> + * ttm_mem_type_manager_used
> + *
> + * @man: Manager to get used state for
> + *
> + * Get the in use flag for a manager.
> + * Returns:
> + * true is used, false if not.
> + */
> +static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
> +{
> +	return man->use_type;
> +}
> +
>   /**
>    * ttm_mem_type_manager_cleanup
>    *

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 57/59] drm/ttm: rename bo manager to range manager.
  2020-08-04  2:56 ` [PATCH 57/59] drm/ttm: rename bo manager to range manager Dave Airlie
@ 2020-08-04 11:40   ` Christian König
  2020-08-05  5:56     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:40 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The generic manager is called the range manager now, rename
> the file and some internals.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/Makefile                  |  2 +-
>   .../{ttm_bo_manager.c => ttm_range_manager.c} | 26 +++++++++----------
>   2 files changed, 14 insertions(+), 14 deletions(-)
>   rename drivers/gpu/drm/ttm/{ttm_bo_manager.c => ttm_range_manager.c} (88%)
>
> diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
> index caea2a099496..e54326e6cea4 100644
> --- a/drivers/gpu/drm/ttm/Makefile
> +++ b/drivers/gpu/drm/ttm/Makefile
> @@ -4,7 +4,7 @@
>   
>   ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
>   	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
> -	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
> +	ttm_execbuf_util.o ttm_page_alloc.o ttm_range_manager.o
>   ttm-$(CONFIG_AGP) += ttm_agp_backend.o
>   ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> similarity index 88%
> rename from drivers/gpu/drm/ttm/ttm_bo_manager.c
> rename to drivers/gpu/drm/ttm/ttm_range_manager.c
> index 6679dc11934f..52d9a0ed7165 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -54,10 +54,10 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_man
>   	return container_of(man, struct ttm_range_manager, manager);
>   }
>   
> -static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
> -			       struct ttm_buffer_object *bo,
> -			       const struct ttm_place *place,
> -			       struct ttm_mem_reg *mem)
> +static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
> +				  struct ttm_buffer_object *bo,
> +				  const struct ttm_place *place,
> +				  struct ttm_mem_reg *mem)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
>   	struct drm_mm *mm = &rman->mm;
> @@ -95,8 +95,8 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
>   	return ret;
>   }
>   
> -static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
> -				struct ttm_mem_reg *mem)
> +static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
> +				   struct ttm_mem_reg *mem)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
>   
> @@ -110,7 +110,7 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
>   	}
>   }
>   
> -static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> +static const struct ttm_mem_type_manager_func ttm_range_manager_func;
>   
>   int ttm_range_man_init(struct ttm_bo_device *bdev,
>   		       unsigned type,
> @@ -131,7 +131,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   	man->default_caching = default_caching;
>   	man->use_tt = use_tt;
>   
> -	man->func = &ttm_bo_manager_func;
> +	man->func = &ttm_range_manager_func;
>   
>   	ttm_mem_type_manager_init(man, p_size);
>   
> @@ -170,7 +170,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>   }
>   EXPORT_SYMBOL(ttm_range_man_fini);
>   
> -static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
> +static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
>   			     struct drm_printer *printer)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
> @@ -180,8 +180,8 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>   	spin_unlock(&rman->lock);
>   }
>   
> -static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> -	.get_node = ttm_bo_man_get_node,
> -	.put_node = ttm_bo_man_put_node,
> -	.debug = ttm_bo_man_debug
> +static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
> +	.get_node = ttm_range_man_get_node,
> +	.put_node = ttm_range_man_put_node,
> +	.debug = ttm_range_man_debug
>   };

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager.
  2020-08-04  2:56 ` [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager Dave Airlie
@ 2020-08-04 11:41   ` Christian König
  2020-08-05  5:57     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:41 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This name makes a lot more sense, since these are about managing
> driver resources rather than just memory ranges.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   | 36 +++++-----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       |  8 +--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 36 +++++-----
>   drivers/gpu/drm/drm_gem_vram_helper.c         |  4 +-
>   drivers/gpu/drm/nouveau/nouveau_ttm.c         | 46 ++++++-------
>   drivers/gpu/drm/nouveau/nouveau_ttm.h         |  6 +-
>   drivers/gpu/drm/qxl/qxl_ttm.c                 |  4 +-
>   drivers/gpu/drm/radeon/radeon_gem.c           |  2 +-
>   drivers/gpu/drm/radeon/radeon_ttm.c           |  4 +-
>   drivers/gpu/drm/ttm/ttm_bo.c                  | 66 +++++++++----------
>   drivers/gpu/drm/ttm/ttm_bo_util.c             | 26 ++++----
>   drivers/gpu/drm/ttm/ttm_bo_vm.c               |  2 +-
>   drivers/gpu/drm/ttm/ttm_range_manager.c       | 28 ++++----
>   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 20 +++---
>   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 26 ++++----
>   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           | 26 ++++----
>   include/drm/ttm/ttm_bo_api.h                  |  6 +-
>   include/drm/ttm/ttm_bo_driver.h               | 60 ++++++++---------
>   23 files changed, 210 insertions(+), 210 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index e24f421e5553..478f67498a17 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -517,7 +517,7 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
>   uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
>   {
>   	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
> -	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   
>   	return amdgpu_vram_mgr_usage(vram_man);
>   }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 9829640e1769..ecd051976bce 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
>   {
>   	s64 time_us, increment_us;
>   	u64 free_vram, total_vram, used_vram;
> -	struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	/* Allow a maximum of 200 accumulated ms. This is basically per-IB
>   	 * throttling.
>   	 *
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 71461d652fcc..8b600b804f34 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -25,13 +25,13 @@
>   #include "amdgpu.h"
>   
>   struct amdgpu_gtt_mgr {
> -	struct ttm_mem_type_manager manager;
> +	struct ttm_resource_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   	atomic64_t available;
>   };
>   
> -static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man)
> +static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_resource_manager *man)
>   {
>   	return container_of(man, struct amdgpu_gtt_mgr, manager);
>   }
> @@ -54,7 +54,7 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
>   			man->size * PAGE_SIZE);
>   }
> @@ -72,7 +72,7 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
>   			amdgpu_gtt_mgr_usage(man));
>   }
> @@ -82,7 +82,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
>   static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
>   	           amdgpu_mem_info_gtt_used_show, NULL);
>   
> -static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
> +static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
>   /**
>    * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
>    *
> @@ -93,7 +93,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
>    */
>   int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	struct amdgpu_gtt_mgr *mgr;
>   	uint64_t start, size;
>   	int ret;
> @@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   	man->available_caching = TTM_PL_MASK_CACHING;
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   
> -	ttm_mem_type_manager_init(man, gtt_size >> PAGE_SHIFT);
> +	ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
>   
>   	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
>   	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
> @@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   	}
>   
>   	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   
> @@ -142,13 +142,13 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>    */
>   void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	int ret;
>   
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   
> -	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> +	ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
>   	if (ret)
>   		return;
>   
> @@ -159,7 +159,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>   	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
>   	device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
>   
> -	ttm_mem_type_manager_cleanup(man);
> +	ttm_resource_manager_cleanup(man);
>   	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
>   	kfree(mgr);
>   }
> @@ -186,7 +186,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
>    *
>    * Dummy, allocate the node but no space for it yet.
>    */
> -static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
> +static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>   			      struct ttm_buffer_object *tbo,
>   			      const struct ttm_place *place,
>   			      struct ttm_mem_reg *mem)
> @@ -249,7 +249,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
>    *
>    * Free the allocated GTT again.
>    */
> -static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
> +static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
>   			       struct ttm_mem_reg *mem)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> @@ -272,7 +272,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>    *
>    * Return how many bytes are used in the GTT domain
>    */
> -uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
> +uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	s64 result = man->size - atomic64_read(&mgr->available);
> @@ -280,7 +280,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
>   	return (result > 0 ? result : 0) * PAGE_SIZE;
>   }
>   
> -int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
> +int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node;
> @@ -307,7 +307,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
>    *
>    * Dump the table content using printk.
>    */
> -static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
> +static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
>   				 struct drm_printer *printer)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> @@ -321,7 +321,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
>   		   amdgpu_gtt_mgr_usage(man) >> 20);
>   }
>   
> -static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
> +static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
>   	.get_node = amdgpu_gtt_mgr_new,
>   	.put_node = amdgpu_gtt_mgr_del,
>   	.debug = amdgpu_gtt_mgr_debug
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 594687cc99ac..2763bca163e3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -631,9 +631,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>   	}
>   	case AMDGPU_INFO_MEMORY: {
>   		struct drm_amdgpu_memory_info mem;
> -		struct ttm_mem_type_manager *vram_man =
> +		struct ttm_resource_manager *vram_man =
>   			ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> -		struct ttm_mem_type_manager *gtt_man =
> +		struct ttm_resource_manager *gtt_man =
>   			ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>   		memset(&mem, 0, sizeof(mem));
>   		mem.vram.total_heap_size = adev->gmc.real_vram_size;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ced418cba2f7..ce98df5b0c21 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -442,7 +442,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
>   static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
>   					  unsigned long size, u32 domain)
>   {
> -	struct ttm_mem_type_manager *man = NULL;
> +	struct ttm_resource_manager *man = NULL;
>   
>   	/*
>   	 * If GTT is part of requested domains the check must succeed to
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index b190d50dc9bb..cae7eada7215 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2030,7 +2030,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
>    */
>   void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	uint64_t size;
>   	int r;
>   
> @@ -2252,7 +2252,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
>   	unsigned ttm_pl = (uintptr_t)node->info_ent->data;
>   	struct drm_device *dev = node->minor->dev;
>   	struct amdgpu_device *adev = dev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
>   	man->func->debug(man, &p);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> index c01fdb3f0458..3db29ae1f802 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> @@ -73,8 +73,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
>   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
>   
>   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
> -uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
> -int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man);
> +uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
> +int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
>   
>   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
>   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> @@ -86,8 +86,8 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
>   			      struct device *dev,
>   			      enum dma_data_direction dir,
>   			      struct sg_table *sgt);
> -uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
> -uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man);
> +uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man);
> +uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man);
>   
>   int amdgpu_ttm_init(struct amdgpu_device *adev);
>   void amdgpu_ttm_late_init(struct amdgpu_device *adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 8cc44c3d2fdd..b227e380094f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -29,7 +29,7 @@
>   #include "atom.h"
>   
>   struct amdgpu_vram_mgr {
> -	struct ttm_mem_type_manager manager;
> +	struct ttm_resource_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   	atomic64_t usage;
> @@ -37,7 +37,7 @@ struct amdgpu_vram_mgr {
>   	struct amdgpu_device *adev;
>   };
>   
> -static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
> +static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_resource_manager *man)
>   {
>   	return container_of(man, struct amdgpu_vram_mgr, manager);
>   }
> @@ -89,7 +89,7 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
>   			amdgpu_vram_mgr_usage(man));
>   }
> @@ -107,7 +107,7 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev,
>   {
>   	struct drm_device *ddev = dev_get_drvdata(dev);
>   	struct amdgpu_device *adev = ddev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	return snprintf(buf, PAGE_SIZE, "%llu\n",
>   			amdgpu_vram_mgr_vis_usage(man));
>   }
> @@ -165,7 +165,7 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
>   	NULL
>   };
>   
> -static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
> +static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
>   
>   /**
>    * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
> @@ -177,7 +177,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
>    */
>   int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	struct amdgpu_vram_mgr *mgr;
>   	int ret;
>   
> @@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>   	man->default_caching = TTM_PL_FLAG_WC;
>   
> -	ttm_mem_type_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> +	ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
>   
>   	man->func = &amdgpu_vram_mgr_func;
>   
> @@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>   		DRM_ERROR("Failed to register sysfs\n");
>   
>   	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   
> @@ -219,13 +219,13 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>    */
>   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	int ret;
>   
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   
> -	ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> +	ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
>   	if (ret)
>   		return;
>   
> @@ -235,7 +235,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
>   
>   	sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
>   
> -	ttm_mem_type_manager_cleanup(man);
> +	ttm_resource_manager_cleanup(man);
>   	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
>   	kfree(mgr);
>   }
> @@ -321,7 +321,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
>    *
>    * Allocate VRAM for the given BO.
>    */
> -static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
> +static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>   			       struct ttm_buffer_object *tbo,
>   			       const struct ttm_place *place,
>   			       struct ttm_mem_reg *mem)
> @@ -439,7 +439,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
>    *
>    * Free the allocated VRAM again.
>    */
> -static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
> +static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
>   				struct ttm_mem_reg *mem)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> @@ -573,7 +573,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
>    *
>    * Returns how many bytes are used in this domain.
>    */
> -uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
> +uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   
> @@ -587,7 +587,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
>    *
>    * Returns how many bytes are used in the visible part of VRAM
>    */
> -uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
> +uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   
> @@ -602,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
>    *
>    * Dump the table content using printk.
>    */
> -static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
> +static void amdgpu_vram_mgr_debug(struct ttm_resource_manager *man,
>   				  struct drm_printer *printer)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> @@ -616,7 +616,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
>   		   amdgpu_vram_mgr_vis_usage(man) >> 20);
>   }
>   
> -static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
> +static const struct ttm_resource_manager_func amdgpu_vram_mgr_func = {
>   	.get_node	= amdgpu_vram_mgr_new,
>   	.put_node	= amdgpu_vram_mgr_del,
>   	.debug		= amdgpu_vram_mgr_debug
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 2187787f397e..e3660d00987d 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1075,10 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
>   {
>   	struct drm_info_node *node = (struct drm_info_node *) m->private;
>   	struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
> -	ttm_mem_type_manager_debug(man, &p);
> +	ttm_resource_manager_debug(man, &p);
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 38a0e4bd16f7..d6ad0977dc7d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -32,13 +32,13 @@
>   #include <core/tegra.h>
>   
>   static void
> -nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
> +nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
>   {
>   	nouveau_mem_del(reg);
>   }
>   
>   static int
> -nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
> +nouveau_vram_manager_new(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
>   			 struct ttm_mem_reg *reg)
> @@ -63,13 +63,13 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
>   	return 0;
>   }
>   
> -const struct ttm_mem_type_manager_func nouveau_vram_manager = {
> +const struct ttm_resource_manager_func nouveau_vram_manager = {
>   	.get_node = nouveau_vram_manager_new,
>   	.put_node = nouveau_manager_del,
>   };
>   
>   static int
> -nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
> +nouveau_gart_manager_new(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
>   			 struct ttm_mem_reg *reg)
> @@ -86,13 +86,13 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
>   	return 0;
>   }
>   
> -const struct ttm_mem_type_manager_func nouveau_gart_manager = {
> +const struct ttm_resource_manager_func nouveau_gart_manager = {
>   	.get_node = nouveau_gart_manager_new,
>   	.put_node = nouveau_manager_del,
>   };
>   
>   static int
> -nv04_gart_manager_new(struct ttm_mem_type_manager *man,
> +nv04_gart_manager_new(struct ttm_resource_manager *man,
>   		      struct ttm_buffer_object *bo,
>   		      const struct ttm_place *place,
>   		      struct ttm_mem_reg *reg)
> @@ -118,7 +118,7 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
>   	return 0;
>   }
>   
> -const struct ttm_mem_type_manager_func nv04_gart_manager = {
> +const struct ttm_resource_manager_func nv04_gart_manager = {
>   	.get_node = nv04_gart_manager_new,
>   	.put_node = nouveau_manager_del,
>   };
> @@ -160,7 +160,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>   	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
>   		/* Some BARs do not support being ioremapped WC */
>   		const u8 type = mmu->type[drm->ttm.type_vram].type;
> -		struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> +		struct ttm_resource_manager *man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
>   		if (!man)
>   			return -ENOMEM;
>   
> @@ -175,10 +175,10 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>   		man->func = &nouveau_vram_manager;
>   		man->use_io_reserve_lru = true;
>   
> -		ttm_mem_type_manager_init(man,
> +		ttm_resource_manager_init(man,
>   					  drm->gem.vram_available >> PAGE_SHIFT);
>   		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
> -		ttm_mem_type_manager_set_used(man, true);
> +		ttm_resource_manager_set_used(man, true);
>   		return 0;
>   	} else {
>   		return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
> @@ -191,12 +191,12 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>   static void
>   nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
>   
>   	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> -		ttm_mem_type_manager_set_used(man, false);
> -		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> -		ttm_mem_type_manager_cleanup(man);
> +		ttm_resource_manager_set_used(man, false);
> +		ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
> +		ttm_resource_manager_cleanup(man);
>   		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
>   		kfree(man);
>   	} else
> @@ -206,10 +206,10 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>   static int
>   nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
>   	unsigned available_caching, default_caching;
> -	const struct ttm_mem_type_manager_func *func = NULL;
> +	const struct ttm_resource_manager_func *func = NULL;
>   	if (drm->agp.bridge) {
>   		available_caching = TTM_PL_FLAG_UNCACHED |
>   			TTM_PL_FLAG_WC;
> @@ -229,7 +229,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>   					  true,
>   					  size_pages);
>   
> -	man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> +	man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
>   	if (!man)
>   		return -ENOMEM;
>   
> @@ -237,24 +237,24 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>   	man->available_caching = available_caching;
>   	man->default_caching = default_caching;
>   	man->use_tt = true;
> -	ttm_mem_type_manager_init(man, size_pages);
> +	ttm_resource_manager_init(man, size_pages);
>   	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   
>   static void
>   nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
> +	struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
>   
>   	if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
>   	    drm->agp.bridge)
>   		ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
>   	else {
> -		ttm_mem_type_manager_set_used(man, false);
> -		ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> -		ttm_mem_type_manager_cleanup(man);
> +		ttm_resource_manager_set_used(man, false);
> +		ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
> +		ttm_resource_manager_cleanup(man);
>   		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
>   		kfree(man);
>   	}
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.h b/drivers/gpu/drm/nouveau/nouveau_ttm.h
> index 085280754b3e..eaf25461cd91 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.h
> @@ -8,9 +8,9 @@ nouveau_bdev(struct ttm_bo_device *bd)
>   	return container_of(bd, struct nouveau_drm, ttm.bdev);
>   }
>   
> -extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
> -extern const struct ttm_mem_type_manager_func nouveau_gart_manager;
> -extern const struct ttm_mem_type_manager_func nv04_gart_manager;
> +extern const struct ttm_resource_manager_func nouveau_vram_manager;
> +extern const struct ttm_resource_manager_func nouveau_gart_manager;
> +extern const struct ttm_resource_manager_func nv04_gart_manager;
>   
>   struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo,
>   					u32 page_flags);
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index b7365b2e4c7f..1c06fe780815 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -274,10 +274,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)
>   static int qxl_mm_dump_table(struct seq_file *m, void *data)
>   {
>   	struct drm_info_node *node = (struct drm_info_node *)m->private;
> -	struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data;
> +	struct ttm_resource_manager *man = (struct ttm_resource_manager *)node->info_ent->data;
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
> -	ttm_mem_type_manager_debug(man, &p);
> +	ttm_resource_manager_debug(man, &p);
>   	return 0;
>   }
>   #endif
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index 3ec028dba739..7f5dfe04789e 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -224,7 +224,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
>   {
>   	struct radeon_device *rdev = dev->dev_private;
>   	struct drm_radeon_gem_info *args = data;
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
>   
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 474d2161da1e..05b5f29f2b61 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -836,7 +836,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
>    * isn't running */
>   void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	if (!rdev->mman.initialized)
>   		return;
> @@ -895,7 +895,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
>   	unsigned ttm_pl = *(int*)node->info_ent->data;
>   	struct drm_device *dev = node->minor->dev;
>   	struct radeon_device *rdev = dev->dev_private;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
> +	struct ttm_resource_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
>   	struct drm_printer p = drm_seq_file_printer(m);
>   
>   	man->func->debug(man, &p);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 7d10abae9a60..48840a3cf4c4 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -77,7 +77,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
>   	return 0;
>   }
>   
> -void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> +void ttm_resource_manager_debug(struct ttm_resource_manager *man,
>   				struct drm_printer *p)
>   {
>   	drm_printf(p, "    use_type: %d\n", man->use_type);
> @@ -88,14 +88,14 @@ void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
>   	if (man->func && man->func->debug)
>   		(*man->func->debug)(man, p);
>   }
> -EXPORT_SYMBOL(ttm_mem_type_manager_debug);
> +EXPORT_SYMBOL(ttm_resource_manager_debug);
>   
>   static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
>   					struct ttm_placement *placement)
>   {
>   	struct drm_printer p = drm_debug_printer(TTM_PFX);
>   	int i, ret, mem_type;
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
>   		   bo, bo->mem.num_pages, bo->mem.size >> 10,
> @@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
>   		drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
>   			   i, placement->placement[i].flags, mem_type);
>   		man = ttm_manager_type(bo->bdev, mem_type);
> -		ttm_mem_type_manager_debug(man, &p);
> +		ttm_resource_manager_debug(man, &p);
>   	}
>   }
>   
> @@ -148,7 +148,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
>   				  struct ttm_mem_reg *mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	if (!list_empty(&bo->lru))
>   		return;
> @@ -223,7 +223,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
>   
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>   		struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i];
> -		struct ttm_mem_type_manager *man;
> +		struct ttm_resource_manager *man;
>   
>   		if (!pos->first)
>   			continue;
> @@ -238,7 +238,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
>   
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>   		struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i];
> -		struct ttm_mem_type_manager *man;
> +		struct ttm_resource_manager *man;
>   
>   		if (!pos->first)
>   			continue;
> @@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> -	struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
> +	struct ttm_resource_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> +	struct ttm_resource_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   
>   	ret = ttm_mem_io_lock(old_man, true);
> @@ -551,7 +551,7 @@ static void ttm_bo_release(struct kref *kref)
>   	struct ttm_buffer_object *bo =
>   	    container_of(kref, struct ttm_buffer_object, kref);
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
>   	size_t acc_size = bo->acc_size;
>   	int ret;
>   
> @@ -768,7 +768,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
>   }
>   
>   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> -			       struct ttm_mem_type_manager *man,
> +			       struct ttm_resource_manager *man,
>   			       const struct ttm_place *place,
>   			       struct ttm_operation_ctx *ctx,
>   			       struct ww_acquire_ctx *ticket)
> @@ -843,7 +843,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   			  const struct ttm_place *place,
>   			  struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
>   	mem->mm_node = NULL;
>   	if (!man->func || !man->func->get_node)
> @@ -854,7 +854,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   
>   void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
>   	if (!man->func || !man->func->put_node)
>   		return;
> @@ -869,7 +869,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
>    * Add the last move fence to the BO and reserve a new shared slot.
>    */
>   static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
> -				 struct ttm_mem_type_manager *man,
> +				 struct ttm_resource_manager *man,
>   				 struct ttm_mem_reg *mem,
>   				 bool no_wait_gpu)
>   {
> @@ -911,7 +911,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	struct ww_acquire_ctx *ticket;
>   	int ret;
>   
> @@ -931,7 +931,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   	return ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
>   }
>   
> -static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
> +static uint32_t ttm_bo_select_caching(struct ttm_resource_manager *man,
>   				      uint32_t cur_placement,
>   				      uint32_t proposed_placement)
>   {
> @@ -956,7 +956,7 @@ static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
>   	return result;
>   }
>   
> -static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
> +static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
>   				 uint32_t mem_type,
>   				 const struct ttm_place *place,
>   				 uint32_t *masked_placement)
> @@ -993,7 +993,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	uint32_t mem_type = TTM_PL_SYSTEM;
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	uint32_t cur_flags = 0;
>   	int ret;
>   
> @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   		return ret;
>   
>   	man = ttm_manager_type(bdev, mem_type);
> -	if (!man || !ttm_mem_type_manager_used(man))
> +	if (!man || !ttm_resource_manager_used(man))
>   		return -EBUSY;
>   
>   	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> @@ -1049,7 +1049,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   
>   	for (i = 0; i < placement->num_placement; ++i) {
>   		const struct ttm_place *place = &placement->placement[i];
> -		struct ttm_mem_type_manager *man;
> +		struct ttm_resource_manager *man;
>   
>   		ret = ttm_bo_mem_placement(bo, place, mem, ctx);
>   		if (ret == -EBUSY)
> @@ -1406,8 +1406,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
>   }
>   EXPORT_SYMBOL(ttm_bo_create);
>   
> -int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> -					  struct ttm_mem_type_manager *man)
> +int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
> +					  struct ttm_resource_manager *man)
>   {
>   	struct ttm_operation_ctx ctx = {
>   		.interruptible = false,
> @@ -1449,12 +1449,12 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
>   
>   	return 0;
>   }
> -EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
> +EXPORT_SYMBOL(ttm_resource_manager_force_list_clean);
>   
>   
>   int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem_type);
>   
>   	if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
>   		pr_err("Illegal memory manager memory type %u\n", mem_type);
> @@ -1466,11 +1466,11 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		return 0;
>   	}
>   
> -	return ttm_mem_type_manager_force_list_clean(bdev, man);
> +	return ttm_resource_manager_force_list_clean(bdev, man);
>   }
>   EXPORT_SYMBOL(ttm_bo_evict_mm);
>   
> -void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> +void ttm_resource_manager_init(struct ttm_resource_manager *man,
>   			       unsigned long p_size)
>   {
>   	unsigned i;
> @@ -1485,7 +1485,7 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
>   		INIT_LIST_HEAD(&man->lru[i]);
>   	man->move = NULL;
>   }
> -EXPORT_SYMBOL(ttm_mem_type_manager_init);
> +EXPORT_SYMBOL(ttm_resource_manager_init);
>   
>   static void ttm_bo_global_kobj_release(struct kobject *kobj)
>   {
> @@ -1552,10 +1552,10 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>   	struct ttm_bo_global *glob = &ttm_bo_glob;
>   	int ret = 0;
>   	unsigned i;
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
>   
>   	mutex_lock(&ttm_global_mutex);
> @@ -1582,7 +1582,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
>   
>   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>   {
> -	struct ttm_mem_type_manager *man = &bdev->sysman;
> +	struct ttm_resource_manager *man = &bdev->sysman;
>   
>   	/*
>   	 * Initialize the system memory buffer type.
> @@ -1592,9 +1592,9 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>   	man->available_caching = TTM_PL_MASK_CACHING;
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   
> -	ttm_mem_type_manager_init(man, 0);
> +	ttm_resource_manager_init(man, 0);
>   	ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   }
>   
>   int ttm_bo_device_init(struct ttm_bo_device *bdev,
> @@ -1645,7 +1645,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
>   void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
>   
>   	ttm_mem_io_lock(man, false);
>   	ttm_bo_unmap_virtual_locked(bo);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 879c8ded0cd8..8ef0de8e36c5 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -91,7 +91,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
>   }
>   EXPORT_SYMBOL(ttm_bo_move_ttm);
>   
> -int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
> +int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible)
>   {
>   	if (likely(!man->use_io_reserve_lru))
>   		return 0;
> @@ -103,7 +103,7 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
>   	return 0;
>   }
>   
> -void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
> +void ttm_mem_io_unlock(struct ttm_resource_manager *man)
>   {
>   	if (likely(!man->use_io_reserve_lru))
>   		return;
> @@ -111,7 +111,7 @@ void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
>   	mutex_unlock(&man->io_reserve_mutex);
>   }
>   
> -static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
> +static int ttm_mem_io_evict(struct ttm_resource_manager *man)
>   {
>   	struct ttm_buffer_object *bo;
>   
> @@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
>   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
>   		       struct ttm_mem_reg *mem)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   
>   	if (mem->bus.io_reserved_count++)
> @@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
>   
>   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   	struct ttm_mem_reg *mem = &bo->mem;
>   	int ret;
>   
> @@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
>   			       struct ttm_mem_reg *mem,
>   			       void **virtual)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
>   	void *addr;
>   
> @@ -230,7 +230,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
>   				struct ttm_mem_reg *mem,
>   				void *virtual)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   
>   	man = ttm_manager_type(bdev, mem->mem_type);
>   
> @@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   		       struct ttm_mem_reg *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
>   	struct ttm_tt *ttm = bo->ttm;
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   	struct ttm_mem_reg old_copy = *old_mem;
> @@ -570,7 +570,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
>   		unsigned long start_page, unsigned long num_pages,
>   		struct ttm_bo_kmap_obj *map)
>   {
> -	struct ttm_mem_type_manager *man =
> +	struct ttm_resource_manager *man =
>   		ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   	unsigned long offset, size;
>   	int ret;
> @@ -600,7 +600,7 @@ EXPORT_SYMBOL(ttm_bo_kmap);
>   void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
>   {
>   	struct ttm_buffer_object *bo = map->bo;
> -	struct ttm_mem_type_manager *man =
> +	struct ttm_resource_manager *man =
>   		ttm_manager_type(bo->bdev, bo->mem.mem_type);
>   
>   	if (!map->virtual)
> @@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
>   			      struct ttm_mem_reg *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   	int ret;
>   	struct ttm_buffer_object *ghost_obj;
> @@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   
> -	struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> -	struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> +	struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> +	struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
>   
>   	int ret;
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 5ae679184eb5..c8efceef015d 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -281,7 +281,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>   	pgoff_t i;
>   	vm_fault_t ret = VM_FAULT_NOPAGE;
>   	unsigned long address = vmf->address;
> -	struct ttm_mem_type_manager *man =
> +	struct ttm_resource_manager *man =
>   		ttm_manager_type(bdev, bo->mem.mem_type);
>   
>   	/*
> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index 52d9a0ed7165..22de9f209449 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -44,17 +44,17 @@
>    */
>   
>   struct ttm_range_manager {
> -	struct ttm_mem_type_manager manager;
> +	struct ttm_resource_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   };
>   
> -static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man)
> +static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_manager *man)
>   {
>   	return container_of(man, struct ttm_range_manager, manager);
>   }
>   
> -static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
> +static int ttm_range_man_get_node(struct ttm_resource_manager *man,
>   				  struct ttm_buffer_object *bo,
>   				  const struct ttm_place *place,
>   				  struct ttm_mem_reg *mem)
> @@ -95,7 +95,7 @@ static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
>   	return ret;
>   }
>   
> -static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
> +static void ttm_range_man_put_node(struct ttm_resource_manager *man,
>   				   struct ttm_mem_reg *mem)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
> @@ -110,7 +110,7 @@ static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
>   	}
>   }
>   
> -static const struct ttm_mem_type_manager_func ttm_range_manager_func;
> +static const struct ttm_resource_manager_func ttm_range_manager_func;
>   
>   int ttm_range_man_init(struct ttm_bo_device *bdev,
>   		       unsigned type,
> @@ -119,7 +119,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   		       bool use_tt,
>   		       unsigned long p_size)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	struct ttm_range_manager *rman;
>   
>   	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> @@ -133,13 +133,13 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>   
>   	man->func = &ttm_range_manager_func;
>   
> -	ttm_mem_type_manager_init(man, p_size);
> +	ttm_resource_manager_init(man, p_size);
>   
>   	drm_mm_init(&rman->mm, 0, p_size);
>   	spin_lock_init(&rman->lock);
>   
>   	ttm_set_driver_manager(bdev, type, &rman->manager);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   EXPORT_SYMBOL(ttm_range_man_init);
> @@ -147,14 +147,14 @@ EXPORT_SYMBOL(ttm_range_man_init);
>   int ttm_range_man_fini(struct ttm_bo_device *bdev,
>   		       unsigned type)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> +	struct ttm_resource_manager *man = ttm_manager_type(bdev, type);
>   	struct ttm_range_manager *rman = to_range_manager(man);
>   	struct drm_mm *mm = &rman->mm;
>   	int ret;
>   
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   
> -	ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> +	ret = ttm_resource_manager_force_list_clean(bdev, man);
>   	if (ret)
>   		return ret;
>   
> @@ -163,14 +163,14 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>   	drm_mm_takedown(mm);
>   	spin_unlock(&rman->lock);
>   
> -	ttm_mem_type_manager_cleanup(man);
> +	ttm_resource_manager_cleanup(man);
>   	ttm_set_driver_manager(bdev, type, NULL);
>   	kfree(rman);
>   	return 0;
>   }
>   EXPORT_SYMBOL(ttm_range_man_fini);
>   
> -static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
> +static void ttm_range_man_debug(struct ttm_resource_manager *man,
>   			     struct drm_printer *printer)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
> @@ -180,7 +180,7 @@ static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
>   	spin_unlock(&rman->lock);
>   }
>   
> -static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
> +static const struct ttm_resource_manager_func ttm_range_manager_func = {
>   	.get_node = ttm_range_man_get_node,
>   	.put_node = ttm_range_man_put_node,
>   	.debug = ttm_range_man_debug
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index b2f1e7a3b048..7645d67aa6b6 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>   				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
>   				 false, dev_priv->vram_size >> PAGE_SHIFT);
>   #endif
> -	ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
> +	ttm_resource_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
>   	return ret;
>   }
>   
> @@ -1189,12 +1189,12 @@ static void vmw_master_drop(struct drm_device *dev,
>    */
>   static void __vmw_svga_enable(struct vmw_private *dev_priv)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   
>   	spin_lock(&dev_priv->svga_lock);
> -	if (!ttm_mem_type_manager_used(man)) {
> +	if (!ttm_resource_manager_used(man)) {
>   		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> -		ttm_mem_type_manager_set_used(man, true);
> +		ttm_resource_manager_set_used(man, true);
>   	}
>   	spin_unlock(&dev_priv->svga_lock);
>   }
> @@ -1220,11 +1220,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)
>    */
>   static void __vmw_svga_disable(struct vmw_private *dev_priv)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   
>   	spin_lock(&dev_priv->svga_lock);
> -	if (ttm_mem_type_manager_used(man)) {
> -		ttm_mem_type_manager_set_used(man, false);
> +	if (ttm_resource_manager_used(man)) {
> +		ttm_resource_manager_set_used(man, false);
>   		vmw_write(dev_priv, SVGA_REG_ENABLE,
>   			  SVGA_REG_ENABLE_HIDE |
>   			  SVGA_REG_ENABLE_ENABLE);
> @@ -1241,7 +1241,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
>    */
>   void vmw_svga_disable(struct vmw_private *dev_priv)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   	/*
>   	 * Disabling SVGA will turn off device modesetting capabilities, so
>   	 * notify KMS about that so that it doesn't cache atomic state that
> @@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
>   	vmw_kms_lost_device(dev_priv->dev);
>   	ttm_write_lock(&dev_priv->reservation_sem, false);
>   	spin_lock(&dev_priv->svga_lock);
> -	if (ttm_mem_type_manager_used(man)) {
> -		ttm_mem_type_manager_set_used(man, false);
> +	if (ttm_resource_manager_used(man)) {
> +		ttm_resource_manager_set_used(man, false);
>   		spin_unlock(&dev_priv->svga_lock);
>   		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
>   			DRM_ERROR("Failed evicting VRAM buffers.\n");
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index ca5037184814..c8fe6e9cf092 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -37,7 +37,7 @@
>   #include <linux/kernel.h>
>   
>   struct vmwgfx_gmrid_man {
> -	struct ttm_mem_type_manager manager;
> +	struct ttm_resource_manager manager;
>   	spinlock_t lock;
>   	struct ida gmr_ida;
>   	uint32_t max_gmr_ids;
> @@ -45,12 +45,12 @@ struct vmwgfx_gmrid_man {
>   	uint32_t used_gmr_pages;
>   };
>   
> -static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man)
> +static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *man)
>   {
>   	return container_of(man, struct vmwgfx_gmrid_man, manager);
>   }
>   
> -static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
> +static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
>   				  struct ttm_buffer_object *bo,
>   				  const struct ttm_place *place,
>   				  struct ttm_mem_reg *mem)
> @@ -84,7 +84,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
>   	return -ENOSPC;
>   }
>   
> -static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
> +static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
>   				   struct ttm_mem_reg *mem)
>   {
>   	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> @@ -98,11 +98,11 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
>   	}
>   }
>   
> -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
> +static const struct ttm_resource_manager_func vmw_gmrid_manager_func;
>   
>   int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	struct vmwgfx_gmrid_man *gman =
>   		kzalloc(sizeof(*gman), GFP_KERNEL);
>   
> @@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   	/* TODO: This is most likely not correct */
>   	man->use_tt = true;
> -	ttm_mem_type_manager_init(man, 0);
> +	ttm_resource_manager_init(man, 0);
>   	spin_lock_init(&gman->lock);
>   	gman->used_gmr_pages = 0;
>   	ida_init(&gman->gmr_ida);
> @@ -134,20 +134,20 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>   		BUG();
>   	}
>   	ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   
>   void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> +	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, type);
>   	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>   
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   
> -	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> +	ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
>   
> -	ttm_mem_type_manager_cleanup(man);
> +	ttm_resource_manager_cleanup(man);
>   
>   	ttm_set_driver_manager(&dev_priv->bdev, type, NULL);
>   	ida_destroy(&gman->gmr_ida);
> @@ -155,7 +155,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>   
>   }
>   
> -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> +static const struct ttm_resource_manager_func vmw_gmrid_manager_func = {
>   	.get_node = vmw_gmrid_man_get_node,
>   	.put_node = vmw_gmrid_man_put_node,
>   };
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 4110e8309188..6cac7b091205 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -16,12 +16,12 @@
>    * @lock: Manager lock.
>    */
>   struct vmw_thp_manager {
> -	struct ttm_mem_type_manager manager;
> +	struct ttm_resource_manager manager;
>   	struct drm_mm mm;
>   	spinlock_t lock;
>   };
>   
> -static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man)
> +static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
>   {
>   	return container_of(man, struct vmw_thp_manager, manager);
>   }
> @@ -44,7 +44,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
>   	return -ENOSPC;
>   }
>   
> -static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
> +static int vmw_thp_get_node(struct ttm_resource_manager *man,
>   			    struct ttm_buffer_object *bo,
>   			    const struct ttm_place *place,
>   			    struct ttm_mem_reg *mem)
> @@ -106,7 +106,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
>   
>   
>   
> -static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
> +static void vmw_thp_put_node(struct ttm_resource_manager *man,
>   			     struct ttm_mem_reg *mem)
>   {
>   	struct vmw_thp_manager *rman = to_thp_manager(man);
> @@ -123,7 +123,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
>   
>   int vmw_thp_init(struct vmw_private *dev_priv)
>   {
> -	struct ttm_mem_type_manager *man;
> +	struct ttm_resource_manager *man;
>   	struct vmw_thp_manager *rman;
>   
>   	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> @@ -134,39 +134,39 @@ int vmw_thp_init(struct vmw_private *dev_priv)
>   	man->available_caching = TTM_PL_FLAG_CACHED;
>   	man->default_caching = TTM_PL_FLAG_CACHED;
>   
> -	ttm_mem_type_manager_init(man,
> +	ttm_resource_manager_init(man,
>   				  dev_priv->vram_size >> PAGE_SHIFT);
>   
>   	drm_mm_init(&rman->mm, 0, man->size);
>   	spin_lock_init(&rman->lock);
>   
>   	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
> -	ttm_mem_type_manager_set_used(man, true);
> +	ttm_resource_manager_set_used(man, true);
>   	return 0;
>   }
>   
>   void vmw_thp_fini(struct vmw_private *dev_priv)
>   {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +	struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>   	struct vmw_thp_manager *rman = to_thp_manager(man);
>   	struct drm_mm *mm = &rman->mm;
>   	int ret;
>   
> -	ttm_mem_type_manager_set_used(man, false);
> +	ttm_resource_manager_set_used(man, false);
>   
> -	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> +	ret = ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
>   	if (ret)
>   		return;
>   	spin_lock(&rman->lock);
>   	drm_mm_clean(mm);
>   	drm_mm_takedown(mm);
>   	spin_unlock(&rman->lock);
> -	ttm_mem_type_manager_cleanup(man);
> +	ttm_resource_manager_cleanup(man);
>   	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
>   	kfree(rman);
>   }
>   
> -static void vmw_thp_debug(struct ttm_mem_type_manager *man,
> +static void vmw_thp_debug(struct ttm_resource_manager *man,
>   			  struct drm_printer *printer)
>   {
>   	struct vmw_thp_manager *rman = to_thp_manager(man);
> @@ -176,7 +176,7 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
>   	spin_unlock(&rman->lock);
>   }
>   
> -const struct ttm_mem_type_manager_func vmw_thp_func = {
> +const struct ttm_resource_manager_func vmw_thp_func = {
>   	.get_node = vmw_thp_get_node,
>   	.put_node = vmw_thp_put_node,
>   	.debug = vmw_thp_debug
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index eb465e9ca0c1..15958dff11d2 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -54,7 +54,7 @@ struct ttm_place;
>   
>   struct ttm_lru_bulk_move;
>   
> -struct ttm_mem_type_manager;
> +struct ttm_resource_manager;
>   
>   /**
>    * struct ttm_bus_placement
> @@ -534,14 +534,14 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
>   		  struct ttm_buffer_object **p_bo);
>   
>   /**
> - * ttm_mem_type_manager_init
> + * ttm_resource_manager_init
>    *
>    * @man: memory manager object to init
>    * @p_size: size managed area in pages.
>    *
>    * Initialise core parts of a manager object.
>    */
> -void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> +void ttm_resource_manager_init(struct ttm_resource_manager *man,
>   			       unsigned long p_size);
>   
>   /**
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index f231fe34e744..d1eff7de4fa3 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -45,11 +45,11 @@
>   
>   #define TTM_MAX_BO_PRIORITY	4U
>   
> -struct ttm_mem_type_manager;
> +struct ttm_resource_manager;
>   
> -struct ttm_mem_type_manager_func {
> +struct ttm_resource_manager_func {
>   	/**
> -	 * struct ttm_mem_type_manager member get_node
> +	 * struct ttm_resource_manager member get_node
>   	 *
>   	 * @man: Pointer to a memory type manager.
>   	 * @bo: Pointer to the buffer object we're allocating space for.
> @@ -69,20 +69,20 @@ struct ttm_mem_type_manager_func {
>   	 * the function should return a negative error code.
>   	 *
>   	 * Note that @mem::mm_node will only be dereferenced by
> -	 * struct ttm_mem_type_manager functions and optionally by the driver,
> +	 * struct ttm_resource_manager functions and optionally by the driver,
>   	 * which has knowledge of the underlying type.
>   	 *
>   	 * This function may not be called from within atomic context, so
>   	 * an implementation can and must use either a mutex or a spinlock to
>   	 * protect any data structures managing the space.
>   	 */
> -	int  (*get_node)(struct ttm_mem_type_manager *man,
> +	int  (*get_node)(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
>   			 struct ttm_mem_reg *mem);
>   
>   	/**
> -	 * struct ttm_mem_type_manager member put_node
> +	 * struct ttm_resource_manager member put_node
>   	 *
>   	 * @man: Pointer to a memory type manager.
>   	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> @@ -91,11 +91,11 @@ struct ttm_mem_type_manager_func {
>   	 * and that are identified by @mem::mm_node and @mem::start. May not
>   	 * be called from within atomic context.
>   	 */
> -	void (*put_node)(struct ttm_mem_type_manager *man,
> +	void (*put_node)(struct ttm_resource_manager *man,
>   			 struct ttm_mem_reg *mem);
>   
>   	/**
> -	 * struct ttm_mem_type_manager member debug
> +	 * struct ttm_resource_manager member debug
>   	 *
>   	 * @man: Pointer to a memory type manager.
>   	 * @printer: Prefix to be used in printout to identify the caller.
> @@ -104,12 +104,12 @@ struct ttm_mem_type_manager_func {
>   	 * type manager to aid debugging of out-of-memory conditions.
>   	 * It may not be called from within atomic context.
>   	 */
> -	void (*debug)(struct ttm_mem_type_manager *man,
> +	void (*debug)(struct ttm_resource_manager *man,
>   		      struct drm_printer *printer);
>   };
>   
>   /**
> - * struct ttm_mem_type_manager
> + * struct ttm_resource_manager
>    *
>    * @use_type: The memory type is enabled.
>    * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
> @@ -136,7 +136,7 @@ struct ttm_mem_type_manager_func {
>   
>   
>   
> -struct ttm_mem_type_manager {
> +struct ttm_resource_manager {
>   	/*
>   	 * No protection. Constant from start.
>   	 */
> @@ -145,7 +145,7 @@ struct ttm_mem_type_manager {
>   	uint64_t size;
>   	uint32_t available_caching;
>   	uint32_t default_caching;
> -	const struct ttm_mem_type_manager_func *func;
> +	const struct ttm_resource_manager_func *func;
>   	struct mutex io_reserve_mutex;
>   	bool use_io_reserve_lru;
>   	spinlock_t move_lock;
> @@ -390,7 +390,7 @@ extern struct ttm_bo_global {
>    * struct ttm_bo_device - Buffer object driver device-specific data.
>    *
>    * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
> - * @man: An array of mem_type_managers.
> + * @man: An array of resource_managers.
>    * @vma_manager: Address space manager (pointer)
>    * lru_lock: Spinlock that protects the buffer+device lru lists and
>    * ddestroy lists.
> @@ -411,8 +411,8 @@ struct ttm_bo_device {
>   	/*
>   	 * access via ttm_manager_type.
>   	 */
> -	struct ttm_mem_type_manager sysman;
> -	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
> +	struct ttm_resource_manager sysman;
> +	struct ttm_resource_manager *man_drv[TTM_NUM_MEM_TYPES];
>   	/*
>   	 * Protected by internal locks.
>   	 */
> @@ -440,7 +440,7 @@ struct ttm_bo_device {
>   	bool no_retry;
>   };
>   
> -static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> +static inline struct ttm_resource_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
>   	return bdev->man_drv[mem_type];
> @@ -448,7 +448,7 @@ static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device
>   
>   static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
>   					  int type,
> -					  struct ttm_mem_type_manager *manager)
> +					  struct ttm_resource_manager *manager)
>   {
>   	bdev->man_drv[type] = manager;
>   }
> @@ -570,8 +570,8 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo);
>   
>   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo);
>   void ttm_mem_io_free_vm(struct ttm_buffer_object *bo);
> -int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible);
> -void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
> +int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible);
> +void ttm_mem_io_unlock(struct ttm_resource_manager *man);
>   
>   /**
>    * ttm_bo_reserve:
> @@ -665,7 +665,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>   }
>   
>   /**
> - * ttm_mem_type_manager_set_used
> + * ttm_resource_manager_set_used
>    *
>    * @man: A memory manager object.
>    * @used: usage state to set.
> @@ -673,13 +673,13 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>    * Set the manager in use flag. If disabled the manager is no longer
>    * used for object placement.
>    */
> -static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
> +static inline void ttm_resource_manager_set_used(struct ttm_resource_manager *man, bool used)
>   {
>   	man->use_type = used;
>   }
>   
>   /**
> - * ttm_mem_type_manager_used
> + * ttm_resource_manager_used
>    *
>    * @man: Manager to get used state for
>    *
> @@ -687,26 +687,26 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
>    * Returns:
>    * true is used, false if not.
>    */
> -static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
> +static inline bool ttm_resource_manager_used(struct ttm_resource_manager *man)
>   {
>   	return man->use_type;
>   }
>   
>   /**
> - * ttm_mem_type_manager_cleanup
> + * ttm_resource_manager_cleanup
>    *
>    * @man: A memory manager object.
>    *
>    * Cleanup the move fences from the memory manager object.
>    */
> -static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> +static inline void ttm_resource_manager_cleanup(struct ttm_resource_manager *man)
>   {
>   	dma_fence_put(man->move);
>   	man->move = NULL;
>   }
>   
>   /*
> - * ttm_mem_type_manager_force_list_clean
> + * ttm_resource_manager_force_list_clean
>    *
>    * @bdev - device to use
>    * @man - manager to use
> @@ -714,8 +714,8 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
>    * Force all the objects out of a memory manager until clean.
>    * Part of memory manager cleanup sequence.
>    */
> -int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> -					  struct ttm_mem_type_manager *man);
> +int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
> +					  struct ttm_resource_manager *man);
>   
>   /*
>    * ttm_bo_util.c
> @@ -864,12 +864,12 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>   		       unsigned type);
>   
>   /**
> - * ttm_mem_type_manager_debug
> + * ttm_resource_manager_debug
>    *
>    * @man: manager type to dump.
>    * @p: printer to use for debug.
>    */
> -void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> +void ttm_resource_manager_debug(struct ttm_resource_manager *man,
>   				struct drm_printer *p);
>   
>   #endif

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource.
  2020-08-04  2:56 ` [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource Dave Airlie
@ 2020-08-04 11:41   ` Christian König
  2020-08-05  5:58     ` Ben Skeggs
  0 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-04 11:41 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This name better reflects what the object does. I didn't rename
> all the pointers it seemed too messy.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  6 +--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h    |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       | 46 +++++++++----------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       | 10 ++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c        |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 12 ++---
>   drivers/gpu/drm/drm_gem_vram_helper.c         |  6 +--
>   drivers/gpu/drm/nouveau/nouveau_bo.c          | 28 +++++------
>   drivers/gpu/drm/nouveau/nouveau_bo.h          | 14 +++---
>   drivers/gpu/drm/nouveau/nouveau_bo0039.c      |  4 +-
>   drivers/gpu/drm/nouveau/nouveau_bo5039.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_bo74c1.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_bo85b5.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_bo9039.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_bo90b5.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_boa0b5.c      |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 +-
>   drivers/gpu/drm/nouveau/nouveau_mem.c         |  8 ++--
>   drivers/gpu/drm/nouveau/nouveau_mem.h         | 10 ++--
>   drivers/gpu/drm/nouveau/nouveau_sgdma.c       |  4 +-
>   drivers/gpu/drm/nouveau/nouveau_ttm.c         |  8 ++--
>   drivers/gpu/drm/nouveau/nv17_fence.c          |  2 +-
>   drivers/gpu/drm/nouveau/nv50_fence.c          |  2 +-
>   drivers/gpu/drm/qxl/qxl_drv.h                 |  2 +-
>   drivers/gpu/drm/qxl/qxl_ttm.c                 | 14 +++---
>   drivers/gpu/drm/radeon/radeon.h               |  2 +-
>   drivers/gpu/drm/radeon/radeon_object.c        |  2 +-
>   drivers/gpu/drm/radeon/radeon_object.h        |  2 +-
>   drivers/gpu/drm/radeon/radeon_ttm.c           | 28 +++++------
>   drivers/gpu/drm/radeon/radeon_vm.c            |  2 +-
>   drivers/gpu/drm/ttm/ttm_agp_backend.c         |  2 +-
>   drivers/gpu/drm/ttm/ttm_bo.c                  | 26 +++++------
>   drivers/gpu/drm/ttm/ttm_bo_util.c             | 46 +++++++++----------
>   drivers/gpu/drm/ttm/ttm_range_manager.c       |  4 +-
>   drivers/gpu/drm/ttm/ttm_tt.c                  |  2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_bo.c            |  4 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  4 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  4 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_resource.c      |  2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  6 +--
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c    |  8 ++--
>   include/drm/ttm/ttm_bo_api.h                  | 10 ++--
>   include/drm/ttm/ttm_bo_driver.h               | 42 ++++++++---------
>   include/drm/ttm/ttm_tt.h                      | 10 ++--
>   45 files changed, 202 insertions(+), 202 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 8b600b804f34..fb1415488579 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -171,7 +171,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
>    *
>    * Check if a mem object has already address space allocated.
>    */
> -bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
> +bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem)
>   {
>   	return mem->mm_node != NULL;
>   }
> @@ -189,7 +189,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
>   static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>   			      struct ttm_buffer_object *tbo,
>   			      const struct ttm_place *place,
> -			      struct ttm_mem_reg *mem)
> +			      struct ttm_resource *mem)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node;
> @@ -250,7 +250,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>    * Free the allocated GTT again.
>    */
>   static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
> -			       struct ttm_mem_reg *mem)
> +			       struct ttm_resource *mem)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
>   	struct amdgpu_gtt_node *node = mem->mm_node;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ce98df5b0c21..43f4966331dd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1268,11 +1268,11 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
>    */
>   void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
>   			   bool evict,
> -			   struct ttm_mem_reg *new_mem)
> +			   struct ttm_resource *new_mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
>   	struct amdgpu_bo *abo;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   
>   	if (!amdgpu_bo_is_amdgpu_bo(bo))
>   		return;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index e01e8903741e..5ddb6cf96030 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -283,7 +283,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
>   			   uint64_t *flags);
>   void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
>   			   bool evict,
> -			   struct ttm_mem_reg *new_mem);
> +			   struct ttm_resource *new_mem);
>   void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
>   int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
>   void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index cae7eada7215..682172d59f60 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -183,9 +183,9 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
>    * Assign the memory from new_mem to the memory of the buffer object bo.
>    */
>   static void amdgpu_move_null(struct ttm_buffer_object *bo,
> -			     struct ttm_mem_reg *new_mem)
> +			     struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   
>   	BUG_ON(old_mem->mm_node != NULL);
>   	*old_mem = *new_mem;
> @@ -202,7 +202,7 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo,
>    */
>   static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
>   				    struct drm_mm_node *mm_node,
> -				    struct ttm_mem_reg *mem)
> +				    struct ttm_resource *mem)
>   {
>   	uint64_t addr = 0;
>   
> @@ -222,7 +222,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
>    * @offset: The offset that drm_mm_node is used for finding.
>    *
>    */
> -static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
> +static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_resource *mem,
>   					       uint64_t *offset)
>   {
>   	struct drm_mm_node *mm_node = mem->mm_node;
> @@ -250,7 +250,7 @@ static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
>    * the physical address for local memory.
>    */
>   static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
> -				 struct ttm_mem_reg *mem,
> +				 struct ttm_resource *mem,
>   				 struct drm_mm_node *mm_node,
>   				 unsigned num_pages, uint64_t offset,
>   				 unsigned window, struct amdgpu_ring *ring,
> @@ -474,8 +474,8 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>    */
>   static int amdgpu_move_blit(struct ttm_buffer_object *bo,
>   			    bool evict, bool no_wait_gpu,
> -			    struct ttm_mem_reg *new_mem,
> -			    struct ttm_mem_reg *old_mem)
> +			    struct ttm_resource *new_mem,
> +			    struct ttm_resource *old_mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
>   	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
> @@ -534,10 +534,10 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
>    */
>   static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
>   				struct ttm_operation_ctx *ctx,
> -				struct ttm_mem_reg *new_mem)
> +				struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> -	struct ttm_mem_reg tmp_mem;
> +	struct ttm_resource *old_mem = &bo->mem;
> +	struct ttm_resource tmp_mem;
>   	struct ttm_place placements;
>   	struct ttm_placement placement;
>   	int r;
> @@ -590,10 +590,10 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
>    */
>   static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
>   				struct ttm_operation_ctx *ctx,
> -				struct ttm_mem_reg *new_mem)
> +				struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> -	struct ttm_mem_reg tmp_mem;
> +	struct ttm_resource *old_mem = &bo->mem;
> +	struct ttm_resource tmp_mem;
>   	struct ttm_placement placement;
>   	struct ttm_place placements;
>   	int r;
> @@ -636,7 +636,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
>    * Called by amdgpu_bo_move()
>    */
>   static bool amdgpu_mem_visible(struct amdgpu_device *adev,
> -			       struct ttm_mem_reg *mem)
> +			       struct ttm_resource *mem)
>   {
>   	struct drm_mm_node *nodes = mem->mm_node;
>   
> @@ -646,7 +646,7 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
>   	if (mem->mem_type != TTM_PL_VRAM)
>   		return false;
>   
> -	/* ttm_mem_reg_ioremap only supports contiguous memory */
> +	/* ttm_resource_ioremap only supports contiguous memory */
>   	if (nodes->size != mem->num_pages)
>   		return false;
>   
> @@ -661,11 +661,11 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
>    */
>   static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>   			  struct ttm_operation_ctx *ctx,
> -			  struct ttm_mem_reg *new_mem)
> +			  struct ttm_resource *new_mem)
>   {
>   	struct amdgpu_device *adev;
>   	struct amdgpu_bo *abo;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   	int r;
>   
>   	/* Can't move a pinned BO */
> @@ -747,7 +747,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>    *
>    * Called by ttm_mem_io_reserve() ultimately via ttm_bo_vm_fault()
>    */
> -static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> +static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
>   	struct drm_mm_node *mm_node = mem->mm_node;
> @@ -771,7 +771,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
>   			return -EINVAL;
>   		/* Only physically contiguous buffers apply. In a contiguous
>   		 * buffer, size of the first mm_node would match the number of
> -		 * pages in ttm_mem_reg.
> +		 * pages in ttm_resource.
>   		 */
>   		if (adev->mman.aper_base_kaddr &&
>   		    (mm_node->size == mem->num_pages))
> @@ -1116,7 +1116,7 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
>    * This handles binding GTT memory to the device address space.
>    */
>   static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
> -				   struct ttm_mem_reg *bo_mem)
> +				   struct ttm_resource *bo_mem)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
>   	struct amdgpu_ttm_tt *gtt = (void*)ttm;
> @@ -1167,7 +1167,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
>   	struct ttm_operation_ctx ctx = { false, false };
>   	struct amdgpu_ttm_tt *gtt = (void*)bo->ttm;
> -	struct ttm_mem_reg tmp;
> +	struct ttm_resource tmp;
>   	struct ttm_placement placement;
>   	struct ttm_place placements;
>   	uint64_t addr, flags;
> @@ -1507,7 +1507,7 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm)
>    *
>    * Figure out the flags to use for a VM PDE (Page Directory Entry).
>    */
> -uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
> +uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem)
>   {
>   	uint64_t flags = 0;
>   
> @@ -1533,7 +1533,7 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
>    * Figure out the flags to use for a VM PTE (Page Table Entry).
>    */
>   uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
> -				 struct ttm_mem_reg *mem)
> +				 struct ttm_resource *mem)
>   {
>   	uint64_t flags = amdgpu_ttm_tt_pde_flags(ttm, mem);
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> index 3db29ae1f802..36b024fd077e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> @@ -63,7 +63,7 @@ struct amdgpu_mman {
>   
>   struct amdgpu_copy_mem {
>   	struct ttm_buffer_object	*bo;
> -	struct ttm_mem_reg		*mem;
> +	struct ttm_resource		*mem;
>   	unsigned long			offset;
>   };
>   
> @@ -72,13 +72,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev);
>   int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
>   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
>   
> -bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
> +bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
>   uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
>   int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
>   
>   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
>   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> -			      struct ttm_mem_reg *mem,
> +			      struct ttm_resource *mem,
>   			      struct device *dev,
>   			      enum dma_data_direction dir,
>   			      struct sg_table **sgt);
> @@ -142,9 +142,9 @@ bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm,
>   				       int *last_invalidated);
>   bool amdgpu_ttm_tt_is_userptr(struct ttm_tt *ttm);
>   bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm);
> -uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem);
> +uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem);
>   uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
> -				 struct ttm_mem_reg *mem);
> +				 struct ttm_resource *mem);
>   
>   int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 71e005cf2952..8bc2253939be 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1765,7 +1765,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
>   	struct amdgpu_vm *vm = bo_va->base.vm;
>   	struct amdgpu_bo_va_mapping *mapping;
>   	dma_addr_t *pages_addr = NULL;
> -	struct ttm_mem_reg *mem;
> +	struct ttm_resource *mem;
>   	struct drm_mm_node *nodes;
>   	struct dma_fence **last_update;
>   	struct dma_resv *resv;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index b227e380094f..44f20b30420e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -272,7 +272,7 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,
>   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> -	struct ttm_mem_reg *mem = &bo->tbo.mem;
> +	struct ttm_resource *mem = &bo->tbo.mem;
>   	struct drm_mm_node *nodes = mem->mm_node;
>   	unsigned pages = mem->num_pages;
>   	u64 usage;
> @@ -292,13 +292,13 @@ u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
>   /**
>    * amdgpu_vram_mgr_virt_start - update virtual start address
>    *
> - * @mem: ttm_mem_reg to update
> + * @mem: ttm_resource to update
>    * @node: just allocated node
>    *
>    * Calculate a virtual BO start address to easily check if everything is CPU
>    * accessible.
>    */
> -static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
> +static void amdgpu_vram_mgr_virt_start(struct ttm_resource *mem,
>   				       struct drm_mm_node *node)
>   {
>   	unsigned long start;
> @@ -324,7 +324,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
>   static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>   			       struct ttm_buffer_object *tbo,
>   			       const struct ttm_place *place,
> -			       struct ttm_mem_reg *mem)
> +			       struct ttm_resource *mem)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	struct amdgpu_device *adev = mgr->adev;
> @@ -440,7 +440,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>    * Free the allocated VRAM again.
>    */
>   static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
> -				struct ttm_mem_reg *mem)
> +				struct ttm_resource *mem)
>   {
>   	struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
>   	struct amdgpu_device *adev = mgr->adev;
> @@ -480,7 +480,7 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
>    * Allocate and fill a sg table from a VRAM allocation.
>    */
>   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> -			      struct ttm_mem_reg *mem,
> +			      struct ttm_resource *mem,
>   			      struct device *dev,
>   			      enum dma_data_direction dir,
>   			      struct sg_table **sgt)
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index e3660d00987d..b410930d94a0 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -653,7 +653,7 @@ static void drm_gem_vram_bo_driver_evict_flags(struct drm_gem_vram_object *gbo,
>   
>   static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
>   					       bool evict,
> -					       struct ttm_mem_reg *new_mem)
> +					       struct ttm_resource *new_mem)
>   {
>   	struct ttm_bo_kmap_obj *kmap = &gbo->kmap;
>   
> @@ -1020,7 +1020,7 @@ static void bo_driver_evict_flags(struct ttm_buffer_object *bo,
>   
>   static void bo_driver_move_notify(struct ttm_buffer_object *bo,
>   				  bool evict,
> -				  struct ttm_mem_reg *new_mem)
> +				  struct ttm_resource *new_mem)
>   {
>   	struct drm_gem_vram_object *gbo;
>   
> @@ -1034,7 +1034,7 @@ static void bo_driver_move_notify(struct ttm_buffer_object *bo,
>   }
>   
>   static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
> -				    struct ttm_mem_reg *mem)
> +				    struct ttm_resource *mem)
>   {
>   	struct drm_vram_mm *vmm = drm_vram_mm_of_bdev(bdev);
>   
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index aebec45b8416..80d22a98950b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -666,7 +666,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
>   
>   static int
>   nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
> -		     struct ttm_mem_reg *reg)
> +		     struct ttm_resource *reg)
>   {
>   	struct nouveau_mem *old_mem = nouveau_mem(&bo->mem);
>   	struct nouveau_mem *new_mem = nouveau_mem(reg);
> @@ -698,7 +698,7 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
>   
>   static int
>   nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
> -		     bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> +		     bool no_wait_gpu, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
>   	struct nouveau_channel *chan = drm->ttm.chan;
> @@ -708,7 +708,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
>   
>   	/* create temporary vmas for the transfer and attach them to the
>   	 * old nvkm_mem node, these will get cleaned up after ttm has
> -	 * destroyed the ttm_mem_reg
> +	 * destroyed the ttm_resource
>   	 */
>   	if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
>   		ret = nouveau_bo_move_prep(drm, bo, new_reg);
> @@ -744,7 +744,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
>   		s32 oclass;
>   		int (*exec)(struct nouveau_channel *,
>   			    struct ttm_buffer_object *,
> -			    struct ttm_mem_reg *, struct ttm_mem_reg *);
> +			    struct ttm_resource *, struct ttm_resource *);
>   		int (*init)(struct nouveau_channel *, u32 handle);
>   	} _methods[] = {
>   		{  "COPY", 4, 0xc5b5, nve0_bo_move_copy, nve0_bo_move_init },
> @@ -805,7 +805,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
>   
>   static int
>   nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
> -		      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> +		      bool no_wait_gpu, struct ttm_resource *new_reg)
>   {
>   	struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
>   	struct ttm_place placement_memtype = {
> @@ -814,7 +814,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
>   		.flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
>   	};
>   	struct ttm_placement placement;
> -	struct ttm_mem_reg tmp_reg;
> +	struct ttm_resource tmp_reg;
>   	int ret;
>   
>   	placement.num_placement = placement.num_busy_placement = 1;
> @@ -842,7 +842,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
>   
>   static int
>   nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
> -		      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> +		      bool no_wait_gpu, struct ttm_resource *new_reg)
>   {
>   	struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
>   	struct ttm_place placement_memtype = {
> @@ -851,7 +851,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
>   		.flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
>   	};
>   	struct ttm_placement placement;
> -	struct ttm_mem_reg tmp_reg;
> +	struct ttm_resource tmp_reg;
>   	int ret;
>   
>   	placement.num_placement = placement.num_busy_placement = 1;
> @@ -878,7 +878,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
>   
>   static void
>   nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
> -		     struct ttm_mem_reg *new_reg)
> +		     struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = new_reg ? nouveau_mem(new_reg) : NULL;
>   	struct nouveau_bo *nvbo = nouveau_bo(bo);
> @@ -910,7 +910,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
>   }
>   
>   static int
> -nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_reg,
> +nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_resource *new_reg,
>   		   struct nouveau_drm_tile **new_tile)
>   {
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> @@ -946,11 +946,11 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
>   static int
>   nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
>   		struct ttm_operation_ctx *ctx,
> -		struct ttm_mem_reg *new_reg)
> +		struct ttm_resource *new_reg)
>   {
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
>   	struct nouveau_bo *nvbo = nouveau_bo(bo);
> -	struct ttm_mem_reg *old_reg = &bo->mem;
> +	struct ttm_resource *old_reg = &bo->mem;
>   	struct nouveau_drm_tile *new_tile = NULL;
>   	int ret = 0;
>   
> @@ -1019,7 +1019,7 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
>   }
>   
>   static int
> -nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
> +nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
>   {
>   	struct nouveau_drm *drm = nouveau_bdev(bdev);
>   	struct nvkm_device *device = nvxx_device(&drm->client.device);
> @@ -1099,7 +1099,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
>   }
>   
>   static void
> -nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
> +nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_resource *reg)
>   {
>   	struct nouveau_drm *drm = nouveau_bdev(bdev);
>   	struct nouveau_mem *mem = nouveau_mem(reg);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h
> index 52489ce7d029..aecb7481df0d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
> @@ -139,28 +139,28 @@ nouveau_bo_new_pin_map(struct nouveau_cli *cli, u64 size, int align, u32 flags,
>   
>   int nv04_bo_move_init(struct nouveau_channel *, u32);
>   int nv04_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nv50_bo_move_init(struct nouveau_channel *, u32);
>   int nv50_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nv84_bo_move_exec(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nva3_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nvc0_bo_move_init(struct nouveau_channel *, u32);
>   int nvc0_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nvc0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   int nve0_bo_move_init(struct nouveau_channel *, u32);
>   int nve0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> -		      struct ttm_mem_reg *, struct ttm_mem_reg *);
> +		      struct ttm_resource *, struct ttm_resource *);
>   
>   #define NVBO_WR32_(b,o,dr,f) nouveau_bo_wr32((b), (o)/4 + (dr), (f))
>   #define NVBO_RD32_(b,o,dr)   nouveau_bo_rd32((b), (o)/4 + (dr))
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> index bf7ae2cecaf6..7390132129fe 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> @@ -36,7 +36,7 @@
>   
>   static inline uint32_t
>   nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
> -		      struct nouveau_channel *chan, struct ttm_mem_reg *reg)
> +		      struct nouveau_channel *chan, struct ttm_resource *reg)
>   {
>   	if (reg->mem_type == TTM_PL_TT)
>   		return NvDmaTT;
> @@ -45,7 +45,7 @@ nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
>   
>   int
>   nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nvif_push *push = chan->chan.push;
>   	u32 src_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, old_reg);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> index f9b9b85abe44..4c75c7b3804c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> @@ -37,7 +37,7 @@
>   
>   int
>   nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
>   	struct nvif_push *push = chan->chan.push;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> index 1b5fd78ddcba..ed6c09d67840 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> @@ -34,7 +34,7 @@
>   
>   int
>   nv84_bo_move_exec(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
>   	struct nvif_push *push = chan->chan.push;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> index f0df172b029e..dec29b2d8bb2 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> @@ -38,7 +38,7 @@
>   
>   int
>   nva3_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
>   	struct nvif_push *push = chan->chan.push;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo9039.c b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> index 52fefb37064c..776b04976cdf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> @@ -36,7 +36,7 @@
>   
>   int
>   nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nvif_push *push = chan->chan.push;
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> index 34b79d561c7f..8499f58213e3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> @@ -31,7 +31,7 @@
>   
>   int
>   nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
>   	struct nvif_push *push = chan->chan.push;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> index 394e29012e50..575212472e7a 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> @@ -36,7 +36,7 @@
>   
>   int
>   nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> -		  struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> +		  struct ttm_resource *old_reg, struct ttm_resource *new_reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(old_reg);
>   	struct nvif_push *push = chan->chan.push;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
> index ae76a5865a5a..f63ac72aa556 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
> @@ -157,7 +157,7 @@ struct nouveau_drm {
>   		atomic_t validate_sequence;
>   		int (*move)(struct nouveau_channel *,
>   			    struct ttm_buffer_object *,
> -			    struct ttm_mem_reg *, struct ttm_mem_reg *);
> +			    struct ttm_resource *, struct ttm_resource *);
>   		struct nouveau_channel *chan;
>   		struct nvif_object copy;
>   		int mtrr;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
> index b1bb542d3115..269d8707acc3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_mem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
> @@ -92,7 +92,7 @@ nouveau_mem_fini(struct nouveau_mem *mem)
>   }
>   
>   int
> -nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
> +nouveau_mem_host(struct ttm_resource *reg, struct ttm_dma_tt *tt)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(reg);
>   	struct nouveau_cli *cli = mem->cli;
> @@ -130,7 +130,7 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
>   }
>   
>   int
> -nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
> +nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(reg);
>   	struct nouveau_cli *cli = mem->cli;
> @@ -173,7 +173,7 @@ nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
>   }
>   
>   void
> -nouveau_mem_del(struct ttm_mem_reg *reg)
> +nouveau_mem_del(struct ttm_resource *reg)
>   {
>   	struct nouveau_mem *mem = nouveau_mem(reg);
>   	nouveau_mem_fini(mem);
> @@ -183,7 +183,7 @@ nouveau_mem_del(struct ttm_mem_reg *reg)
>   
>   int
>   nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
> -		struct ttm_mem_reg *reg)
> +		struct ttm_resource *reg)
>   {
>   	struct nouveau_mem *mem;
>   
> diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.h b/drivers/gpu/drm/nouveau/nouveau_mem.h
> index f6d039e73812..3fe1cfed57a1 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_mem.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_mem.h
> @@ -7,7 +7,7 @@ struct ttm_dma_tt;
>   #include <nvif/vmm.h>
>   
>   static inline struct nouveau_mem *
> -nouveau_mem(struct ttm_mem_reg *reg)
> +nouveau_mem(struct ttm_resource *reg)
>   {
>   	return reg->mm_node;
>   }
> @@ -21,10 +21,10 @@ struct nouveau_mem {
>   };
>   
>   int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
> -		    struct ttm_mem_reg *);
> -void nouveau_mem_del(struct ttm_mem_reg *);
> -int nouveau_mem_vram(struct ttm_mem_reg *, bool contig, u8 page);
> -int nouveau_mem_host(struct ttm_mem_reg *, struct ttm_dma_tt *);
> +		    struct ttm_resource *);
> +void nouveau_mem_del(struct ttm_resource *);
> +int nouveau_mem_vram(struct ttm_resource *, bool contig, u8 page);
> +int nouveau_mem_host(struct ttm_resource *, struct ttm_dma_tt *);
>   void nouveau_mem_fini(struct nouveau_mem *);
>   int nouveau_mem_map(struct nouveau_mem *, struct nvif_vmm *, struct nvif_vma *);
>   #endif
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> index c3ccf661b7a6..eef75c53a197 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> @@ -26,7 +26,7 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm)
>   }
>   
>   static int
> -nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
> +nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
>   {
>   	struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
>   	struct nouveau_mem *mem = nouveau_mem(reg);
> @@ -60,7 +60,7 @@ static struct ttm_backend_func nv04_sgdma_backend = {
>   };
>   
>   static int
> -nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
> +nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
>   {
>   	struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
>   	struct nouveau_mem *mem = nouveau_mem(reg);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index d6ad0977dc7d..9e96b6ff24cf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -32,7 +32,7 @@
>   #include <core/tegra.h>
>   
>   static void
> -nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
> +nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_resource *reg)
>   {
>   	nouveau_mem_del(reg);
>   }
> @@ -41,7 +41,7 @@ static int
>   nouveau_vram_manager_new(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
> -			 struct ttm_mem_reg *reg)
> +			 struct ttm_resource *reg)
>   {
>   	struct nouveau_bo *nvbo = nouveau_bo(bo);
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> @@ -72,7 +72,7 @@ static int
>   nouveau_gart_manager_new(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
> -			 struct ttm_mem_reg *reg)
> +			 struct ttm_resource *reg)
>   {
>   	struct nouveau_bo *nvbo = nouveau_bo(bo);
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> @@ -95,7 +95,7 @@ static int
>   nv04_gart_manager_new(struct ttm_resource_manager *man,
>   		      struct ttm_buffer_object *bo,
>   		      const struct ttm_place *place,
> -		      struct ttm_mem_reg *reg)
> +		      struct ttm_resource *reg)
>   {
>   	struct nouveau_bo *nvbo = nouveau_bo(bo);
>   	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
> index cd1e87a528a4..6b697ee6bc0e 100644
> --- a/drivers/gpu/drm/nouveau/nv17_fence.c
> +++ b/drivers/gpu/drm/nouveau/nv17_fence.c
> @@ -78,7 +78,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
>   {
>   	struct nv10_fence_priv *priv = chan->drm->fence;
>   	struct nv10_fence_chan *fctx;
> -	struct ttm_mem_reg *reg = &priv->bo->bo.mem;
> +	struct ttm_resource *reg = &priv->bo->bo.mem;
>   	u32 start = reg->start * PAGE_SIZE;
>   	u32 limit = start + reg->size - 1;
>   	int ret = 0;
> diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
> index ebb740686b44..49b46f51073c 100644
> --- a/drivers/gpu/drm/nouveau/nv50_fence.c
> +++ b/drivers/gpu/drm/nouveau/nv50_fence.c
> @@ -37,7 +37,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
>   {
>   	struct nv10_fence_priv *priv = chan->drm->fence;
>   	struct nv10_fence_chan *fctx;
> -	struct ttm_mem_reg *reg = &priv->bo->bo.mem;
> +	struct ttm_resource *reg = &priv->bo->bo.mem;
>   	u32 start = reg->start * PAGE_SIZE;
>   	u32 limit = start + reg->size - 1;
>   	int ret;
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 9691449aefdb..aae90a9ee1db 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -350,7 +350,7 @@ int qxl_mode_dumb_mmap(struct drm_file *filp,
>   int qxl_ttm_init(struct qxl_device *qdev);
>   void qxl_ttm_fini(struct qxl_device *qdev);
>   int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
> -			   struct ttm_mem_reg *mem);
> +			   struct ttm_resource *mem);
>   
>   /* qxl image */
>   
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 1c06fe780815..dc31f3fea33c 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -71,7 +71,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
>   }
>   
>   int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
> -			   struct ttm_mem_reg *mem)
> +			   struct ttm_resource *mem)
>   {
>   	struct qxl_device *qdev = qxl_get_qdev(bdev);
>   
> @@ -111,7 +111,7 @@ struct qxl_ttm_tt {
>   };
>   
>   static int qxl_ttm_backend_bind(struct ttm_tt *ttm,
> -				struct ttm_mem_reg *bo_mem)
> +				struct ttm_resource *bo_mem)
>   {
>   	struct qxl_ttm_tt *gtt = (void *)ttm;
>   
> @@ -163,9 +163,9 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
>   }
>   
>   static void qxl_move_null(struct ttm_buffer_object *bo,
> -			     struct ttm_mem_reg *new_mem)
> +			     struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   
>   	BUG_ON(old_mem->mm_node != NULL);
>   	*old_mem = *new_mem;
> @@ -174,9 +174,9 @@ static void qxl_move_null(struct ttm_buffer_object *bo,
>   
>   static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
>   		       struct ttm_operation_ctx *ctx,
> -		       struct ttm_mem_reg *new_mem)
> +		       struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   	int ret;
>   
>   	ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
> @@ -192,7 +192,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
>   
>   static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
>   			       bool evict,
> -			       struct ttm_mem_reg *new_mem)
> +			       struct ttm_resource *new_mem)
>   {
>   	struct qxl_bo *qbo;
>   	struct qxl_device *qdev;
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index b7c3fb2bfb54..cc4f58d16589 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -2857,7 +2857,7 @@ int radeon_vm_clear_invalids(struct radeon_device *rdev,
>   			     struct radeon_vm *vm);
>   int radeon_vm_bo_update(struct radeon_device *rdev,
>   			struct radeon_bo_va *bo_va,
> -			struct ttm_mem_reg *mem);
> +			struct ttm_resource *mem);
>   void radeon_vm_bo_invalidate(struct radeon_device *rdev,
>   			     struct radeon_bo *bo);
>   struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index f3dee01250da..bb7582afd803 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -775,7 +775,7 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
>   
>   void radeon_bo_move_notify(struct ttm_buffer_object *bo,
>   			   bool evict,
> -			   struct ttm_mem_reg *new_mem)
> +			   struct ttm_resource *new_mem)
>   {
>   	struct radeon_bo *rbo;
>   
> diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
> index 60275b822f79..44b47241ee42 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.h
> +++ b/drivers/gpu/drm/radeon/radeon_object.h
> @@ -165,7 +165,7 @@ extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
>   				bool force_drop);
>   extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
>   				  bool evict,
> -				  struct ttm_mem_reg *new_mem);
> +				  struct ttm_resource *new_mem);
>   extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
>   extern int radeon_bo_get_surface_reg(struct radeon_bo *bo);
>   extern void radeon_bo_fence(struct radeon_bo *bo, struct radeon_fence *fence,
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 05b5f29f2b61..a068d6960c23 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -166,9 +166,9 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
>   }
>   
>   static void radeon_move_null(struct ttm_buffer_object *bo,
> -			     struct ttm_mem_reg *new_mem)
> +			     struct ttm_resource *new_mem)
>   {
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   
>   	BUG_ON(old_mem->mm_node != NULL);
>   	*old_mem = *new_mem;
> @@ -177,8 +177,8 @@ static void radeon_move_null(struct ttm_buffer_object *bo,
>   
>   static int radeon_move_blit(struct ttm_buffer_object *bo,
>   			bool evict, bool no_wait_gpu,
> -			struct ttm_mem_reg *new_mem,
> -			struct ttm_mem_reg *old_mem)
> +			struct ttm_resource *new_mem,
> +			struct ttm_resource *old_mem)
>   {
>   	struct radeon_device *rdev;
>   	uint64_t old_start, new_start;
> @@ -233,11 +233,11 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
>   static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
>   				bool evict, bool interruptible,
>   				bool no_wait_gpu,
> -				struct ttm_mem_reg *new_mem)
> +				struct ttm_resource *new_mem)
>   {
>   	struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> -	struct ttm_mem_reg tmp_mem;
> +	struct ttm_resource *old_mem = &bo->mem;
> +	struct ttm_resource tmp_mem;
>   	struct ttm_place placements;
>   	struct ttm_placement placement;
>   	int r;
> @@ -278,11 +278,11 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
>   static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
>   				bool evict, bool interruptible,
>   				bool no_wait_gpu,
> -				struct ttm_mem_reg *new_mem)
> +				struct ttm_resource *new_mem)
>   {
>   	struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> -	struct ttm_mem_reg tmp_mem;
> +	struct ttm_resource *old_mem = &bo->mem;
> +	struct ttm_resource tmp_mem;
>   	struct ttm_placement placement;
>   	struct ttm_place placements;
>   	int r;
> @@ -315,11 +315,11 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
>   
>   static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
>   			  struct ttm_operation_ctx *ctx,
> -			  struct ttm_mem_reg *new_mem)
> +			  struct ttm_resource *new_mem)
>   {
>   	struct radeon_device *rdev;
>   	struct radeon_bo *rbo;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   	int r;
>   
>   	r = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
> @@ -376,7 +376,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
>   	return 0;
>   }
>   
> -static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> +static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
>   {
>   	struct radeon_device *rdev = radeon_get_rdev(bdev);
>   
> @@ -544,7 +544,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
>   }
>   
>   static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
> -				   struct ttm_mem_reg *bo_mem)
> +				   struct ttm_resource *bo_mem)
>   {
>   	struct radeon_ttm_tt *gtt = (void*)ttm;
>   	uint32_t flags = RADEON_GART_PAGE_VALID | RADEON_GART_PAGE_READ |
> diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
> index f60fae0aed11..71e2c3785ab9 100644
> --- a/drivers/gpu/drm/radeon/radeon_vm.c
> +++ b/drivers/gpu/drm/radeon/radeon_vm.c
> @@ -911,7 +911,7 @@ static void radeon_vm_fence_pts(struct radeon_vm *vm,
>    */
>   int radeon_vm_bo_update(struct radeon_device *rdev,
>   			struct radeon_bo_va *bo_va,
> -			struct ttm_mem_reg *mem)
> +			struct ttm_resource *mem)
>   {
>   	struct radeon_vm *vm = bo_va->vm;
>   	struct radeon_ib ib;
> diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
> index 38f1351140e2..09fe80e215c5 100644
> --- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
> +++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
> @@ -48,7 +48,7 @@ struct ttm_agp_backend {
>   	struct agp_bridge_data *bridge;
>   };
>   
> -static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
> +static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
>   {
>   	struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
>   	struct page *dummy_read_page = ttm_bo_glob.dummy_read_page;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 48840a3cf4c4..1ea5de976ec3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -145,7 +145,7 @@ static inline uint32_t ttm_bo_type_flags(unsigned type)
>   }
>   
>   static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
> -				  struct ttm_mem_reg *mem)
> +				  struct ttm_resource *mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	struct ttm_resource_manager *man;
> @@ -268,7 +268,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
>   EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
>   
>   static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> -				  struct ttm_mem_reg *mem, bool evict,
> +				  struct ttm_resource *mem, bool evict,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> @@ -642,7 +642,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
>   			struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_reg evict_mem;
> +	struct ttm_resource evict_mem;
>   	struct ttm_placement placement;
>   	int ret = 0;
>   
> @@ -841,7 +841,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>   
>   static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   			  const struct ttm_place *place,
> -			  struct ttm_mem_reg *mem)
> +			  struct ttm_resource *mem)
>   {
>   	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
> @@ -852,7 +852,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
>   	return man->func->get_node(man, bo, place, mem);
>   }
>   
> -void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
> +void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem)
>   {
>   	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
>   
> @@ -870,7 +870,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
>    */
>   static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
>   				 struct ttm_resource_manager *man,
> -				 struct ttm_mem_reg *mem,
> +				 struct ttm_resource *mem,
>   				 bool no_wait_gpu)
>   {
>   	struct dma_fence *fence;
> @@ -907,7 +907,7 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
>    */
>   static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   				  const struct ttm_place *place,
> -				  struct ttm_mem_reg *mem,
> +				  struct ttm_resource *mem,
>   				  struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> @@ -988,7 +988,7 @@ static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
>    */
>   static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>   				const struct ttm_place *place,
> -				struct ttm_mem_reg *mem,
> +				struct ttm_resource *mem,
>   				struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> @@ -1036,7 +1036,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>    */
>   int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   			struct ttm_placement *placement,
> -			struct ttm_mem_reg *mem,
> +			struct ttm_resource *mem,
>   			struct ttm_operation_ctx *ctx)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> @@ -1114,7 +1114,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
>   			      struct ttm_operation_ctx *ctx)
>   {
>   	int ret = 0;
> -	struct ttm_mem_reg mem;
> +	struct ttm_resource mem;
>   
>   	dma_resv_assert_held(bo->base.resv);
>   
> @@ -1140,7 +1140,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
>   
>   static bool ttm_bo_places_compat(const struct ttm_place *places,
>   				 unsigned num_placement,
> -				 struct ttm_mem_reg *mem,
> +				 struct ttm_resource *mem,
>   				 uint32_t *new_flags)
>   {
>   	unsigned i;
> @@ -1163,7 +1163,7 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
>   }
>   
>   bool ttm_bo_mem_compat(struct ttm_placement *placement,
> -		       struct ttm_mem_reg *mem,
> +		       struct ttm_resource *mem,
>   		       uint32_t *new_flags)
>   {
>   	if (ttm_bo_places_compat(placement->placement, placement->num_placement,
> @@ -1732,7 +1732,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
>   	if (bo->mem.mem_type != TTM_PL_SYSTEM ||
>   	    bo->ttm->caching_state != tt_cached) {
>   		struct ttm_operation_ctx ctx = { false, false };
> -		struct ttm_mem_reg evict_mem;
> +		struct ttm_resource evict_mem;
>   
>   		evict_mem = bo->mem;
>   		evict_mem.mm_node = NULL;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 8ef0de8e36c5..496158acd5b9 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -52,10 +52,10 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
>   
>   int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
>   		   struct ttm_operation_ctx *ctx,
> -		    struct ttm_mem_reg *new_mem)
> +		    struct ttm_resource *new_mem)
>   {
>   	struct ttm_tt *ttm = bo->ttm;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   	int ret;
>   
>   	if (old_mem->mem_type != TTM_PL_SYSTEM) {
> @@ -127,7 +127,7 @@ static int ttm_mem_io_evict(struct ttm_resource_manager *man)
>   }
>   
>   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_reg *mem)
> +		       struct ttm_resource *mem)
>   {
>   	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
>   	int ret;
> @@ -149,7 +149,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
>   }
>   
>   void ttm_mem_io_free(struct ttm_bo_device *bdev,
> -		     struct ttm_mem_reg *mem)
> +		     struct ttm_resource *mem)
>   {
>   	if (--mem->bus.io_reserved_count)
>   		return;
> @@ -163,7 +163,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
>   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
>   {
>   	struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> -	struct ttm_mem_reg *mem = &bo->mem;
> +	struct ttm_resource *mem = &bo->mem;
>   	int ret;
>   
>   	if (mem->bus.io_reserved_vm)
> @@ -181,7 +181,7 @@ int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
>   
>   void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
>   {
> -	struct ttm_mem_reg *mem = &bo->mem;
> +	struct ttm_resource *mem = &bo->mem;
>   
>   	if (!mem->bus.io_reserved_vm)
>   		return;
> @@ -191,8 +191,8 @@ void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
>   	ttm_mem_io_free(bo->bdev, mem);
>   }
>   
> -static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
> -			       struct ttm_mem_reg *mem,
> +static int ttm_resource_ioremap(struct ttm_bo_device *bdev,
> +			       struct ttm_resource *mem,
>   			       void **virtual)
>   {
>   	struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> @@ -226,8 +226,8 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
>   	return 0;
>   }
>   
> -static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
> -				struct ttm_mem_reg *mem,
> +static void ttm_resource_iounmap(struct ttm_bo_device *bdev,
> +				struct ttm_resource *mem,
>   				void *virtual)
>   {
>   	struct ttm_resource_manager *man;
> @@ -300,13 +300,13 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
>   
>   int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   		       struct ttm_operation_ctx *ctx,
> -		       struct ttm_mem_reg *new_mem)
> +		       struct ttm_resource *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
>   	struct ttm_tt *ttm = bo->ttm;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> -	struct ttm_mem_reg old_copy = *old_mem;
> +	struct ttm_resource *old_mem = &bo->mem;
> +	struct ttm_resource old_copy = *old_mem;
>   	void *old_iomap;
>   	void *new_iomap;
>   	int ret;
> @@ -319,10 +319,10 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   	if (ret)
>   		return ret;
>   
> -	ret = ttm_mem_reg_ioremap(bdev, old_mem, &old_iomap);
> +	ret = ttm_resource_ioremap(bdev, old_mem, &old_iomap);
>   	if (ret)
>   		return ret;
> -	ret = ttm_mem_reg_ioremap(bdev, new_mem, &new_iomap);
> +	ret = ttm_resource_ioremap(bdev, new_mem, &new_iomap);
>   	if (ret)
>   		goto out;
>   
> @@ -390,9 +390,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   	}
>   
>   out1:
> -	ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
> +	ttm_resource_iounmap(bdev, old_mem, new_iomap);
>   out:
> -	ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
> +	ttm_resource_iounmap(bdev, &old_copy, old_iomap);
>   
>   	/*
>   	 * On error, keep the mm node!
> @@ -502,7 +502,7 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo,
>   			  unsigned long size,
>   			  struct ttm_bo_kmap_obj *map)
>   {
> -	struct ttm_mem_reg *mem = &bo->mem;
> +	struct ttm_resource *mem = &bo->mem;
>   
>   	if (bo->mem.bus.addr) {
>   		map->bo_kmap_type = ttm_bo_map_premapped;
> @@ -526,7 +526,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
>   			   unsigned long num_pages,
>   			   struct ttm_bo_kmap_obj *map)
>   {
> -	struct ttm_mem_reg *mem = &bo->mem;
> +	struct ttm_resource *mem = &bo->mem;
>   	struct ttm_operation_ctx ctx = {
>   		.interruptible = false,
>   		.no_wait_gpu = false
> @@ -631,11 +631,11 @@ EXPORT_SYMBOL(ttm_bo_kunmap);
>   int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
>   			      struct dma_fence *fence,
>   			      bool evict,
> -			      struct ttm_mem_reg *new_mem)
> +			      struct ttm_resource *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
>   	struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   	int ret;
>   	struct ttm_buffer_object *ghost_obj;
>   
> @@ -692,10 +692,10 @@ EXPORT_SYMBOL(ttm_bo_move_accel_cleanup);
>   
>   int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>   			 struct dma_fence *fence, bool evict,
> -			 struct ttm_mem_reg *new_mem)
> +			 struct ttm_resource *new_mem)
>   {
>   	struct ttm_bo_device *bdev = bo->bdev;
> -	struct ttm_mem_reg *old_mem = &bo->mem;
> +	struct ttm_resource *old_mem = &bo->mem;
>   
>   	struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
>   	struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index 22de9f209449..7442d811f867 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -57,7 +57,7 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_man
>   static int ttm_range_man_get_node(struct ttm_resource_manager *man,
>   				  struct ttm_buffer_object *bo,
>   				  const struct ttm_place *place,
> -				  struct ttm_mem_reg *mem)
> +				  struct ttm_resource *mem)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
>   	struct drm_mm *mm = &rman->mm;
> @@ -96,7 +96,7 @@ static int ttm_range_man_get_node(struct ttm_resource_manager *man,
>   }
>   
>   static void ttm_range_man_put_node(struct ttm_resource_manager *man,
> -				   struct ttm_mem_reg *mem)
> +				   struct ttm_resource *mem)
>   {
>   	struct ttm_range_manager *rman = to_range_manager(man);
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 9d1c7177384c..1ccf1ef050d6 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -316,7 +316,7 @@ void ttm_tt_unbind(struct ttm_tt *ttm)
>   	}
>   }
>   
> -int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
> +int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
>   		struct ttm_operation_ctx *ctx)
>   {
>   	int ret = 0;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> index 1e59c019affa..3229451d0706 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> @@ -1135,14 +1135,14 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
>    * vmw_bo_move_notify - TTM move_notify_callback
>    *
>    * @bo: The TTM buffer object about to move.
> - * @mem: The struct ttm_mem_reg indicating to what memory
> + * @mem: The struct ttm_resource indicating to what memory
>    *       region the move is taking place.
>    *
>    * Detaches cached maps and device bindings that require that the
>    * buffer doesn't move.
>    */
>   void vmw_bo_move_notify(struct ttm_buffer_object *bo,
> -			struct ttm_mem_reg *mem)
> +			struct ttm_resource *mem)
>   {
>   	struct vmw_buffer_object *vbo;
>   
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index aa763c6b1146..871ad738dadb 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -793,7 +793,7 @@ extern void vmw_resource_unreserve(struct vmw_resource *res,
>   				   struct vmw_buffer_object *new_backup,
>   				   unsigned long new_backup_offset);
>   extern void vmw_query_move_notify(struct ttm_buffer_object *bo,
> -				  struct ttm_mem_reg *mem);
> +				  struct ttm_resource *mem);
>   extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob);
>   extern void vmw_resource_evict_all(struct vmw_private *dev_priv);
>   extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo);
> @@ -878,7 +878,7 @@ extern void vmw_bo_fence_single(struct ttm_buffer_object *bo,
>   extern void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo);
>   extern void vmw_bo_unmap(struct vmw_buffer_object *vbo);
>   extern void vmw_bo_move_notify(struct ttm_buffer_object *bo,
> -			       struct ttm_mem_reg *mem);
> +			       struct ttm_resource *mem);
>   extern void vmw_bo_swap_notify(struct ttm_buffer_object *bo);
>   extern struct vmw_buffer_object *
>   vmw_user_bo_noref_lookup(struct ttm_object_file *tfile, u32 handle);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index c8fe6e9cf092..3fea7a6c7cfa 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -53,7 +53,7 @@ static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *ma
>   static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
>   				  struct ttm_buffer_object *bo,
>   				  const struct ttm_place *place,
> -				  struct ttm_mem_reg *mem)
> +				  struct ttm_resource *mem)
>   {
>   	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>   	int id;
> @@ -85,7 +85,7 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
>   }
>   
>   static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
> -				   struct ttm_mem_reg *mem)
> +				   struct ttm_resource *mem)
>   {
>   	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>   
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> index c8441030637a..c0f156078dda 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> @@ -855,7 +855,7 @@ int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob)
>    * states from the device.
>    */
>   void vmw_query_move_notify(struct ttm_buffer_object *bo,
> -			   struct ttm_mem_reg *mem)
> +			   struct ttm_resource *mem)
>   {
>   	struct vmw_buffer_object *dx_query_mob;
>   	struct ttm_bo_device *bdev = bo->bdev;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 6cac7b091205..f594e2e6ab7e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -29,7 +29,7 @@ static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
>   static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
>   				  unsigned long align_pages,
>   				  const struct ttm_place *place,
> -				  struct ttm_mem_reg *mem,
> +				  struct ttm_resource *mem,
>   				  unsigned long lpfn,
>   				  enum drm_mm_insert_mode mode)
>   {
> @@ -47,7 +47,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
>   static int vmw_thp_get_node(struct ttm_resource_manager *man,
>   			    struct ttm_buffer_object *bo,
>   			    const struct ttm_place *place,
> -			    struct ttm_mem_reg *mem)
> +			    struct ttm_resource *mem)
>   {
>   	struct vmw_thp_manager *rman = to_thp_manager(man);
>   	struct drm_mm *mm = &rman->mm;
> @@ -107,7 +107,7 @@ static int vmw_thp_get_node(struct ttm_resource_manager *man,
>   
>   
>   static void vmw_thp_put_node(struct ttm_resource_manager *man,
> -			     struct ttm_mem_reg *mem)
> +			     struct ttm_resource *mem)
>   {
>   	struct vmw_thp_manager *rman = to_thp_manager(man);
>   
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 3a141a08d4bd..7247347a9bca 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -539,7 +539,7 @@ const struct vmw_sg_table *vmw_bo_sg_table(struct ttm_buffer_object *bo)
>   }
>   
>   
> -static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
> +static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
>   {
>   	struct vmw_ttm_tt *vmw_be =
>   		container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm);
> @@ -711,7 +711,7 @@ static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp)
>   	return vmw_user_bo_verify_access(bo, tfile);
>   }
>   
> -static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> +static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
>   {
>   	struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev);
>   
> @@ -741,7 +741,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
>    * vmw_move_notify - TTM move_notify_callback
>    *
>    * @bo: The TTM buffer object about to move.
> - * @mem: The struct ttm_mem_reg indicating to what memory
> + * @mem: The struct ttm_resource indicating to what memory
>    *       region the move is taking place.
>    *
>    * Calls move_notify for all subsystems needing it.
> @@ -749,7 +749,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
>    */
>   static void vmw_move_notify(struct ttm_buffer_object *bo,
>   			    bool evict,
> -			    struct ttm_mem_reg *mem)
> +			    struct ttm_resource *mem)
>   {
>   	vmw_bo_move_notify(bo, mem);
>   	vmw_query_move_notify(bo, mem);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 15958dff11d2..247d4f803443 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -81,7 +81,7 @@ struct ttm_bus_placement {
>   
>   
>   /**
> - * struct ttm_mem_reg
> + * struct ttm_resource
>    *
>    * @mm_node: Memory manager node.
>    * @size: Requested size of memory region.
> @@ -94,7 +94,7 @@ struct ttm_bus_placement {
>    * buffer object.
>    */
>   
> -struct ttm_mem_reg {
> +struct ttm_resource {
>   	void *mm_node;
>   	unsigned long start;
>   	unsigned long size;
> @@ -187,7 +187,7 @@ struct ttm_buffer_object {
>   	 * Members protected by the bo::resv::reserved lock.
>   	 */
>   
> -	struct ttm_mem_reg mem;
> +	struct ttm_resource mem;
>   	struct file *persistent_swap_storage;
>   	struct ttm_tt *ttm;
>   	bool evicted;
> @@ -316,12 +316,12 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait);
>    * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo
>    *
>    * @placement:  Return immediately if buffer is busy.
> - * @mem:  The struct ttm_mem_reg indicating the region where the bo resides
> + * @mem:  The struct ttm_resource indicating the region where the bo resides
>    * @new_flags: Describes compatible placement found
>    *
>    * Returns true if the placement is compatible
>    */
> -bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_mem_reg *mem,
> +bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_resource *mem,
>   		       uint32_t *new_flags);
>   
>   /**
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index d1eff7de4fa3..576c91c85a6b 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -55,7 +55,7 @@ struct ttm_resource_manager_func {
>   	 * @bo: Pointer to the buffer object we're allocating space for.
>   	 * @placement: Placement details.
>   	 * @flags: Additional placement flags.
> -	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> +	 * @mem: Pointer to a struct ttm_resource to be filled in.
>   	 *
>   	 * This function should allocate space in the memory type managed
>   	 * by @man. Placement details if
> @@ -79,20 +79,20 @@ struct ttm_resource_manager_func {
>   	int  (*get_node)(struct ttm_resource_manager *man,
>   			 struct ttm_buffer_object *bo,
>   			 const struct ttm_place *place,
> -			 struct ttm_mem_reg *mem);
> +			 struct ttm_resource *mem);
>   
>   	/**
>   	 * struct ttm_resource_manager member put_node
>   	 *
>   	 * @man: Pointer to a memory type manager.
> -	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> +	 * @mem: Pointer to a struct ttm_resource to be filled in.
>   	 *
>   	 * This function frees memory type resources previously allocated
>   	 * and that are identified by @mem::mm_node and @mem::start. May not
>   	 * be called from within atomic context.
>   	 */
>   	void (*put_node)(struct ttm_resource_manager *man,
> -			 struct ttm_mem_reg *mem);
> +			 struct ttm_resource *mem);
>   
>   	/**
>   	 * struct ttm_resource_manager member debug
> @@ -251,7 +251,7 @@ struct ttm_bo_driver {
>   	 */
>   	int (*move)(struct ttm_buffer_object *bo, bool evict,
>   		    struct ttm_operation_ctx *ctx,
> -		    struct ttm_mem_reg *new_mem);
> +		    struct ttm_resource *new_mem);
>   
>   	/**
>   	 * struct ttm_bo_driver_member verify_access
> @@ -277,7 +277,7 @@ struct ttm_bo_driver {
>   	 */
>   	void (*move_notify)(struct ttm_buffer_object *bo,
>   			    bool evict,
> -			    struct ttm_mem_reg *new_mem);
> +			    struct ttm_resource *new_mem);
>   	/* notify the driver we are taking a fault on this BO
>   	 * and have reserved it */
>   	int (*fault_reserve_notify)(struct ttm_buffer_object *bo);
> @@ -294,9 +294,9 @@ struct ttm_bo_driver {
>   	 * are balanced.
>   	 */
>   	int (*io_mem_reserve)(struct ttm_bo_device *bdev,
> -			      struct ttm_mem_reg *mem);
> +			      struct ttm_resource *mem);
>   	void (*io_mem_free)(struct ttm_bo_device *bdev,
> -			    struct ttm_mem_reg *mem);
> +			    struct ttm_resource *mem);
>   
>   	/**
>   	 * Return the pfn for a given page_offset inside the BO.
> @@ -508,7 +508,7 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
>    * @bo: Pointer to a struct ttm_buffer_object. the data of which
>    * we want to allocate space for.
>    * @proposed_placement: Proposed new placement for the buffer object.
> - * @mem: A struct ttm_mem_reg.
> + * @mem: A struct ttm_resource.
>    * @interruptible: Sleep interruptible when sliping.
>    * @no_wait_gpu: Return immediately if the GPU is busy.
>    *
> @@ -523,10 +523,10 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
>    */
>   int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   		     struct ttm_placement *placement,
> -		     struct ttm_mem_reg *mem,
> +		     struct ttm_resource *mem,
>   		     struct ttm_operation_ctx *ctx);
>   
> -void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);
> +void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem);
>   
>   int ttm_bo_device_release(struct ttm_bo_device *bdev);
>   
> @@ -722,16 +722,16 @@ int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
>    */
>   
>   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> -		       struct ttm_mem_reg *mem);
> +		       struct ttm_resource *mem);
>   void ttm_mem_io_free(struct ttm_bo_device *bdev,
> -		     struct ttm_mem_reg *mem);
> +		     struct ttm_resource *mem);
>   /**
>    * ttm_bo_move_ttm
>    *
>    * @bo: A pointer to a struct ttm_buffer_object.
>    * @interruptible: Sleep interruptible if waiting.
>    * @no_wait_gpu: Return immediately if the GPU is busy.
> - * @new_mem: struct ttm_mem_reg indicating where to move.
> + * @new_mem: struct ttm_resource indicating where to move.
>    *
>    * Optimized move function for a buffer object with both old and
>    * new placement backed by a TTM. The function will, if successful,
> @@ -745,7 +745,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
>   
>   int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
>   		    struct ttm_operation_ctx *ctx,
> -		    struct ttm_mem_reg *new_mem);
> +		    struct ttm_resource *new_mem);
>   
>   /**
>    * ttm_bo_move_memcpy
> @@ -753,7 +753,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
>    * @bo: A pointer to a struct ttm_buffer_object.
>    * @interruptible: Sleep interruptible if waiting.
>    * @no_wait_gpu: Return immediately if the GPU is busy.
> - * @new_mem: struct ttm_mem_reg indicating where to move.
> + * @new_mem: struct ttm_resource indicating where to move.
>    *
>    * Fallback move function for a mappable buffer object in mappable memory.
>    * The function will, if successful,
> @@ -767,7 +767,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
>   
>   int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   		       struct ttm_operation_ctx *ctx,
> -		       struct ttm_mem_reg *new_mem);
> +		       struct ttm_resource *new_mem);
>   
>   /**
>    * ttm_bo_free_old_node
> @@ -784,7 +784,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
>    * @bo: A pointer to a struct ttm_buffer_object.
>    * @fence: A fence object that signals when moving is complete.
>    * @evict: This is an evict move. Don't return until the buffer is idle.
> - * @new_mem: struct ttm_mem_reg indicating where to move.
> + * @new_mem: struct ttm_resource indicating where to move.
>    *
>    * Accelerated move function to be called when an accelerated move
>    * has been scheduled. The function will create a new temporary buffer object
> @@ -795,7 +795,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
>    */
>   int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
>   			      struct dma_fence *fence, bool evict,
> -			      struct ttm_mem_reg *new_mem);
> +			      struct ttm_resource *new_mem);
>   
>   /**
>    * ttm_bo_pipeline_move.
> @@ -803,14 +803,14 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
>    * @bo: A pointer to a struct ttm_buffer_object.
>    * @fence: A fence object that signals when moving is complete.
>    * @evict: This is an evict move. Don't return until the buffer is idle.
> - * @new_mem: struct ttm_mem_reg indicating where to move.
> + * @new_mem: struct ttm_resource indicating where to move.
>    *
>    * Function for pipelining accelerated moves. Either free the memory
>    * immediately or hang it on a temporary buffer object.
>    */
>   int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>   			 struct dma_fence *fence, bool evict,
> -			 struct ttm_mem_reg *new_mem);
> +			 struct ttm_resource *new_mem);
>   
>   /**
>    * ttm_bo_pipeline_gutting.
> diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
> index 5e2393fe42c6..241cc40839ed 100644
> --- a/include/drm/ttm/ttm_tt.h
> +++ b/include/drm/ttm/ttm_tt.h
> @@ -30,7 +30,7 @@
>   #include <linux/types.h>
>   
>   struct ttm_tt;
> -struct ttm_mem_reg;
> +struct ttm_resource;
>   struct ttm_buffer_object;
>   struct ttm_operation_ctx;
>   
> @@ -53,14 +53,14 @@ struct ttm_backend_func {
>   	 * struct ttm_backend_func member bind
>   	 *
>   	 * @ttm: Pointer to a struct ttm_tt.
> -	 * @bo_mem: Pointer to a struct ttm_mem_reg describing the
> +	 * @bo_mem: Pointer to a struct ttm_resource describing the
>   	 * memory type and location for binding.
>   	 *
>   	 * Bind the backend pages into the aperture in the location
>   	 * indicated by @bo_mem. This function should be able to handle
>   	 * differences between aperture and system page sizes.
>   	 */
> -	int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
> +	int (*bind) (struct ttm_tt *ttm, struct ttm_resource *bo_mem);
>   
>   	/**
>   	 * struct ttm_backend_func member unbind
> @@ -179,11 +179,11 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
>    * ttm_ttm_bind:
>    *
>    * @ttm: The struct ttm_tt containing backing pages.
> - * @bo_mem: The struct ttm_mem_reg identifying the binding location.
> + * @bo_mem: The struct ttm_resource identifying the binding location.
>    *
>    * Bind the pages of @ttm to an aperture location identified by @bo_mem
>    */
> -int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
> +int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
>   		struct ttm_operation_ctx *ctx);
>   
>   /**

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 13/59] drm/ttm: split the mm manager init code (v2)
  2020-08-04 11:07   ` Christian König
@ 2020-08-04 13:08     ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-04 13:08 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Am 04.08.20 um 13:07 schrieb Christian König:
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
>> From: Dave Airlie <airlied@redhat.com>
>>
>> This will allow the driver to control the ordering here better.
>>
>> Eventually the old path will be removed.
>>
>> v2: add docs for new APIs.
>> rename new path to ttm_mem_type_manager_init/set_used(for now)
>>
>> Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>


BTW: I've just noticed that you (most likely) accidentally added a tab 
after every use of ttm_mem_type_manager_set_used() in the follow up patches.

Not sure where this is coming from, but it annoys checkpatch quite a bit :)

Christian.


>
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo.c    | 34 +++++++++++++++++++--------------
>>   include/drm/ttm/ttm_bo_api.h    | 15 +++++++++++++++
>>   include/drm/ttm/ttm_bo_driver.h | 15 +++++++++++++++
>>   3 files changed, 50 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 2ac70ec1f37d..300bcc10696a 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -1509,35 +1509,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device 
>> *bdev, unsigned mem_type)
>>   }
>>   EXPORT_SYMBOL(ttm_bo_evict_mm);
>>   -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
>> -            unsigned long p_size)
>> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>> +                   struct ttm_mem_type_manager *man,
>> +                   unsigned long p_size)
>>   {
>> -    int ret;
>> -    struct ttm_mem_type_manager *man;
>>       unsigned i;
>>   -    BUG_ON(type >= TTM_NUM_MEM_TYPES);
>> -    man = &bdev->man[type];
>>       BUG_ON(man->has_type);
>>       man->use_io_reserve_lru = false;
>>       mutex_init(&man->io_reserve_mutex);
>>       spin_lock_init(&man->move_lock);
>>       INIT_LIST_HEAD(&man->io_reserve_lru);
>>       man->bdev = bdev;
>> -
>> -    if (type != TTM_PL_SYSTEM) {
>> -        ret = (*man->func->init)(man, p_size);
>> -        if (ret)
>> -            return ret;
>> -    }
>> -    man->has_type = true;
>> -    man->use_type = true;
>>       man->size = p_size;
>>         for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
>>           INIT_LIST_HEAD(&man->lru[i]);
>>       man->move = NULL;
>> +}
>> +EXPORT_SYMBOL(ttm_mem_type_manager_init);
>>   +int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
>> +            unsigned long p_size)
>> +{
>> +    int ret;
>> +    struct ttm_mem_type_manager *man;
>> +
>> +    BUG_ON(type >= TTM_NUM_MEM_TYPES);
>> +    ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
>> +
>> +    if (type != TTM_PL_SYSTEM) {
>> +        ret = (*man->func->init)(man, p_size);
>> +        if (ret)
>> +            return ret;
>> +    }
>> +    ttm_mem_type_manager_set_used(man, true);
>>       return 0;
>>   }
>>   EXPORT_SYMBOL(ttm_bo_init_mm);
>> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
>> index a9e13b252820..89053e761a69 100644
>> --- a/include/drm/ttm/ttm_bo_api.h
>> +++ b/include/drm/ttm/ttm_bo_api.h
>> @@ -54,6 +54,8 @@ struct ttm_place;
>>     struct ttm_lru_bulk_move;
>>   +struct ttm_mem_type_manager;
>> +
>>   /**
>>    * struct ttm_bus_placement
>>    *
>> @@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev, 
>> unsigned long size,
>>             uint32_t page_alignment, bool interruptible,
>>             struct ttm_buffer_object **p_bo);
>>   +/**
>> + * ttm_mem_type_manager_init
>> + *
>> + * @bdev: Pointer to a ttm_bo_device struct.
>> + * @man: memory manager object to init
>> + * @p_size: size managed area in pages.
>> + *
>> + * Initialise core parts of a a manager object.
>> + */
>> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>> +                   struct ttm_mem_type_manager *man,
>> +                   unsigned long p_size);
>> +
>>   /**
>>    * ttm_bo_init_mm
>>    *
>> diff --git a/include/drm/ttm/ttm_bo_driver.h 
>> b/include/drm/ttm/ttm_bo_driver.h
>> index 73f5d9c766cc..6b49c0356343 100644
>> --- a/include/drm/ttm/ttm_bo_driver.h
>> +++ b/include/drm/ttm/ttm_bo_driver.h
>> @@ -678,6 +678,21 @@ static inline void ttm_bo_unreserve(struct 
>> ttm_buffer_object *bo)
>>       dma_resv_unlock(bo->base.resv);
>>   }
>>   +/**
>> + * ttm_mem_type_manager_set_used
>> + *
>> + * @man: A memory manager object.
>> + * @used: usage state to set.
>> + *
>> + * Set the manager in use flag. If disabled the manager is no longer
>> + * used for object placement.
>> + */
>> +static inline void ttm_mem_type_manager_set_used(struct 
>> ttm_mem_type_manager *man, bool used)
>> +{
>> +    man->has_type = true;
>> +    man->use_type = used;
>> +}
>> +
>>   /*
>>    * ttm_bo_util.c
>>    */
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2)
  2020-08-04  2:55 ` [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2) Dave Airlie
@ 2020-08-05  5:32   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:32 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Instead of rolling driver copies of them.
>
> v2: cleanup return handling (Ben)
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_bo.c | 38 ++--------------------------
>  1 file changed, 2 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 356c1aae327d..aebec45b8416 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1171,8 +1171,6 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
>         struct ttm_dma_tt *ttm_dma = (void *)ttm;
>         struct nouveau_drm *drm;
>         struct device *dev;
> -       unsigned i;
> -       int r;
>         bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
>
>         if (ttm->state != tt_unpopulated)
> @@ -1200,31 +1198,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
>                 return ttm_dma_populate((void *)ttm, dev, ctx);
>         }
>  #endif
> -
> -       r = ttm_pool_populate(ttm, ctx);
> -       if (r) {
> -               return r;
> -       }
> -
> -       for (i = 0; i < ttm->num_pages; i++) {
> -               dma_addr_t addr;
> -
> -               addr = dma_map_page(dev, ttm->pages[i], 0, PAGE_SIZE,
> -                                   DMA_BIDIRECTIONAL);
> -
> -               if (dma_mapping_error(dev, addr)) {
> -                       while (i--) {
> -                               dma_unmap_page(dev, ttm_dma->dma_address[i],
> -                                              PAGE_SIZE, DMA_BIDIRECTIONAL);
> -                               ttm_dma->dma_address[i] = 0;
> -                       }
> -                       ttm_pool_unpopulate(ttm);
> -                       return -EFAULT;
> -               }
> -
> -               ttm_dma->dma_address[i] = addr;
> -       }
> -       return 0;
> +       return ttm_populate_and_map_pages(dev, ttm_dma, ctx);
>  }
>
>  static void
> @@ -1233,7 +1207,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
>         struct ttm_dma_tt *ttm_dma = (void *)ttm;
>         struct nouveau_drm *drm;
>         struct device *dev;
> -       unsigned i;
>         bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
>
>         if (slave)
> @@ -1256,14 +1229,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
>         }
>  #endif
>
> -       for (i = 0; i < ttm->num_pages; i++) {
> -               if (ttm_dma->dma_address[i]) {
> -                       dma_unmap_page(dev, ttm_dma->dma_address[i], PAGE_SIZE,
> -                                      DMA_BIDIRECTIONAL);
> -               }
> -       }
> -
> -       ttm_pool_unpopulate(ttm);
> +       ttm_unmap_and_unpopulate_pages(dev, ttm_dma);
>  }
>
>  void
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail
  2020-08-04 10:34   ` Christian König
@ 2020-08-05  5:32     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:32 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 20:34, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > The pattern was repeated a few times, just make an inline for it.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    |  8 ++------
> >   drivers/gpu/drm/ttm/ttm_bo_vm.c |  4 +---
> >   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++---
> >   3 files changed, 11 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 721ff546bf47..2b49037231eb 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1103,9 +1103,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
> >
> >   error:
> >       if (bo->mem.mem_type == TTM_PL_SYSTEM && !list_empty(&bo->lru)) {
> > -             spin_lock(&ttm_bo_glob.lru_lock);
> > -             ttm_bo_move_to_lru_tail(bo, NULL);
> > -             spin_unlock(&ttm_bo_glob.lru_lock);
> > +             ttm_bo_move_to_lru_tail_unlocked(bo);
> >       }
> >
> >       return ret;
> > @@ -1320,9 +1318,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
> >               return ret;
> >       }
> >
> > -     spin_lock(&ttm_bo_glob.lru_lock);
> > -     ttm_bo_move_to_lru_tail(bo, NULL);
> > -     spin_unlock(&ttm_bo_glob.lru_lock);
> > +     ttm_bo_move_to_lru_tail_unlocked(bo);
> >
> >       return ret;
> >   }
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index d7a6537dd6ee..468a0eb9e632 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -308,9 +308,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
> >               }
> >
> >               if (bo->moving != moving) {
> > -                     spin_lock(&ttm_bo_glob.lru_lock);
> > -                     ttm_bo_move_to_lru_tail(bo, NULL);
> > -                     spin_unlock(&ttm_bo_glob.lru_lock);
> > +                     ttm_bo_move_to_lru_tail_unlocked(bo);
> >               }
> >               dma_fence_put(moving);
> >       }
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index c20fef4da1d3..7958e411269a 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -658,6 +658,13 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
> >       return 0;
> >   }
> >
> > +static inline void ttm_bo_move_to_lru_tail_unlocked(struct ttm_buffer_object *bo)
> > +{
> > +     spin_lock(&ttm_bo_glob.lru_lock);
> > +     ttm_bo_move_to_lru_tail(bo, NULL);
> > +     spin_unlock(&ttm_bo_glob.lru_lock);
> > +}
> > +
> >   /**
> >    * ttm_bo_unreserve
> >    *
> > @@ -667,9 +674,7 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
> >    */
> >   static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
> >   {
> > -     spin_lock(&ttm_bo_glob.lru_lock);
> > -     ttm_bo_move_to_lru_tail(bo, NULL);
> > -     spin_unlock(&ttm_bo_glob.lru_lock);
> > +     ttm_bo_move_to_lru_tail_unlocked(bo);
> >       dma_resv_unlock(bo->base.resv);
> >   }
> >
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 08/59] drm/ttm: export memory type debug entrypoint.
  2020-08-04 10:35   ` Christian König
@ 2020-08-05  5:34     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:34 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 20:35, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > As suggested on review, just export the memory type debug for
> > drivers to use, while also making the debug callback optional
> > (don't need to test for system as it won't init it).
> >
> > rename it to be more consistent with object name for now.
> > (we may rename all the objects later.)
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    | 13 +++++++------
> >   include/drm/ttm/ttm_bo_driver.h |  8 ++++++++
> >   2 files changed, 15 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 2b49037231eb..2ac70ec1f37d 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -77,26 +77,26 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
> >       return 0;
> >   }
> >
> > -static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p,
> > -                            int mem_type)
> > +void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> > +                             struct drm_printer *p)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->man[mem_type];
> > -
> >       drm_printf(p, "    has_type: %d\n", man->has_type);
> >       drm_printf(p, "    use_type: %d\n", man->use_type);
> >       drm_printf(p, "    use_tt: %d\n", man->use_tt);
> >       drm_printf(p, "    size: %llu\n", man->size);
> >       drm_printf(p, "    available_caching: 0x%08X\n", man->available_caching);
> >       drm_printf(p, "    default_caching: 0x%08X\n", man->default_caching);
> > -     if (mem_type != TTM_PL_SYSTEM)
> > +     if (man->func && man->func->debug)
> >               (*man->func->debug)(man, p);
> >   }
> > +EXPORT_SYMBOL(ttm_mem_type_manager_debug);
> >
> >   static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> >                                       struct ttm_placement *placement)
> >   {
> >       struct drm_printer p = drm_debug_printer(TTM_PFX);
> >       int i, ret, mem_type;
> > +     struct ttm_mem_type_manager *man;
> >
> >       drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
> >                  bo, bo->mem.num_pages, bo->mem.size >> 10,
> > @@ -108,7 +108,8 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> >                       return;
> >               drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
> >                          i, placement->placement[i].flags, mem_type);
> > -             ttm_mem_type_debug(bo->bdev, &p, mem_type);
> > +             man = &bo->bdev->man[mem_type];
> > +             ttm_mem_type_manager_debug(man, &p);
> >       }
> >   }
> >
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 7958e411269a..73f5d9c766cc 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -795,4 +795,12 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
> >
> >   extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> >
> > +/**
> > + * ttm_mem_type_manager_debug
> > + *
> > + * @man: manager type to dump.
> > + * @p: printer to use for debug.
> > + */
> > +void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> > +                             struct drm_printer *p);
> >   #endif
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback
  2020-08-04  2:55 ` [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback Dave Airlie
@ 2020-08-05  5:34   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:34 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Acked-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index b0012021ae12..6de762a0c229 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -49,12 +49,6 @@ nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
>         nouveau_mem_del(reg);
>  }
>
> -static void
> -nouveau_manager_debug(struct ttm_mem_type_manager *man,
> -                     struct drm_printer *printer)
> -{
> -}
> -
>  static int
>  nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
>                          struct ttm_buffer_object *bo,
> @@ -86,7 +80,6 @@ const struct ttm_mem_type_manager_func nouveau_vram_manager = {
>         .takedown = nouveau_manager_fini,
>         .get_node = nouveau_vram_manager_new,
>         .put_node = nouveau_manager_del,
> -       .debug = nouveau_manager_debug,
>  };
>
>  static int
> @@ -112,7 +105,6 @@ const struct ttm_mem_type_manager_func nouveau_gart_manager = {
>         .takedown = nouveau_manager_fini,
>         .get_node = nouveau_gart_manager_new,
>         .put_node = nouveau_manager_del,
> -       .debug = nouveau_manager_debug
>  };
>
>  static int
> @@ -147,7 +139,6 @@ const struct ttm_mem_type_manager_func nv04_gart_manager = {
>         .takedown = nouveau_manager_fini,
>         .get_node = nv04_gart_manager_new,
>         .put_node = nouveau_manager_del,
> -       .debug = nouveau_manager_debug
>  };
>
>  int
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 19/59] drm/nouveau: use new memory manager init paths
  2020-08-04  2:55 ` [PATCH 19/59] drm/nouveau: use new memory manager init paths Dave Airlie
@ 2020-08-05  5:40   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:40 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 43 ++++++++++++---------------
>  1 file changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 6de762a0c229..cfcbecd332ef 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -31,12 +31,6 @@
>
>  #include <core/tegra.h>
>
> -static int
> -nouveau_manager_init(struct ttm_mem_type_manager *man, unsigned long psize)
> -{
> -       return 0;
> -}
> -
>  static int
>  nouveau_manager_fini(struct ttm_mem_type_manager *man)
>  {
> @@ -76,7 +70,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nouveau_vram_manager = {
> -       .init = nouveau_manager_init,
>         .takedown = nouveau_manager_fini,
>         .get_node = nouveau_vram_manager_new,
>         .put_node = nouveau_manager_del,
> @@ -101,7 +94,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nouveau_gart_manager = {
> -       .init = nouveau_manager_init,
>         .takedown = nouveau_manager_fini,
>         .get_node = nouveau_gart_manager_new,
>         .put_node = nouveau_manager_del,
> @@ -135,7 +127,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nv04_gart_manager = {
> -       .init = nouveau_manager_init,
>         .takedown = nouveau_manager_fini,
>         .get_node = nv04_gart_manager_new,
>         .put_node = nouveau_manager_del,
> @@ -191,27 +182,21 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>
>                 man->func = &nouveau_vram_manager;
>                 man->use_io_reserve_lru = true;
> +               ttm_mem_type_manager_init(&drm->ttm.bdev, man,
> +                                         drm->gem.vram_available >> PAGE_SHIFT);
> +               ttm_mem_type_manager_set_used(man, true);
> +               return 0;
>         } else {
> -               man->func = &ttm_bo_manager_func;
> +               return ttm_range_man_init(&drm->ttm.bdev, man,
> +                                         drm->gem.vram_available >> PAGE_SHIFT);
>         }
> -
> -       return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
> -                             drm->gem.vram_available >> PAGE_SHIFT);
>  }
>
>  static int
>  nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  {
>         struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
> -
> -       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
> -               man->func = &nouveau_gart_manager;
> -       else
> -       if (!drm->agp.bridge)
> -               man->func = &nv04_gart_manager;
> -       else
> -               man->func = &ttm_bo_manager_func;
> -
> +       unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
>         man->use_tt = true;
>         if (drm->agp.bridge) {
>                 man->available_caching = TTM_PL_FLAG_UNCACHED |
> @@ -222,8 +207,18 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>                 man->default_caching = TTM_PL_FLAG_CACHED;
>         }
>
> -       return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_TT,
> -                             drm->gem.gart_available >> PAGE_SHIFT);
> +       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
> +               man->func = &nouveau_gart_manager;
> +       else if (!drm->agp.bridge)
> +               man->func = &nv04_gart_manager;
> +       else
> +               return ttm_range_man_init(&drm->ttm.bdev, man,
> +                                         size_pages);
> +
> +       ttm_mem_type_manager_init(&drm->ttm.bdev, man,
> +                                 size_pages);
> +       ttm_mem_type_manager_set_used(man, true);
> +       return 0;
>  }
>
>  int
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 22/59] drm/ttm: convert system manager init to new code.
  2020-08-04  2:55 ` [PATCH 22/59] drm/ttm: convert system manager init to new code Dave Airlie
@ 2020-08-05  5:40   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:40 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Remove the exit path, since this can't fail now.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++-------------
>  1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 300bcc10696a..c56cbc6c0ba8 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1650,6 +1650,22 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>  }
>  EXPORT_SYMBOL(ttm_bo_device_release);
>
> +static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> +{
> +       struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM];
> +
> +       /*
> +        * Initialize the system memory buffer type.
> +        * Other types need to be driver / IOCTL initialized.
> +        */
> +       man->use_tt = true;
> +       man->available_caching = TTM_PL_MASK_CACHING;
> +       man->default_caching = TTM_PL_FLAG_CACHED;
> +
> +       ttm_mem_type_manager_init(bdev, man, 0);
> +       ttm_mem_type_manager_set_used(man, true);
> +}
> +
>  int ttm_bo_device_init(struct ttm_bo_device *bdev,
>                        struct ttm_bo_driver *driver,
>                        struct address_space *mapping,
> @@ -1670,16 +1686,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>
>         memset(bdev->man, 0, sizeof(bdev->man));
>
> -       /*
> -        * Initialize the system memory buffer type.
> -        * Other types need to be driver / IOCTL initialized.
> -        */
> -       bdev->man[TTM_PL_SYSTEM].use_tt = true;
> -       bdev->man[TTM_PL_SYSTEM].available_caching = TTM_PL_MASK_CACHING;
> -       bdev->man[TTM_PL_SYSTEM].default_caching = TTM_PL_FLAG_CACHED;
> -       ret = ttm_bo_init_mm(bdev, TTM_PL_SYSTEM, 0);
> -       if (unlikely(ret != 0))
> -               goto out_no_sys;
> +       ttm_bo_init_sysman(bdev);
>
>         bdev->vma_manager = vma_manager;
>         INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
> @@ -1691,9 +1698,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>         mutex_unlock(&ttm_global_mutex);
>
>         return 0;
> -out_no_sys:
> -       ttm_bo_global_release();
> -       return ret;
>  }
>  EXPORT_SYMBOL(ttm_bo_device_init);
>
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 23/59] drm/ttm: purge old manager init path.
  2020-08-04  2:55 ` [PATCH 23/59] drm/ttm: purge old manager init path Dave Airlie
@ 2020-08-05  5:41   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:41 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo.c         | 19 ------------------
>  drivers/gpu/drm/ttm/ttm_bo_manager.c | 29 ++++++++++------------------
>  include/drm/ttm/ttm_bo_api.h         | 18 -----------------
>  include/drm/ttm/ttm_bo_driver.h      | 15 --------------
>  4 files changed, 10 insertions(+), 71 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index c56cbc6c0ba8..da88ea6cb814 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1529,25 +1529,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>  }
>  EXPORT_SYMBOL(ttm_mem_type_manager_init);
>
> -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> -                       unsigned long p_size)
> -{
> -       int ret;
> -       struct ttm_mem_type_manager *man;
> -
> -       BUG_ON(type >= TTM_NUM_MEM_TYPES);
> -       ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
> -
> -       if (type != TTM_PL_SYSTEM) {
> -               ret = (*man->func->init)(man, p_size);
> -               if (ret)
> -                       return ret;
> -       }
> -       ttm_mem_type_manager_set_used(man, true);
> -       return 0;
> -}
> -EXPORT_SYMBOL(ttm_bo_init_mm);
> -
>  static void ttm_bo_global_kobj_release(struct kobject *kobj)
>  {
>         struct ttm_bo_global *glob =
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index eb86c8694f47..b56c6961b278 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -104,11 +104,18 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
>         }
>  }
>
> -static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,
> -                                  unsigned long p_size)
> +static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> +
> +int ttm_range_man_init(struct ttm_bo_device *bdev,
> +                      struct ttm_mem_type_manager *man,
> +                      unsigned long p_size)
>  {
>         struct ttm_range_manager *rman;
>
> +       man->func = &ttm_bo_manager_func;
> +
> +       ttm_mem_type_manager_init(bdev, man, p_size);
> +
>         rman = kzalloc(sizeof(*rman), GFP_KERNEL);
>         if (!rman)
>                 return -ENOMEM;
> @@ -116,21 +123,7 @@ static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,
>         drm_mm_init(&rman->mm, 0, p_size);
>         spin_lock_init(&rman->lock);
>         man->priv = rman;
> -       return 0;
> -}
>
> -int ttm_range_man_init(struct ttm_bo_device *bdev,
> -                      struct ttm_mem_type_manager *man,
> -                      unsigned long p_size)
> -{
> -       int ret;
> -
> -       man->func = &ttm_bo_manager_func;
> -
> -       ttm_mem_type_manager_init(bdev, man, p_size);
> -       ret = ttm_bo_man_init_private(man, p_size);
> -       if (ret)
> -               return ret;
>         ttm_mem_type_manager_set_used(man, true);
>         return 0;
>  }
> @@ -163,11 +156,9 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>         spin_unlock(&rman->lock);
>  }
>
> -const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> -       .init = ttm_bo_man_init_private,
> +static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
>         .takedown = ttm_bo_man_takedown,
>         .get_node = ttm_bo_man_get_node,
>         .put_node = ttm_bo_man_put_node,
>         .debug = ttm_bo_man_debug
>  };
> -EXPORT_SYMBOL(ttm_bo_manager_func);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 89053e761a69..2c84622faa44 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -546,24 +546,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>                                struct ttm_mem_type_manager *man,
>                                unsigned long p_size);
>
> -/**
> - * ttm_bo_init_mm
> - *
> - * @bdev: Pointer to a ttm_bo_device struct.
> - * @mem_type: The memory type.
> - * @p_size: size managed area in pages.
> - *
> - * Initialize a manager for a given memory type.
> - * Note: if part of driver firstopen, it must be protected from a
> - * potentially racing lastclose.
> - * Returns:
> - * -EINVAL: invalid size or memory type.
> - * -ENOMEM: Not enough memory.
> - * May also return driver-specified errors.
> - */
> -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
> -                  unsigned long p_size);
> -
>  /**
>   * ttm_bo_clean_mm
>   *
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 3672dea3edca..548c27294c64 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -48,19 +48,6 @@
>  struct ttm_mem_type_manager;
>
>  struct ttm_mem_type_manager_func {
> -       /**
> -        * struct ttm_mem_type_manager member init
> -        *
> -        * @man: Pointer to a memory type manager.
> -        * @p_size: Implementation dependent, but typically the size of the
> -        * range to be managed in pages.
> -        *
> -        * Called to initialize a private range manager. The function is
> -        * expected to initialize the man::priv member.
> -        * Returns 0 on success, negative error code on failure.
> -        */
> -       int  (*init)(struct ttm_mem_type_manager *man, unsigned long p_size);
> -
>         /**
>          * struct ttm_mem_type_manager member takedown
>          *
> @@ -822,8 +809,6 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>                        struct ttm_mem_type_manager *man,
>                        unsigned long p_size);
>
> -extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> -
>  /**
>   * ttm_mem_type_manager_debug
>   *
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places
  2020-08-04  2:55 ` [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places Dave Airlie
@ 2020-08-05  5:42   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:42 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:57, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> This makes it easier to cleanup things
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index da88ea6cb814..af1b1c3f6ed2 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -769,13 +769,12 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
>  }
>
>  static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> -                              uint32_t mem_type,
> +                              struct ttm_mem_type_manager *man,
>                                const struct ttm_place *place,
>                                struct ttm_operation_ctx *ctx,
>                                struct ww_acquire_ctx *ticket)
>  {
>         struct ttm_buffer_object *bo = NULL, *busy_bo = NULL;
> -       struct ttm_mem_type_manager *man = &bdev->man[mem_type];
>         bool locked = false;
>         unsigned i;
>         int ret;
> @@ -924,7 +923,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>                         break;
>                 if (unlikely(ret != -ENOSPC))
>                         return ret;
> -               ret = ttm_mem_evict_first(bdev, mem->mem_type, place, ctx,
> +               ret = ttm_mem_evict_first(bdev, man, place, ctx,
>                                           ticket);
>                 if (unlikely(ret != 0))
>                         return ret;
> @@ -1409,14 +1408,13 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
>  EXPORT_SYMBOL(ttm_bo_create);
>
>  static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
> -                                  unsigned mem_type)
> +                                  struct ttm_mem_type_manager *man)
>  {
>         struct ttm_operation_ctx ctx = {
>                 .interruptible = false,
>                 .no_wait_gpu = false,
>                 .flags = TTM_OPT_FLAG_FORCE_ALLOC
>         };
> -       struct ttm_mem_type_manager *man = &bdev->man[mem_type];
>         struct ttm_bo_global *glob = &ttm_bo_glob;
>         struct dma_fence *fence;
>         int ret;
> @@ -1430,7 +1428,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
>         for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>                 while (!list_empty(&man->lru[i])) {
>                         spin_unlock(&glob->lru_lock);
> -                       ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx,
> +                       ret = ttm_mem_evict_first(bdev, man, NULL, &ctx,
>                                                   NULL);
>                         if (ret)
>                                 return ret;
> @@ -1475,7 +1473,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>
>         ret = 0;
>         if (mem_type > 0) {
> -               ret = ttm_bo_force_list_clean(bdev, mem_type);
> +               ret = ttm_bo_force_list_clean(bdev, man);
>                 if (ret) {
>                         pr_err("Cleanup eviction failed\n");
>                         return ret;
> @@ -1505,7 +1503,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>                 return 0;
>         }
>
> -       return ttm_bo_force_list_clean(bdev, mem_type);
> +       return ttm_bo_force_list_clean(bdev, man);
>  }
>  EXPORT_SYMBOL(ttm_bo_evict_mm);
>
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2)
  2020-08-04 11:18   ` Christian König
@ 2020-08-05  5:42     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:42 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:18, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > The disable path is just temporary for now, it will be dropped once has_type
> > is gone in a later patch.
> >
> > v2: add docs.
> > rename to ttm_mem_type_manager namespace
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
> >   include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
> >   2 files changed, 28 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index af1b1c3f6ed2..127a0b62bf98 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1468,8 +1468,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               return ret;
> >       }
> >
> > -     man->use_type = false;
> > -     man->has_type = false;
> > +     ttm_mem_type_manager_disable(man);
> >
> >       ret = 0;
> >       if (mem_type > 0) {
> > @@ -1482,8 +1481,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               ret = (*man->func->takedown)(man);
> >       }
> >
> > -     dma_fence_put(man->move);
> > -     man->move = NULL;
> > +     ttm_mem_type_manager_cleanup(man);
> >
> >       return ret;
> >   }
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 548c27294c64..41bfa514c29d 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -680,6 +680,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
> >       man->use_type = used;
> >   }
> >
> > +/**
> > + * ttm_mem_type_manager_disable.
> > + *
> > + * @man: A memory manager object.
> > + *
> > + * Indicate the manager is not to be used and deregistered. (temporary during rework).
> > + */
> > +static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> > +{
> > +     man->has_type = false;
> > +     man->use_type = false;
> > +}
> > +
> > +/**
> > + * ttm_mem_type_manager_cleanup
> > + *
> > + * @man: A memory manager object.
> > + *
> > + * Cleanup the move fences from the memory manager object.
> > + */
> > +static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> > +{
> > +     dma_fence_put(man->move);
> > +     man->move = NULL;
> > +}
> > +
> >   /*
> >    * ttm_bo_util.c
> >    */
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2)
  2020-08-04 11:20   ` Christian König
@ 2020-08-05  5:43     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:43 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:20, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > Allow the takedown path callback to be optional as well.
> >
> > v2: use fini for range manager
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c         | 12 +++++++-----
> >   drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++--
> >   include/drm/ttm/ttm_bo_driver.h      | 24 ++++++++++++++++++++++++
> >   3 files changed, 50 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 127a0b62bf98..a45038c74de6 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1407,8 +1407,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
> >   }
> >   EXPORT_SYMBOL(ttm_bo_create);
> >
> > -static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
> > -                                struct ttm_mem_type_manager *man)
> > +int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> > +                                       struct ttm_mem_type_manager *man)
> >   {
> >       struct ttm_operation_ctx ctx = {
> >               .interruptible = false,
> > @@ -1450,6 +1450,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
> >
> >       return 0;
> >   }
> > +EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
> >
> >   int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >   {
> > @@ -1472,13 +1473,14 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >
> >       ret = 0;
> >       if (mem_type > 0) {
> > -             ret = ttm_bo_force_list_clean(bdev, man);
> > +             ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> >               if (ret) {
> >                       pr_err("Cleanup eviction failed\n");
> >                       return ret;
> >               }
> >
> > -             ret = (*man->func->takedown)(man);
> > +             if (man->func->takedown)
> > +                     ret = (*man->func->takedown)(man);
> >       }
> >
> >       ttm_mem_type_manager_cleanup(man);
> > @@ -1501,7 +1503,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               return 0;
> >       }
> >
> > -     return ttm_bo_force_list_clean(bdev, man);
> > +     return ttm_mem_type_manager_force_list_clean(bdev, man);
> >   }
> >   EXPORT_SYMBOL(ttm_bo_evict_mm);
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > index b56c6961b278..96da22be672b 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > @@ -129,7 +129,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >   }
> >   EXPORT_SYMBOL(ttm_range_man_init);
> >
> > -static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
> > +static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
> >   {
> >       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> >       struct drm_mm *mm = &rman->mm;
> > @@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
> >       return -EBUSY;
> >   }
> >
> > +int ttm_range_man_fini(struct ttm_bo_device *bdev,
> > +                    struct ttm_mem_type_manager *man)
> > +{
> > +     int ret;
> > +
> > +     ttm_mem_type_manager_disable(man);
> > +
> > +     ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> > +     if (ret)
> > +             return ret;
> > +
> > +     ttm_bo_man_takedown_private(man);
> > +     ttm_mem_type_manager_cleanup(man);
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(ttm_range_man_fini);
> > +
> >   static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
> >                            struct drm_printer *printer)
> >   {
> > @@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
> >   }
> >
> >   static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> > -     .takedown = ttm_bo_man_takedown,
> > +     .takedown = ttm_bo_man_takedown_private,
> >       .get_node = ttm_bo_man_get_node,
> >       .put_node = ttm_bo_man_put_node,
> >       .debug = ttm_bo_man_debug
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 41bfa514c29d..9b4c22abc22c 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -706,6 +706,18 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
> >       man->move = NULL;
> >   }
> >
> > +/*
> > + * ttm_mem_type_manager_force_list_clean
> > + *
> > + * @bdev - device to use
> > + * @man - manager to use
> > + *
> > + * Force all the objects out of a memory manager until clean.
> > + * Part of memory manager cleanup sequence.
> > + */
> > +int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> > +                                       struct ttm_mem_type_manager *man);
> > +
> >   /*
> >    * ttm_bo_util.c
> >    */
> > @@ -835,6 +847,17 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >                      struct ttm_mem_type_manager *man,
> >                      unsigned long p_size);
> >
> > +/**
> > + * ttm_range_man_fini
> > + *
> > + * @bdev: ttm device
> > + * @type: memory manager type
> > + *
> > + * Remove the generic range manager from a slot and tear it down.
> > + */
> > +int ttm_range_man_fini(struct ttm_bo_device *bdev,
> > +                    struct ttm_mem_type_manager *man);
> > +
> >   /**
> >    * ttm_mem_type_manager_debug
> >    *
> > @@ -843,4 +866,5 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >    */
> >   void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> >                               struct drm_printer *p);
> > +
> >   #endif
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 30/59] drm/nouveau: use new cleanup paths
  2020-08-04  2:56 ` [PATCH 30/59] drm/nouveau: use new cleanup paths Dave Airlie
@ 2020-08-05  5:44   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:44 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++++-------
>  1 file changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index cfcbecd332ef..bb310719e3f5 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -31,12 +31,6 @@
>
>  #include <core/tegra.h>
>
> -static int
> -nouveau_manager_fini(struct ttm_mem_type_manager *man)
> -{
> -       return 0;
> -}
> -
>  static void
>  nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
>  {
> @@ -70,7 +64,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nouveau_vram_manager = {
> -       .takedown = nouveau_manager_fini,
>         .get_node = nouveau_vram_manager_new,
>         .put_node = nouveau_manager_del,
>  };
> @@ -94,7 +87,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nouveau_gart_manager = {
> -       .takedown = nouveau_manager_fini,
>         .get_node = nouveau_gart_manager_new,
>         .put_node = nouveau_manager_del,
>  };
> @@ -127,7 +119,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
>  }
>
>  const struct ttm_mem_type_manager_func nv04_gart_manager = {
> -       .takedown = nouveau_manager_fini,
>         .get_node = nv04_gart_manager_new,
>         .put_node = nouveau_manager_del,
>  };
> @@ -192,6 +183,19 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>         }
>  }
>
> +static void
> +nouveau_ttm_fini_vram(struct nouveau_drm *drm)
> +{
> +       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
> +
> +       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> +               ttm_mem_type_manager_disable(man);
> +               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> +               ttm_mem_type_manager_cleanup(man);
> +       } else
> +               ttm_range_man_fini(&drm->ttm.bdev, man);
> +}
> +
>  static int
>  nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  {
> @@ -221,6 +225,21 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>         return 0;
>  }
>
> +static void
> +nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
> +{
> +       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
> +
> +       if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
> +           drm->agp.bridge)
> +               ttm_range_man_fini(&drm->ttm.bdev, man);
> +       else {
> +               ttm_mem_type_manager_disable(man);
> +               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> +               ttm_mem_type_manager_cleanup(man);
> +       }
> +}
> +
>  int
>  nouveau_ttm_init(struct nouveau_drm *drm)
>  {
> @@ -310,8 +329,8 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
>  {
>         struct nvkm_device *device = nvxx_device(&drm->client.device);
>
> -       ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM);
> -       ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT);
> +       nouveau_ttm_fini_vram(drm);
> +       nouveau_ttm_fini_gtt(drm);
>
>         ttm_bo_device_release(&drm->ttm.bdev);
>
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 34/59] drm/ttm: remove range manager legacy takedown path
  2020-08-04  2:56 ` [PATCH 34/59] drm/ttm: remove range manager legacy takedown path Dave Airlie
@ 2020-08-05  5:45   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:45 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Now all drivers have been converted, drop the non-driver path.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo_manager.c | 28 +++++++++-------------------
>  1 file changed, 9 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index 96da22be672b..86bf5e71e959 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -129,26 +129,11 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>  }
>  EXPORT_SYMBOL(ttm_range_man_init);
>
> -static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man)
> -{
> -       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> -       struct drm_mm *mm = &rman->mm;
> -
> -       spin_lock(&rman->lock);
> -       if (drm_mm_clean(mm)) {
> -               drm_mm_takedown(mm);
> -               spin_unlock(&rman->lock);
> -               kfree(rman);
> -               man->priv = NULL;
> -               return 0;
> -       }
> -       spin_unlock(&rman->lock);
> -       return -EBUSY;
> -}
> -
>  int ttm_range_man_fini(struct ttm_bo_device *bdev,
>                        struct ttm_mem_type_manager *man)
>  {
> +       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> +       struct drm_mm *mm = &rman->mm;
>         int ret;
>
>         ttm_mem_type_manager_disable(man);
> @@ -157,7 +142,13 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>         if (ret)
>                 return ret;
>
> -       ttm_bo_man_takedown_private(man);
> +       spin_lock(&rman->lock);
> +       drm_mm_clean(mm);
> +       drm_mm_takedown(mm);
> +       spin_unlock(&rman->lock);
> +       kfree(rman);
> +       man->priv = NULL;
> +
>         ttm_mem_type_manager_cleanup(man);
>         return 0;
>  }
> @@ -174,7 +165,6 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>  }
>
>  static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> -       .takedown = ttm_bo_man_takedown_private,
>         .get_node = ttm_bo_man_get_node,
>         .put_node = ttm_bo_man_put_node,
>         .debug = ttm_bo_man_debug
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only.
  2020-08-04  2:56 ` [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only Dave Airlie
@ 2020-08-05  5:46   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:46 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Drivers should all be cleaning up their memory managers
> themselves now, so let the core just clean the system one up.
>
> Remove the legacy cleaning interface.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo.c    | 54 +++------------------------------
>  include/drm/ttm/ttm_bo_api.h    | 28 -----------------
>  include/drm/ttm/ttm_bo_driver.h | 10 ------
>  3 files changed, 4 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index a45038c74de6..ebecb796dd49 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1452,42 +1452,6 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
>  }
>  EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
>
> -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> -{
> -       struct ttm_mem_type_manager *man;
> -       int ret = -EINVAL;
> -
> -       if (mem_type >= TTM_NUM_MEM_TYPES) {
> -               pr_err("Illegal memory type %d\n", mem_type);
> -               return ret;
> -       }
> -       man = &bdev->man[mem_type];
> -
> -       if (!man->has_type) {
> -               pr_err("Trying to take down uninitialized memory manager type %u\n",
> -                      mem_type);
> -               return ret;
> -       }
> -
> -       ttm_mem_type_manager_disable(man);
> -
> -       ret = 0;
> -       if (mem_type > 0) {
> -               ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> -               if (ret) {
> -                       pr_err("Cleanup eviction failed\n");
> -                       return ret;
> -               }
> -
> -               if (man->func->takedown)
> -                       ret = (*man->func->takedown)(man);
> -       }
> -
> -       ttm_mem_type_manager_cleanup(man);
> -
> -       return ret;
> -}
> -EXPORT_SYMBOL(ttm_bo_clean_mm);
>
>  int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>  {
> @@ -1591,21 +1555,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>  {
>         struct ttm_bo_global *glob = &ttm_bo_glob;
>         int ret = 0;
> -       unsigned i = TTM_NUM_MEM_TYPES;
> +       unsigned i;
>         struct ttm_mem_type_manager *man;
>
> -       while (i--) {
> -               man = &bdev->man[i];
> -               if (man->has_type) {
> -                       man->use_type = false;
> -                       if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) {
> -                               ret = -EBUSY;
> -                               pr_err("DRM memory manager type %d is not clean\n",
> -                                      i);
> -                       }
> -                       man->has_type = false;
> -               }
> -       }
> +       man = &bdev->man[TTM_PL_SYSTEM];
> +       ttm_mem_type_manager_disable(man);
>
>         mutex_lock(&ttm_global_mutex);
>         list_del(&bdev->device_list);
> @@ -1618,7 +1572,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
>
>         spin_lock(&glob->lru_lock);
>         for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
> -               if (list_empty(&bdev->man[0].lru[0]))
> +               if (list_empty(&man->lru[0]))
>                         pr_debug("Swap list %d was clean\n", i);
>         spin_unlock(&glob->lru_lock);
>
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 2c84622faa44..9c55eafd0e7d 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -546,34 +546,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>                                struct ttm_mem_type_manager *man,
>                                unsigned long p_size);
>
> -/**
> - * ttm_bo_clean_mm
> - *
> - * @bdev: Pointer to a ttm_bo_device struct.
> - * @mem_type: The memory type.
> - *
> - * Take down a manager for a given memory type after first walking
> - * the LRU list to evict any buffers left alive.
> - *
> - * Normally, this function is part of lastclose() or unload(), and at that
> - * point there shouldn't be any buffers left created by user-space, since
> - * there should've been removed by the file descriptor release() method.
> - * However, before this function is run, make sure to signal all sync objects,
> - * and verify that the delayed delete queue is empty. The driver must also
> - * make sure that there are no NO_EVICT buffers present in this memory type
> - * when the call is made.
> - *
> - * If this function is part of a VT switch, the caller must make sure that
> - * there are no appications currently validating buffers before this
> - * function is called. The caller can do that by first taking the
> - * struct ttm_bo_device::ttm_lock in write mode.
> - *
> - * Returns:
> - * -EINVAL: invalid or uninitialized memory type.
> - * -EBUSY: There are still buffers left in this memory type.
> - */
> -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
> -
>  /**
>   * ttm_bo_evict_mm
>   *
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 9b4c22abc22c..8cc39cd55a14 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -48,16 +48,6 @@
>  struct ttm_mem_type_manager;
>
>  struct ttm_mem_type_manager_func {
> -       /**
> -        * struct ttm_mem_type_manager member takedown
> -        *
> -        * @man: Pointer to a memory type manager.
> -        *
> -        * Called to undo the setup done in init. All allocated resources
> -        * should be freed.
> -        */
> -       int  (*takedown)(struct ttm_mem_type_manager *man);
> -
>         /**
>          * struct ttm_mem_type_manager member get_node
>          *
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev.
  2020-08-04 11:25   ` Christian König
@ 2020-08-05  5:47     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:47 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:25, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This will allow different abstractions later.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c      | 34 +++++++++++++++----------------
> >   drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++---------
> >   drivers/gpu/drm/ttm/ttm_bo_vm.c   |  2 +-
> >   include/drm/ttm/ttm_bo_driver.h   |  6 ++++++
> >   4 files changed, 34 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index ebecb796dd49..8777c323e7de 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> >                       return;
> >               drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
> >                          i, placement->placement[i].flags, mem_type);
> > -             man = &bo->bdev->man[mem_type];
> > +             man = ttm_manager_type(bo->bdev, mem_type);
> >               ttm_mem_type_manager_debug(man, &p);
> >       }
> >   }
> > @@ -157,7 +157,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
> >       if (mem->placement & TTM_PL_FLAG_NO_EVICT)
> >               return;
> >
> > -     man = &bdev->man[mem->mem_type];
> > +     man = ttm_manager_type(bdev, mem->mem_type);
> >       list_add_tail(&bo->lru, &man->lru[bo->priority]);
> >
> >       if (man->use_tt && bo->ttm &&
> > @@ -232,7 +232,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
> >               dma_resv_assert_held(pos->first->base.resv);
> >               dma_resv_assert_held(pos->last->base.resv);
> >
> > -             man = &pos->first->bdev->man[TTM_PL_TT];
> > +             man = ttm_manager_type(pos->first->bdev, TTM_PL_TT);
> >               list_bulk_move_tail(&man->lru[i], &pos->first->lru,
> >                                   &pos->last->lru);
> >       }
> > @@ -247,7 +247,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
> >               dma_resv_assert_held(pos->first->base.resv);
> >               dma_resv_assert_held(pos->last->base.resv);
> >
> > -             man = &pos->first->bdev->man[TTM_PL_VRAM];
> > +             man = ttm_manager_type(pos->first->bdev, TTM_PL_VRAM);
> >               list_bulk_move_tail(&man->lru[i], &pos->first->lru,
> >                                   &pos->last->lru);
> >       }
> > @@ -273,8 +273,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type];
> > -     struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> > +     struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >
> >       ret = ttm_mem_io_lock(old_man, true);
> > @@ -340,7 +340,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> >       return 0;
> >
> >   out_err:
> > -     new_man = &bdev->man[bo->mem.mem_type];
> > +     new_man = ttm_manager_type(bdev, bo->mem.mem_type);
> >       if (!new_man->use_tt) {
> >               ttm_tt_destroy(bo->ttm);
> >               bo->ttm = NULL;
> > @@ -552,7 +552,7 @@ static void ttm_bo_release(struct kref *kref)
> >       struct ttm_buffer_object *bo =
> >           container_of(kref, struct ttm_buffer_object, kref);
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> >       size_t acc_size = bo->acc_size;
> >       int ret;
> >
> > @@ -844,7 +844,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >                         const struct ttm_place *place,
> >                         struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> >       mem->mm_node = NULL;
> >       if (!man->func || !man->func->get_node)
> > @@ -855,7 +855,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >
> >   void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> >       if (!man->func || !man->func->put_node)
> >               return;
> > @@ -912,7 +912,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       struct ww_acquire_ctx *ticket;
> >       int ret;
> >
> > @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >       if (ret)
> >               return ret;
> >
> > -     man = &bdev->man[mem_type];
> > +     man = ttm_manager_type(bdev, mem_type);
> >       if (!man->has_type || !man->use_type)
> >               return -EBUSY;
> >
> > @@ -1065,7 +1065,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
> >               if (unlikely(ret))
> >                       goto error;
> >
> > -             man = &bdev->man[mem->mem_type];
> > +             man = ttm_manager_type(bdev, mem->mem_type);
> >               ret = ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
> >               if (unlikely(ret)) {
> >                       ttm_bo_mem_put(bo, mem);
> > @@ -1455,7 +1455,7 @@ EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
> >
> >   int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->man[mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
> >
> >       if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
> >               pr_err("Illegal memory manager memory type %u\n", mem_type);
> > @@ -1558,7 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> >       unsigned i;
> >       struct ttm_mem_type_manager *man;
> >
> > -     man = &bdev->man[TTM_PL_SYSTEM];
> > +     man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> >       ttm_mem_type_manager_disable(man);
> >
> >       mutex_lock(&ttm_global_mutex);
> > @@ -1585,7 +1585,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
> >
> >   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> >
> >       /*
> >        * Initialize the system memory buffer type.
> > @@ -1649,7 +1649,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
> >   void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> >
> >       ttm_mem_io_lock(man, false);
> >       ttm_bo_unmap_virtual_locked(bo);
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > index 1f502be0b646..879c8ded0cd8 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > @@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
> >   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> >                      struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >
> >       if (mem->bus.io_reserved_count++)
> > @@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
> >
> >   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
> >   {
> > -     struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >       struct ttm_mem_reg *mem = &bo->mem;
> >       int ret;
> >
> > @@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
> >                              struct ttm_mem_reg *mem,
> >                              void **virtual)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >       void *addr;
> >
> > @@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
> >   {
> >       struct ttm_mem_type_manager *man;
> >
> > -     man = &bdev->man[mem->mem_type];
> > +     man = ttm_manager_type(bdev, mem->mem_type);
> >
> >       if (virtual && mem->bus.addr == NULL)
> >               iounmap(virtual);
> > @@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >                      struct ttm_mem_reg *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> >       struct ttm_tt *ttm = bo->ttm;
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >       struct ttm_mem_reg old_copy = *old_mem;
> > @@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
> >               struct ttm_bo_kmap_obj *map)
> >   {
> >       struct ttm_mem_type_manager *man =
> > -             &bo->bdev->man[bo->mem.mem_type];
> > +             ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >       unsigned long offset, size;
> >       int ret;
> >
> > @@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
> >   {
> >       struct ttm_buffer_object *bo = map->bo;
> >       struct ttm_mem_type_manager *man =
> > -             &bo->bdev->man[bo->mem.mem_type];
> > +             ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >
> >       if (!map->virtual)
> >               return;
> > @@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
> >                             struct ttm_mem_reg *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >       int ret;
> >       struct ttm_buffer_object *ghost_obj;
> > @@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >
> > -     struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type];
> > -     struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type];
> > +     struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> > +     struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> >
> >       int ret;
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index 468a0eb9e632..5ae679184eb5 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
> >       vm_fault_t ret = VM_FAULT_NOPAGE;
> >       unsigned long address = vmf->address;
> >       struct ttm_mem_type_manager *man =
> > -             &bdev->man[bo->mem.mem_type];
> > +             ttm_manager_type(bdev, bo->mem.mem_type);
> >
> >       /*
> >        * Refuse to fault imported pages. This should be handled
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 8cc39cd55a14..e80deee3ae99 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -444,6 +444,12 @@ struct ttm_bo_device {
> >       bool no_retry;
> >   };
> >
> > +static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> > +                                                         int mem_type)
> > +{
> > +     return &bdev->man[mem_type];
> > +}
> > +
> >   /**
> >    * struct ttm_lru_bulk_move_pos
> >    *
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 39/59] drm/nouveau/ttm: use wrapper to access memory managers
  2020-08-04  2:56 ` [PATCH 39/59] drm/nouveau/ttm: " Dave Airlie
@ 2020-08-05  5:48   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:48 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index bb310719e3f5..cc6cf04553dd 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -156,7 +156,7 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
>  static int
>  nouveau_ttm_init_vram(struct nouveau_drm *drm)
>  {
> -       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
> +       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
>         struct nvif_mmu *mmu = &drm->client.mmu;
>
>         man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> @@ -186,7 +186,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>  static void
>  nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>  {
> -       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM];
> +       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
>
>         if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
>                 ttm_mem_type_manager_disable(man);
> @@ -199,7 +199,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>  static int
>  nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  {
> -       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
> +       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
>         unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
>         man->use_tt = true;
>         if (drm->agp.bridge) {
> @@ -228,7 +228,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  static void
>  nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
>  {
> -       struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT];
> +       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
>
>         if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
>             drm->agp.bridge)
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used.
  2020-08-04 11:29   ` Christian König
@ 2020-08-05  5:49     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:49 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:30, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > Other users of this should notice this change and switch to wrapper.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    | 2 +-
> >   include/drm/ttm/ttm_bo_driver.h | 7 +++++--
> >   2 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 8777c323e7de..3a3a4dfb0fff 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1617,7 +1617,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
> >
> >       bdev->driver = driver;
> >
> > -     memset(bdev->man, 0, sizeof(bdev->man));
> > +     memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
> >
> >       ttm_bo_init_sysman(bdev);
> >
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index e80deee3ae99..03b253d14e6a 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -415,7 +415,10 @@ struct ttm_bo_device {
> >        */
> >       struct list_head device_list;
> >       struct ttm_bo_driver *driver;
> > -     struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> > +     /*
> > +      * access via ttm_manager_type.
> > +      */
> > +     struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> >
> >       /*
> >        * Protected by internal locks.
> > @@ -447,7 +450,7 @@ struct ttm_bo_device {
> >   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> >                                                           int mem_type)
> >   {
> > -     return &bdev->man[mem_type];
> > +     return &bdev->man_priv[mem_type];
> >   }
> >
> >   /**
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses
  2020-08-04 11:30   ` Christian König
@ 2020-08-05  5:49     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:49 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:30, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This will get removed eventually and all drivers will use this.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
> >   1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 03b253d14e6a..6940d85a531a 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -419,7 +419,7 @@ struct ttm_bo_device {
> >        * access via ttm_manager_type.
> >        */
> >       struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> > -
> > +     struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
> >       /*
> >        * Protected by internal locks.
> >        */
> > @@ -450,9 +450,18 @@ struct ttm_bo_device {
> >   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> >                                                           int mem_type)
> >   {
> > +     if (bdev->man_drv[mem_type])
> > +             return bdev->man_drv[mem_type];
> >       return &bdev->man_priv[mem_type];
> >   }
> >
> > +static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
> > +                                       int type,
> > +                                       struct ttm_mem_type_manager *manager)
> > +{
> > +     bdev->man_drv[type] = manager;
> > +}
> > +
> >   /**
> >    * struct ttm_lru_bulk_move_pos
> >    *
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args
  2020-08-04 11:35   ` Christian König
@ 2020-08-05  5:51     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:51 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:35, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This makes it easier to move these to a driver allocated system
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++-------
> >   drivers/gpu/drm/drm_gem_vram_helper.c   | 10 ++++----
> >   drivers/gpu/drm/nouveau/nouveau_ttm.c   | 22 +++++++++++-------
> >   drivers/gpu/drm/qxl/qxl_ttm.c           | 13 ++++-------
> >   drivers/gpu/drm/radeon/radeon_ttm.c     | 31 ++++++++++++-------------
> >   drivers/gpu/drm/ttm/ttm_bo_manager.c    | 19 +++++++++++----
> >   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c     | 13 ++++-------
> >   include/drm/ttm/ttm_bo_driver.h         | 12 +++++++---
> >   8 files changed, 70 insertions(+), 65 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index 1bd860877f1e..b190d50dc9bb 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
> >                                   unsigned int type,
> >                                   uint64_t size)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type);
> > -
> > -     man->available_caching = TTM_PL_FLAG_UNCACHED;
> > -     man->default_caching = TTM_PL_FLAG_UNCACHED;
> > -
> > -     return ttm_range_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT);
> > +     return ttm_range_man_init(&adev->mman.bdev, type,
> > +                               TTM_PL_FLAG_UNCACHED, TTM_PL_FLAG_UNCACHED,
> > +                               false, size >> PAGE_SHIFT);
> >   }
> >
> >   /**
> > @@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
> >
> >       amdgpu_vram_mgr_fini(adev);
> >       amdgpu_gtt_mgr_fini(adev);
> > -     ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS));
> > -     ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS));
> > -     ttm_range_man_fini(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA));
> > +     ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GDS);
> > +     ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_GWS);
> > +     ttm_range_man_fini(&adev->mman.bdev, AMDGPU_PL_OA);
> >       ttm_bo_device_release(&adev->mman.bdev);
> >       adev->mman.initialized = false;
> >       DRM_INFO("amdgpu: ttm finalized\n");
> > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> > index a01768adb96d..2187787f397e 100644
> > --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> > @@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
> >   static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
> >                           uint64_t vram_base, size_t vram_size)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
> >       int ret;
> >
> >       vmm->vram_base = vram_base;
> > @@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
> >       if (ret)
> >               return ret;
> >
> > -     man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> > -     man->default_caching = TTM_PL_FLAG_WC;
> > -     ret = ttm_range_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT);
> > +     ret = ttm_range_man_init(&vmm->bdev, TTM_PL_VRAM,
> > +                              TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> > +                              TTM_PL_FLAG_WC, false,
> > +                              vram_size >> PAGE_SHIFT);
> >       if (ret)
> >               return ret;
> >
> > @@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
> >
> >   static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
> >   {
> > -     ttm_range_man_fini(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM));
> > +     ttm_range_man_fini(&vmm->bdev, TTM_PL_VRAM);
> >       ttm_bo_device_release(&vmm->bdev);
> >   }
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > index cc6cf04553dd..1c636723823c 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > @@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
> >   static int
> >   nouveau_ttm_init_vram(struct nouveau_drm *drm)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> >       struct nvif_mmu *mmu = &drm->client.mmu;
> >
> > -     man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> > -     man->default_caching = TTM_PL_FLAG_WC;
> > -
> >       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> > +             struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> > +
> >               /* Some BARs do not support being ioremapped WC */
> >               const u8 type = mmu->type[drm->ttm.type_vram].type;
> >
> > +             man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> > +             man->default_caching = TTM_PL_FLAG_WC;
> > +
> >               if (type & NVIF_MEM_UNCACHED) {
> >                       man->available_caching = TTM_PL_FLAG_UNCACHED;
> >                       man->default_caching = TTM_PL_FLAG_UNCACHED;
> > @@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> >               ttm_mem_type_manager_set_used(man, true);
> >               return 0;
> >       } else {
> > -             return ttm_range_man_init(&drm->ttm.bdev, man,
> > +             return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
> > +                                       TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> > +                                       TTM_PL_FLAG_WC, false,
> >                                         drm->gem.vram_available >> PAGE_SHIFT);
> >       }
> >   }
> > @@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
> >               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> >               ttm_mem_type_manager_cleanup(man);
> >       } else
> > -             ttm_range_man_fini(&drm->ttm.bdev, man);
> > +             ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
> >   }
> >
> >   static int
> > @@ -216,9 +219,10 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> >       else if (!drm->agp.bridge)
> >               man->func = &nv04_gart_manager;
> >       else
> > -             return ttm_range_man_init(&drm->ttm.bdev, man,
> > +             return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
> > +                                       TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> > +                                       TTM_PL_FLAG_WC, true,
> >                                         size_pages);
> > -
> >       ttm_mem_type_manager_init(&drm->ttm.bdev, man,
> >                                 size_pages);
> >       ttm_mem_type_manager_set_used(man, true);
> > @@ -232,7 +236,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
> >
> >       if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
> >           drm->agp.bridge)
> > -             ttm_range_man_fini(&drm->ttm.bdev, man);
> > +             ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
> >       else {
> >               ttm_mem_type_manager_disable(man);
> >               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> > diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> > index 57c96f7271db..b7365b2e4c7f 100644
> > --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> > +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> > @@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
> >                                unsigned int type,
> >                                uint64_t size)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type);
> > -
> > -     man->available_caching = TTM_PL_MASK_CACHING;
> > -     man->default_caching = TTM_PL_FLAG_CACHED;
> > -
> > -     return ttm_range_man_init(&qdev->mman.bdev, man, size);
> > +     return ttm_range_man_init(&qdev->mman.bdev, type, TTM_PL_MASK_CACHING,
> > +                               TTM_PL_FLAG_CACHED, false, size);
> >   }
> >
> >   int qxl_ttm_init(struct qxl_device *qdev)
> > @@ -266,9 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev)
> >
> >   void qxl_ttm_fini(struct qxl_device *qdev)
> >   {
> > -
> > -     ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM));
> > -     ttm_range_man_fini(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV));
> > +     ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_VRAM);
> > +     ttm_range_man_fini(&qdev->mman.bdev, TTM_PL_PRIV);
> >       ttm_bo_device_release(&qdev->mman.bdev);
> >       DRM_INFO("qxl: ttm finalized\n");
> >   }
> > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> > index 03c0a24e74c4..474d2161da1e 100644
> > --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> > @@ -68,35 +68,34 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
> >
> >   static int radeon_ttm_init_vram(struct radeon_device *rdev)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
> > -
> > -     man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> > -     man->default_caching = TTM_PL_FLAG_WC;
> > -
> > -     return ttm_range_man_init(&rdev->mman.bdev, man,
> > +     return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_VRAM,
> > +                               TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> > +                               TTM_PL_FLAG_WC, false,
> >                                 rdev->mc.real_vram_size >> PAGE_SHIFT);
> >   }
> >
> >   static int radeon_ttm_init_gtt(struct radeon_device *rdev)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT);
> > +     uint32_t available_caching, default_caching;
> > +
> > +     available_caching = TTM_PL_MASK_CACHING;
> > +     default_caching = TTM_PL_FLAG_CACHED;
> >
> > -     man->available_caching = TTM_PL_MASK_CACHING;
> > -     man->default_caching = TTM_PL_FLAG_CACHED;
> > -     man->use_tt = true;
> >   #if IS_ENABLED(CONFIG_AGP)
> >       if (rdev->flags & RADEON_IS_AGP) {
> >               if (!rdev->ddev->agp) {
> >                       DRM_ERROR("AGP is not enabled\n");
> >                       return -EINVAL;
> >               }
> > -             man->available_caching = TTM_PL_FLAG_UNCACHED |
> > -                                      TTM_PL_FLAG_WC;
> > -             man->default_caching = TTM_PL_FLAG_WC;
> > +             available_caching = TTM_PL_FLAG_UNCACHED |
> > +                     TTM_PL_FLAG_WC;
> > +             default_caching = TTM_PL_FLAG_WC;
> >       }
> >   #endif
> >
> > -     return ttm_range_man_init(&rdev->mman.bdev, man,
> > +     return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_TT,
> > +                               available_caching,
> > +                               default_caching, true,
> >                                 rdev->mc.gtt_size >> PAGE_SHIFT);
> >   }
> >
> > @@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
> >               }
> >               radeon_bo_unref(&rdev->stolen_vga_memory);
> >       }
> > -     ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM));
> > -     ttm_range_man_fini(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT));
> > +     ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_VRAM);
> > +     ttm_range_man_fini(&rdev->mman.bdev, TTM_PL_TT);
> >       ttm_bo_device_release(&rdev->mman.bdev);
> >       radeon_gart_fini(rdev);
> >       rdev->mman.initialized = false;
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > index 86bf5e71e959..d83cb967a107 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > @@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
> >   static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> >
> >   int ttm_range_man_init(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_type_manager *man,
> > +                    unsigned type,
> > +                    uint32_t available_caching,
> > +                    uint32_t default_caching,
> > +                    bool use_tt,
> >                      unsigned long p_size)
> >   {
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> >       struct ttm_range_manager *rman;
> >
> > -     man->func = &ttm_bo_manager_func;
> > -
> > -     ttm_mem_type_manager_init(bdev, man, p_size);
> > +     man->available_caching = available_caching;
> > +     man->default_caching = default_caching;
> > +     man->use_tt = use_tt;
> >
> >       rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> >       if (!rman)
> >               return -ENOMEM;
> >
> > +     man->func = &ttm_bo_manager_func;
> > +
> > +     ttm_mem_type_manager_init(bdev, man, p_size);
> > +
> >       drm_mm_init(&rman->mm, 0, p_size);
> >       spin_lock_init(&rman->lock);
> >       man->priv = rman;
> > @@ -130,8 +138,9 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >   EXPORT_SYMBOL(ttm_range_man_init);
> >
> >   int ttm_range_man_fini(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_type_manager *man)
> > +                    unsigned type)
> >   {
> > +     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> >       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> >       struct drm_mm *mm = &rman->mm;
> >       int ret;
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > index 6ed92f38b54b..7168403fb4f8 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -626,13 +626,9 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
> >   #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >       ret = vmw_thp_init(dev_priv);
> >   #else
> > -     struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
> > -
> > -     man->available_caching = TTM_PL_FLAG_CACHED;
> > -     man->default_caching = TTM_PL_FLAG_CACHED;
> > -
> > -     ret = ttm_range_man_init(&dev_priv->bdev, man,
> > -                              dev_priv->vram_size >> PAGE_SHIFT);
> > +     ret = ttm_range_man_init(&dev_priv->bdev, TTM_PL_VRAM,
> > +                              TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
> > +                              false, dev_priv->vram_size >> PAGE_SHIFT);
> >   #endif
> >       ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
> >       return ret;
> > @@ -643,8 +639,7 @@ static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
> >   #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >       vmw_thp_fini(dev_priv);
> >   #else
> > -     ttm_bo_man_fini(&dev_priv->bdev,
> > -                     ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM));
> > +     ttm_bo_man_fini(&dev_priv->bdev, TTM_PL_VRAM);
> >   #endif
> >   }
> >
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 6940d85a531a..789c1eb26859 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -845,14 +845,20 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
> >    * ttm_range_man_init
> >    *
> >    * @bdev: ttm device
> > - * @man: the manager to initialise with the range manager.
> > + * @type: memory manager type
> > + * @available_caching: TTM_PL_FLAG_* for allowed caching modes
> > + * @default_caching: default caching mode
> > + * @use_tt: if the memory manager uses tt
> >    * @p_size: size of area to be managed in pages.
> >    *
> >    * Initialise a generic range manager for the selected memory type.
> >    * The range manager is installed for this device in the type slot.
> >    */
> >   int ttm_range_man_init(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_type_manager *man,
> > +                    unsigned type,
> > +                    uint32_t available_caching,
> > +                    uint32_t default_caching,
> > +                    bool use_tt,
> >                      unsigned long p_size);
> >
> >   /**
> > @@ -864,7 +870,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >    * Remove the generic range manager from a slot and tear it down.
> >    */
> >   int ttm_range_man_fini(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_type_manager *man);
> > +                    unsigned type);
> >
> >   /**
> >    * ttm_mem_type_manager_debug
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation
  2020-08-04  2:56 ` [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation Dave Airlie
@ 2020-08-05  5:52   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:52 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo_manager.c | 31 +++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index d83cb967a107..01d41c6f2f7b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -44,16 +44,22 @@
>   */
>
>  struct ttm_range_manager {
> +       struct ttm_mem_type_manager manager;
>         struct drm_mm mm;
>         spinlock_t lock;
>  };
>
> +static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man)
> +{
> +       return container_of(man, struct ttm_range_manager, manager);
> +}
> +
>  static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
>                                struct ttm_buffer_object *bo,
>                                const struct ttm_place *place,
>                                struct ttm_mem_reg *mem)
>  {
> -       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> +       struct ttm_range_manager *rman = to_range_manager(man);
>         struct drm_mm *mm = &rman->mm;
>         struct drm_mm_node *node;
>         enum drm_mm_insert_mode mode;
> @@ -92,7 +98,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
>  static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
>                                 struct ttm_mem_reg *mem)
>  {
> -       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> +       struct ttm_range_manager *rman = to_range_manager(man);
>
>         if (mem->mm_node) {
>                 spin_lock(&rman->lock);
> @@ -113,25 +119,26 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>                        bool use_tt,
>                        unsigned long p_size)
>  {
> -       struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> +       struct ttm_mem_type_manager *man;
>         struct ttm_range_manager *rman;
>
> -       man->available_caching = available_caching;
> -       man->default_caching = default_caching;
> -       man->use_tt = use_tt;
> -
>         rman = kzalloc(sizeof(*rman), GFP_KERNEL);
>         if (!rman)
>                 return -ENOMEM;
>
> +       man = &rman->manager;
> +       man->available_caching = available_caching;
> +       man->default_caching = default_caching;
> +       man->use_tt = use_tt;
> +
>         man->func = &ttm_bo_manager_func;
>
>         ttm_mem_type_manager_init(bdev, man, p_size);
>
>         drm_mm_init(&rman->mm, 0, p_size);
>         spin_lock_init(&rman->lock);
> -       man->priv = rman;
>
> +       ttm_set_driver_manager(bdev, type, &rman->manager);
>         ttm_mem_type_manager_set_used(man, true);
>         return 0;
>  }
> @@ -141,7 +148,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>                        unsigned type)
>  {
>         struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> -       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> +       struct ttm_range_manager *rman = to_range_manager(man);
>         struct drm_mm *mm = &rman->mm;
>         int ret;
>
> @@ -155,10 +162,10 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
>         drm_mm_clean(mm);
>         drm_mm_takedown(mm);
>         spin_unlock(&rman->lock);
> -       kfree(rman);
> -       man->priv = NULL;
>
>         ttm_mem_type_manager_cleanup(man);
> +       ttm_set_driver_manager(bdev, type, NULL);
> +       kfree(rman);
>         return 0;
>  }
>  EXPORT_SYMBOL(ttm_range_man_fini);
> @@ -166,7 +173,7 @@ EXPORT_SYMBOL(ttm_range_man_fini);
>  static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
>                              struct drm_printer *printer)
>  {
> -       struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
> +       struct ttm_range_manager *rman = to_range_manager(man);
>
>         spin_lock(&rman->lock);
>         drm_mm_print(&rman->mm, printer);
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager
  2020-08-04  2:56 ` [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager Dave Airlie
@ 2020-08-05  5:53   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:53 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c | 45 +++++++++++++++++++--------
>  1 file changed, 32 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 1c636723823c..58d9bd708e95 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -157,12 +157,12 @@ static int
>  nouveau_ttm_init_vram(struct nouveau_drm *drm)
>  {
>         struct nvif_mmu *mmu = &drm->client.mmu;
> -
>         if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> -               struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> -
>                 /* Some BARs do not support being ioremapped WC */
>                 const u8 type = mmu->type[drm->ttm.type_vram].type;
> +               struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> +               if (!man)
> +                       return -ENOMEM;
>
>                 man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>                 man->default_caching = TTM_PL_FLAG_WC;
> @@ -174,8 +174,10 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>
>                 man->func = &nouveau_vram_manager;
>                 man->use_io_reserve_lru = true;
> +
>                 ttm_mem_type_manager_init(&drm->ttm.bdev, man,
>                                           drm->gem.vram_available >> PAGE_SHIFT);
> +               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
>                 ttm_mem_type_manager_set_used(man, true);
>                 return 0;
>         } else {
> @@ -195,6 +197,8 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>                 ttm_mem_type_manager_disable(man);
>                 ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
>                 ttm_mem_type_manager_cleanup(man);
> +               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
> +               kfree(man);
>         } else
>                 ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
>  }
> @@ -202,30 +206,43 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
>  static int
>  nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  {
> -       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
> +       struct ttm_mem_type_manager *man;
>         unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
> -       man->use_tt = true;
> +       unsigned available_caching, default_caching;
> +       const struct ttm_mem_type_manager_func *func = NULL;
>         if (drm->agp.bridge) {
> -               man->available_caching = TTM_PL_FLAG_UNCACHED |
> +               available_caching = TTM_PL_FLAG_UNCACHED |
>                         TTM_PL_FLAG_WC;
> -               man->default_caching = TTM_PL_FLAG_WC;
> +               default_caching = TTM_PL_FLAG_WC;
>         } else {
> -               man->available_caching = TTM_PL_MASK_CACHING;
> -               man->default_caching = TTM_PL_FLAG_CACHED;
> +               available_caching = TTM_PL_MASK_CACHING;
> +               default_caching = TTM_PL_FLAG_CACHED;
>         }
>
>         if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
> -               man->func = &nouveau_gart_manager;
> +               func = &nouveau_gart_manager;
>         else if (!drm->agp.bridge)
> -               man->func = &nv04_gart_manager;
> +               func = &nv04_gart_manager;
>         else
>                 return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
> -                                         TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> -                                         TTM_PL_FLAG_WC, true,
> +                                         available_caching, default_caching,
> +                                         true,
>                                           size_pages);
> +
> +       man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> +       if (!man)
> +               return -ENOMEM;
> +
> +       man->func = func;
> +       man->available_caching = available_caching;
> +       man->default_caching = default_caching;
> +       man->use_tt = true;
>         ttm_mem_type_manager_init(&drm->ttm.bdev, man,
>                                   size_pages);
> +
> +       ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
>         ttm_mem_type_manager_set_used(man, true);
> +
>         return 0;
>  }
>
> @@ -241,6 +258,8 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
>                 ttm_mem_type_manager_disable(man);
>                 ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
>                 ttm_mem_type_manager_cleanup(man);
> +               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
> +               kfree(man);
>         }
>  }
>
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 51/59] drm/ttm: drop priv pointer in memory manager
  2020-08-04  2:56 ` [PATCH 51/59] drm/ttm: drop priv pointer in memory manager Dave Airlie
@ 2020-08-05  5:54   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:54 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> This isn't needed anymore by any drivers.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  include/drm/ttm/ttm_bo_driver.h | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 789c1eb26859..b477c1ad5c3e 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -123,7 +123,6 @@ struct ttm_mem_type_manager_func {
>   * @default_caching: The default caching policy used for a buffer object
>   * placed in this memory type if the user doesn't provide one.
>   * @func: structure pointer implementing the range manager. See above
> - * @priv: Driver private closure for @func.
>   * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures
>   * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions
>   * reserved by the TTM vm system.
> @@ -152,7 +151,6 @@ struct ttm_mem_type_manager {
>         uint32_t available_caching;
>         uint32_t default_caching;
>         const struct ttm_mem_type_manager_func *func;
> -       void *priv;
>         struct mutex io_reserve_mutex;
>         bool use_io_reserve_lru;
>         spinlock_t move_lock;
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 53/59] drm/ttm: drop man->bdev link.
  2020-08-04  2:56 ` [PATCH 53/59] drm/ttm: drop man->bdev link Dave Airlie
@ 2020-08-05  5:54   ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:54 UTC (permalink / raw)
  To: Dave Airlie
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Gerd Hoffmann,
	Christian König, Ben Skeggs

On Tue, 4 Aug 2020 at 12:58, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> This link isn't needed anymore, drop it from the init interface.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   | 2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 2 +-
>  drivers/gpu/drm/nouveau/nouveau_ttm.c         | 6 ++----
>  drivers/gpu/drm/ttm/ttm_bo.c                  | 6 ++----
>  drivers/gpu/drm/ttm/ttm_bo_manager.c          | 2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           | 2 +-
>  include/drm/ttm/ttm_bo_api.h                  | 6 ++----
>  include/drm/ttm/ttm_bo_driver.h               | 2 --
>  9 files changed, 11 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index b664c5cb13ce..9fc3d876ed38 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>         man->available_caching = TTM_PL_MASK_CACHING;
>         man->default_caching = TTM_PL_FLAG_CACHED;
>
> -       ttm_mem_type_manager_init(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT);
> +       ttm_mem_type_manager_init(man, gtt_size >> PAGE_SHIFT);
>
>         start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
>         size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index bbc528c0ed3e..684698cdf772 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
>         man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
>         man->default_caching = TTM_PL_FLAG_WC;
>
> -       ttm_mem_type_manager_init(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> +       ttm_mem_type_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
>
>         man->func = &amdgpu_vram_mgr_func;
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 58d9bd708e95..d408e1485cce 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -175,7 +175,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>                 man->func = &nouveau_vram_manager;
>                 man->use_io_reserve_lru = true;
>
> -               ttm_mem_type_manager_init(&drm->ttm.bdev, man,
> +               ttm_mem_type_manager_init(man,
>                                           drm->gem.vram_available >> PAGE_SHIFT);
>                 ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
>                 ttm_mem_type_manager_set_used(man, true);
> @@ -237,9 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>         man->available_caching = available_caching;
>         man->default_caching = default_caching;
>         man->use_tt = true;
> -       ttm_mem_type_manager_init(&drm->ttm.bdev, man,
> -                                 size_pages);
> -
> +       ttm_mem_type_manager_init(man, size_pages);
>         ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
>         ttm_mem_type_manager_set_used(man, true);
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 3a3a4dfb0fff..78b72443a9ef 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1471,8 +1471,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>  }
>  EXPORT_SYMBOL(ttm_bo_evict_mm);
>
> -void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> -                              struct ttm_mem_type_manager *man,
> +void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
>                                unsigned long p_size)
>  {
>         unsigned i;
> @@ -1482,7 +1481,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>         mutex_init(&man->io_reserve_mutex);
>         spin_lock_init(&man->move_lock);
>         INIT_LIST_HEAD(&man->io_reserve_lru);
> -       man->bdev = bdev;
>         man->size = p_size;
>
>         for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
> @@ -1595,7 +1593,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
>         man->available_caching = TTM_PL_MASK_CACHING;
>         man->default_caching = TTM_PL_FLAG_CACHED;
>
> -       ttm_mem_type_manager_init(bdev, man, 0);
> +       ttm_mem_type_manager_init(man, 0);
>         ttm_mem_type_manager_set_used(man, true);
>  }
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index 01d41c6f2f7b..1b7245ce3356 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -133,7 +133,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
>
>         man->func = &ttm_bo_manager_func;
>
> -       ttm_mem_type_manager_init(bdev, man, p_size);
> +       ttm_mem_type_manager_init(man, p_size);
>
>         drm_mm_init(&rman->mm, 0, p_size);
>         spin_lock_init(&rman->lock);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index bc51b7773084..c3fa25161fd0 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>         man->default_caching = TTM_PL_FLAG_CACHED;
>         /* TODO: This is most likely not correct */
>         man->use_tt = true;
> -       ttm_mem_type_manager_init(&dev_priv->bdev, man, 0);
> +       ttm_mem_type_manager_init(man, 0);
>         spin_lock_init(&gman->lock);
>         gman->used_gmr_pages = 0;
>         ida_init(&gman->gmr_ida);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 1cefd9c1e8ea..0b9c29249393 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -134,7 +134,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
>         man->available_caching = TTM_PL_FLAG_CACHED;
>         man->default_caching = TTM_PL_FLAG_CACHED;
>
> -       ttm_mem_type_manager_init(&dev_priv->bdev, man,
> +       ttm_mem_type_manager_init(man,
>                                   dev_priv->vram_size >> PAGE_SHIFT);
>
>         drm_mm_init(&rman->mm, 0, man->size);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 9c55eafd0e7d..eb465e9ca0c1 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -536,14 +536,12 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
>  /**
>   * ttm_mem_type_manager_init
>   *
> - * @bdev: Pointer to a ttm_bo_device struct.
>   * @man: memory manager object to init
>   * @p_size: size managed area in pages.
>   *
> - * Initialise core parts of a a manager object.
> + * Initialise core parts of a manager object.
>   */
> -void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
> -                              struct ttm_mem_type_manager *man,
> +void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
>                                unsigned long p_size);
>
>  /**
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index b477c1ad5c3e..bfd19400372f 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -138,8 +138,6 @@ struct ttm_mem_type_manager_func {
>
>
>  struct ttm_mem_type_manager {
> -       struct ttm_bo_device *bdev;
> -
>         /*
>          * No protection. Constant from start.
>          */
> --
> 2.26.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2)
  2020-08-04 11:37   ` Christian König
@ 2020-08-05  5:55     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:55 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:37, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > The driver now controls these, the core just controls the system
> > memory one.
> >
> > v2: init sysman explicitly and assign it as a driver manager
> > to simplify the lookup sequence.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    | 6 +++---
> >   include/drm/ttm/ttm_bo_driver.h | 6 ++----
> >   2 files changed, 5 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 78b72443a9ef..12abe46bfbc1 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1558,6 +1558,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> >
> >       man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> >       ttm_mem_type_manager_disable(man);
> > +     ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
> >
> >       mutex_lock(&ttm_global_mutex);
> >       list_del(&bdev->device_list);
> > @@ -1583,7 +1584,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
> >
> >   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> > +     struct ttm_mem_type_manager *man = &bdev->sysman;
> >
> >       /*
> >        * Initialize the system memory buffer type.
> > @@ -1594,6 +1595,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> >       man->default_caching = TTM_PL_FLAG_CACHED;
> >
> >       ttm_mem_type_manager_init(man, 0);
> > +     ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
> >       ttm_mem_type_manager_set_used(man, true);
> >   }
> >
> > @@ -1615,8 +1617,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
> >
> >       bdev->driver = driver;
> >
> > -     memset(bdev->man_priv, 0, sizeof(bdev->man_priv));
> > -
> >       ttm_bo_init_sysman(bdev);
> >
> >       bdev->vma_manager = vma_manager;
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index bfd19400372f..d5646d7cac60 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -414,7 +414,7 @@ struct ttm_bo_device {
> >       /*
> >        * access via ttm_manager_type.
> >        */
> > -     struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> > +     struct ttm_mem_type_manager sysman;
> >       struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
> >       /*
> >        * Protected by internal locks.
> > @@ -446,9 +446,7 @@ struct ttm_bo_device {
> >   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> >                                                           int mem_type)
> >   {
> > -     if (bdev->man_drv[mem_type])
> > -             return bdev->man_drv[mem_type];
> > -     return &bdev->man_priv[mem_type];
> > +     return bdev->man_drv[mem_type];
> >   }
> >
> >   static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 55/59] drm/ttm: drop type manager has_type
  2020-08-04 11:37   ` Christian König
@ 2020-08-05  5:55     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:55 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:38, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > under driver control, this flag isn't needed anymore,
> > remove the API that used to access it, and consoldiate
> > with the used api.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_ttm.c         |  4 ++--
> >   drivers/gpu/drm/ttm/ttm_bo.c                  |  8 +++-----
> >   drivers/gpu/drm/ttm/ttm_bo_manager.c          |  2 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  2 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  2 +-
> >   include/drm/ttm/ttm_bo_driver.h               | 17 -----------------
> >   8 files changed, 10 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > index 9fc3d876ed38..71461d652fcc 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > @@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       int ret;
> >
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >
> >       ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> >       if (ret)
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > index 684698cdf772..8cc44c3d2fdd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > @@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >       int ret;
> >
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >
> >       ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> >       if (ret)
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > index d408e1485cce..22185a8dcfa1 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > @@ -194,7 +194,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
> >       struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> >
> >       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> > -             ttm_mem_type_manager_disable(man);
> > +             ttm_mem_type_manager_set_used(man, false);
> >               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> >               ttm_mem_type_manager_cleanup(man);
> >               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
> > @@ -253,7 +253,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
> >           drm->agp.bridge)
> >               ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
> >       else {
> > -             ttm_mem_type_manager_disable(man);
> > +             ttm_mem_type_manager_set_used(man, false);
> >               ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> >               ttm_mem_type_manager_cleanup(man);
> >               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 12abe46bfbc1..cda33b4af681 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -80,7 +80,6 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
> >   void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> >                               struct drm_printer *p)
> >   {
> > -     drm_printf(p, "    has_type: %d\n", man->has_type);
> >       drm_printf(p, "    use_type: %d\n", man->use_type);
> >       drm_printf(p, "    use_tt: %d\n", man->use_tt);
> >       drm_printf(p, "    size: %llu\n", man->size);
> > @@ -1003,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >               return ret;
> >
> >       man = ttm_manager_type(bdev, mem_type);
> > -     if (!man->has_type || !man->use_type)
> > +     if (!man || !man->use_type)
> >               return -EBUSY;
> >
> >       if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> > @@ -1462,7 +1461,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               return -EINVAL;
> >       }
> >
> > -     if (!man->has_type) {
> > +     if (!man) {
> >               pr_err("Memory type %u has not been initialized\n", mem_type);
> >               return 0;
> >       }
> > @@ -1476,7 +1475,6 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> >   {
> >       unsigned i;
> >
> > -     BUG_ON(man->has_type);
> >       man->use_io_reserve_lru = false;
> >       mutex_init(&man->io_reserve_mutex);
> >       spin_lock_init(&man->move_lock);
> > @@ -1557,7 +1555,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> >       struct ttm_mem_type_manager *man;
> >
> >       man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >       ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
> >
> >       mutex_lock(&ttm_global_mutex);
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > index 1b7245ce3356..6679dc11934f 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > @@ -152,7 +152,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
> >       struct drm_mm *mm = &rman->mm;
> >       int ret;
> >
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >
> >       ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> >       if (ret)
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > index c3fa25161fd0..ca5037184814 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > @@ -143,7 +143,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
> >       struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> >       struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> >
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >
> >       ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > index 0b9c29249393..4110e8309188 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > @@ -152,7 +152,7 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
> >       struct drm_mm *mm = &rman->mm;
> >       int ret;
> >
> > -     ttm_mem_type_manager_disable(man);
> > +     ttm_mem_type_manager_set_used(man, false);
> >
> >       ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> >       if (ret)
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index d5646d7cac60..300934289e64 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -111,7 +111,6 @@ struct ttm_mem_type_manager_func {
> >   /**
> >    * struct ttm_mem_type_manager
> >    *
> > - * @has_type: The memory type has been initialized.
> >    * @use_type: The memory type is enabled.
> >    * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
> >    * managed by this memory type.
> > @@ -141,8 +140,6 @@ struct ttm_mem_type_manager {
> >       /*
> >        * No protection. Constant from start.
> >        */
> > -
> > -     bool has_type;
> >       bool use_type;
> >       bool use_tt;
> >       uint64_t size;
> > @@ -678,23 +675,9 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
> >    */
> >   static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
> >   {
> > -     man->has_type = true;
> >       man->use_type = used;
> >   }
> >
> > -/**
> > - * ttm_mem_type_manager_disable.
> > - *
> > - * @man: A memory manager object.
> > - *
> > - * Indicate the manager is not to be used and deregistered. (temporary during rework).
> > - */
> > -static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> > -{
> > -     man->has_type = false;
> > -     man->use_type = false;
> > -}
> > -
> >   /**
> >    * ttm_mem_type_manager_cleanup
> >    *
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use
  2020-08-04 11:38   ` Christian König
@ 2020-08-05  5:56     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:56 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:38, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This converts vmwgfx over to using an interface to set the
> > in use and check the in use flag.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/nouveau/nouveau_ttm.c |  1 -
> >   drivers/gpu/drm/ttm/ttm_bo.c          |  2 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 14 +++++++-------
> >   include/drm/ttm/ttm_bo_driver.h       | 14 ++++++++++++++
> >   4 files changed, 22 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > index 22185a8dcfa1..38a0e4bd16f7 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > @@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> >       ttm_mem_type_manager_init(man, size_pages);
> >       ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
> >       ttm_mem_type_manager_set_used(man, true);
> > -
> >       return 0;
> >   }
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index cda33b4af681..7d10abae9a60 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >               return ret;
> >
> >       man = ttm_manager_type(bdev, mem_type);
> > -     if (!man || !man->use_type)
> > +     if (!man || !ttm_mem_type_manager_used(man))
> >               return -EBUSY;
> >
> >       if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > index 7168403fb4f8..b2f1e7a3b048 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
> >                                TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
> >                                false, dev_priv->vram_size >> PAGE_SHIFT);
> >   #endif
> > -     ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
> > +     ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
> >       return ret;
> >   }
> >
> > @@ -1192,9 +1192,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)
> >       struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (!man->use_type) {
> > +     if (!ttm_mem_type_manager_used(man)) {
> >               vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> > -             man->use_type = true;
> > +             ttm_mem_type_manager_set_used(man, true);
> >       }
> >       spin_unlock(&dev_priv->svga_lock);
> >   }
> > @@ -1223,8 +1223,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
> >       struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (man->use_type) {
> > -             man->use_type = false;
> > +     if (ttm_mem_type_manager_used(man)) {
> > +             ttm_mem_type_manager_set_used(man, false);
> >               vmw_write(dev_priv, SVGA_REG_ENABLE,
> >                         SVGA_REG_ENABLE_HIDE |
> >                         SVGA_REG_ENABLE_ENABLE);
> > @@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
> >       vmw_kms_lost_device(dev_priv->dev);
> >       ttm_write_lock(&dev_priv->reservation_sem, false);
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (man->use_type) {
> > -             man->use_type = false;
> > +     if (ttm_mem_type_manager_used(man)) {
> > +             ttm_mem_type_manager_set_used(man, false);
> >               spin_unlock(&dev_priv->svga_lock);
> >               if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
> >                       DRM_ERROR("Failed evicting VRAM buffers.\n");
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 300934289e64..f231fe34e744 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -678,6 +678,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
> >       man->use_type = used;
> >   }
> >
> > +/**
> > + * ttm_mem_type_manager_used
> > + *
> > + * @man: Manager to get used state for
> > + *
> > + * Get the in use flag for a manager.
> > + * Returns:
> > + * true is used, false if not.
> > + */
> > +static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
> > +{
> > +     return man->use_type;
> > +}
> > +
> >   /**
> >    * ttm_mem_type_manager_cleanup
> >    *
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 57/59] drm/ttm: rename bo manager to range manager.
  2020-08-04 11:40   ` Christian König
@ 2020-08-05  5:56     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:56 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:40, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > The generic manager is called the range manager now, rename
> > the file and some internals.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/Makefile                  |  2 +-
> >   .../{ttm_bo_manager.c => ttm_range_manager.c} | 26 +++++++++----------
> >   2 files changed, 14 insertions(+), 14 deletions(-)
> >   rename drivers/gpu/drm/ttm/{ttm_bo_manager.c => ttm_range_manager.c} (88%)
> >
> > diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile
> > index caea2a099496..e54326e6cea4 100644
> > --- a/drivers/gpu/drm/ttm/Makefile
> > +++ b/drivers/gpu/drm/ttm/Makefile
> > @@ -4,7 +4,7 @@
> >
> >   ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
> >       ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
> > -     ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
> > +     ttm_execbuf_util.o ttm_page_alloc.o ttm_range_manager.o
> >   ttm-$(CONFIG_AGP) += ttm_agp_backend.o
> >   ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > similarity index 88%
> > rename from drivers/gpu/drm/ttm/ttm_bo_manager.c
> > rename to drivers/gpu/drm/ttm/ttm_range_manager.c
> > index 6679dc11934f..52d9a0ed7165 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > @@ -54,10 +54,10 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_man
> >       return container_of(man, struct ttm_range_manager, manager);
> >   }
> >
> > -static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
> > -                            struct ttm_buffer_object *bo,
> > -                            const struct ttm_place *place,
> > -                            struct ttm_mem_reg *mem)
> > +static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
> > +                               struct ttm_buffer_object *bo,
> > +                               const struct ttm_place *place,
> > +                               struct ttm_mem_reg *mem)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> >       struct drm_mm *mm = &rman->mm;
> > @@ -95,8 +95,8 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
> >       return ret;
> >   }
> >
> > -static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
> > -                             struct ttm_mem_reg *mem)
> > +static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
> > +                                struct ttm_mem_reg *mem)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> >
> > @@ -110,7 +110,7 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
> >       }
> >   }
> >
> > -static const struct ttm_mem_type_manager_func ttm_bo_manager_func;
> > +static const struct ttm_mem_type_manager_func ttm_range_manager_func;
> >
> >   int ttm_range_man_init(struct ttm_bo_device *bdev,
> >                      unsigned type,
> > @@ -131,7 +131,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >       man->default_caching = default_caching;
> >       man->use_tt = use_tt;
> >
> > -     man->func = &ttm_bo_manager_func;
> > +     man->func = &ttm_range_manager_func;
> >
> >       ttm_mem_type_manager_init(man, p_size);
> >
> > @@ -170,7 +170,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
> >   }
> >   EXPORT_SYMBOL(ttm_range_man_fini);
> >
> > -static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
> > +static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
> >                            struct drm_printer *printer)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> > @@ -180,8 +180,8 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
> >       spin_unlock(&rman->lock);
> >   }
> >
> > -static const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
> > -     .get_node = ttm_bo_man_get_node,
> > -     .put_node = ttm_bo_man_put_node,
> > -     .debug = ttm_bo_man_debug
> > +static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
> > +     .get_node = ttm_range_man_get_node,
> > +     .put_node = ttm_range_man_put_node,
> > +     .debug = ttm_range_man_debug
> >   };
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager.
  2020-08-04 11:41   ` Christian König
@ 2020-08-05  5:57     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:57 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:41, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This name makes a lot more sense, since these are about managing
> > driver resources rather than just memory ranges.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c    |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   | 36 +++++-----
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |  4 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  4 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       |  8 +--
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 36 +++++-----
> >   drivers/gpu/drm/drm_gem_vram_helper.c         |  4 +-
> >   drivers/gpu/drm/nouveau/nouveau_ttm.c         | 46 ++++++-------
> >   drivers/gpu/drm/nouveau/nouveau_ttm.h         |  6 +-
> >   drivers/gpu/drm/qxl/qxl_ttm.c                 |  4 +-
> >   drivers/gpu/drm/radeon/radeon_gem.c           |  2 +-
> >   drivers/gpu/drm/radeon/radeon_ttm.c           |  4 +-
> >   drivers/gpu/drm/ttm/ttm_bo.c                  | 66 +++++++++----------
> >   drivers/gpu/drm/ttm/ttm_bo_util.c             | 26 ++++----
> >   drivers/gpu/drm/ttm/ttm_bo_vm.c               |  2 +-
> >   drivers/gpu/drm/ttm/ttm_range_manager.c       | 28 ++++----
> >   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 20 +++---
> >   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 26 ++++----
> >   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           | 26 ++++----
> >   include/drm/ttm/ttm_bo_api.h                  |  6 +-
> >   include/drm/ttm/ttm_bo_driver.h               | 60 ++++++++---------
> >   23 files changed, 210 insertions(+), 210 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> > index e24f421e5553..478f67498a17 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> > @@ -517,7 +517,7 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,
> >   uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
> >   {
> >       struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
> > -     struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >
> >       return amdgpu_vram_mgr_usage(vram_man);
> >   }
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 9829640e1769..ecd051976bce 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
> >   {
> >       s64 time_us, increment_us;
> >       u64 free_vram, total_vram, used_vram;
> > -     struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >       /* Allow a maximum of 200 accumulated ms. This is basically per-IB
> >        * throttling.
> >        *
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > index 71461d652fcc..8b600b804f34 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > @@ -25,13 +25,13 @@
> >   #include "amdgpu.h"
> >
> >   struct amdgpu_gtt_mgr {
> > -     struct ttm_mem_type_manager manager;
> > +     struct ttm_resource_manager manager;
> >       struct drm_mm mm;
> >       spinlock_t lock;
> >       atomic64_t available;
> >   };
> >
> > -static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man)
> > +static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_resource_manager *man)
> >   {
> >       return container_of(man, struct amdgpu_gtt_mgr, manager);
> >   }
> > @@ -54,7 +54,7 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev,
> >   {
> >       struct drm_device *ddev = dev_get_drvdata(dev);
> >       struct amdgpu_device *adev = ddev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> >       return snprintf(buf, PAGE_SIZE, "%llu\n",
> >                       man->size * PAGE_SIZE);
> >   }
> > @@ -72,7 +72,7 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
> >   {
> >       struct drm_device *ddev = dev_get_drvdata(dev);
> >       struct amdgpu_device *adev = ddev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> >       return snprintf(buf, PAGE_SIZE, "%llu\n",
> >                       amdgpu_gtt_mgr_usage(man));
> >   }
> > @@ -82,7 +82,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
> >   static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,
> >                  amdgpu_mem_info_gtt_used_show, NULL);
> >
> > -static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
> > +static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
> >   /**
> >    * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
> >    *
> > @@ -93,7 +93,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
> >    */
> >   int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       struct amdgpu_gtt_mgr *mgr;
> >       uint64_t start, size;
> >       int ret;
> > @@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
> >       man->available_caching = TTM_PL_MASK_CACHING;
> >       man->default_caching = TTM_PL_FLAG_CACHED;
> >
> > -     ttm_mem_type_manager_init(man, gtt_size >> PAGE_SHIFT);
> > +     ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
> >
> >       start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
> >       size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
> > @@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
> >       }
> >
> >       ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >
> > @@ -142,13 +142,13 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
> >    */
> >   void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       int ret;
> >
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >
> > -     ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> > +     ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
> >       if (ret)
> >               return;
> >
> > @@ -159,7 +159,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
> >       device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total);
> >       device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used);
> >
> > -     ttm_mem_type_manager_cleanup(man);
> > +     ttm_resource_manager_cleanup(man);
> >       ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
> >       kfree(mgr);
> >   }
> > @@ -186,7 +186,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
> >    *
> >    * Dummy, allocate the node but no space for it yet.
> >    */
> > -static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
> > +static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
> >                             struct ttm_buffer_object *tbo,
> >                             const struct ttm_place *place,
> >                             struct ttm_mem_reg *mem)
> > @@ -249,7 +249,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
> >    *
> >    * Free the allocated GTT again.
> >    */
> > -static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
> > +static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
> >                              struct ttm_mem_reg *mem)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> > @@ -272,7 +272,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
> >    *
> >    * Return how many bytes are used in the GTT domain
> >    */
> > -uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
> > +uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       s64 result = man->size - atomic64_read(&mgr->available);
> > @@ -280,7 +280,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)
> >       return (result > 0 ? result : 0) * PAGE_SIZE;
> >   }
> >
> > -int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
> > +int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       struct amdgpu_gtt_node *node;
> > @@ -307,7 +307,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)
> >    *
> >    * Dump the table content using printk.
> >    */
> > -static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
> > +static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
> >                                struct drm_printer *printer)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> > @@ -321,7 +321,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
> >                  amdgpu_gtt_mgr_usage(man) >> 20);
> >   }
> >
> > -static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
> > +static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
> >       .get_node = amdgpu_gtt_mgr_new,
> >       .put_node = amdgpu_gtt_mgr_del,
> >       .debug = amdgpu_gtt_mgr_debug
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > index 594687cc99ac..2763bca163e3 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> > @@ -631,9 +631,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
> >       }
> >       case AMDGPU_INFO_MEMORY: {
> >               struct drm_amdgpu_memory_info mem;
> > -             struct ttm_mem_type_manager *vram_man =
> > +             struct ttm_resource_manager *vram_man =
> >                       ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > -             struct ttm_mem_type_manager *gtt_man =
> > +             struct ttm_resource_manager *gtt_man =
> >                       ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
> >               memset(&mem, 0, sizeof(mem));
> >               mem.vram.total_heap_size = adev->gmc.real_vram_size;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > index ced418cba2f7..ce98df5b0c21 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > @@ -442,7 +442,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
> >   static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
> >                                         unsigned long size, u32 domain)
> >   {
> > -     struct ttm_mem_type_manager *man = NULL;
> > +     struct ttm_resource_manager *man = NULL;
> >
> >       /*
> >        * If GTT is part of requested domains the check must succeed to
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index b190d50dc9bb..cae7eada7215 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -2030,7 +2030,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
> >    */
> >   void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >       uint64_t size;
> >       int r;
> >
> > @@ -2252,7 +2252,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
> >       unsigned ttm_pl = (uintptr_t)node->info_ent->data;
> >       struct drm_device *dev = node->minor->dev;
> >       struct amdgpu_device *adev = dev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
> >       struct drm_printer p = drm_seq_file_printer(m);
> >
> >       man->func->debug(man, &p);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > index c01fdb3f0458..3db29ae1f802 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > @@ -73,8 +73,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
> >   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
> >
> >   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
> > -uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
> > -int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man);
> > +uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
> > +int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
> >
> >   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
> >   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> > @@ -86,8 +86,8 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
> >                             struct device *dev,
> >                             enum dma_data_direction dir,
> >                             struct sg_table *sgt);
> > -uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
> > -uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man);
> > +uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man);
> > +uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man);
> >
> >   int amdgpu_ttm_init(struct amdgpu_device *adev);
> >   void amdgpu_ttm_late_init(struct amdgpu_device *adev);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > index 8cc44c3d2fdd..b227e380094f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > @@ -29,7 +29,7 @@
> >   #include "atom.h"
> >
> >   struct amdgpu_vram_mgr {
> > -     struct ttm_mem_type_manager manager;
> > +     struct ttm_resource_manager manager;
> >       struct drm_mm mm;
> >       spinlock_t lock;
> >       atomic64_t usage;
> > @@ -37,7 +37,7 @@ struct amdgpu_vram_mgr {
> >       struct amdgpu_device *adev;
> >   };
> >
> > -static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man)
> > +static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_resource_manager *man)
> >   {
> >       return container_of(man, struct amdgpu_vram_mgr, manager);
> >   }
> > @@ -89,7 +89,7 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev,
> >   {
> >       struct drm_device *ddev = dev_get_drvdata(dev);
> >       struct amdgpu_device *adev = ddev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >       return snprintf(buf, PAGE_SIZE, "%llu\n",
> >                       amdgpu_vram_mgr_usage(man));
> >   }
> > @@ -107,7 +107,7 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev,
> >   {
> >       struct drm_device *ddev = dev_get_drvdata(dev);
> >       struct amdgpu_device *adev = ddev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >       return snprintf(buf, PAGE_SIZE, "%llu\n",
> >                       amdgpu_vram_mgr_vis_usage(man));
> >   }
> > @@ -165,7 +165,7 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {
> >       NULL
> >   };
> >
> > -static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
> > +static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
> >
> >   /**
> >    * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
> > @@ -177,7 +177,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
> >    */
> >   int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       struct amdgpu_vram_mgr *mgr;
> >       int ret;
> >
> > @@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> >       man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> >       man->default_caching = TTM_PL_FLAG_WC;
> >
> > -     ttm_mem_type_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> > +     ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> >
> >       man->func = &amdgpu_vram_mgr_func;
> >
> > @@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> >               DRM_ERROR("Failed to register sysfs\n");
> >
> >       ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >
> > @@ -219,13 +219,13 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> >    */
> >   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >       int ret;
> >
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >
> > -     ret = ttm_mem_type_manager_force_list_clean(&adev->mman.bdev, man);
> > +     ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
> >       if (ret)
> >               return;
> >
> > @@ -235,7 +235,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
> >
> >       sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
> >
> > -     ttm_mem_type_manager_cleanup(man);
> > +     ttm_resource_manager_cleanup(man);
> >       ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
> >       kfree(mgr);
> >   }
> > @@ -321,7 +321,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
> >    *
> >    * Allocate VRAM for the given BO.
> >    */
> > -static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
> > +static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
> >                              struct ttm_buffer_object *tbo,
> >                              const struct ttm_place *place,
> >                              struct ttm_mem_reg *mem)
> > @@ -439,7 +439,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
> >    *
> >    * Free the allocated VRAM again.
> >    */
> > -static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
> > +static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
> >                               struct ttm_mem_reg *mem)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> > @@ -573,7 +573,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,
> >    *
> >    * Returns how many bytes are used in this domain.
> >    */
> > -uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
> > +uint64_t amdgpu_vram_mgr_usage(struct ttm_resource_manager *man)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >
> > @@ -587,7 +587,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)
> >    *
> >    * Returns how many bytes are used in the visible part of VRAM
> >    */
> > -uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
> > +uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_resource_manager *man)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >
> > @@ -602,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)
> >    *
> >    * Dump the table content using printk.
> >    */
> > -static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
> > +static void amdgpu_vram_mgr_debug(struct ttm_resource_manager *man,
> >                                 struct drm_printer *printer)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> > @@ -616,7 +616,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
> >                  amdgpu_vram_mgr_vis_usage(man) >> 20);
> >   }
> >
> > -static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
> > +static const struct ttm_resource_manager_func amdgpu_vram_mgr_func = {
> >       .get_node       = amdgpu_vram_mgr_new,
> >       .put_node       = amdgpu_vram_mgr_del,
> >       .debug          = amdgpu_vram_mgr_debug
> > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> > index 2187787f397e..e3660d00987d 100644
> > --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> > @@ -1075,10 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
> >   {
> >       struct drm_info_node *node = (struct drm_info_node *) m->private;
> >       struct drm_vram_mm *vmm = node->minor->dev->vram_mm;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
> >       struct drm_printer p = drm_seq_file_printer(m);
> >
> > -     ttm_mem_type_manager_debug(man, &p);
> > +     ttm_resource_manager_debug(man, &p);
> >       return 0;
> >   }
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > index 38a0e4bd16f7..d6ad0977dc7d 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > @@ -32,13 +32,13 @@
> >   #include <core/tegra.h>
> >
> >   static void
> > -nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
> > +nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
> >   {
> >       nouveau_mem_del(reg);
> >   }
> >
> >   static int
> > -nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
> > +nouveau_vram_manager_new(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> >                        struct ttm_mem_reg *reg)
> > @@ -63,13 +63,13 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
> >       return 0;
> >   }
> >
> > -const struct ttm_mem_type_manager_func nouveau_vram_manager = {
> > +const struct ttm_resource_manager_func nouveau_vram_manager = {
> >       .get_node = nouveau_vram_manager_new,
> >       .put_node = nouveau_manager_del,
> >   };
> >
> >   static int
> > -nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
> > +nouveau_gart_manager_new(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> >                        struct ttm_mem_reg *reg)
> > @@ -86,13 +86,13 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
> >       return 0;
> >   }
> >
> > -const struct ttm_mem_type_manager_func nouveau_gart_manager = {
> > +const struct ttm_resource_manager_func nouveau_gart_manager = {
> >       .get_node = nouveau_gart_manager_new,
> >       .put_node = nouveau_manager_del,
> >   };
> >
> >   static int
> > -nv04_gart_manager_new(struct ttm_mem_type_manager *man,
> > +nv04_gart_manager_new(struct ttm_resource_manager *man,
> >                     struct ttm_buffer_object *bo,
> >                     const struct ttm_place *place,
> >                     struct ttm_mem_reg *reg)
> > @@ -118,7 +118,7 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
> >       return 0;
> >   }
> >
> > -const struct ttm_mem_type_manager_func nv04_gart_manager = {
> > +const struct ttm_resource_manager_func nv04_gart_manager = {
> >       .get_node = nv04_gart_manager_new,
> >       .put_node = nouveau_manager_del,
> >   };
> > @@ -160,7 +160,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> >       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> >               /* Some BARs do not support being ioremapped WC */
> >               const u8 type = mmu->type[drm->ttm.type_vram].type;
> > -             struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> > +             struct ttm_resource_manager *man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
> >               if (!man)
> >                       return -ENOMEM;
> >
> > @@ -175,10 +175,10 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> >               man->func = &nouveau_vram_manager;
> >               man->use_io_reserve_lru = true;
> >
> > -             ttm_mem_type_manager_init(man,
> > +             ttm_resource_manager_init(man,
> >                                         drm->gem.vram_available >> PAGE_SHIFT);
> >               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
> > -             ttm_mem_type_manager_set_used(man, true);
> > +             ttm_resource_manager_set_used(man, true);
> >               return 0;
> >       } else {
> >               return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
> > @@ -191,12 +191,12 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> >   static void
> >   nouveau_ttm_fini_vram(struct nouveau_drm *drm)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
> >
> >       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> > -             ttm_mem_type_manager_set_used(man, false);
> > -             ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> > -             ttm_mem_type_manager_cleanup(man);
> > +             ttm_resource_manager_set_used(man, false);
> > +             ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
> > +             ttm_resource_manager_cleanup(man);
> >               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
> >               kfree(man);
> >       } else
> > @@ -206,10 +206,10 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
> >   static int
> >   nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
> >       unsigned available_caching, default_caching;
> > -     const struct ttm_mem_type_manager_func *func = NULL;
> > +     const struct ttm_resource_manager_func *func = NULL;
> >       if (drm->agp.bridge) {
> >               available_caching = TTM_PL_FLAG_UNCACHED |
> >                       TTM_PL_FLAG_WC;
> > @@ -229,7 +229,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> >                                         true,
> >                                         size_pages);
> >
> > -     man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL);
> > +     man = kzalloc(sizeof(struct ttm_resource_manager), GFP_KERNEL);
> >       if (!man)
> >               return -ENOMEM;
> >
> > @@ -237,24 +237,24 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> >       man->available_caching = available_caching;
> >       man->default_caching = default_caching;
> >       man->use_tt = true;
> > -     ttm_mem_type_manager_init(man, size_pages);
> > +     ttm_resource_manager_init(man, size_pages);
> >       ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >
> >   static void
> >   nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
> >
> >       if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
> >           drm->agp.bridge)
> >               ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
> >       else {
> > -             ttm_mem_type_manager_set_used(man, false);
> > -             ttm_mem_type_manager_force_list_clean(&drm->ttm.bdev, man);
> > -             ttm_mem_type_manager_cleanup(man);
> > +             ttm_resource_manager_set_used(man, false);
> > +             ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
> > +             ttm_resource_manager_cleanup(man);
> >               ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
> >               kfree(man);
> >       }
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.h b/drivers/gpu/drm/nouveau/nouveau_ttm.h
> > index 085280754b3e..eaf25461cd91 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.h
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.h
> > @@ -8,9 +8,9 @@ nouveau_bdev(struct ttm_bo_device *bd)
> >       return container_of(bd, struct nouveau_drm, ttm.bdev);
> >   }
> >
> > -extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
> > -extern const struct ttm_mem_type_manager_func nouveau_gart_manager;
> > -extern const struct ttm_mem_type_manager_func nv04_gart_manager;
> > +extern const struct ttm_resource_manager_func nouveau_vram_manager;
> > +extern const struct ttm_resource_manager_func nouveau_gart_manager;
> > +extern const struct ttm_resource_manager_func nv04_gart_manager;
> >
> >   struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo,
> >                                       u32 page_flags);
> > diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> > index b7365b2e4c7f..1c06fe780815 100644
> > --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> > +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> > @@ -274,10 +274,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)
> >   static int qxl_mm_dump_table(struct seq_file *m, void *data)
> >   {
> >       struct drm_info_node *node = (struct drm_info_node *)m->private;
> > -     struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data;
> > +     struct ttm_resource_manager *man = (struct ttm_resource_manager *)node->info_ent->data;
> >       struct drm_printer p = drm_seq_file_printer(m);
> >
> > -     ttm_mem_type_manager_debug(man, &p);
> > +     ttm_resource_manager_debug(man, &p);
> >       return 0;
> >   }
> >   #endif
> > diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> > index 3ec028dba739..7f5dfe04789e 100644
> > --- a/drivers/gpu/drm/radeon/radeon_gem.c
> > +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> > @@ -224,7 +224,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
> >   {
> >       struct radeon_device *rdev = dev->dev_private;
> >       struct drm_radeon_gem_info *args = data;
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM);
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> > index 474d2161da1e..05b5f29f2b61 100644
> > --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> > @@ -836,7 +836,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
> >    * isn't running */
> >   void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       if (!rdev->mman.initialized)
> >               return;
> > @@ -895,7 +895,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
> >       unsigned ttm_pl = *(int*)node->info_ent->data;
> >       struct drm_device *dev = node->minor->dev;
> >       struct radeon_device *rdev = dev->dev_private;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl);
> >       struct drm_printer p = drm_seq_file_printer(m);
> >
> >       man->func->debug(man, &p);
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 7d10abae9a60..48840a3cf4c4 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -77,7 +77,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,
> >       return 0;
> >   }
> >
> > -void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> > +void ttm_resource_manager_debug(struct ttm_resource_manager *man,
> >                               struct drm_printer *p)
> >   {
> >       drm_printf(p, "    use_type: %d\n", man->use_type);
> > @@ -88,14 +88,14 @@ void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> >       if (man->func && man->func->debug)
> >               (*man->func->debug)(man, p);
> >   }
> > -EXPORT_SYMBOL(ttm_mem_type_manager_debug);
> > +EXPORT_SYMBOL(ttm_resource_manager_debug);
> >
> >   static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> >                                       struct ttm_placement *placement)
> >   {
> >       struct drm_printer p = drm_debug_printer(TTM_PFX);
> >       int i, ret, mem_type;
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       drm_printf(&p, "No space for %p (%lu pages, %luK, %luM)\n",
> >                  bo, bo->mem.num_pages, bo->mem.size >> 10,
> > @@ -108,7 +108,7 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> >               drm_printf(&p, "  placement[%d]=0x%08X (%d)\n",
> >                          i, placement->placement[i].flags, mem_type);
> >               man = ttm_manager_type(bo->bdev, mem_type);
> > -             ttm_mem_type_manager_debug(man, &p);
> > +             ttm_resource_manager_debug(man, &p);
> >       }
> >   }
> >
> > @@ -148,7 +148,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
> >                                 struct ttm_mem_reg *mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       if (!list_empty(&bo->lru))
> >               return;
> > @@ -223,7 +223,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
> >
> >       for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
> >               struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i];
> > -             struct ttm_mem_type_manager *man;
> > +             struct ttm_resource_manager *man;
> >
> >               if (!pos->first)
> >                       continue;
> > @@ -238,7 +238,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
> >
> >       for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
> >               struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i];
> > -             struct ttm_mem_type_manager *man;
> > +             struct ttm_resource_manager *man;
> >
> >               if (!pos->first)
> >                       continue;
> > @@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> > -     struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
> > +     struct ttm_resource_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type);
> > +     struct ttm_resource_manager *new_man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >
> >       ret = ttm_mem_io_lock(old_man, true);
> > @@ -551,7 +551,7 @@ static void ttm_bo_release(struct kref *kref)
> >       struct ttm_buffer_object *bo =
> >           container_of(kref, struct ttm_buffer_object, kref);
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> >       size_t acc_size = bo->acc_size;
> >       int ret;
> >
> > @@ -768,7 +768,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
> >   }
> >
> >   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> > -                            struct ttm_mem_type_manager *man,
> > +                            struct ttm_resource_manager *man,
> >                              const struct ttm_place *place,
> >                              struct ttm_operation_ctx *ctx,
> >                              struct ww_acquire_ctx *ticket)
> > @@ -843,7 +843,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >                         const struct ttm_place *place,
> >                         struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> >       mem->mm_node = NULL;
> >       if (!man->func || !man->func->get_node)
> > @@ -854,7 +854,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >
> >   void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> >       if (!man->func || !man->func->put_node)
> >               return;
> > @@ -869,7 +869,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
> >    * Add the last move fence to the BO and reserve a new shared slot.
> >    */
> >   static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
> > -                              struct ttm_mem_type_manager *man,
> > +                              struct ttm_resource_manager *man,
> >                                struct ttm_mem_reg *mem,
> >                                bool no_wait_gpu)
> >   {
> > @@ -911,7 +911,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       struct ww_acquire_ctx *ticket;
> >       int ret;
> >
> > @@ -931,7 +931,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
> >       return ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
> >   }
> >
> > -static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
> > +static uint32_t ttm_bo_select_caching(struct ttm_resource_manager *man,
> >                                     uint32_t cur_placement,
> >                                     uint32_t proposed_placement)
> >   {
> > @@ -956,7 +956,7 @@ static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
> >       return result;
> >   }
> >
> > -static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
> > +static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
> >                                uint32_t mem_type,
> >                                const struct ttm_place *place,
> >                                uint32_t *masked_placement)
> > @@ -993,7 +993,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       uint32_t mem_type = TTM_PL_SYSTEM;
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       uint32_t cur_flags = 0;
> >       int ret;
> >
> > @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >               return ret;
> >
> >       man = ttm_manager_type(bdev, mem_type);
> > -     if (!man || !ttm_mem_type_manager_used(man))
> > +     if (!man || !ttm_resource_manager_used(man))
> >               return -EBUSY;
> >
> >       if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> > @@ -1049,7 +1049,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
> >
> >       for (i = 0; i < placement->num_placement; ++i) {
> >               const struct ttm_place *place = &placement->placement[i];
> > -             struct ttm_mem_type_manager *man;
> > +             struct ttm_resource_manager *man;
> >
> >               ret = ttm_bo_mem_placement(bo, place, mem, ctx);
> >               if (ret == -EBUSY)
> > @@ -1406,8 +1406,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
> >   }
> >   EXPORT_SYMBOL(ttm_bo_create);
> >
> > -int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> > -                                       struct ttm_mem_type_manager *man)
> > +int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
> > +                                       struct ttm_resource_manager *man)
> >   {
> >       struct ttm_operation_ctx ctx = {
> >               .interruptible = false,
> > @@ -1449,12 +1449,12 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> >
> >       return 0;
> >   }
> > -EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean);
> > +EXPORT_SYMBOL(ttm_resource_manager_force_list_clean);
> >
> >
> >   int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, mem_type);
> >
> >       if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
> >               pr_err("Illegal memory manager memory type %u\n", mem_type);
> > @@ -1466,11 +1466,11 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               return 0;
> >       }
> >
> > -     return ttm_mem_type_manager_force_list_clean(bdev, man);
> > +     return ttm_resource_manager_force_list_clean(bdev, man);
> >   }
> >   EXPORT_SYMBOL(ttm_bo_evict_mm);
> >
> > -void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> > +void ttm_resource_manager_init(struct ttm_resource_manager *man,
> >                              unsigned long p_size)
> >   {
> >       unsigned i;
> > @@ -1485,7 +1485,7 @@ void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> >               INIT_LIST_HEAD(&man->lru[i]);
> >       man->move = NULL;
> >   }
> > -EXPORT_SYMBOL(ttm_mem_type_manager_init);
> > +EXPORT_SYMBOL(ttm_resource_manager_init);
> >
> >   static void ttm_bo_global_kobj_release(struct kobject *kobj)
> >   {
> > @@ -1552,10 +1552,10 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> >       struct ttm_bo_global *glob = &ttm_bo_glob;
> >       int ret = 0;
> >       unsigned i;
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       man = ttm_manager_type(bdev, TTM_PL_SYSTEM);
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >       ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, NULL);
> >
> >       mutex_lock(&ttm_global_mutex);
> > @@ -1582,7 +1582,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);
> >
> >   static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> >   {
> > -     struct ttm_mem_type_manager *man = &bdev->sysman;
> > +     struct ttm_resource_manager *man = &bdev->sysman;
> >
> >       /*
> >        * Initialize the system memory buffer type.
> > @@ -1592,9 +1592,9 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> >       man->available_caching = TTM_PL_MASK_CACHING;
> >       man->default_caching = TTM_PL_FLAG_CACHED;
> >
> > -     ttm_mem_type_manager_init(man, 0);
> > +     ttm_resource_manager_init(man, 0);
> >       ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >   }
> >
> >   int ttm_bo_device_init(struct ttm_bo_device *bdev,
> > @@ -1645,7 +1645,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
> >   void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, bo->mem.mem_type);
> >
> >       ttm_mem_io_lock(man, false);
> >       ttm_bo_unmap_virtual_locked(bo);
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > index 879c8ded0cd8..8ef0de8e36c5 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > @@ -91,7 +91,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> >   }
> >   EXPORT_SYMBOL(ttm_bo_move_ttm);
> >
> > -int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
> > +int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible)
> >   {
> >       if (likely(!man->use_io_reserve_lru))
> >               return 0;
> > @@ -103,7 +103,7 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)
> >       return 0;
> >   }
> >
> > -void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
> > +void ttm_mem_io_unlock(struct ttm_resource_manager *man)
> >   {
> >       if (likely(!man->use_io_reserve_lru))
> >               return;
> > @@ -111,7 +111,7 @@ void ttm_mem_io_unlock(struct ttm_mem_type_manager *man)
> >       mutex_unlock(&man->io_reserve_mutex);
> >   }
> >
> > -static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
> > +static int ttm_mem_io_evict(struct ttm_resource_manager *man)
> >   {
> >       struct ttm_buffer_object *bo;
> >
> > @@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
> >   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> >                      struct ttm_mem_reg *mem)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >
> >       if (mem->bus.io_reserved_count++)
> > @@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
> >
> >   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >       struct ttm_mem_reg *mem = &bo->mem;
> >       int ret;
> >
> > @@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
> >                              struct ttm_mem_reg *mem,
> >                              void **virtual)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> >       void *addr;
> >
> > @@ -230,7 +230,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
> >                               struct ttm_mem_reg *mem,
> >                               void *virtual)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >
> >       man = ttm_manager_type(bdev, mem->mem_type);
> >
> > @@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >                      struct ttm_mem_reg *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> >       struct ttm_tt *ttm = bo->ttm;
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >       struct ttm_mem_reg old_copy = *old_mem;
> > @@ -570,7 +570,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
> >               unsigned long start_page, unsigned long num_pages,
> >               struct ttm_bo_kmap_obj *map)
> >   {
> > -     struct ttm_mem_type_manager *man =
> > +     struct ttm_resource_manager *man =
> >               ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >       unsigned long offset, size;
> >       int ret;
> > @@ -600,7 +600,7 @@ EXPORT_SYMBOL(ttm_bo_kmap);
> >   void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
> >   {
> >       struct ttm_buffer_object *bo = map->bo;
> > -     struct ttm_mem_type_manager *man =
> > +     struct ttm_resource_manager *man =
> >               ttm_manager_type(bo->bdev, bo->mem.mem_type);
> >
> >       if (!map->virtual)
> > @@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
> >                             struct ttm_mem_reg *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >       int ret;
> >       struct ttm_buffer_object *ghost_obj;
> > @@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       struct ttm_mem_reg *old_mem = &bo->mem;
> >
> > -     struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> > -     struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> > +     struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> > +     struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> >
> >       int ret;
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index 5ae679184eb5..c8efceef015d 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -281,7 +281,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
> >       pgoff_t i;
> >       vm_fault_t ret = VM_FAULT_NOPAGE;
> >       unsigned long address = vmf->address;
> > -     struct ttm_mem_type_manager *man =
> > +     struct ttm_resource_manager *man =
> >               ttm_manager_type(bdev, bo->mem.mem_type);
> >
> >       /*
> > diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > index 52d9a0ed7165..22de9f209449 100644
> > --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > @@ -44,17 +44,17 @@
> >    */
> >
> >   struct ttm_range_manager {
> > -     struct ttm_mem_type_manager manager;
> > +     struct ttm_resource_manager manager;
> >       struct drm_mm mm;
> >       spinlock_t lock;
> >   };
> >
> > -static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man)
> > +static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_manager *man)
> >   {
> >       return container_of(man, struct ttm_range_manager, manager);
> >   }
> >
> > -static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
> > +static int ttm_range_man_get_node(struct ttm_resource_manager *man,
> >                                 struct ttm_buffer_object *bo,
> >                                 const struct ttm_place *place,
> >                                 struct ttm_mem_reg *mem)
> > @@ -95,7 +95,7 @@ static int ttm_range_man_get_node(struct ttm_mem_type_manager *man,
> >       return ret;
> >   }
> >
> > -static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
> > +static void ttm_range_man_put_node(struct ttm_resource_manager *man,
> >                                  struct ttm_mem_reg *mem)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> > @@ -110,7 +110,7 @@ static void ttm_range_man_put_node(struct ttm_mem_type_manager *man,
> >       }
> >   }
> >
> > -static const struct ttm_mem_type_manager_func ttm_range_manager_func;
> > +static const struct ttm_resource_manager_func ttm_range_manager_func;
> >
> >   int ttm_range_man_init(struct ttm_bo_device *bdev,
> >                      unsigned type,
> > @@ -119,7 +119,7 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >                      bool use_tt,
> >                      unsigned long p_size)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       struct ttm_range_manager *rman;
> >
> >       rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> > @@ -133,13 +133,13 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> >
> >       man->func = &ttm_range_manager_func;
> >
> > -     ttm_mem_type_manager_init(man, p_size);
> > +     ttm_resource_manager_init(man, p_size);
> >
> >       drm_mm_init(&rman->mm, 0, p_size);
> >       spin_lock_init(&rman->lock);
> >
> >       ttm_set_driver_manager(bdev, type, &rman->manager);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >   EXPORT_SYMBOL(ttm_range_man_init);
> > @@ -147,14 +147,14 @@ EXPORT_SYMBOL(ttm_range_man_init);
> >   int ttm_range_man_fini(struct ttm_bo_device *bdev,
> >                      unsigned type)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(bdev, type);
> >       struct ttm_range_manager *rman = to_range_manager(man);
> >       struct drm_mm *mm = &rman->mm;
> >       int ret;
> >
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >
> > -     ret = ttm_mem_type_manager_force_list_clean(bdev, man);
> > +     ret = ttm_resource_manager_force_list_clean(bdev, man);
> >       if (ret)
> >               return ret;
> >
> > @@ -163,14 +163,14 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
> >       drm_mm_takedown(mm);
> >       spin_unlock(&rman->lock);
> >
> > -     ttm_mem_type_manager_cleanup(man);
> > +     ttm_resource_manager_cleanup(man);
> >       ttm_set_driver_manager(bdev, type, NULL);
> >       kfree(rman);
> >       return 0;
> >   }
> >   EXPORT_SYMBOL(ttm_range_man_fini);
> >
> > -static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
> > +static void ttm_range_man_debug(struct ttm_resource_manager *man,
> >                            struct drm_printer *printer)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> > @@ -180,7 +180,7 @@ static void ttm_range_man_debug(struct ttm_mem_type_manager *man,
> >       spin_unlock(&rman->lock);
> >   }
> >
> > -static const struct ttm_mem_type_manager_func ttm_range_manager_func = {
> > +static const struct ttm_resource_manager_func ttm_range_manager_func = {
> >       .get_node = ttm_range_man_get_node,
> >       .put_node = ttm_range_man_put_node,
> >       .debug = ttm_range_man_debug
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > index b2f1e7a3b048..7645d67aa6b6 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
> >                                TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
> >                                false, dev_priv->vram_size >> PAGE_SHIFT);
> >   #endif
> > -     ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
> > +     ttm_resource_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
> >       return ret;
> >   }
> >
> > @@ -1189,12 +1189,12 @@ static void vmw_master_drop(struct drm_device *dev,
> >    */
> >   static void __vmw_svga_enable(struct vmw_private *dev_priv)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (!ttm_mem_type_manager_used(man)) {
> > +     if (!ttm_resource_manager_used(man)) {
> >               vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> > -             ttm_mem_type_manager_set_used(man, true);
> > +             ttm_resource_manager_set_used(man, true);
> >       }
> >       spin_unlock(&dev_priv->svga_lock);
> >   }
> > @@ -1220,11 +1220,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)
> >    */
> >   static void __vmw_svga_disable(struct vmw_private *dev_priv)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (ttm_mem_type_manager_used(man)) {
> > -             ttm_mem_type_manager_set_used(man, false);
> > +     if (ttm_resource_manager_used(man)) {
> > +             ttm_resource_manager_set_used(man, false);
> >               vmw_write(dev_priv, SVGA_REG_ENABLE,
> >                         SVGA_REG_ENABLE_HIDE |
> >                         SVGA_REG_ENABLE_ENABLE);
> > @@ -1241,7 +1241,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
> >    */
> >   void vmw_svga_disable(struct vmw_private *dev_priv)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >       /*
> >        * Disabling SVGA will turn off device modesetting capabilities, so
> >        * notify KMS about that so that it doesn't cache atomic state that
> > @@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
> >       vmw_kms_lost_device(dev_priv->dev);
> >       ttm_write_lock(&dev_priv->reservation_sem, false);
> >       spin_lock(&dev_priv->svga_lock);
> > -     if (ttm_mem_type_manager_used(man)) {
> > -             ttm_mem_type_manager_set_used(man, false);
> > +     if (ttm_resource_manager_used(man)) {
> > +             ttm_resource_manager_set_used(man, false);
> >               spin_unlock(&dev_priv->svga_lock);
> >               if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
> >                       DRM_ERROR("Failed evicting VRAM buffers.\n");
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > index ca5037184814..c8fe6e9cf092 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > @@ -37,7 +37,7 @@
> >   #include <linux/kernel.h>
> >
> >   struct vmwgfx_gmrid_man {
> > -     struct ttm_mem_type_manager manager;
> > +     struct ttm_resource_manager manager;
> >       spinlock_t lock;
> >       struct ida gmr_ida;
> >       uint32_t max_gmr_ids;
> > @@ -45,12 +45,12 @@ struct vmwgfx_gmrid_man {
> >       uint32_t used_gmr_pages;
> >   };
> >
> > -static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man)
> > +static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *man)
> >   {
> >       return container_of(man, struct vmwgfx_gmrid_man, manager);
> >   }
> >
> > -static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
> > +static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
> >                                 struct ttm_buffer_object *bo,
> >                                 const struct ttm_place *place,
> >                                 struct ttm_mem_reg *mem)
> > @@ -84,7 +84,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
> >       return -ENOSPC;
> >   }
> >
> > -static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
> > +static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
> >                                  struct ttm_mem_reg *mem)
> >   {
> >       struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> > @@ -98,11 +98,11 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
> >       }
> >   }
> >
> > -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
> > +static const struct ttm_resource_manager_func vmw_gmrid_manager_func;
> >
> >   int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       struct vmwgfx_gmrid_man *gman =
> >               kzalloc(sizeof(*gman), GFP_KERNEL);
> >
> > @@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
> >       man->default_caching = TTM_PL_FLAG_CACHED;
> >       /* TODO: This is most likely not correct */
> >       man->use_tt = true;
> > -     ttm_mem_type_manager_init(man, 0);
> > +     ttm_resource_manager_init(man, 0);
> >       spin_lock_init(&gman->lock);
> >       gman->used_gmr_pages = 0;
> >       ida_init(&gman->gmr_ida);
> > @@ -134,20 +134,20 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
> >               BUG();
> >       }
> >       ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >
> >   void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> >       struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> >
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >
> > -     ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> > +     ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
> >
> > -     ttm_mem_type_manager_cleanup(man);
> > +     ttm_resource_manager_cleanup(man);
> >
> >       ttm_set_driver_manager(&dev_priv->bdev, type, NULL);
> >       ida_destroy(&gman->gmr_ida);
> > @@ -155,7 +155,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
> >
> >   }
> >
> > -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> > +static const struct ttm_resource_manager_func vmw_gmrid_manager_func = {
> >       .get_node = vmw_gmrid_man_get_node,
> >       .put_node = vmw_gmrid_man_put_node,
> >   };
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > index 4110e8309188..6cac7b091205 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > @@ -16,12 +16,12 @@
> >    * @lock: Manager lock.
> >    */
> >   struct vmw_thp_manager {
> > -     struct ttm_mem_type_manager manager;
> > +     struct ttm_resource_manager manager;
> >       struct drm_mm mm;
> >       spinlock_t lock;
> >   };
> >
> > -static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man)
> > +static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
> >   {
> >       return container_of(man, struct vmw_thp_manager, manager);
> >   }
> > @@ -44,7 +44,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
> >       return -ENOSPC;
> >   }
> >
> > -static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
> > +static int vmw_thp_get_node(struct ttm_resource_manager *man,
> >                           struct ttm_buffer_object *bo,
> >                           const struct ttm_place *place,
> >                           struct ttm_mem_reg *mem)
> > @@ -106,7 +106,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
> >
> >
> >
> > -static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
> > +static void vmw_thp_put_node(struct ttm_resource_manager *man,
> >                            struct ttm_mem_reg *mem)
> >   {
> >       struct vmw_thp_manager *rman = to_thp_manager(man);
> > @@ -123,7 +123,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
> >
> >   int vmw_thp_init(struct vmw_private *dev_priv)
> >   {
> > -     struct ttm_mem_type_manager *man;
> > +     struct ttm_resource_manager *man;
> >       struct vmw_thp_manager *rman;
> >
> >       rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> > @@ -134,39 +134,39 @@ int vmw_thp_init(struct vmw_private *dev_priv)
> >       man->available_caching = TTM_PL_FLAG_CACHED;
> >       man->default_caching = TTM_PL_FLAG_CACHED;
> >
> > -     ttm_mem_type_manager_init(man,
> > +     ttm_resource_manager_init(man,
> >                                 dev_priv->vram_size >> PAGE_SHIFT);
> >
> >       drm_mm_init(&rman->mm, 0, man->size);
> >       spin_lock_init(&rman->lock);
> >
> >       ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
> > -     ttm_mem_type_manager_set_used(man, true);
> > +     ttm_resource_manager_set_used(man, true);
> >       return 0;
> >   }
> >
> >   void vmw_thp_fini(struct vmw_private *dev_priv)
> >   {
> > -     struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> > +     struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> >       struct vmw_thp_manager *rman = to_thp_manager(man);
> >       struct drm_mm *mm = &rman->mm;
> >       int ret;
> >
> > -     ttm_mem_type_manager_set_used(man, false);
> > +     ttm_resource_manager_set_used(man, false);
> >
> > -     ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> > +     ret = ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
> >       if (ret)
> >               return;
> >       spin_lock(&rman->lock);
> >       drm_mm_clean(mm);
> >       drm_mm_takedown(mm);
> >       spin_unlock(&rman->lock);
> > -     ttm_mem_type_manager_cleanup(man);
> > +     ttm_resource_manager_cleanup(man);
> >       ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
> >       kfree(rman);
> >   }
> >
> > -static void vmw_thp_debug(struct ttm_mem_type_manager *man,
> > +static void vmw_thp_debug(struct ttm_resource_manager *man,
> >                         struct drm_printer *printer)
> >   {
> >       struct vmw_thp_manager *rman = to_thp_manager(man);
> > @@ -176,7 +176,7 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
> >       spin_unlock(&rman->lock);
> >   }
> >
> > -const struct ttm_mem_type_manager_func vmw_thp_func = {
> > +const struct ttm_resource_manager_func vmw_thp_func = {
> >       .get_node = vmw_thp_get_node,
> >       .put_node = vmw_thp_put_node,
> >       .debug = vmw_thp_debug
> > diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> > index eb465e9ca0c1..15958dff11d2 100644
> > --- a/include/drm/ttm/ttm_bo_api.h
> > +++ b/include/drm/ttm/ttm_bo_api.h
> > @@ -54,7 +54,7 @@ struct ttm_place;
> >
> >   struct ttm_lru_bulk_move;
> >
> > -struct ttm_mem_type_manager;
> > +struct ttm_resource_manager;
> >
> >   /**
> >    * struct ttm_bus_placement
> > @@ -534,14 +534,14 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,
> >                 struct ttm_buffer_object **p_bo);
> >
> >   /**
> > - * ttm_mem_type_manager_init
> > + * ttm_resource_manager_init
> >    *
> >    * @man: memory manager object to init
> >    * @p_size: size managed area in pages.
> >    *
> >    * Initialise core parts of a manager object.
> >    */
> > -void ttm_mem_type_manager_init(struct ttm_mem_type_manager *man,
> > +void ttm_resource_manager_init(struct ttm_resource_manager *man,
> >                              unsigned long p_size);
> >
> >   /**
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index f231fe34e744..d1eff7de4fa3 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -45,11 +45,11 @@
> >
> >   #define TTM_MAX_BO_PRIORITY 4U
> >
> > -struct ttm_mem_type_manager;
> > +struct ttm_resource_manager;
> >
> > -struct ttm_mem_type_manager_func {
> > +struct ttm_resource_manager_func {
> >       /**
> > -      * struct ttm_mem_type_manager member get_node
> > +      * struct ttm_resource_manager member get_node
> >        *
> >        * @man: Pointer to a memory type manager.
> >        * @bo: Pointer to the buffer object we're allocating space for.
> > @@ -69,20 +69,20 @@ struct ttm_mem_type_manager_func {
> >        * the function should return a negative error code.
> >        *
> >        * Note that @mem::mm_node will only be dereferenced by
> > -      * struct ttm_mem_type_manager functions and optionally by the driver,
> > +      * struct ttm_resource_manager functions and optionally by the driver,
> >        * which has knowledge of the underlying type.
> >        *
> >        * This function may not be called from within atomic context, so
> >        * an implementation can and must use either a mutex or a spinlock to
> >        * protect any data structures managing the space.
> >        */
> > -     int  (*get_node)(struct ttm_mem_type_manager *man,
> > +     int  (*get_node)(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> >                        struct ttm_mem_reg *mem);
> >
> >       /**
> > -      * struct ttm_mem_type_manager member put_node
> > +      * struct ttm_resource_manager member put_node
> >        *
> >        * @man: Pointer to a memory type manager.
> >        * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> > @@ -91,11 +91,11 @@ struct ttm_mem_type_manager_func {
> >        * and that are identified by @mem::mm_node and @mem::start. May not
> >        * be called from within atomic context.
> >        */
> > -     void (*put_node)(struct ttm_mem_type_manager *man,
> > +     void (*put_node)(struct ttm_resource_manager *man,
> >                        struct ttm_mem_reg *mem);
> >
> >       /**
> > -      * struct ttm_mem_type_manager member debug
> > +      * struct ttm_resource_manager member debug
> >        *
> >        * @man: Pointer to a memory type manager.
> >        * @printer: Prefix to be used in printout to identify the caller.
> > @@ -104,12 +104,12 @@ struct ttm_mem_type_manager_func {
> >        * type manager to aid debugging of out-of-memory conditions.
> >        * It may not be called from within atomic context.
> >        */
> > -     void (*debug)(struct ttm_mem_type_manager *man,
> > +     void (*debug)(struct ttm_resource_manager *man,
> >                     struct drm_printer *printer);
> >   };
> >
> >   /**
> > - * struct ttm_mem_type_manager
> > + * struct ttm_resource_manager
> >    *
> >    * @use_type: The memory type is enabled.
> >    * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory
> > @@ -136,7 +136,7 @@ struct ttm_mem_type_manager_func {
> >
> >
> >
> > -struct ttm_mem_type_manager {
> > +struct ttm_resource_manager {
> >       /*
> >        * No protection. Constant from start.
> >        */
> > @@ -145,7 +145,7 @@ struct ttm_mem_type_manager {
> >       uint64_t size;
> >       uint32_t available_caching;
> >       uint32_t default_caching;
> > -     const struct ttm_mem_type_manager_func *func;
> > +     const struct ttm_resource_manager_func *func;
> >       struct mutex io_reserve_mutex;
> >       bool use_io_reserve_lru;
> >       spinlock_t move_lock;
> > @@ -390,7 +390,7 @@ extern struct ttm_bo_global {
> >    * struct ttm_bo_device - Buffer object driver device-specific data.
> >    *
> >    * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
> > - * @man: An array of mem_type_managers.
> > + * @man: An array of resource_managers.
> >    * @vma_manager: Address space manager (pointer)
> >    * lru_lock: Spinlock that protects the buffer+device lru lists and
> >    * ddestroy lists.
> > @@ -411,8 +411,8 @@ struct ttm_bo_device {
> >       /*
> >        * access via ttm_manager_type.
> >        */
> > -     struct ttm_mem_type_manager sysman;
> > -     struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
> > +     struct ttm_resource_manager sysman;
> > +     struct ttm_resource_manager *man_drv[TTM_NUM_MEM_TYPES];
> >       /*
> >        * Protected by internal locks.
> >        */
> > @@ -440,7 +440,7 @@ struct ttm_bo_device {
> >       bool no_retry;
> >   };
> >
> > -static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> > +static inline struct ttm_resource_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> >                                                           int mem_type)
> >   {
> >       return bdev->man_drv[mem_type];
> > @@ -448,7 +448,7 @@ static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device
> >
> >   static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
> >                                         int type,
> > -                                       struct ttm_mem_type_manager *manager)
> > +                                       struct ttm_resource_manager *manager)
> >   {
> >       bdev->man_drv[type] = manager;
> >   }
> > @@ -570,8 +570,8 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo);
> >
> >   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo);
> >   void ttm_mem_io_free_vm(struct ttm_buffer_object *bo);
> > -int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible);
> > -void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
> > +int ttm_mem_io_lock(struct ttm_resource_manager *man, bool interruptible);
> > +void ttm_mem_io_unlock(struct ttm_resource_manager *man);
> >
> >   /**
> >    * ttm_bo_reserve:
> > @@ -665,7 +665,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
> >   }
> >
> >   /**
> > - * ttm_mem_type_manager_set_used
> > + * ttm_resource_manager_set_used
> >    *
> >    * @man: A memory manager object.
> >    * @used: usage state to set.
> > @@ -673,13 +673,13 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
> >    * Set the manager in use flag. If disabled the manager is no longer
> >    * used for object placement.
> >    */
> > -static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *man, bool used)
> > +static inline void ttm_resource_manager_set_used(struct ttm_resource_manager *man, bool used)
> >   {
> >       man->use_type = used;
> >   }
> >
> >   /**
> > - * ttm_mem_type_manager_used
> > + * ttm_resource_manager_used
> >    *
> >    * @man: Manager to get used state for
> >    *
> > @@ -687,26 +687,26 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
> >    * Returns:
> >    * true is used, false if not.
> >    */
> > -static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
> > +static inline bool ttm_resource_manager_used(struct ttm_resource_manager *man)
> >   {
> >       return man->use_type;
> >   }
> >
> >   /**
> > - * ttm_mem_type_manager_cleanup
> > + * ttm_resource_manager_cleanup
> >    *
> >    * @man: A memory manager object.
> >    *
> >    * Cleanup the move fences from the memory manager object.
> >    */
> > -static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> > +static inline void ttm_resource_manager_cleanup(struct ttm_resource_manager *man)
> >   {
> >       dma_fence_put(man->move);
> >       man->move = NULL;
> >   }
> >
> >   /*
> > - * ttm_mem_type_manager_force_list_clean
> > + * ttm_resource_manager_force_list_clean
> >    *
> >    * @bdev - device to use
> >    * @man - manager to use
> > @@ -714,8 +714,8 @@ static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man
> >    * Force all the objects out of a memory manager until clean.
> >    * Part of memory manager cleanup sequence.
> >    */
> > -int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev,
> > -                                       struct ttm_mem_type_manager *man);
> > +int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
> > +                                       struct ttm_resource_manager *man);
> >
> >   /*
> >    * ttm_bo_util.c
> > @@ -864,12 +864,12 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
> >                      unsigned type);
> >
> >   /**
> > - * ttm_mem_type_manager_debug
> > + * ttm_resource_manager_debug
> >    *
> >    * @man: manager type to dump.
> >    * @p: printer to use for debug.
> >    */
> > -void ttm_mem_type_manager_debug(struct ttm_mem_type_manager *man,
> > +void ttm_resource_manager_debug(struct ttm_resource_manager *man,
> >                               struct drm_printer *p);
> >
> >   #endif
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource.
  2020-08-04 11:41   ` Christian König
@ 2020-08-05  5:58     ` Ben Skeggs
  0 siblings, 0 replies; 136+ messages in thread
From: Ben Skeggs @ 2020-08-05  5:58 UTC (permalink / raw)
  To: Christian König
  Cc: sroland, ML dri-devel, linux-graphics-maintainer, Ben Skeggs,
	Gerd Hoffmann

On Tue, 4 Aug 2020 at 21:41, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This name better reflects what the object does. I didn't rename
> > all the pointers it seemed too messy.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c   |  6 +--
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  4 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h    |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       | 46 +++++++++----------
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       | 10 ++--
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c        |  2 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  | 12 ++---
> >   drivers/gpu/drm/drm_gem_vram_helper.c         |  6 +--
> >   drivers/gpu/drm/nouveau/nouveau_bo.c          | 28 +++++------
> >   drivers/gpu/drm/nouveau/nouveau_bo.h          | 14 +++---
> >   drivers/gpu/drm/nouveau/nouveau_bo0039.c      |  4 +-
> >   drivers/gpu/drm/nouveau/nouveau_bo5039.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_bo74c1.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_bo85b5.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_bo9039.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_bo90b5.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_boa0b5.c      |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_mem.c         |  8 ++--
> >   drivers/gpu/drm/nouveau/nouveau_mem.h         | 10 ++--
> >   drivers/gpu/drm/nouveau/nouveau_sgdma.c       |  4 +-
> >   drivers/gpu/drm/nouveau/nouveau_ttm.c         |  8 ++--
> >   drivers/gpu/drm/nouveau/nv17_fence.c          |  2 +-
> >   drivers/gpu/drm/nouveau/nv50_fence.c          |  2 +-
> >   drivers/gpu/drm/qxl/qxl_drv.h                 |  2 +-
> >   drivers/gpu/drm/qxl/qxl_ttm.c                 | 14 +++---
> >   drivers/gpu/drm/radeon/radeon.h               |  2 +-
> >   drivers/gpu/drm/radeon/radeon_object.c        |  2 +-
> >   drivers/gpu/drm/radeon/radeon_object.h        |  2 +-
> >   drivers/gpu/drm/radeon/radeon_ttm.c           | 28 +++++------
> >   drivers/gpu/drm/radeon/radeon_vm.c            |  2 +-
> >   drivers/gpu/drm/ttm/ttm_agp_backend.c         |  2 +-
> >   drivers/gpu/drm/ttm/ttm_bo.c                  | 26 +++++------
> >   drivers/gpu/drm/ttm/ttm_bo_util.c             | 46 +++++++++----------
> >   drivers/gpu/drm/ttm/ttm_range_manager.c       |  4 +-
> >   drivers/gpu/drm/ttm/ttm_tt.c                  |  2 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_bo.c            |  4 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  4 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  4 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_resource.c      |  2 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  6 +--
> >   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c    |  8 ++--
> >   include/drm/ttm/ttm_bo_api.h                  | 10 ++--
> >   include/drm/ttm/ttm_bo_driver.h               | 42 ++++++++---------
> >   include/drm/ttm/ttm_tt.h                      | 10 ++--
> >   45 files changed, 202 insertions(+), 202 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > index 8b600b804f34..fb1415488579 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> > @@ -171,7 +171,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
> >    *
> >    * Check if a mem object has already address space allocated.
> >    */
> > -bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
> > +bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem)
> >   {
> >       return mem->mm_node != NULL;
> >   }
> > @@ -189,7 +189,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
> >   static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
> >                             struct ttm_buffer_object *tbo,
> >                             const struct ttm_place *place,
> > -                           struct ttm_mem_reg *mem)
> > +                           struct ttm_resource *mem)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       struct amdgpu_gtt_node *node;
> > @@ -250,7 +250,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
> >    * Free the allocated GTT again.
> >    */
> >   static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
> > -                            struct ttm_mem_reg *mem)
> > +                            struct ttm_resource *mem)
> >   {
> >       struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> >       struct amdgpu_gtt_node *node = mem->mm_node;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > index ce98df5b0c21..43f4966331dd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> > @@ -1268,11 +1268,11 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
> >    */
> >   void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
> >                          bool evict,
> > -                        struct ttm_mem_reg *new_mem)
> > +                        struct ttm_resource *new_mem)
> >   {
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
> >       struct amdgpu_bo *abo;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >
> >       if (!amdgpu_bo_is_amdgpu_bo(bo))
> >               return;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> > index e01e8903741e..5ddb6cf96030 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> > @@ -283,7 +283,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
> >                          uint64_t *flags);
> >   void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
> >                          bool evict,
> > -                        struct ttm_mem_reg *new_mem);
> > +                        struct ttm_resource *new_mem);
> >   void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
> >   int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
> >   void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index cae7eada7215..682172d59f60 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -183,9 +183,9 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
> >    * Assign the memory from new_mem to the memory of the buffer object bo.
> >    */
> >   static void amdgpu_move_null(struct ttm_buffer_object *bo,
> > -                          struct ttm_mem_reg *new_mem)
> > +                          struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >
> >       BUG_ON(old_mem->mm_node != NULL);
> >       *old_mem = *new_mem;
> > @@ -202,7 +202,7 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo,
> >    */
> >   static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
> >                                   struct drm_mm_node *mm_node,
> > -                                 struct ttm_mem_reg *mem)
> > +                                 struct ttm_resource *mem)
> >   {
> >       uint64_t addr = 0;
> >
> > @@ -222,7 +222,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
> >    * @offset: The offset that drm_mm_node is used for finding.
> >    *
> >    */
> > -static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
> > +static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_resource *mem,
> >                                              uint64_t *offset)
> >   {
> >       struct drm_mm_node *mm_node = mem->mm_node;
> > @@ -250,7 +250,7 @@ static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
> >    * the physical address for local memory.
> >    */
> >   static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
> > -                              struct ttm_mem_reg *mem,
> > +                              struct ttm_resource *mem,
> >                                struct drm_mm_node *mm_node,
> >                                unsigned num_pages, uint64_t offset,
> >                                unsigned window, struct amdgpu_ring *ring,
> > @@ -474,8 +474,8 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
> >    */
> >   static int amdgpu_move_blit(struct ttm_buffer_object *bo,
> >                           bool evict, bool no_wait_gpu,
> > -                         struct ttm_mem_reg *new_mem,
> > -                         struct ttm_mem_reg *old_mem)
> > +                         struct ttm_resource *new_mem,
> > +                         struct ttm_resource *old_mem)
> >   {
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
> >       struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
> > @@ -534,10 +534,10 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
> >    */
> >   static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> >                               struct ttm_operation_ctx *ctx,
> > -                             struct ttm_mem_reg *new_mem)
> > +                             struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > -     struct ttm_mem_reg tmp_mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> > +     struct ttm_resource tmp_mem;
> >       struct ttm_place placements;
> >       struct ttm_placement placement;
> >       int r;
> > @@ -590,10 +590,10 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> >    */
> >   static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> >                               struct ttm_operation_ctx *ctx,
> > -                             struct ttm_mem_reg *new_mem)
> > +                             struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > -     struct ttm_mem_reg tmp_mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> > +     struct ttm_resource tmp_mem;
> >       struct ttm_placement placement;
> >       struct ttm_place placements;
> >       int r;
> > @@ -636,7 +636,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> >    * Called by amdgpu_bo_move()
> >    */
> >   static bool amdgpu_mem_visible(struct amdgpu_device *adev,
> > -                            struct ttm_mem_reg *mem)
> > +                            struct ttm_resource *mem)
> >   {
> >       struct drm_mm_node *nodes = mem->mm_node;
> >
> > @@ -646,7 +646,7 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
> >       if (mem->mem_type != TTM_PL_VRAM)
> >               return false;
> >
> > -     /* ttm_mem_reg_ioremap only supports contiguous memory */
> > +     /* ttm_resource_ioremap only supports contiguous memory */
> >       if (nodes->size != mem->num_pages)
> >               return false;
> >
> > @@ -661,11 +661,11 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
> >    */
> >   static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> >                         struct ttm_operation_ctx *ctx,
> > -                       struct ttm_mem_reg *new_mem)
> > +                       struct ttm_resource *new_mem)
> >   {
> >       struct amdgpu_device *adev;
> >       struct amdgpu_bo *abo;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >       int r;
> >
> >       /* Can't move a pinned BO */
> > @@ -747,7 +747,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> >    *
> >    * Called by ttm_mem_io_reserve() ultimately via ttm_bo_vm_fault()
> >    */
> > -static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> > +static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
> >   {
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
> >       struct drm_mm_node *mm_node = mem->mm_node;
> > @@ -771,7 +771,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
> >                       return -EINVAL;
> >               /* Only physically contiguous buffers apply. In a contiguous
> >                * buffer, size of the first mm_node would match the number of
> > -              * pages in ttm_mem_reg.
> > +              * pages in ttm_resource.
> >                */
> >               if (adev->mman.aper_base_kaddr &&
> >                   (mm_node->size == mem->num_pages))
> > @@ -1116,7 +1116,7 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
> >    * This handles binding GTT memory to the device address space.
> >    */
> >   static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
> > -                                struct ttm_mem_reg *bo_mem)
> > +                                struct ttm_resource *bo_mem)
> >   {
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
> >       struct amdgpu_ttm_tt *gtt = (void*)ttm;
> > @@ -1167,7 +1167,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
> >       struct ttm_operation_ctx ctx = { false, false };
> >       struct amdgpu_ttm_tt *gtt = (void*)bo->ttm;
> > -     struct ttm_mem_reg tmp;
> > +     struct ttm_resource tmp;
> >       struct ttm_placement placement;
> >       struct ttm_place placements;
> >       uint64_t addr, flags;
> > @@ -1507,7 +1507,7 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm)
> >    *
> >    * Figure out the flags to use for a VM PDE (Page Directory Entry).
> >    */
> > -uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
> > +uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem)
> >   {
> >       uint64_t flags = 0;
> >
> > @@ -1533,7 +1533,7 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
> >    * Figure out the flags to use for a VM PTE (Page Table Entry).
> >    */
> >   uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
> > -                              struct ttm_mem_reg *mem)
> > +                              struct ttm_resource *mem)
> >   {
> >       uint64_t flags = amdgpu_ttm_tt_pde_flags(ttm, mem);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > index 3db29ae1f802..36b024fd077e 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
> > @@ -63,7 +63,7 @@ struct amdgpu_mman {
> >
> >   struct amdgpu_copy_mem {
> >       struct ttm_buffer_object        *bo;
> > -     struct ttm_mem_reg              *mem;
> > +     struct ttm_resource             *mem;
> >       unsigned long                   offset;
> >   };
> >
> > @@ -72,13 +72,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev);
> >   int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
> >   void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
> >
> > -bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
> > +bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
> >   uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man);
> >   int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);
> >
> >   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo);
> >   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> > -                           struct ttm_mem_reg *mem,
> > +                           struct ttm_resource *mem,
> >                             struct device *dev,
> >                             enum dma_data_direction dir,
> >                             struct sg_table **sgt);
> > @@ -142,9 +142,9 @@ bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm,
> >                                      int *last_invalidated);
> >   bool amdgpu_ttm_tt_is_userptr(struct ttm_tt *ttm);
> >   bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm);
> > -uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_mem_reg *mem);
> > +uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem);
> >   uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
> > -                              struct ttm_mem_reg *mem);
> > +                              struct ttm_resource *mem);
> >
> >   int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > index 71e005cf2952..8bc2253939be 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > @@ -1765,7 +1765,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
> >       struct amdgpu_vm *vm = bo_va->base.vm;
> >       struct amdgpu_bo_va_mapping *mapping;
> >       dma_addr_t *pages_addr = NULL;
> > -     struct ttm_mem_reg *mem;
> > +     struct ttm_resource *mem;
> >       struct drm_mm_node *nodes;
> >       struct dma_fence **last_update;
> >       struct dma_resv *resv;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > index b227e380094f..44f20b30420e 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> > @@ -272,7 +272,7 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,
> >   u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
> >   {
> >       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> > -     struct ttm_mem_reg *mem = &bo->tbo.mem;
> > +     struct ttm_resource *mem = &bo->tbo.mem;
> >       struct drm_mm_node *nodes = mem->mm_node;
> >       unsigned pages = mem->num_pages;
> >       u64 usage;
> > @@ -292,13 +292,13 @@ u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
> >   /**
> >    * amdgpu_vram_mgr_virt_start - update virtual start address
> >    *
> > - * @mem: ttm_mem_reg to update
> > + * @mem: ttm_resource to update
> >    * @node: just allocated node
> >    *
> >    * Calculate a virtual BO start address to easily check if everything is CPU
> >    * accessible.
> >    */
> > -static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
> > +static void amdgpu_vram_mgr_virt_start(struct ttm_resource *mem,
> >                                      struct drm_mm_node *node)
> >   {
> >       unsigned long start;
> > @@ -324,7 +324,7 @@ static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
> >   static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
> >                              struct ttm_buffer_object *tbo,
> >                              const struct ttm_place *place,
> > -                            struct ttm_mem_reg *mem)
> > +                            struct ttm_resource *mem)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >       struct amdgpu_device *adev = mgr->adev;
> > @@ -440,7 +440,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
> >    * Free the allocated VRAM again.
> >    */
> >   static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
> > -                             struct ttm_mem_reg *mem)
> > +                             struct ttm_resource *mem)
> >   {
> >       struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);
> >       struct amdgpu_device *adev = mgr->adev;
> > @@ -480,7 +480,7 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
> >    * Allocate and fill a sg table from a VRAM allocation.
> >    */
> >   int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> > -                           struct ttm_mem_reg *mem,
> > +                           struct ttm_resource *mem,
> >                             struct device *dev,
> >                             enum dma_data_direction dir,
> >                             struct sg_table **sgt)
> > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> > index e3660d00987d..b410930d94a0 100644
> > --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> > @@ -653,7 +653,7 @@ static void drm_gem_vram_bo_driver_evict_flags(struct drm_gem_vram_object *gbo,
> >
> >   static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
> >                                              bool evict,
> > -                                            struct ttm_mem_reg *new_mem)
> > +                                            struct ttm_resource *new_mem)
> >   {
> >       struct ttm_bo_kmap_obj *kmap = &gbo->kmap;
> >
> > @@ -1020,7 +1020,7 @@ static void bo_driver_evict_flags(struct ttm_buffer_object *bo,
> >
> >   static void bo_driver_move_notify(struct ttm_buffer_object *bo,
> >                                 bool evict,
> > -                               struct ttm_mem_reg *new_mem)
> > +                               struct ttm_resource *new_mem)
> >   {
> >       struct drm_gem_vram_object *gbo;
> >
> > @@ -1034,7 +1034,7 @@ static void bo_driver_move_notify(struct ttm_buffer_object *bo,
> >   }
> >
> >   static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
> > -                                 struct ttm_mem_reg *mem)
> > +                                 struct ttm_resource *mem)
> >   {
> >       struct drm_vram_mm *vmm = drm_vram_mm_of_bdev(bdev);
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> > index aebec45b8416..80d22a98950b 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> > @@ -666,7 +666,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
> >
> >   static int
> >   nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
> > -                  struct ttm_mem_reg *reg)
> > +                  struct ttm_resource *reg)
> >   {
> >       struct nouveau_mem *old_mem = nouveau_mem(&bo->mem);
> >       struct nouveau_mem *new_mem = nouveau_mem(reg);
> > @@ -698,7 +698,7 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
> >
> >   static int
> >   nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
> > -                  bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> > +                  bool no_wait_gpu, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> >       struct nouveau_channel *chan = drm->ttm.chan;
> > @@ -708,7 +708,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
> >
> >       /* create temporary vmas for the transfer and attach them to the
> >        * old nvkm_mem node, these will get cleaned up after ttm has
> > -      * destroyed the ttm_mem_reg
> > +      * destroyed the ttm_resource
> >        */
> >       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
> >               ret = nouveau_bo_move_prep(drm, bo, new_reg);
> > @@ -744,7 +744,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
> >               s32 oclass;
> >               int (*exec)(struct nouveau_channel *,
> >                           struct ttm_buffer_object *,
> > -                         struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                         struct ttm_resource *, struct ttm_resource *);
> >               int (*init)(struct nouveau_channel *, u32 handle);
> >       } _methods[] = {
> >               {  "COPY", 4, 0xc5b5, nve0_bo_move_copy, nve0_bo_move_init },
> > @@ -805,7 +805,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
> >
> >   static int
> >   nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
> > -                   bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> > +                   bool no_wait_gpu, struct ttm_resource *new_reg)
> >   {
> >       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
> >       struct ttm_place placement_memtype = {
> > @@ -814,7 +814,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
> >               .flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
> >       };
> >       struct ttm_placement placement;
> > -     struct ttm_mem_reg tmp_reg;
> > +     struct ttm_resource tmp_reg;
> >       int ret;
> >
> >       placement.num_placement = placement.num_busy_placement = 1;
> > @@ -842,7 +842,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
> >
> >   static int
> >   nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
> > -                   bool no_wait_gpu, struct ttm_mem_reg *new_reg)
> > +                   bool no_wait_gpu, struct ttm_resource *new_reg)
> >   {
> >       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
> >       struct ttm_place placement_memtype = {
> > @@ -851,7 +851,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
> >               .flags = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING
> >       };
> >       struct ttm_placement placement;
> > -     struct ttm_mem_reg tmp_reg;
> > +     struct ttm_resource tmp_reg;
> >       int ret;
> >
> >       placement.num_placement = placement.num_busy_placement = 1;
> > @@ -878,7 +878,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
> >
> >   static void
> >   nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
> > -                  struct ttm_mem_reg *new_reg)
> > +                  struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = new_reg ? nouveau_mem(new_reg) : NULL;
> >       struct nouveau_bo *nvbo = nouveau_bo(bo);
> > @@ -910,7 +910,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
> >   }
> >
> >   static int
> > -nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_reg,
> > +nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_resource *new_reg,
> >                  struct nouveau_drm_tile **new_tile)
> >   {
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> > @@ -946,11 +946,11 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
> >   static int
> >   nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
> >               struct ttm_operation_ctx *ctx,
> > -             struct ttm_mem_reg *new_reg)
> > +             struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> >       struct nouveau_bo *nvbo = nouveau_bo(bo);
> > -     struct ttm_mem_reg *old_reg = &bo->mem;
> > +     struct ttm_resource *old_reg = &bo->mem;
> >       struct nouveau_drm_tile *new_tile = NULL;
> >       int ret = 0;
> >
> > @@ -1019,7 +1019,7 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
> >   }
> >
> >   static int
> > -nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
> > +nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
> >   {
> >       struct nouveau_drm *drm = nouveau_bdev(bdev);
> >       struct nvkm_device *device = nvxx_device(&drm->client.device);
> > @@ -1099,7 +1099,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
> >   }
> >
> >   static void
> > -nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
> > +nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_resource *reg)
> >   {
> >       struct nouveau_drm *drm = nouveau_bdev(bdev);
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h
> > index 52489ce7d029..aecb7481df0d 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo.h
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
> > @@ -139,28 +139,28 @@ nouveau_bo_new_pin_map(struct nouveau_cli *cli, u64 size, int align, u32 flags,
> >
> >   int nv04_bo_move_init(struct nouveau_channel *, u32);
> >   int nv04_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nv50_bo_move_init(struct nouveau_channel *, u32);
> >   int nv50_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nv84_bo_move_exec(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nva3_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nvc0_bo_move_init(struct nouveau_channel *, u32);
> >   int nvc0_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nvc0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   int nve0_bo_move_init(struct nouveau_channel *, u32);
> >   int nve0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *,
> > -                   struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                   struct ttm_resource *, struct ttm_resource *);
> >
> >   #define NVBO_WR32_(b,o,dr,f) nouveau_bo_wr32((b), (o)/4 + (dr), (f))
> >   #define NVBO_RD32_(b,o,dr)   nouveau_bo_rd32((b), (o)/4 + (dr))
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> > index bf7ae2cecaf6..7390132129fe 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c
> > @@ -36,7 +36,7 @@
> >
> >   static inline uint32_t
> >   nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
> > -                   struct nouveau_channel *chan, struct ttm_mem_reg *reg)
> > +                   struct nouveau_channel *chan, struct ttm_resource *reg)
> >   {
> >       if (reg->mem_type == TTM_PL_TT)
> >               return NvDmaTT;
> > @@ -45,7 +45,7 @@ nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
> >
> >   int
> >   nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nvif_push *push = chan->chan.push;
> >       u32 src_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, old_reg);
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> > index f9b9b85abe44..4c75c7b3804c 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c
> > @@ -37,7 +37,7 @@
> >
> >   int
> >   nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> >       struct nvif_push *push = chan->chan.push;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> > index 1b5fd78ddcba..ed6c09d67840 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c
> > @@ -34,7 +34,7 @@
> >
> >   int
> >   nv84_bo_move_exec(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> >       struct nvif_push *push = chan->chan.push;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> > index f0df172b029e..dec29b2d8bb2 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c
> > @@ -38,7 +38,7 @@
> >
> >   int
> >   nva3_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> >       struct nvif_push *push = chan->chan.push;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo9039.c b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> > index 52fefb37064c..776b04976cdf 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo9039.c
> > @@ -36,7 +36,7 @@
> >
> >   int
> >   nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nvif_push *push = chan->chan.push;
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> > index 34b79d561c7f..8499f58213e3 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c
> > @@ -31,7 +31,7 @@
> >
> >   int
> >   nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> >       struct nvif_push *push = chan->chan.push;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> > index 394e29012e50..575212472e7a 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c
> > @@ -36,7 +36,7 @@
> >
> >   int
> >   nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
> > -               struct ttm_mem_reg *old_reg, struct ttm_mem_reg *new_reg)
> > +               struct ttm_resource *old_reg, struct ttm_resource *new_reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(old_reg);
> >       struct nvif_push *push = chan->chan.push;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
> > index ae76a5865a5a..f63ac72aa556 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
> > +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
> > @@ -157,7 +157,7 @@ struct nouveau_drm {
> >               atomic_t validate_sequence;
> >               int (*move)(struct nouveau_channel *,
> >                           struct ttm_buffer_object *,
> > -                         struct ttm_mem_reg *, struct ttm_mem_reg *);
> > +                         struct ttm_resource *, struct ttm_resource *);
> >               struct nouveau_channel *chan;
> >               struct nvif_object copy;
> >               int mtrr;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
> > index b1bb542d3115..269d8707acc3 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_mem.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
> > @@ -92,7 +92,7 @@ nouveau_mem_fini(struct nouveau_mem *mem)
> >   }
> >
> >   int
> > -nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
> > +nouveau_mem_host(struct ttm_resource *reg, struct ttm_dma_tt *tt)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> >       struct nouveau_cli *cli = mem->cli;
> > @@ -130,7 +130,7 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
> >   }
> >
> >   int
> > -nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
> > +nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> >       struct nouveau_cli *cli = mem->cli;
> > @@ -173,7 +173,7 @@ nouveau_mem_vram(struct ttm_mem_reg *reg, bool contig, u8 page)
> >   }
> >
> >   void
> > -nouveau_mem_del(struct ttm_mem_reg *reg)
> > +nouveau_mem_del(struct ttm_resource *reg)
> >   {
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> >       nouveau_mem_fini(mem);
> > @@ -183,7 +183,7 @@ nouveau_mem_del(struct ttm_mem_reg *reg)
> >
> >   int
> >   nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
> > -             struct ttm_mem_reg *reg)
> > +             struct ttm_resource *reg)
> >   {
> >       struct nouveau_mem *mem;
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.h b/drivers/gpu/drm/nouveau/nouveau_mem.h
> > index f6d039e73812..3fe1cfed57a1 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_mem.h
> > +++ b/drivers/gpu/drm/nouveau/nouveau_mem.h
> > @@ -7,7 +7,7 @@ struct ttm_dma_tt;
> >   #include <nvif/vmm.h>
> >
> >   static inline struct nouveau_mem *
> > -nouveau_mem(struct ttm_mem_reg *reg)
> > +nouveau_mem(struct ttm_resource *reg)
> >   {
> >       return reg->mm_node;
> >   }
> > @@ -21,10 +21,10 @@ struct nouveau_mem {
> >   };
> >
> >   int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
> > -                 struct ttm_mem_reg *);
> > -void nouveau_mem_del(struct ttm_mem_reg *);
> > -int nouveau_mem_vram(struct ttm_mem_reg *, bool contig, u8 page);
> > -int nouveau_mem_host(struct ttm_mem_reg *, struct ttm_dma_tt *);
> > +                 struct ttm_resource *);
> > +void nouveau_mem_del(struct ttm_resource *);
> > +int nouveau_mem_vram(struct ttm_resource *, bool contig, u8 page);
> > +int nouveau_mem_host(struct ttm_resource *, struct ttm_dma_tt *);
> >   void nouveau_mem_fini(struct nouveau_mem *);
> >   int nouveau_mem_map(struct nouveau_mem *, struct nvif_vmm *, struct nvif_vma *);
> >   #endif
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > index c3ccf661b7a6..eef75c53a197 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> > @@ -26,7 +26,7 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm)
> >   }
> >
> >   static int
> > -nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
> > +nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
> >   {
> >       struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> > @@ -60,7 +60,7 @@ static struct ttm_backend_func nv04_sgdma_backend = {
> >   };
> >
> >   static int
> > -nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
> > +nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_resource *reg)
> >   {
> >       struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
> >       struct nouveau_mem *mem = nouveau_mem(reg);
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > index d6ad0977dc7d..9e96b6ff24cf 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> > @@ -32,7 +32,7 @@
> >   #include <core/tegra.h>
> >
> >   static void
> > -nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_mem_reg *reg)
> > +nouveau_manager_del(struct ttm_resource_manager *man, struct ttm_resource *reg)
> >   {
> >       nouveau_mem_del(reg);
> >   }
> > @@ -41,7 +41,7 @@ static int
> >   nouveau_vram_manager_new(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> > -                      struct ttm_mem_reg *reg)
> > +                      struct ttm_resource *reg)
> >   {
> >       struct nouveau_bo *nvbo = nouveau_bo(bo);
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> > @@ -72,7 +72,7 @@ static int
> >   nouveau_gart_manager_new(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> > -                      struct ttm_mem_reg *reg)
> > +                      struct ttm_resource *reg)
> >   {
> >       struct nouveau_bo *nvbo = nouveau_bo(bo);
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> > @@ -95,7 +95,7 @@ static int
> >   nv04_gart_manager_new(struct ttm_resource_manager *man,
> >                     struct ttm_buffer_object *bo,
> >                     const struct ttm_place *place,
> > -                   struct ttm_mem_reg *reg)
> > +                   struct ttm_resource *reg)
> >   {
> >       struct nouveau_bo *nvbo = nouveau_bo(bo);
> >       struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
> > diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
> > index cd1e87a528a4..6b697ee6bc0e 100644
> > --- a/drivers/gpu/drm/nouveau/nv17_fence.c
> > +++ b/drivers/gpu/drm/nouveau/nv17_fence.c
> > @@ -78,7 +78,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
> >   {
> >       struct nv10_fence_priv *priv = chan->drm->fence;
> >       struct nv10_fence_chan *fctx;
> > -     struct ttm_mem_reg *reg = &priv->bo->bo.mem;
> > +     struct ttm_resource *reg = &priv->bo->bo.mem;
> >       u32 start = reg->start * PAGE_SIZE;
> >       u32 limit = start + reg->size - 1;
> >       int ret = 0;
> > diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
> > index ebb740686b44..49b46f51073c 100644
> > --- a/drivers/gpu/drm/nouveau/nv50_fence.c
> > +++ b/drivers/gpu/drm/nouveau/nv50_fence.c
> > @@ -37,7 +37,7 @@ nv50_fence_context_new(struct nouveau_channel *chan)
> >   {
> >       struct nv10_fence_priv *priv = chan->drm->fence;
> >       struct nv10_fence_chan *fctx;
> > -     struct ttm_mem_reg *reg = &priv->bo->bo.mem;
> > +     struct ttm_resource *reg = &priv->bo->bo.mem;
> >       u32 start = reg->start * PAGE_SIZE;
> >       u32 limit = start + reg->size - 1;
> >       int ret;
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > index 9691449aefdb..aae90a9ee1db 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > @@ -350,7 +350,7 @@ int qxl_mode_dumb_mmap(struct drm_file *filp,
> >   int qxl_ttm_init(struct qxl_device *qdev);
> >   void qxl_ttm_fini(struct qxl_device *qdev);
> >   int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
> > -                        struct ttm_mem_reg *mem);
> > +                        struct ttm_resource *mem);
> >
> >   /* qxl image */
> >
> > diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> > index 1c06fe780815..dc31f3fea33c 100644
> > --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> > +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> > @@ -71,7 +71,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
> >   }
> >
> >   int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
> > -                        struct ttm_mem_reg *mem)
> > +                        struct ttm_resource *mem)
> >   {
> >       struct qxl_device *qdev = qxl_get_qdev(bdev);
> >
> > @@ -111,7 +111,7 @@ struct qxl_ttm_tt {
> >   };
> >
> >   static int qxl_ttm_backend_bind(struct ttm_tt *ttm,
> > -                             struct ttm_mem_reg *bo_mem)
> > +                             struct ttm_resource *bo_mem)
> >   {
> >       struct qxl_ttm_tt *gtt = (void *)ttm;
> >
> > @@ -163,9 +163,9 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
> >   }
> >
> >   static void qxl_move_null(struct ttm_buffer_object *bo,
> > -                          struct ttm_mem_reg *new_mem)
> > +                          struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >
> >       BUG_ON(old_mem->mm_node != NULL);
> >       *old_mem = *new_mem;
> > @@ -174,9 +174,9 @@ static void qxl_move_null(struct ttm_buffer_object *bo,
> >
> >   static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
> >                      struct ttm_operation_ctx *ctx,
> > -                    struct ttm_mem_reg *new_mem)
> > +                    struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >       int ret;
> >
> >       ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
> > @@ -192,7 +192,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
> >
> >   static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
> >                              bool evict,
> > -                            struct ttm_mem_reg *new_mem)
> > +                            struct ttm_resource *new_mem)
> >   {
> >       struct qxl_bo *qbo;
> >       struct qxl_device *qdev;
> > diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> > index b7c3fb2bfb54..cc4f58d16589 100644
> > --- a/drivers/gpu/drm/radeon/radeon.h
> > +++ b/drivers/gpu/drm/radeon/radeon.h
> > @@ -2857,7 +2857,7 @@ int radeon_vm_clear_invalids(struct radeon_device *rdev,
> >                            struct radeon_vm *vm);
> >   int radeon_vm_bo_update(struct radeon_device *rdev,
> >                       struct radeon_bo_va *bo_va,
> > -                     struct ttm_mem_reg *mem);
> > +                     struct ttm_resource *mem);
> >   void radeon_vm_bo_invalidate(struct radeon_device *rdev,
> >                            struct radeon_bo *bo);
> >   struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
> > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > index f3dee01250da..bb7582afd803 100644
> > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > @@ -775,7 +775,7 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
> >
> >   void radeon_bo_move_notify(struct ttm_buffer_object *bo,
> >                          bool evict,
> > -                        struct ttm_mem_reg *new_mem)
> > +                        struct ttm_resource *new_mem)
> >   {
> >       struct radeon_bo *rbo;
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
> > index 60275b822f79..44b47241ee42 100644
> > --- a/drivers/gpu/drm/radeon/radeon_object.h
> > +++ b/drivers/gpu/drm/radeon/radeon_object.h
> > @@ -165,7 +165,7 @@ extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
> >                               bool force_drop);
> >   extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
> >                                 bool evict,
> > -                               struct ttm_mem_reg *new_mem);
> > +                               struct ttm_resource *new_mem);
> >   extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
> >   extern int radeon_bo_get_surface_reg(struct radeon_bo *bo);
> >   extern void radeon_bo_fence(struct radeon_bo *bo, struct radeon_fence *fence,
> > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> > index 05b5f29f2b61..a068d6960c23 100644
> > --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> > @@ -166,9 +166,9 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
> >   }
> >
> >   static void radeon_move_null(struct ttm_buffer_object *bo,
> > -                          struct ttm_mem_reg *new_mem)
> > +                          struct ttm_resource *new_mem)
> >   {
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >
> >       BUG_ON(old_mem->mm_node != NULL);
> >       *old_mem = *new_mem;
> > @@ -177,8 +177,8 @@ static void radeon_move_null(struct ttm_buffer_object *bo,
> >
> >   static int radeon_move_blit(struct ttm_buffer_object *bo,
> >                       bool evict, bool no_wait_gpu,
> > -                     struct ttm_mem_reg *new_mem,
> > -                     struct ttm_mem_reg *old_mem)
> > +                     struct ttm_resource *new_mem,
> > +                     struct ttm_resource *old_mem)
> >   {
> >       struct radeon_device *rdev;
> >       uint64_t old_start, new_start;
> > @@ -233,11 +233,11 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
> >   static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
> >                               bool evict, bool interruptible,
> >                               bool no_wait_gpu,
> > -                             struct ttm_mem_reg *new_mem)
> > +                             struct ttm_resource *new_mem)
> >   {
> >       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > -     struct ttm_mem_reg tmp_mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> > +     struct ttm_resource tmp_mem;
> >       struct ttm_place placements;
> >       struct ttm_placement placement;
> >       int r;
> > @@ -278,11 +278,11 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
> >   static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
> >                               bool evict, bool interruptible,
> >                               bool no_wait_gpu,
> > -                             struct ttm_mem_reg *new_mem)
> > +                             struct ttm_resource *new_mem)
> >   {
> >       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > -     struct ttm_mem_reg tmp_mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> > +     struct ttm_resource tmp_mem;
> >       struct ttm_placement placement;
> >       struct ttm_place placements;
> >       int r;
> > @@ -315,11 +315,11 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
> >
> >   static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
> >                         struct ttm_operation_ctx *ctx,
> > -                       struct ttm_mem_reg *new_mem)
> > +                       struct ttm_resource *new_mem)
> >   {
> >       struct radeon_device *rdev;
> >       struct radeon_bo *rbo;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >       int r;
> >
> >       r = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
> > @@ -376,7 +376,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
> >       return 0;
> >   }
> >
> > -static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> > +static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
> >   {
> >       struct radeon_device *rdev = radeon_get_rdev(bdev);
> >
> > @@ -544,7 +544,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
> >   }
> >
> >   static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
> > -                                struct ttm_mem_reg *bo_mem)
> > +                                struct ttm_resource *bo_mem)
> >   {
> >       struct radeon_ttm_tt *gtt = (void*)ttm;
> >       uint32_t flags = RADEON_GART_PAGE_VALID | RADEON_GART_PAGE_READ |
> > diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
> > index f60fae0aed11..71e2c3785ab9 100644
> > --- a/drivers/gpu/drm/radeon/radeon_vm.c
> > +++ b/drivers/gpu/drm/radeon/radeon_vm.c
> > @@ -911,7 +911,7 @@ static void radeon_vm_fence_pts(struct radeon_vm *vm,
> >    */
> >   int radeon_vm_bo_update(struct radeon_device *rdev,
> >                       struct radeon_bo_va *bo_va,
> > -                     struct ttm_mem_reg *mem)
> > +                     struct ttm_resource *mem)
> >   {
> >       struct radeon_vm *vm = bo_va->vm;
> >       struct radeon_ib ib;
> > diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
> > index 38f1351140e2..09fe80e215c5 100644
> > --- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
> > +++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
> > @@ -48,7 +48,7 @@ struct ttm_agp_backend {
> >       struct agp_bridge_data *bridge;
> >   };
> >
> > -static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
> > +static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
> >   {
> >       struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
> >       struct page *dummy_read_page = ttm_bo_glob.dummy_read_page;
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 48840a3cf4c4..1ea5de976ec3 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -145,7 +145,7 @@ static inline uint32_t ttm_bo_type_flags(unsigned type)
> >   }
> >
> >   static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
> > -                               struct ttm_mem_reg *mem)
> > +                               struct ttm_resource *mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       struct ttm_resource_manager *man;
> > @@ -268,7 +268,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
> >   EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
> >
> >   static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> > -                               struct ttm_mem_reg *mem, bool evict,
> > +                               struct ttm_resource *mem, bool evict,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > @@ -642,7 +642,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
> >                       struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_reg evict_mem;
> > +     struct ttm_resource evict_mem;
> >       struct ttm_placement placement;
> >       int ret = 0;
> >
> > @@ -841,7 +841,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> >
> >   static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >                         const struct ttm_place *place,
> > -                       struct ttm_mem_reg *mem)
> > +                       struct ttm_resource *mem)
> >   {
> >       struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> > @@ -852,7 +852,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,
> >       return man->func->get_node(man, bo, place, mem);
> >   }
> >
> > -void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem)
> > +void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem)
> >   {
> >       struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, mem->mem_type);
> >
> > @@ -870,7 +870,7 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
> >    */
> >   static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
> >                                struct ttm_resource_manager *man,
> > -                              struct ttm_mem_reg *mem,
> > +                              struct ttm_resource *mem,
> >                                bool no_wait_gpu)
> >   {
> >       struct dma_fence *fence;
> > @@ -907,7 +907,7 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
> >    */
> >   static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
> >                                 const struct ttm_place *place,
> > -                               struct ttm_mem_reg *mem,
> > +                               struct ttm_resource *mem,
> >                                 struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > @@ -988,7 +988,7 @@ static bool ttm_bo_mt_compatible(struct ttm_resource_manager *man,
> >    */
> >   static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >                               const struct ttm_place *place,
> > -                             struct ttm_mem_reg *mem,
> > +                             struct ttm_resource *mem,
> >                               struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > @@ -1036,7 +1036,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> >    */
> >   int ttm_bo_mem_space(struct ttm_buffer_object *bo,
> >                       struct ttm_placement *placement,
> > -                     struct ttm_mem_reg *mem,
> > +                     struct ttm_resource *mem,
> >                       struct ttm_operation_ctx *ctx)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > @@ -1114,7 +1114,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
> >                             struct ttm_operation_ctx *ctx)
> >   {
> >       int ret = 0;
> > -     struct ttm_mem_reg mem;
> > +     struct ttm_resource mem;
> >
> >       dma_resv_assert_held(bo->base.resv);
> >
> > @@ -1140,7 +1140,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
> >
> >   static bool ttm_bo_places_compat(const struct ttm_place *places,
> >                                unsigned num_placement,
> > -                              struct ttm_mem_reg *mem,
> > +                              struct ttm_resource *mem,
> >                                uint32_t *new_flags)
> >   {
> >       unsigned i;
> > @@ -1163,7 +1163,7 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
> >   }
> >
> >   bool ttm_bo_mem_compat(struct ttm_placement *placement,
> > -                    struct ttm_mem_reg *mem,
> > +                    struct ttm_resource *mem,
> >                      uint32_t *new_flags)
> >   {
> >       if (ttm_bo_places_compat(placement->placement, placement->num_placement,
> > @@ -1732,7 +1732,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
> >       if (bo->mem.mem_type != TTM_PL_SYSTEM ||
> >           bo->ttm->caching_state != tt_cached) {
> >               struct ttm_operation_ctx ctx = { false, false };
> > -             struct ttm_mem_reg evict_mem;
> > +             struct ttm_resource evict_mem;
> >
> >               evict_mem = bo->mem;
> >               evict_mem.mm_node = NULL;
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > index 8ef0de8e36c5..496158acd5b9 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> > @@ -52,10 +52,10 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
> >
> >   int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> >                  struct ttm_operation_ctx *ctx,
> > -                 struct ttm_mem_reg *new_mem)
> > +                 struct ttm_resource *new_mem)
> >   {
> >       struct ttm_tt *ttm = bo->ttm;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >       int ret;
> >
> >       if (old_mem->mem_type != TTM_PL_SYSTEM) {
> > @@ -127,7 +127,7 @@ static int ttm_mem_io_evict(struct ttm_resource_manager *man)
> >   }
> >
> >   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_reg *mem)
> > +                    struct ttm_resource *mem)
> >   {
> >       struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> >       int ret;
> > @@ -149,7 +149,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> >   }
> >
> >   void ttm_mem_io_free(struct ttm_bo_device *bdev,
> > -                  struct ttm_mem_reg *mem)
> > +                  struct ttm_resource *mem)
> >   {
> >       if (--mem->bus.io_reserved_count)
> >               return;
> > @@ -163,7 +163,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
> >   int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
> >   {
> >       struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> > -     struct ttm_mem_reg *mem = &bo->mem;
> > +     struct ttm_resource *mem = &bo->mem;
> >       int ret;
> >
> >       if (mem->bus.io_reserved_vm)
> > @@ -181,7 +181,7 @@ int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo)
> >
> >   void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
> >   {
> > -     struct ttm_mem_reg *mem = &bo->mem;
> > +     struct ttm_resource *mem = &bo->mem;
> >
> >       if (!mem->bus.io_reserved_vm)
> >               return;
> > @@ -191,8 +191,8 @@ void ttm_mem_io_free_vm(struct ttm_buffer_object *bo)
> >       ttm_mem_io_free(bo->bdev, mem);
> >   }
> >
> > -static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
> > -                            struct ttm_mem_reg *mem,
> > +static int ttm_resource_ioremap(struct ttm_bo_device *bdev,
> > +                            struct ttm_resource *mem,
> >                              void **virtual)
> >   {
> >       struct ttm_resource_manager *man = ttm_manager_type(bdev, mem->mem_type);
> > @@ -226,8 +226,8 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,
> >       return 0;
> >   }
> >
> > -static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev,
> > -                             struct ttm_mem_reg *mem,
> > +static void ttm_resource_iounmap(struct ttm_bo_device *bdev,
> > +                             struct ttm_resource *mem,
> >                               void *virtual)
> >   {
> >       struct ttm_resource_manager *man;
> > @@ -300,13 +300,13 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
> >
> >   int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >                      struct ttm_operation_ctx *ctx,
> > -                    struct ttm_mem_reg *new_mem)
> > +                    struct ttm_resource *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> >       struct ttm_tt *ttm = bo->ttm;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > -     struct ttm_mem_reg old_copy = *old_mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> > +     struct ttm_resource old_copy = *old_mem;
> >       void *old_iomap;
> >       void *new_iomap;
> >       int ret;
> > @@ -319,10 +319,10 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >       if (ret)
> >               return ret;
> >
> > -     ret = ttm_mem_reg_ioremap(bdev, old_mem, &old_iomap);
> > +     ret = ttm_resource_ioremap(bdev, old_mem, &old_iomap);
> >       if (ret)
> >               return ret;
> > -     ret = ttm_mem_reg_ioremap(bdev, new_mem, &new_iomap);
> > +     ret = ttm_resource_ioremap(bdev, new_mem, &new_iomap);
> >       if (ret)
> >               goto out;
> >
> > @@ -390,9 +390,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >       }
> >
> >   out1:
> > -     ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
> > +     ttm_resource_iounmap(bdev, old_mem, new_iomap);
> >   out:
> > -     ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
> > +     ttm_resource_iounmap(bdev, &old_copy, old_iomap);
> >
> >       /*
> >        * On error, keep the mm node!
> > @@ -502,7 +502,7 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo,
> >                         unsigned long size,
> >                         struct ttm_bo_kmap_obj *map)
> >   {
> > -     struct ttm_mem_reg *mem = &bo->mem;
> > +     struct ttm_resource *mem = &bo->mem;
> >
> >       if (bo->mem.bus.addr) {
> >               map->bo_kmap_type = ttm_bo_map_premapped;
> > @@ -526,7 +526,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
> >                          unsigned long num_pages,
> >                          struct ttm_bo_kmap_obj *map)
> >   {
> > -     struct ttm_mem_reg *mem = &bo->mem;
> > +     struct ttm_resource *mem = &bo->mem;
> >       struct ttm_operation_ctx ctx = {
> >               .interruptible = false,
> >               .no_wait_gpu = false
> > @@ -631,11 +631,11 @@ EXPORT_SYMBOL(ttm_bo_kunmap);
> >   int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
> >                             struct dma_fence *fence,
> >                             bool evict,
> > -                           struct ttm_mem_reg *new_mem)
> > +                           struct ttm_resource *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> >       struct ttm_resource_manager *man = ttm_manager_type(bdev, new_mem->mem_type);
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >       int ret;
> >       struct ttm_buffer_object *ghost_obj;
> >
> > @@ -692,10 +692,10 @@ EXPORT_SYMBOL(ttm_bo_move_accel_cleanup);
> >
> >   int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
> >                        struct dma_fence *fence, bool evict,
> > -                      struct ttm_mem_reg *new_mem)
> > +                      struct ttm_resource *new_mem)
> >   {
> >       struct ttm_bo_device *bdev = bo->bdev;
> > -     struct ttm_mem_reg *old_mem = &bo->mem;
> > +     struct ttm_resource *old_mem = &bo->mem;
> >
> >       struct ttm_resource_manager *from = ttm_manager_type(bdev, old_mem->mem_type);
> >       struct ttm_resource_manager *to = ttm_manager_type(bdev, new_mem->mem_type);
> > diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > index 22de9f209449..7442d811f867 100644
> > --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> > +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> > @@ -57,7 +57,7 @@ static inline struct ttm_range_manager *to_range_manager(struct ttm_resource_man
> >   static int ttm_range_man_get_node(struct ttm_resource_manager *man,
> >                                 struct ttm_buffer_object *bo,
> >                                 const struct ttm_place *place,
> > -                               struct ttm_mem_reg *mem)
> > +                               struct ttm_resource *mem)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> >       struct drm_mm *mm = &rman->mm;
> > @@ -96,7 +96,7 @@ static int ttm_range_man_get_node(struct ttm_resource_manager *man,
> >   }
> >
> >   static void ttm_range_man_put_node(struct ttm_resource_manager *man,
> > -                                struct ttm_mem_reg *mem)
> > +                                struct ttm_resource *mem)
> >   {
> >       struct ttm_range_manager *rman = to_range_manager(man);
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> > index 9d1c7177384c..1ccf1ef050d6 100644
> > --- a/drivers/gpu/drm/ttm/ttm_tt.c
> > +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> > @@ -316,7 +316,7 @@ void ttm_tt_unbind(struct ttm_tt *ttm)
> >       }
> >   }
> >
> > -int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
> > +int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
> >               struct ttm_operation_ctx *ctx)
> >   {
> >       int ret = 0;
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> > index 1e59c019affa..3229451d0706 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
> > @@ -1135,14 +1135,14 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
> >    * vmw_bo_move_notify - TTM move_notify_callback
> >    *
> >    * @bo: The TTM buffer object about to move.
> > - * @mem: The struct ttm_mem_reg indicating to what memory
> > + * @mem: The struct ttm_resource indicating to what memory
> >    *       region the move is taking place.
> >    *
> >    * Detaches cached maps and device bindings that require that the
> >    * buffer doesn't move.
> >    */
> >   void vmw_bo_move_notify(struct ttm_buffer_object *bo,
> > -                     struct ttm_mem_reg *mem)
> > +                     struct ttm_resource *mem)
> >   {
> >       struct vmw_buffer_object *vbo;
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> > index aa763c6b1146..871ad738dadb 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> > @@ -793,7 +793,7 @@ extern void vmw_resource_unreserve(struct vmw_resource *res,
> >                                  struct vmw_buffer_object *new_backup,
> >                                  unsigned long new_backup_offset);
> >   extern void vmw_query_move_notify(struct ttm_buffer_object *bo,
> > -                               struct ttm_mem_reg *mem);
> > +                               struct ttm_resource *mem);
> >   extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob);
> >   extern void vmw_resource_evict_all(struct vmw_private *dev_priv);
> >   extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo);
> > @@ -878,7 +878,7 @@ extern void vmw_bo_fence_single(struct ttm_buffer_object *bo,
> >   extern void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo);
> >   extern void vmw_bo_unmap(struct vmw_buffer_object *vbo);
> >   extern void vmw_bo_move_notify(struct ttm_buffer_object *bo,
> > -                            struct ttm_mem_reg *mem);
> > +                            struct ttm_resource *mem);
> >   extern void vmw_bo_swap_notify(struct ttm_buffer_object *bo);
> >   extern struct vmw_buffer_object *
> >   vmw_user_bo_noref_lookup(struct ttm_object_file *tfile, u32 handle);
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > index c8fe6e9cf092..3fea7a6c7cfa 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> > @@ -53,7 +53,7 @@ static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *ma
> >   static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
> >                                 struct ttm_buffer_object *bo,
> >                                 const struct ttm_place *place,
> > -                               struct ttm_mem_reg *mem)
> > +                               struct ttm_resource *mem)
> >   {
> >       struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> >       int id;
> > @@ -85,7 +85,7 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
> >   }
> >
> >   static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
> > -                                struct ttm_mem_reg *mem)
> > +                                struct ttm_resource *mem)
> >   {
> >       struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> > index c8441030637a..c0f156078dda 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> > @@ -855,7 +855,7 @@ int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob)
> >    * states from the device.
> >    */
> >   void vmw_query_move_notify(struct ttm_buffer_object *bo,
> > -                        struct ttm_mem_reg *mem)
> > +                        struct ttm_resource *mem)
> >   {
> >       struct vmw_buffer_object *dx_query_mob;
> >       struct ttm_bo_device *bdev = bo->bdev;
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > index 6cac7b091205..f594e2e6ab7e 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> > @@ -29,7 +29,7 @@ static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
> >   static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
> >                                 unsigned long align_pages,
> >                                 const struct ttm_place *place,
> > -                               struct ttm_mem_reg *mem,
> > +                               struct ttm_resource *mem,
> >                                 unsigned long lpfn,
> >                                 enum drm_mm_insert_mode mode)
> >   {
> > @@ -47,7 +47,7 @@ static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
> >   static int vmw_thp_get_node(struct ttm_resource_manager *man,
> >                           struct ttm_buffer_object *bo,
> >                           const struct ttm_place *place,
> > -                         struct ttm_mem_reg *mem)
> > +                         struct ttm_resource *mem)
> >   {
> >       struct vmw_thp_manager *rman = to_thp_manager(man);
> >       struct drm_mm *mm = &rman->mm;
> > @@ -107,7 +107,7 @@ static int vmw_thp_get_node(struct ttm_resource_manager *man,
> >
> >
> >   static void vmw_thp_put_node(struct ttm_resource_manager *man,
> > -                          struct ttm_mem_reg *mem)
> > +                          struct ttm_resource *mem)
> >   {
> >       struct vmw_thp_manager *rman = to_thp_manager(man);
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> > index 3a141a08d4bd..7247347a9bca 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> > @@ -539,7 +539,7 @@ const struct vmw_sg_table *vmw_bo_sg_table(struct ttm_buffer_object *bo)
> >   }
> >
> >
> > -static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
> > +static int vmw_ttm_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
> >   {
> >       struct vmw_ttm_tt *vmw_be =
> >               container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm);
> > @@ -711,7 +711,7 @@ static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp)
> >       return vmw_user_bo_verify_access(bo, tfile);
> >   }
> >
> > -static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
> > +static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
> >   {
> >       struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev);
> >
> > @@ -741,7 +741,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
> >    * vmw_move_notify - TTM move_notify_callback
> >    *
> >    * @bo: The TTM buffer object about to move.
> > - * @mem: The struct ttm_mem_reg indicating to what memory
> > + * @mem: The struct ttm_resource indicating to what memory
> >    *       region the move is taking place.
> >    *
> >    * Calls move_notify for all subsystems needing it.
> > @@ -749,7 +749,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
> >    */
> >   static void vmw_move_notify(struct ttm_buffer_object *bo,
> >                           bool evict,
> > -                         struct ttm_mem_reg *mem)
> > +                         struct ttm_resource *mem)
> >   {
> >       vmw_bo_move_notify(bo, mem);
> >       vmw_query_move_notify(bo, mem);
> > diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> > index 15958dff11d2..247d4f803443 100644
> > --- a/include/drm/ttm/ttm_bo_api.h
> > +++ b/include/drm/ttm/ttm_bo_api.h
> > @@ -81,7 +81,7 @@ struct ttm_bus_placement {
> >
> >
> >   /**
> > - * struct ttm_mem_reg
> > + * struct ttm_resource
> >    *
> >    * @mm_node: Memory manager node.
> >    * @size: Requested size of memory region.
> > @@ -94,7 +94,7 @@ struct ttm_bus_placement {
> >    * buffer object.
> >    */
> >
> > -struct ttm_mem_reg {
> > +struct ttm_resource {
> >       void *mm_node;
> >       unsigned long start;
> >       unsigned long size;
> > @@ -187,7 +187,7 @@ struct ttm_buffer_object {
> >        * Members protected by the bo::resv::reserved lock.
> >        */
> >
> > -     struct ttm_mem_reg mem;
> > +     struct ttm_resource mem;
> >       struct file *persistent_swap_storage;
> >       struct ttm_tt *ttm;
> >       bool evicted;
> > @@ -316,12 +316,12 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait);
> >    * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo
> >    *
> >    * @placement:  Return immediately if buffer is busy.
> > - * @mem:  The struct ttm_mem_reg indicating the region where the bo resides
> > + * @mem:  The struct ttm_resource indicating the region where the bo resides
> >    * @new_flags: Describes compatible placement found
> >    *
> >    * Returns true if the placement is compatible
> >    */
> > -bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_mem_reg *mem,
> > +bool ttm_bo_mem_compat(struct ttm_placement *placement, struct ttm_resource *mem,
> >                      uint32_t *new_flags);
> >
> >   /**
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index d1eff7de4fa3..576c91c85a6b 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -55,7 +55,7 @@ struct ttm_resource_manager_func {
> >        * @bo: Pointer to the buffer object we're allocating space for.
> >        * @placement: Placement details.
> >        * @flags: Additional placement flags.
> > -      * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> > +      * @mem: Pointer to a struct ttm_resource to be filled in.
> >        *
> >        * This function should allocate space in the memory type managed
> >        * by @man. Placement details if
> > @@ -79,20 +79,20 @@ struct ttm_resource_manager_func {
> >       int  (*get_node)(struct ttm_resource_manager *man,
> >                        struct ttm_buffer_object *bo,
> >                        const struct ttm_place *place,
> > -                      struct ttm_mem_reg *mem);
> > +                      struct ttm_resource *mem);
> >
> >       /**
> >        * struct ttm_resource_manager member put_node
> >        *
> >        * @man: Pointer to a memory type manager.
> > -      * @mem: Pointer to a struct ttm_mem_reg to be filled in.
> > +      * @mem: Pointer to a struct ttm_resource to be filled in.
> >        *
> >        * This function frees memory type resources previously allocated
> >        * and that are identified by @mem::mm_node and @mem::start. May not
> >        * be called from within atomic context.
> >        */
> >       void (*put_node)(struct ttm_resource_manager *man,
> > -                      struct ttm_mem_reg *mem);
> > +                      struct ttm_resource *mem);
> >
> >       /**
> >        * struct ttm_resource_manager member debug
> > @@ -251,7 +251,7 @@ struct ttm_bo_driver {
> >        */
> >       int (*move)(struct ttm_buffer_object *bo, bool evict,
> >                   struct ttm_operation_ctx *ctx,
> > -                 struct ttm_mem_reg *new_mem);
> > +                 struct ttm_resource *new_mem);
> >
> >       /**
> >        * struct ttm_bo_driver_member verify_access
> > @@ -277,7 +277,7 @@ struct ttm_bo_driver {
> >        */
> >       void (*move_notify)(struct ttm_buffer_object *bo,
> >                           bool evict,
> > -                         struct ttm_mem_reg *new_mem);
> > +                         struct ttm_resource *new_mem);
> >       /* notify the driver we are taking a fault on this BO
> >        * and have reserved it */
> >       int (*fault_reserve_notify)(struct ttm_buffer_object *bo);
> > @@ -294,9 +294,9 @@ struct ttm_bo_driver {
> >        * are balanced.
> >        */
> >       int (*io_mem_reserve)(struct ttm_bo_device *bdev,
> > -                           struct ttm_mem_reg *mem);
> > +                           struct ttm_resource *mem);
> >       void (*io_mem_free)(struct ttm_bo_device *bdev,
> > -                         struct ttm_mem_reg *mem);
> > +                         struct ttm_resource *mem);
> >
> >       /**
> >        * Return the pfn for a given page_offset inside the BO.
> > @@ -508,7 +508,7 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
> >    * @bo: Pointer to a struct ttm_buffer_object. the data of which
> >    * we want to allocate space for.
> >    * @proposed_placement: Proposed new placement for the buffer object.
> > - * @mem: A struct ttm_mem_reg.
> > + * @mem: A struct ttm_resource.
> >    * @interruptible: Sleep interruptible when sliping.
> >    * @no_wait_gpu: Return immediately if the GPU is busy.
> >    *
> > @@ -523,10 +523,10 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
> >    */
> >   int ttm_bo_mem_space(struct ttm_buffer_object *bo,
> >                    struct ttm_placement *placement,
> > -                  struct ttm_mem_reg *mem,
> > +                  struct ttm_resource *mem,
> >                    struct ttm_operation_ctx *ctx);
> >
> > -void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);
> > +void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_resource *mem);
> >
> >   int ttm_bo_device_release(struct ttm_bo_device *bdev);
> >
> > @@ -722,16 +722,16 @@ int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
> >    */
> >
> >   int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> > -                    struct ttm_mem_reg *mem);
> > +                    struct ttm_resource *mem);
> >   void ttm_mem_io_free(struct ttm_bo_device *bdev,
> > -                  struct ttm_mem_reg *mem);
> > +                  struct ttm_resource *mem);
> >   /**
> >    * ttm_bo_move_ttm
> >    *
> >    * @bo: A pointer to a struct ttm_buffer_object.
> >    * @interruptible: Sleep interruptible if waiting.
> >    * @no_wait_gpu: Return immediately if the GPU is busy.
> > - * @new_mem: struct ttm_mem_reg indicating where to move.
> > + * @new_mem: struct ttm_resource indicating where to move.
> >    *
> >    * Optimized move function for a buffer object with both old and
> >    * new placement backed by a TTM. The function will, if successful,
> > @@ -745,7 +745,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
> >
> >   int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> >                   struct ttm_operation_ctx *ctx,
> > -                 struct ttm_mem_reg *new_mem);
> > +                 struct ttm_resource *new_mem);
> >
> >   /**
> >    * ttm_bo_move_memcpy
> > @@ -753,7 +753,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> >    * @bo: A pointer to a struct ttm_buffer_object.
> >    * @interruptible: Sleep interruptible if waiting.
> >    * @no_wait_gpu: Return immediately if the GPU is busy.
> > - * @new_mem: struct ttm_mem_reg indicating where to move.
> > + * @new_mem: struct ttm_resource indicating where to move.
> >    *
> >    * Fallback move function for a mappable buffer object in mappable memory.
> >    * The function will, if successful,
> > @@ -767,7 +767,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> >
> >   int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> >                      struct ttm_operation_ctx *ctx,
> > -                    struct ttm_mem_reg *new_mem);
> > +                    struct ttm_resource *new_mem);
> >
> >   /**
> >    * ttm_bo_free_old_node
> > @@ -784,7 +784,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
> >    * @bo: A pointer to a struct ttm_buffer_object.
> >    * @fence: A fence object that signals when moving is complete.
> >    * @evict: This is an evict move. Don't return until the buffer is idle.
> > - * @new_mem: struct ttm_mem_reg indicating where to move.
> > + * @new_mem: struct ttm_resource indicating where to move.
> >    *
> >    * Accelerated move function to be called when an accelerated move
> >    * has been scheduled. The function will create a new temporary buffer object
> > @@ -795,7 +795,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
> >    */
> >   int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
> >                             struct dma_fence *fence, bool evict,
> > -                           struct ttm_mem_reg *new_mem);
> > +                           struct ttm_resource *new_mem);
> >
> >   /**
> >    * ttm_bo_pipeline_move.
> > @@ -803,14 +803,14 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
> >    * @bo: A pointer to a struct ttm_buffer_object.
> >    * @fence: A fence object that signals when moving is complete.
> >    * @evict: This is an evict move. Don't return until the buffer is idle.
> > - * @new_mem: struct ttm_mem_reg indicating where to move.
> > + * @new_mem: struct ttm_resource indicating where to move.
> >    *
> >    * Function for pipelining accelerated moves. Either free the memory
> >    * immediately or hang it on a temporary buffer object.
> >    */
> >   int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
> >                        struct dma_fence *fence, bool evict,
> > -                      struct ttm_mem_reg *new_mem);
> > +                      struct ttm_resource *new_mem);
> >
> >   /**
> >    * ttm_bo_pipeline_gutting.
> > diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
> > index 5e2393fe42c6..241cc40839ed 100644
> > --- a/include/drm/ttm/ttm_tt.h
> > +++ b/include/drm/ttm/ttm_tt.h
> > @@ -30,7 +30,7 @@
> >   #include <linux/types.h>
> >
> >   struct ttm_tt;
> > -struct ttm_mem_reg;
> > +struct ttm_resource;
> >   struct ttm_buffer_object;
> >   struct ttm_operation_ctx;
> >
> > @@ -53,14 +53,14 @@ struct ttm_backend_func {
> >        * struct ttm_backend_func member bind
> >        *
> >        * @ttm: Pointer to a struct ttm_tt.
> > -      * @bo_mem: Pointer to a struct ttm_mem_reg describing the
> > +      * @bo_mem: Pointer to a struct ttm_resource describing the
> >        * memory type and location for binding.
> >        *
> >        * Bind the backend pages into the aperture in the location
> >        * indicated by @bo_mem. This function should be able to handle
> >        * differences between aperture and system page sizes.
> >        */
> > -     int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
> > +     int (*bind) (struct ttm_tt *ttm, struct ttm_resource *bo_mem);
> >
> >       /**
> >        * struct ttm_backend_func member unbind
> > @@ -179,11 +179,11 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
> >    * ttm_ttm_bind:
> >    *
> >    * @ttm: The struct ttm_tt containing backing pages.
> > - * @bo_mem: The struct ttm_mem_reg identifying the binding location.
> > + * @bo_mem: The struct ttm_resource identifying the binding location.
> >    *
> >    * Bind the pages of @ttm to an aperture location identified by @bo_mem
> >    */
> > -int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
> > +int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem,
> >               struct ttm_operation_ctx *ctx);
> >
> >   /**
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate
  2020-08-04  2:55 ` [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate Dave Airlie
@ 2020-08-05  7:56   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  7:56 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:55:34PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> These two functions has the same code in them, create a common
> helper function instead.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |  4 ++
>  drivers/gpu/drm/vmwgfx/vmwgfx_mob.c        | 60 ++--------------------
>  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 32 ++++++++++++
>  3 files changed, 39 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 3596f3923ea3..b7c763713b4c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1023,6 +1023,10 @@ extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
>  extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
>  extern const struct vmw_sg_table *
>  vmw_bo_sg_table(struct ttm_buffer_object *bo);
> +extern int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
> +				      unsigned long bo_size,
> +				      struct ttm_buffer_object **bo_p);
> +
>  extern void vmw_piter_start(struct vmw_piter *viter,
>  			    const struct vmw_sg_table *vsgt,
>  			    unsigned long p_offs);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> index e8eb42933ca2..7f95ed6aa224 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> @@ -238,10 +238,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
>  	unsigned long offset;
>  	unsigned long bo_size;
>  	struct vmw_otable *otables = batch->otables;
> -	struct ttm_operation_ctx ctx = {
> -		.interruptible = false,
> -		.no_wait_gpu = false
> -	};
>  	SVGAOTableType i;
>  	int ret;
>  
> @@ -255,24 +251,9 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
>  		bo_size += otables[i].size;
>  	}
>  
> -	ret = ttm_bo_create(&dev_priv->bdev, bo_size,
> -			    ttm_bo_type_device,
> -			    &vmw_sys_ne_placement,
> -			    0, false, &batch->otable_bo);
> -
> -	if (unlikely(ret != 0))
> -		goto out_no_bo;
> -
> -	ret = ttm_bo_reserve(batch->otable_bo, false, true, NULL);
> -	BUG_ON(ret != 0);
> -	ret = vmw_bo_driver.ttm_tt_populate(batch->otable_bo->ttm, &ctx);
> -	if (unlikely(ret != 0))
> -		goto out_unreserve;
> -	ret = vmw_bo_map_dma(batch->otable_bo);
> +	ret = vmw_bo_create_and_populate(dev_priv, bo_size, &batch->otable_bo);
>  	if (unlikely(ret != 0))
> -		goto out_unreserve;
> -
> -	ttm_bo_unreserve(batch->otable_bo);
> +		return ret;
>  
>  	offset = 0;
>  	for (i = 0; i < batch->num_otables; ++i) {
> @@ -289,8 +270,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
>  
>  	return 0;
>  
> -out_unreserve:
> -	ttm_bo_unreserve(batch->otable_bo);
>  out_no_setup:
>  	for (i = 0; i < batch->num_otables; ++i) {
>  		if (batch->otables[i].enabled)
> @@ -300,7 +279,6 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
>  
>  	ttm_bo_put(batch->otable_bo);
>  	batch->otable_bo = NULL;
> -out_no_bo:
>  	return ret;
>  }
>  
> @@ -432,41 +410,9 @@ struct vmw_mob *vmw_mob_create(unsigned long data_pages)
>  static int vmw_mob_pt_populate(struct vmw_private *dev_priv,
>  			       struct vmw_mob *mob)
>  {
> -	int ret;
> -	struct ttm_operation_ctx ctx = {
> -		.interruptible = false,
> -		.no_wait_gpu = false
> -	};
> -
>  	BUG_ON(mob->pt_bo != NULL);
>  
> -	ret = ttm_bo_create(&dev_priv->bdev, mob->num_pages * PAGE_SIZE,
> -			    ttm_bo_type_device,
> -			    &vmw_sys_ne_placement,
> -			    0, false, &mob->pt_bo);
> -	if (unlikely(ret != 0))
> -		return ret;
> -
> -	ret = ttm_bo_reserve(mob->pt_bo, false, true, NULL);
> -
> -	BUG_ON(ret != 0);
> -	ret = vmw_bo_driver.ttm_tt_populate(mob->pt_bo->ttm, &ctx);
> -	if (unlikely(ret != 0))
> -		goto out_unreserve;
> -	ret = vmw_bo_map_dma(mob->pt_bo);
> -	if (unlikely(ret != 0))
> -		goto out_unreserve;
> -
> -	ttm_bo_unreserve(mob->pt_bo);
> -
> -	return 0;
> -
> -out_unreserve:
> -	ttm_bo_unreserve(mob->pt_bo);
> -	ttm_bo_put(mob->pt_bo);
> -	mob->pt_bo = NULL;
> -
> -	return ret;
> +	return vmw_bo_create_and_populate(dev_priv, mob->num_pages * PAGE_SIZE, &mob->pt_bo);
>  }
>  
>  /**
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 2deaaed334e6..8e2a82ded900 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -817,3 +817,35 @@ struct ttm_bo_driver vmw_bo_driver = {
>  	.swap_notify = vmw_swap_notify,
>  	.io_mem_reserve = &vmw_ttm_io_mem_reserve,
>  };
> +
> +int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
> +			       unsigned long bo_size,
> +			       struct ttm_buffer_object **bo_p)
> +{
> +	struct ttm_operation_ctx ctx = {
> +		.interruptible = false,
> +		.no_wait_gpu = false
> +	};
> +	struct ttm_buffer_object *bo;
> +	int ret;
> +
> +	ret = ttm_bo_create(&dev_priv->bdev, bo_size,
> +			    ttm_bo_type_device,
> +			    &vmw_sys_ne_placement,
> +			    0, false, &bo);
> +
> +	if (unlikely(ret != 0))
> +		return ret;
> +
> +	ret = ttm_bo_reserve(bo, false, true, NULL);
> +	BUG_ON(ret != 0);
> +	ret = vmw_bo_driver.ttm_tt_populate(bo->ttm, &ctx);
> +	if (likely(ret == 0))
> +		ret = vmw_bo_map_dma(bo);
> +
> +	ttm_bo_unreserve(bo);
> +
> +	if (likely(ret == 0))
> +		*bo_p = bo;
> +	return ret;
> +}

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions.
  2020-08-04  2:55 ` [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions Dave Airlie
@ 2020-08-05  7:59   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  7:59 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:55:35PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> The map one was used once, just inline it, and drop them both.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h        |  2 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 46 +++-------------------
>  2 files changed, 6 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index b7c763713b4c..65c414f119c0 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1019,8 +1019,6 @@ extern struct ttm_placement vmw_mob_placement;
>  extern struct ttm_placement vmw_mob_ne_placement;
>  extern struct ttm_placement vmw_nonfixed_placement;
>  extern struct ttm_bo_driver vmw_bo_driver;
> -extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
> -extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
>  extern const struct vmw_sg_table *
>  vmw_bo_sg_table(struct ttm_buffer_object *bo);
>  extern int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 8e2a82ded900..3a141a08d4bd 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -519,43 +519,6 @@ static void vmw_ttm_unmap_dma(struct vmw_ttm_tt *vmw_tt)
>  	vmw_tt->mapped = false;
>  }
>  
> -
> -/**
> - * vmw_bo_map_dma - Make sure buffer object pages are visible to the device
> - *
> - * @bo: Pointer to a struct ttm_buffer_object
> - *
> - * Wrapper around vmw_ttm_map_dma, that takes a TTM buffer object pointer
> - * instead of a pointer to a struct vmw_ttm_backend as argument.
> - * Note that the buffer object must be either pinned or reserved before
> - * calling this function.
> - */
> -int vmw_bo_map_dma(struct ttm_buffer_object *bo)
> -{
> -	struct vmw_ttm_tt *vmw_tt =
> -		container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
> -
> -	return vmw_ttm_map_dma(vmw_tt);
> -}
> -
> -
> -/**
> - * vmw_bo_unmap_dma - Make sure buffer object pages are visible to the device
> - *
> - * @bo: Pointer to a struct ttm_buffer_object
> - *
> - * Wrapper around vmw_ttm_unmap_dma, that takes a TTM buffer object pointer
> - * instead of a pointer to a struct vmw_ttm_backend as argument.
> - */
> -void vmw_bo_unmap_dma(struct ttm_buffer_object *bo)
> -{
> -	struct vmw_ttm_tt *vmw_tt =
> -		container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
> -
> -	vmw_ttm_unmap_dma(vmw_tt);
> -}
> -
> -
>  /**
>   * vmw_bo_sg_table - Return a struct vmw_sg_table object for a
>   * TTM buffer object
> @@ -839,9 +802,12 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
>  
>  	ret = ttm_bo_reserve(bo, false, true, NULL);
>  	BUG_ON(ret != 0);
> -	ret = vmw_bo_driver.ttm_tt_populate(bo->ttm, &ctx);
> -	if (likely(ret == 0))
> -		ret = vmw_bo_map_dma(bo);
> +	ret = vmw_ttm_populate(bo->ttm, &ctx);

Snuck a replacement for a vfunc call with a direct all in here, maybe
mention that in the commit message.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +	if (likely(ret == 0)) {
> +		struct vmw_ttm_tt *vmw_tt =
> +			container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm.ttm);
> +		ret = vmw_ttm_map_dma(vmw_tt);
> +	}
>  
>  	ttm_bo_unreserve(bo);
>  
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths
  2020-08-04  2:55 ` [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths Dave Airlie
@ 2020-08-05  8:57   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  8:57 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:55:53PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Split out the vram thp init path vs the range manager init.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 +++++++++++++++++++------
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  4 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 12 ++++++++----
>  3 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 1e4c2c6119c3..5a889df2de03 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -620,6 +620,23 @@ static int vmw_dma_masks(struct vmw_private *dev_priv)
>  	return ret;
>  }
>  
> +static int vmw_vram_manager_init(struct vmw_private *dev_priv)
> +{
> +	int ret;
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +	ret = vmw_thp_init(dev_priv);
> +#else
> +	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
> +
> +	man->available_caching = TTM_PL_FLAG_CACHED;
> +	man->default_caching = TTM_PL_FLAG_CACHED;
> +
> +	ret = ttm_range_man_init(&dev_priv->bdev, man,
> +				 dev_priv->vram_size >> PAGE_SHIFT);
> +#endif

The ifdeffery here looks a bit funny, but not really less convoluted than
the old one I think.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
> +	return ret;
> +}
>  static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  {
>  	struct vmw_private *dev_priv;
> @@ -866,16 +883,12 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  	 * Enable VRAM, but initially don't use it until SVGA is enabled and
>  	 * unhidden.
>  	 */
> -	dev_priv->bdev.man[TTM_PL_VRAM].func = &vmw_thp_func;
> -	dev_priv->bdev.man[TTM_PL_VRAM].available_caching = TTM_PL_FLAG_CACHED;
> -	dev_priv->bdev.man[TTM_PL_VRAM].default_caching = TTM_PL_FLAG_CACHED;
> -	ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM,
> -			     (dev_priv->vram_size >> PAGE_SHIFT));
> +
> +	ret = vmw_vram_manager_init(dev_priv);
>  	if (unlikely(ret != 0)) {
>  		DRM_ERROR("Failed initializing memory manager for VRAM.\n");
>  		goto out_no_vram;
>  	}
> -	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
>  
>  	/*
>  	 * "Guest Memory Regions" is an aperture like feature with
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 65c414f119c0..10b681725a53 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1520,9 +1520,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
>  
>  /* Transparent hugepage support - vmwgfx_thp.c */
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> -extern const struct ttm_mem_type_manager_func vmw_thp_func;
> -#else
> -#define vmw_thp_func ttm_bo_manager_func
> +extern int vmw_thp_init(struct vmw_private *dev_priv);
>  #endif
>  
>  /**
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index b7c816ba7166..0292c931c265 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -115,18 +115,23 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
>  	}
>  }
>  
> -static int vmw_thp_init(struct ttm_mem_type_manager *man,
> -			unsigned long p_size)
> +int vmw_thp_init(struct vmw_private *dev_priv)
>  {
> +	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
>  	struct vmw_thp_manager *rman;
> +	man->available_caching = TTM_PL_FLAG_CACHED;
> +	man->default_caching = TTM_PL_FLAG_CACHED;
>  
> +	ttm_mem_type_manager_init(&dev_priv->bdev, man,
> +				  dev_priv->vram_size >> PAGE_SHIFT);
>  	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
>  	if (!rman)
>  		return -ENOMEM;
>  
> -	drm_mm_init(&rman->mm, 0, p_size);
> +	drm_mm_init(&rman->mm, 0, man->size);
>  	spin_lock_init(&rman->lock);
>  	man->priv = rman;
> +	ttm_mem_type_manager_set_used(man, true);
>  	return 0;
>  }
>  
> @@ -158,7 +163,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
>  }
>  
>  const struct ttm_mem_type_manager_func vmw_thp_func = {
> -	.init = vmw_thp_init,
>  	.takedown = vmw_thp_takedown,
>  	.get_node = vmw_thp_get_node,
>  	.put_node = vmw_thp_put_node,
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths.
  2020-08-04  2:55 ` [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths Dave Airlie
@ 2020-08-05  9:00   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:00 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:55:54PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 17 ++++-----------
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 21 ++++++++++++-------
>  3 files changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 5a889df2de03..364d5f3ff9a8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -896,14 +896,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  	 *  slots as well as the bo size.
>  	 */
>  	dev_priv->has_gmr = true;
> -	dev_priv->bdev.man[VMW_PL_GMR].func = &vmw_gmrid_manager_func;
> -	dev_priv->bdev.man[VMW_PL_GMR].available_caching = TTM_PL_FLAG_CACHED;
> -	dev_priv->bdev.man[VMW_PL_GMR].default_caching = TTM_PL_FLAG_CACHED;
>  	/* TODO: This is most likely not correct */
> -	dev_priv->bdev.man[VMW_PL_GMR].use_tt = true;
>  	if (((dev_priv->capabilities & (SVGA_CAP_GMR | SVGA_CAP_GMR2)) == 0) ||
> -	    refuse_dma || ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_GMR,
> -					 VMW_PL_GMR) != 0) {
> +	    refuse_dma ||
> +	    vmw_gmrid_man_init(dev_priv, VMW_PL_GMR) != 0) {
>  		DRM_INFO("No GMR memory available. "
>  			 "Graphics memory resources are very limited.\n");
>  		dev_priv->has_gmr = false;
> @@ -911,13 +907,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  
>  	if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS && !refuse_dma) {
>  		dev_priv->has_mob = true;
> -		dev_priv->bdev.man[VMW_PL_MOB].func = &vmw_gmrid_manager_func;
> -		dev_priv->bdev.man[VMW_PL_MOB].available_caching = TTM_PL_FLAG_CACHED;
> -		dev_priv->bdev.man[VMW_PL_MOB].default_caching = TTM_PL_FLAG_CACHED;
> -		/* TODO: This is most likely not correct */
> -		dev_priv->bdev.man[VMW_PL_MOB].use_tt = true;
> -		if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB,
> -				   VMW_PL_MOB) != 0) {
> +
> +		if (vmw_gmrid_man_init(dev_priv, VMW_PL_MOB) != 0) {
>  			DRM_INFO("No MOB memory available. "
>  				 "3D will be disabled.\n");
>  			dev_priv->has_mob = false;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 10b681725a53..8f319dd6cdb4 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1221,7 +1221,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
>   * GMR Id manager
>   */
>  
> -extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
> +int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type);
>  
>  /**
>   * Prime - vmwgfx_prime.c
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index fb1bf4dd91d1..141fb14e3583 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -94,22 +94,28 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
>  	}
>  }
>  
> -static int vmw_gmrid_man_init(struct ttm_mem_type_manager *man,
> -			      unsigned long p_size)
> +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
> +
> +int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  {
> -	struct vmw_private *dev_priv =
> -		container_of(man->bdev, struct vmw_private, bdev);
> +	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
>  	struct vmwgfx_gmrid_man *gman =
>  		kzalloc(sizeof(*gman), GFP_KERNEL);
>  
>  	if (unlikely(!gman))
>  		return -ENOMEM;
>  
> +	man->func = &vmw_gmrid_manager_func;
> +	man->available_caching = TTM_PL_FLAG_CACHED;
> +	man->default_caching = TTM_PL_FLAG_CACHED;
> +	/* TODO: This is most likely not correct */
> +	man->use_tt = true;
> +	ttm_mem_type_manager_init(&dev_priv->bdev, man, 0);
>  	spin_lock_init(&gman->lock);
>  	gman->used_gmr_pages = 0;
>  	ida_init(&gman->gmr_ida);
>  
> -	switch (p_size) {
> +	switch (type) {
>  	case VMW_PL_GMR:
>  		gman->max_gmr_ids = dev_priv->max_gmr_ids;
>  		gman->max_gmr_pages = dev_priv->max_gmr_pages;
> @@ -122,6 +128,8 @@ static int vmw_gmrid_man_init(struct ttm_mem_type_manager *man,
>  		BUG();
>  	}
>  	man->priv = (void *) gman;
> +
> +	ttm_mem_type_manager_set_used(man, true);
>  	return 0;
>  }
>  
> @@ -137,8 +145,7 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man)
>  	return 0;
>  }
>  
> -const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> -	.init = vmw_gmrid_man_init,
> +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
>  	.takedown = vmw_gmrid_man_takedown,
>  	.get_node = vmw_gmrid_man_get_node,
>  	.put_node = vmw_gmrid_man_put_node,


Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use
  2020-08-04  2:56 ` [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use Dave Airlie
  2020-08-04 11:38   ` Christian König
@ 2020-08-05  9:04   ` daniel
  1 sibling, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:04 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:29PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This converts vmwgfx over to using an interface to set the
> in use and check the in use flag.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Hm, I think this would be a good candidate to eventually rip out once we
have full sub-classing, since it's for vmwgfx internally only. Maybe add a
todo to the kernel-doc.
-Daniel

> ---
>  drivers/gpu/drm/nouveau/nouveau_ttm.c |  1 -
>  drivers/gpu/drm/ttm/ttm_bo.c          |  2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 14 +++++++-------
>  include/drm/ttm/ttm_bo_driver.h       | 14 ++++++++++++++
>  4 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 22185a8dcfa1..38a0e4bd16f7 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>  	ttm_mem_type_manager_init(man, size_pages);
>  	ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
>  	ttm_mem_type_manager_set_used(man, true);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index cda33b4af681..7d10abae9a60 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1002,7 +1002,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>  		return ret;
>  
>  	man = ttm_manager_type(bdev, mem_type);
> -	if (!man || !man->use_type)
> +	if (!man || !ttm_mem_type_manager_used(man))
>  		return -EBUSY;
>  
>  	if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 7168403fb4f8..b2f1e7a3b048 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>  				 TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
>  				 false, dev_priv->vram_size >> PAGE_SHIFT);
>  #endif
> -	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
> +	ttm_mem_type_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
>  	return ret;
>  }
>  
> @@ -1192,9 +1192,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)
>  	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>  
>  	spin_lock(&dev_priv->svga_lock);
> -	if (!man->use_type) {
> +	if (!ttm_mem_type_manager_used(man)) {
>  		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> -		man->use_type = true;
> +		ttm_mem_type_manager_set_used(man, true);
>  	}
>  	spin_unlock(&dev_priv->svga_lock);
>  }
> @@ -1223,8 +1223,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
>  	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>  
>  	spin_lock(&dev_priv->svga_lock);
> -	if (man->use_type) {
> -		man->use_type = false;
> +	if (ttm_mem_type_manager_used(man)) {
> +		ttm_mem_type_manager_set_used(man, false);
>  		vmw_write(dev_priv, SVGA_REG_ENABLE,
>  			  SVGA_REG_ENABLE_HIDE |
>  			  SVGA_REG_ENABLE_ENABLE);
> @@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
>  	vmw_kms_lost_device(dev_priv->dev);
>  	ttm_write_lock(&dev_priv->reservation_sem, false);
>  	spin_lock(&dev_priv->svga_lock);
> -	if (man->use_type) {
> -		man->use_type = false;
> +	if (ttm_mem_type_manager_used(man)) {
> +		ttm_mem_type_manager_set_used(man, false);
>  		spin_unlock(&dev_priv->svga_lock);
>  		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
>  			DRM_ERROR("Failed evicting VRAM buffers.\n");
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 300934289e64..f231fe34e744 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -678,6 +678,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
>  	man->use_type = used;
>  }
>  
> +/**
> + * ttm_mem_type_manager_used
> + *
> + * @man: Manager to get used state for
> + *
> + * Get the in use flag for a manager.
> + * Returns:
> + * true is used, false if not.
> + */
> +static inline bool ttm_mem_type_manager_used(struct ttm_mem_type_manager *man)
> +{
> +	return man->use_type;
> +}
> +
>  /**
>   * ttm_mem_type_manager_cleanup
>   *
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 28/59] drm/vmwgfx: takedown vram manager
  2020-08-04  2:56 ` [PATCH 28/59] drm/vmwgfx: takedown vram manager Dave Airlie
@ 2020-08-05  9:19   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:19 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:01PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Don't bother returning EBUSY, nobody cares enough,
> if the driver has a problem, it should deal with it.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++++++++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 23 +++++++++++++----------
>  3 files changed, 27 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 364d5f3ff9a8..4f4d22bac477 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -637,6 +637,17 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>  	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
>  	return ret;
>  }
> +
> +static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
> +{
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +	vmw_thp_fini(dev_priv);
> +#else
> +	ttm_bo_man_fini(&dev_priv->bdev,
> +			    &dev_priv->bdev.man[TTM_PL_VRAM]);
> +#endif
> +}
> +
>  static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  {
>  	struct vmw_private *dev_priv;
> @@ -988,7 +999,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
>  	if (dev_priv->has_gmr)
>  		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
> -	(void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
> +	vmw_vram_manager_fini(dev_priv);
>  out_no_vram:
>  	(void)ttm_bo_device_release(&dev_priv->bdev);
>  out_no_bdev:
> @@ -1042,6 +1053,7 @@ static void vmw_driver_unload(struct drm_device *dev)
>  	vmw_release_device_early(dev_priv);
>  	if (dev_priv->has_mob)
>  		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
> +	vmw_vram_manager_fini(dev_priv);

I think drmm_ would be neat for all this stuff eventually, but we're still
in the very early phases of rolling that out.


>  	(void) ttm_bo_device_release(&dev_priv->bdev);
>  	drm_vma_offset_manager_destroy(&dev_priv->vma_manager);
>  	vmw_release_device_late(dev_priv);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 8f319dd6cdb4..c6530d7b6d51 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1521,6 +1521,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
>  /* Transparent hugepage support - vmwgfx_thp.c */
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>  extern int vmw_thp_init(struct vmw_private *dev_priv);
> +void vmw_thp_fini(struct vmw_private *dev_priv);
>  #endif
>  
>  /**
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 0292c931c265..548f152b9963 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -135,21 +135,25 @@ int vmw_thp_init(struct vmw_private *dev_priv)
>  	return 0;
>  }
>  
> -static int vmw_thp_takedown(struct ttm_mem_type_manager *man)
> +void vmw_thp_fini(struct vmw_private *dev_priv)
>  {
> +	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
>  	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
>  	struct drm_mm *mm = &rman->mm;
> +	int ret;
> +
> +	ttm_mem_type_manager_disable(man);
>  
> +	ret = ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> +	if (ret)
> +		return;
>  	spin_lock(&rman->lock);
> -	if (drm_mm_clean(mm)) {
> -		drm_mm_takedown(mm);
> -		spin_unlock(&rman->lock);
> -		kfree(rman);
> -		man->priv = NULL;
> -		return 0;
> -	}
> +	drm_mm_clean(mm);
> +	drm_mm_takedown(mm);
>  	spin_unlock(&rman->lock);
> -	return -EBUSY;
> +	kfree(rman);
> +	man->priv = NULL;
> +	ttm_mem_type_manager_cleanup(man);
>  }
>  
>  static void vmw_thp_debug(struct ttm_mem_type_manager *man,
> @@ -163,7 +167,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man,
>  }
>  
>  const struct ttm_mem_type_manager_func vmw_thp_func = {
> -	.takedown = vmw_thp_takedown,
>  	.get_node = vmw_thp_get_node,
>  	.put_node = vmw_thp_put_node,
>  	.debug = vmw_thp_debug

Still the mildly icky #ifdef, but looks good to me.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface
  2020-08-04  2:56 ` [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface Dave Airlie
@ 2020-08-05  9:21   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:21 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:06PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           |  9 ++++-----
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 11 ++++++++---
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 4f4d22bac477..f368a9cc0c2a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -996,9 +996,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  	vmw_kms_close(dev_priv);
>  out_no_kms:
>  	if (dev_priv->has_mob)
> -		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
> +		vmw_gmrid_man_fini(dev_priv, VMW_PL_MOB);
>  	if (dev_priv->has_gmr)
> -		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
> +		vmw_gmrid_man_fini(dev_priv, VMW_PL_GMR);
>  	vmw_vram_manager_fini(dev_priv);
>  out_no_vram:
>  	(void)ttm_bo_device_release(&dev_priv->bdev);
> @@ -1047,12 +1047,11 @@ static void vmw_driver_unload(struct drm_device *dev)
>  	vmw_overlay_close(dev_priv);
>  
>  	if (dev_priv->has_gmr)
> -		(void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
> -	(void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
> +		vmw_gmrid_man_fini(dev_priv, VMW_PL_GMR);
>  
>  	vmw_release_device_early(dev_priv);
>  	if (dev_priv->has_mob)
> -		(void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB);
> +		vmw_gmrid_man_fini(dev_priv, VMW_PL_MOB);
>  	vmw_vram_manager_fini(dev_priv);
>  	(void) ttm_bo_device_release(&dev_priv->bdev);
>  	drm_vma_offset_manager_destroy(&dev_priv->vma_manager);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index c6530d7b6d51..aa763c6b1146 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -1222,6 +1222,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
>   */
>  
>  int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type);
> +void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type);
>  
>  /**
>   * Prime - vmwgfx_prime.c
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index 141fb14e3583..ec1b5bb01a93 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -133,20 +133,25 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  	return 0;
>  }
>  
> -static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man)
> +void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>  {
> +	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
>  	struct vmwgfx_gmrid_man *gman =
>  		(struct vmwgfx_gmrid_man *)man->priv;
>  
> +	ttm_mem_type_manager_disable(man);
> +
> +	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
> +
>  	if (gman) {

I don't think this can ever be non-NULL if init worked, not after the
demidlayering. Maybe put a WARN_ON(!gman) in here. With that:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  		ida_destroy(&gman->gmr_ida);
>  		kfree(gman);
>  	}
> -	return 0;
> +
> +	ttm_mem_type_manager_cleanup(man);
>  }
>  
>  static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> -	.takedown = vmw_gmrid_man_takedown,
>  	.get_node = vmw_gmrid_man_get_node,
>  	.put_node = vmw_gmrid_man_put_node,
>  };
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 42/59] drm/vmwgfx/ttm: use wrapper to access memory manager
  2020-08-04  2:56 ` [PATCH 42/59] drm/vmwgfx/ttm: " Dave Airlie
@ 2020-08-05  9:22   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:22 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:15PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           | 23 +++++++++++--------
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  4 ++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_thp.c           |  4 ++--
>  3 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index f368a9cc0c2a..6ed92f38b54b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -634,7 +634,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
>  	ret = ttm_range_man_init(&dev_priv->bdev, man,
>  				 dev_priv->vram_size >> PAGE_SHIFT);
>  #endif
> -	dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
> +	ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false;
>  	return ret;
>  }
>  
> @@ -644,7 +644,7 @@ static void vmw_vram_manager_fini(struct vmw_private *dev_priv)
>  	vmw_thp_fini(dev_priv);
>  #else
>  	ttm_bo_man_fini(&dev_priv->bdev,
> -			    &dev_priv->bdev.man[TTM_PL_VRAM]);
> +			ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM));
>  #endif
>  }
>  
> @@ -887,7 +887,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
>  		DRM_ERROR("Failed initializing TTM buffer object driver.\n");
>  		goto out_no_bdev;
>  	}
> -	dev_priv->bdev.man[TTM_PL_SYSTEM].available_caching =
> +	ttm_manager_type(&dev_priv->bdev, TTM_PL_SYSTEM)->available_caching =
>  		TTM_PL_FLAG_CACHED;
>  
>  	/*
> @@ -1194,10 +1194,12 @@ static void vmw_master_drop(struct drm_device *dev,
>   */
>  static void __vmw_svga_enable(struct vmw_private *dev_priv)
>  {
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +
>  	spin_lock(&dev_priv->svga_lock);
> -	if (!dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
> +	if (!man->use_type) {
>  		vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE);
> -		dev_priv->bdev.man[TTM_PL_VRAM].use_type = true;
> +		man->use_type = true;
>  	}
>  	spin_unlock(&dev_priv->svga_lock);
>  }
> @@ -1223,9 +1225,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)
>   */
>  static void __vmw_svga_disable(struct vmw_private *dev_priv)
>  {
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +
>  	spin_lock(&dev_priv->svga_lock);
> -	if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
> -		dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
> +	if (man->use_type) {
> +		man->use_type = false;
>  		vmw_write(dev_priv, SVGA_REG_ENABLE,
>  			  SVGA_REG_ENABLE_HIDE |
>  			  SVGA_REG_ENABLE_ENABLE);
> @@ -1242,6 +1246,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
>   */
>  void vmw_svga_disable(struct vmw_private *dev_priv)
>  {
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>  	/*
>  	 * Disabling SVGA will turn off device modesetting capabilities, so
>  	 * notify KMS about that so that it doesn't cache atomic state that
> @@ -1257,8 +1262,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
>  	vmw_kms_lost_device(dev_priv->dev);
>  	ttm_write_lock(&dev_priv->reservation_sem, false);
>  	spin_lock(&dev_priv->svga_lock);
> -	if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
> -		dev_priv->bdev.man[TTM_PL_VRAM].use_type = false;
> +	if (man->use_type) {
> +		man->use_type = false;
>  		spin_unlock(&dev_priv->svga_lock);
>  		if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
>  			DRM_ERROR("Failed evicting VRAM buffers.\n");
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index ec1b5bb01a93..54c85a59dd8b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -98,7 +98,7 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
>  
>  int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  {
> -	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
>  	struct vmwgfx_gmrid_man *gman =
>  		kzalloc(sizeof(*gman), GFP_KERNEL);
>  
> @@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  
>  void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>  {
> -	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
>  	struct vmwgfx_gmrid_man *gman =
>  		(struct vmwgfx_gmrid_man *)man->priv;
>  
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 548f152b9963..720a24214c74 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -117,7 +117,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
>  
>  int vmw_thp_init(struct vmw_private *dev_priv)
>  {
> -	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>  	struct vmw_thp_manager *rman;
>  	man->available_caching = TTM_PL_FLAG_CACHED;
>  	man->default_caching = TTM_PL_FLAG_CACHED;
> @@ -137,7 +137,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
>  
>  void vmw_thp_fini(struct vmw_private *dev_priv)
>  {
> -	struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM];
> +	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
>  	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
>  	struct drm_mm *mm = &rman->mm;
>  	int ret;
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed
  2020-08-04  2:56 ` [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed Dave Airlie
@ 2020-08-05  9:24   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:24 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:21PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 32 +++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 720a24214c74..1cefd9c1e8ea 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -16,10 +16,16 @@
>   * @lock: Manager lock.
>   */
>  struct vmw_thp_manager {
> +	struct ttm_mem_type_manager manager;
>  	struct drm_mm mm;
>  	spinlock_t lock;
>  };
>  
> +static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man)
> +{
> +	return container_of(man, struct vmw_thp_manager, manager);
> +}
> +
>  static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
>  				  unsigned long align_pages,
>  				  const struct ttm_place *place,
> @@ -43,7 +49,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
>  			    const struct ttm_place *place,
>  			    struct ttm_mem_reg *mem)
>  {
> -	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
> +	struct vmw_thp_manager *rman = to_thp_manager(man);
>  	struct drm_mm *mm = &rman->mm;
>  	struct drm_mm_node *node;
>  	unsigned long align_pages;
> @@ -103,7 +109,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
>  static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
>  			     struct ttm_mem_reg *mem)
>  {
> -	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
> +	struct vmw_thp_manager *rman = to_thp_manager(man);
>  
>  	if (mem->mm_node) {
>  		spin_lock(&rman->lock);
> @@ -117,20 +123,24 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,
>  
>  int vmw_thp_init(struct vmw_private *dev_priv)
>  {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> +	struct ttm_mem_type_manager *man;
>  	struct vmw_thp_manager *rman;
> +
> +	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> +	if (!rman)
> +		return -ENOMEM;
> +
> +	man = &rman->manager;
>  	man->available_caching = TTM_PL_FLAG_CACHED;
>  	man->default_caching = TTM_PL_FLAG_CACHED;
>  
>  	ttm_mem_type_manager_init(&dev_priv->bdev, man,
>  				  dev_priv->vram_size >> PAGE_SHIFT);
> -	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> -	if (!rman)
> -		return -ENOMEM;
>  
>  	drm_mm_init(&rman->mm, 0, man->size);
>  	spin_lock_init(&rman->lock);
> -	man->priv = rman;
> +
> +	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
>  	ttm_mem_type_manager_set_used(man, true);
>  	return 0;
>  }
> @@ -138,7 +148,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
>  void vmw_thp_fini(struct vmw_private *dev_priv)
>  {
>  	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
> -	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
> +	struct vmw_thp_manager *rman = to_thp_manager(man);
>  	struct drm_mm *mm = &rman->mm;
>  	int ret;
>  
> @@ -151,15 +161,15 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
>  	drm_mm_clean(mm);
>  	drm_mm_takedown(mm);
>  	spin_unlock(&rman->lock);
> -	kfree(rman);
> -	man->priv = NULL;
>  	ttm_mem_type_manager_cleanup(man);
> +	ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
> +	kfree(rman);
>  }
>  
>  static void vmw_thp_debug(struct ttm_mem_type_manager *man,
>  			  struct drm_printer *printer)
>  {
> -	struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;
> +	struct vmw_thp_manager *rman = to_thp_manager(man);
>  
>  	spin_lock(&rman->lock);
>  	drm_mm_print(&rman->mm, printer);
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation.
  2020-08-04  2:56 ` [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation Dave Airlie
@ 2020-08-05  9:26   ` daniel
  0 siblings, 0 replies; 136+ messages in thread
From: daniel @ 2020-08-05  9:26 UTC (permalink / raw)
  Cc: sroland, dri-devel, linux-graphics-maintainer, kraxel,
	christian.koenig, bskeggs

On Tue, Aug 04, 2020 at 12:56:22PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 32 +++++++++++--------
>  1 file changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index 54c85a59dd8b..bc51b7773084 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -37,6 +37,7 @@
>  #include <linux/kernel.h>
>  
>  struct vmwgfx_gmrid_man {
> +	struct ttm_mem_type_manager manager;
>  	spinlock_t lock;
>  	struct ida gmr_ida;
>  	uint32_t max_gmr_ids;
> @@ -44,13 +45,17 @@ struct vmwgfx_gmrid_man {
>  	uint32_t used_gmr_pages;
>  };
>  
> +static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man)
> +{
> +	return container_of(man, struct vmwgfx_gmrid_man, manager);
> +}
> +
>  static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
>  				  struct ttm_buffer_object *bo,
>  				  const struct ttm_place *place,
>  				  struct ttm_mem_reg *mem)
>  {
> -	struct vmwgfx_gmrid_man *gman =
> -		(struct vmwgfx_gmrid_man *)man->priv;
> +	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>  	int id;
>  
>  	id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL);
> @@ -82,8 +87,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
>  static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
>  				   struct ttm_mem_reg *mem)
>  {
> -	struct vmwgfx_gmrid_man *gman =
> -		(struct vmwgfx_gmrid_man *)man->priv;
> +	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>  
>  	if (mem->mm_node) {
>  		ida_free(&gman->gmr_ida, mem->start);
> @@ -98,13 +102,15 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
>  
>  int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  {
> -	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> +	struct ttm_mem_type_manager *man;
>  	struct vmwgfx_gmrid_man *gman =
>  		kzalloc(sizeof(*gman), GFP_KERNEL);
>  
>  	if (unlikely(!gman))
>  		return -ENOMEM;
>  
> +	man = &gman->manager;
> +
>  	man->func = &vmw_gmrid_manager_func;
>  	man->available_caching = TTM_PL_FLAG_CACHED;
>  	man->default_caching = TTM_PL_FLAG_CACHED;
> @@ -127,8 +133,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  	default:
>  		BUG();
>  	}
> -	man->priv = (void *) gman;
> -
> +	ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager);
>  	ttm_mem_type_manager_set_used(man, true);
>  	return 0;
>  }
> @@ -136,19 +141,18 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
>  void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
>  {
>  	struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type);
> -	struct vmwgfx_gmrid_man *gman =
> -		(struct vmwgfx_gmrid_man *)man->priv;
> +	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
>  
>  	ttm_mem_type_manager_disable(man);
>  
>  	ttm_mem_type_manager_force_list_clean(&dev_priv->bdev, man);
>  
> -	if (gman) {

Ah, here it goes, please disregard my suggestion earlier for adding a
WARN_ON, that's just churn.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -		ida_destroy(&gman->gmr_ida);
> -		kfree(gman);
> -	}
> -
>  	ttm_mem_type_manager_cleanup(man);
> +
> +	ttm_set_driver_manager(&dev_priv->bdev, type, NULL);
> +	ida_destroy(&gman->gmr_ida);
> +	kfree(gman);
> +
>  }
>  
>  static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2)
  2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
                   ` (59 preceding siblings ...)
  2020-08-04  3:01 ` [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
@ 2020-08-05 11:55 ` Christian König
  2020-08-05 11:59   ` Christian König
  60 siblings, 1 reply; 136+ messages in thread
From: Christian König @ 2020-08-05 11:55 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Dave, do you have a branch with the latest version somewhere?

I've tested your ttm-refactor-mem-manager branch from fdo today a bit 
and that pretty quickly results in an -ENOMEM.

Looks like a leak somewhere to me.

Christian.

Am 04.08.20 um 04:55 schrieb Dave Airlie:
> I've decided to repost the whole queue this time, it has a few driver
> patches up front that are just cleanups.
>
> I've reorodered things a little since the first posting, but not much.
>
> misc core/driver cleanups
> mem type manager debug callback cleanup (reordered)
> new mem type manager init path
> new mem type manager cleanup path
> new wrapper to access managers
> driver managed mem type allocations
> cleanup after all of that
> rename ttm_bo_manager to ttm_range_manager (new)
> rename ttm_mem_type_manager to ttm_resource_manager (new)
> rename ttm_mem_reg to ttm_resource (new)
>
> I've marked most things with v2 that have changed, again I'd really
> like to land this in drm-misc sooner rather than later, so it would be
> good to get driver acks from qxl, vmwgfx and nouveau. (all cc'ed).
>
> I've also commented on the list on any outstanding comments from previous
> review that I disagree with or need more discussion.
>
> Dave.
>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

* Re: [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2)
  2020-08-05 11:55 ` Christian König
@ 2020-08-05 11:59   ` Christian König
  0 siblings, 0 replies; 136+ messages in thread
From: Christian König @ 2020-08-05 11:59 UTC (permalink / raw)
  To: Dave Airlie, dri-devel
  Cc: sroland, linux-graphics-maintainer, bskeggs, kraxel

Forget what I wrote the -ENOMEM was a type in my local change :)

Sorry for the noise,
Christian.

Am 05.08.20 um 13:55 schrieb Christian König:
> Dave, do you have a branch with the latest version somewhere?
>
> I've tested your ttm-refactor-mem-manager branch from fdo today a bit 
> and that pretty quickly results in an -ENOMEM.
>
> Looks like a leak somewhere to me.
>
> Christian.
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
>> I've decided to repost the whole queue this time, it has a few driver
>> patches up front that are just cleanups.
>>
>> I've reorodered things a little since the first posting, but not much.
>>
>> misc core/driver cleanups
>> mem type manager debug callback cleanup (reordered)
>> new mem type manager init path
>> new mem type manager cleanup path
>> new wrapper to access managers
>> driver managed mem type allocations
>> cleanup after all of that
>> rename ttm_bo_manager to ttm_range_manager (new)
>> rename ttm_mem_type_manager to ttm_resource_manager (new)
>> rename ttm_mem_reg to ttm_resource (new)
>>
>> I've marked most things with v2 that have changed, again I'd really
>> like to land this in drm-misc sooner rather than later, so it would be
>> good to get driver acks from qxl, vmwgfx and nouveau. (all cc'ed).
>>
>> I've also commented on the list on any outstanding comments from 
>> previous
>> review that I disagree with or need more discussion.
>>
>> Dave.
>>
>>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 136+ messages in thread

end of thread, other threads:[~2020-08-05 11:59 UTC | newest]

Thread overview: 136+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  2:55 [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
2020-08-04  2:55 ` [PATCH 01/59] drm/vmwgfx: consolidate ttm object creation and populate Dave Airlie
2020-08-05  7:56   ` daniel
2020-08-04  2:55 ` [PATCH 02/59] drm/vmwgfx: drop bo map/unmap dma functions Dave Airlie
2020-08-05  7:59   ` daniel
2020-08-04  2:55 ` [PATCH 03/59] nouveau: use ttm populate mapping functions. (v2) Dave Airlie
2020-08-05  5:32   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 04/59] qxl/ttm: drop the unusued no wait flag to reserve function Dave Airlie
2020-08-04 10:46   ` Gerd Hoffmann
2020-08-04  2:55 ` [PATCH 05/59] drm/ttm/amdgpu: consolidate ttm reserve paths Dave Airlie
2020-08-04 10:33   ` Christian König
2020-08-04  2:55 ` [PATCH 06/59] drm/ttm: use a helper for unlocked moves to the lru tail Dave Airlie
2020-08-04 10:34   ` Christian König
2020-08-05  5:32     ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 07/59] drm/vram-helper: remove populate/unpopulate Dave Airlie
2020-08-04  6:54   ` Thomas Zimmermann
2020-08-04  2:55 ` [PATCH 08/59] drm/ttm: export memory type debug entrypoint Dave Airlie
2020-08-04 10:35   ` Christian König
2020-08-05  5:34     ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 09/59] drm/nouveau/ttm: don't fill in blank ttm debug callback Dave Airlie
2020-08-05  5:34   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 10/59] drm/vmwgfx/gmrid: don't provide pointless " Dave Airlie
2020-08-04  2:55 ` [PATCH 11/59] drm/qxl/ttm: call ttm manager debug (v2) Dave Airlie
2020-08-04 10:48   ` Gerd Hoffmann
2020-08-04  2:55 ` [PATCH 12/59] drm/vram-helper: call the ttm manager debug function Dave Airlie
2020-08-04  6:55   ` Thomas Zimmermann
2020-08-04 10:48   ` Gerd Hoffmann
2020-08-04  2:55 ` [PATCH 13/59] drm/ttm: split the mm manager init code (v2) Dave Airlie
2020-08-04 11:07   ` Christian König
2020-08-04 13:08     ` Christian König
2020-08-04 11:10   ` Christian König
2020-08-04  2:55 ` [PATCH 14/59] drm/ttm: provide a driver-led init path for range mm manager. (v2) Dave Airlie
2020-08-04  2:55 ` [PATCH 15/59] drm/amdgpu/ttm: init managers from the driver side Dave Airlie
2020-08-04 11:15   ` Christian König
2020-08-04  2:55 ` [PATCH 16/59] drm/radeon: use new ttm man init path Dave Airlie
2020-08-04 11:15   ` Christian König
2020-08-04  2:55 ` [PATCH 17/59] drm/qxl/ttm: use new init path for manager Dave Airlie
2020-08-04 10:49   ` Gerd Hoffmann
2020-08-04  2:55 ` [PATCH 18/59] drm/vram_helper: use new ttm manager init function Dave Airlie
2020-08-04  6:58   ` Thomas Zimmermann
2020-08-04 10:49   ` Gerd Hoffmann
2020-08-04  2:55 ` [PATCH 19/59] drm/nouveau: use new memory manager init paths Dave Airlie
2020-08-05  5:40   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 20/59] drm/vmwgfx/ttm: convert vram mm init to new code paths Dave Airlie
2020-08-05  8:57   ` daniel
2020-08-04  2:55 ` [PATCH 21/59] drm/vmwgfx/ttm: switch gmrid allocator to new init paths Dave Airlie
2020-08-05  9:00   ` daniel
2020-08-04  2:55 ` [PATCH 22/59] drm/ttm: convert system manager init to new code Dave Airlie
2020-08-05  5:40   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 23/59] drm/ttm: purge old manager init path Dave Airlie
2020-08-05  5:41   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 24/59] drm/ttm: pass man around instead of mem_type in some places Dave Airlie
2020-08-05  5:42   ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2) Dave Airlie
2020-08-04 11:18   ` Christian König
2020-08-05  5:42     ` Ben Skeggs
2020-08-04  2:55 ` [PATCH 26/59] drm/ttm: start allowing drivers to use new takedown path (v2) Dave Airlie
2020-08-04 11:20   ` Christian König
2020-08-05  5:43     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 27/59] drm/amdgpu/ttm: use new takedown path Dave Airlie
2020-08-04  2:56 ` [PATCH 28/59] drm/vmwgfx: takedown vram manager Dave Airlie
2020-08-05  9:19   ` daniel
2020-08-04  2:56 ` [PATCH 29/59] drm/vram_helper: call explicit mm takedown Dave Airlie
2020-08-04  6:59   ` Thomas Zimmermann
2020-08-04  2:56 ` [PATCH 30/59] drm/nouveau: use new cleanup paths Dave Airlie
2020-08-05  5:44   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 31/59] drm/radeon/ttm: use new takedown paths Dave Airlie
2020-08-04  2:56 ` [PATCH 32/59] drm/qxl/ttm: use new takedown path Dave Airlie
2020-08-04 10:50   ` Gerd Hoffmann
2020-08-04  2:56 ` [PATCH 33/59] drm/vmwgfx: fix gmrid takedown paths to new interface Dave Airlie
2020-08-05  9:21   ` daniel
2020-08-04  2:56 ` [PATCH 34/59] drm/ttm: remove range manager legacy takedown path Dave Airlie
2020-08-05  5:45   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 35/59] drm/ttm: make TTM responsible for cleaning system only Dave Airlie
2020-08-05  5:46   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 36/59] drm/ttm: add wrapper to get manager from bdev Dave Airlie
2020-08-04 11:25   ` Christian König
2020-08-05  5:47     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 37/59] drm/amdgfx/ttm: use wrapper to get ttm memory managers Dave Airlie
2020-08-04 11:26   ` Christian König
2020-08-04  2:56 ` [PATCH 38/59] drm/vram-helper: use wrapper to access " Dave Airlie
2020-08-04  7:00   ` Thomas Zimmermann
2020-08-04  2:56 ` [PATCH 39/59] drm/nouveau/ttm: " Dave Airlie
2020-08-05  5:48   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 40/59] drm/qxl/ttm: use wrapper to access memory manager Dave Airlie
2020-08-04 10:50   ` Gerd Hoffmann
2020-08-04  2:56 ` [PATCH 41/59] drm/radeon/ttm: " Dave Airlie
2020-08-04 11:29   ` Christian König
2020-08-04  2:56 ` [PATCH 42/59] drm/vmwgfx/ttm: " Dave Airlie
2020-08-05  9:22   ` daniel
2020-08-04  2:56 ` [PATCH 43/59] drm/ttm: rename manager variable to make sure wrapper is used Dave Airlie
2020-08-04 11:29   ` Christian König
2020-08-05  5:49     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 44/59] drm/ttm: allow drivers to provide their own manager subclasses Dave Airlie
2020-08-04 11:30   ` Christian König
2020-08-05  5:49     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 45/59] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs Dave Airlie
2020-08-04 11:32   ` Christian König
2020-08-04  2:56 ` [PATCH 46/59] drm/ttm: make ttm_range_man_init/takedown take type + args Dave Airlie
2020-08-04 11:35   ` Christian König
2020-08-05  5:51     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 47/59] drm/ttm: move range manager to subclassed driver allocation Dave Airlie
2020-08-05  5:52   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 48/59] drm/vmwgfx/ttm: move thp to driver managed Dave Airlie
2020-08-05  9:24   ` daniel
2020-08-04  2:56 ` [PATCH 49/59] drm/vmwgfx/gmrid: convert to driver controlled allocation Dave Airlie
2020-08-05  9:26   ` daniel
2020-08-04  2:56 ` [PATCH 50/59] drm/nouveau/ttm: move to driver allocated manager Dave Airlie
2020-08-05  5:53   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 51/59] drm/ttm: drop priv pointer in memory manager Dave Airlie
2020-08-05  5:54   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 52/59] drm/amdgpu/ttm: remove man->bdev references Dave Airlie
2020-08-04  2:56 ` [PATCH 53/59] drm/ttm: drop man->bdev link Dave Airlie
2020-08-05  5:54   ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 54/59] drm/ttm: drop list of memory managers from device. (v2) Dave Airlie
2020-08-04 11:37   ` Christian König
2020-08-05  5:55     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 55/59] drm/ttm: drop type manager has_type Dave Airlie
2020-08-04 11:37   ` Christian König
2020-08-05  5:55     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 56/59] drm/ttm: add a wrapper for checking if manager is in use Dave Airlie
2020-08-04 11:38   ` Christian König
2020-08-05  5:56     ` Ben Skeggs
2020-08-05  9:04   ` daniel
2020-08-04  2:56 ` [PATCH 57/59] drm/ttm: rename bo manager to range manager Dave Airlie
2020-08-04 11:40   ` Christian König
2020-08-05  5:56     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 58/59] drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager Dave Airlie
2020-08-04 11:41   ` Christian König
2020-08-05  5:57     ` Ben Skeggs
2020-08-04  2:56 ` [PATCH 59/59] drm/ttm: rename ttm_mem_reg to ttm_resource Dave Airlie
2020-08-04 11:41   ` Christian König
2020-08-05  5:58     ` Ben Skeggs
2020-08-04  3:01 ` [00/59] ttm misc cleanups, mem refactoring, rename objects. (v2) Dave Airlie
2020-08-05 11:55 ` Christian König
2020-08-05 11:59   ` Christian König

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).