[56/59] drm/ttm: add a wrapper for checking if manager is in use
diff mbox series

Message ID 20200804025632.3868079-57-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:56 a.m. UTC
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(-)

Comments

Christian König Aug. 4, 2020, 11:38 a.m. UTC | #1
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
>    *
Ben Skeggs Aug. 5, 2020, 5:56 a.m. UTC | #2
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
Daniel Vetter Aug. 5, 2020, 9:04 a.m. UTC | #3
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

Patch
diff mbox series

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
  *