[19/59] drm/nouveau: use new memory manager init paths
diff mbox series

Message ID 20200804025632.3868079-20-airlied@gmail.com
State New
Headers show
Series
  • ttm misc cleanups, mem refactoring, rename objects. (v2)
Related show

Commit Message

Dave Airlie Aug. 4, 2020, 2:55 a.m. UTC
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(-)

Comments

Ben Skeggs Aug. 5, 2020, 5:40 a.m. UTC | #1
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

Patch
diff mbox series

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