diff mbox series

[47/49] drm/ttm: drop list of memory managers from device.

Message ID 20200731040520.3701599-48-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm mem manager refactoring. | expand

Commit Message

Dave Airlie July 31, 2020, 4:05 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

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

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

Comments

Daniel Vetter July 31, 2020, 9:55 a.m. UTC | #1
On Fri, Jul 31, 2020 at 02:05:18PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> The driver now controls these, the core just controls the system
> memory one.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c    | 2 --
>  include/drm/ttm/ttm_bo_driver.h | 6 ++++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index f2b41c4d7d51..f35548ff17e8 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1608,8 +1608,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 bfc549782775..b2ffeaed94e7 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; /* move to global */

Not sure we want to move this to global. With the shrinker rework ideas I
discussed with Christian somewhere (I think) we could easily do a
per-device shrinker. And then global kinda completely disappears (minus
maybe a drm-global limit on how much crap you can permanently pin in
system memory for scanout, but that's a different thing I think).
-Daniel

>  	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
>  	/*
>  	 * Protected by internal locks.
> @@ -446,9 +446,11 @@ struct ttm_bo_device {
>  static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>  							    int mem_type)
>  {
> +	if (mem_type == TTM_PL_SYSTEM)
> +		return &bdev->sysman;
>  	if (bdev->man_drv[mem_type])
>  		return bdev->man_drv[mem_type];
> -	return &bdev->man_priv[mem_type];
> +	return NULL;
>  }
>  
>  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
Christian König July 31, 2020, 2:57 p.m. UTC | #2
Am 31.07.20 um 06:05 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The driver now controls these, the core just controls the system
> memory one.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 2 --
>   include/drm/ttm/ttm_bo_driver.h | 6 ++++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index f2b41c4d7d51..f35548ff17e8 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1608,8 +1608,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 bfc549782775..b2ffeaed94e7 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; /* move to global */
>   	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
>   	/*
>   	 * Protected by internal locks.
> @@ -446,9 +446,11 @@ struct ttm_bo_device {
>   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
> +	if (mem_type == TTM_PL_SYSTEM)
> +		return &bdev->sysman;
>   	if (bdev->man_drv[mem_type])
>   		return bdev->man_drv[mem_type];
> -	return &bdev->man_priv[mem_type];
> +	return NULL;

Could be simplified to "return bdev->man_drv[mem_type];" if we just 
assign bdev->man_drv[TTM_PL_SYSTEM] during driver init.

Christian.

>   }
>   
>   static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f2b41c4d7d51..f35548ff17e8 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1608,8 +1608,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 bfc549782775..b2ffeaed94e7 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; /* move to global */
 	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
 	/*
 	 * Protected by internal locks.
@@ -446,9 +446,11 @@  struct ttm_bo_device {
 static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
+	if (mem_type == TTM_PL_SYSTEM)
+		return &bdev->sysman;
 	if (bdev->man_drv[mem_type])
 		return bdev->man_drv[mem_type];
-	return &bdev->man_priv[mem_type];
+	return NULL;
 }
 
 static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,