Commit 3f48f938 authored by Dave Airlie's avatar Dave Airlie

drm/ttm: add a wrapper for checking if manager is in use

This converts vmwgfx over to using an interface to set the
in use and check the in use flag.
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-57-airlied@gmail.com
parent 90a0489a
...@@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) ...@@ -240,7 +240,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
ttm_mem_type_manager_init(man, size_pages); ttm_mem_type_manager_init(man, size_pages);
ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
ttm_mem_type_manager_set_used(man, true); ttm_mem_type_manager_set_used(man, true);
return 0; return 0;
} }
......
...@@ -1000,7 +1000,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo, ...@@ -1000,7 +1000,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
return ret; return ret;
man = ttm_manager_type(bdev, mem_type); man = ttm_manager_type(bdev, mem_type);
if (!man || !man->use_type) if (!man || !ttm_mem_type_manager_used(man))
return -EBUSY; return -EBUSY;
if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags)) if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags))
......
...@@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv) ...@@ -630,7 +630,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED,
false, dev_priv->vram_size >> PAGE_SHIFT); false, dev_priv->vram_size >> PAGE_SHIFT);
#endif #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; return ret;
} }
...@@ -1192,9 +1192,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv) ...@@ -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); struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
spin_lock(&dev_priv->svga_lock); 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); 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); spin_unlock(&dev_priv->svga_lock);
} }
...@@ -1223,8 +1223,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv) ...@@ -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); struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
spin_lock(&dev_priv->svga_lock); spin_lock(&dev_priv->svga_lock);
if (man->use_type) { if (ttm_mem_type_manager_used(man)) {
man->use_type = false; ttm_mem_type_manager_set_used(man, false);
vmw_write(dev_priv, SVGA_REG_ENABLE, vmw_write(dev_priv, SVGA_REG_ENABLE,
SVGA_REG_ENABLE_HIDE | SVGA_REG_ENABLE_HIDE |
SVGA_REG_ENABLE_ENABLE); SVGA_REG_ENABLE_ENABLE);
...@@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv) ...@@ -1257,8 +1257,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
vmw_kms_lost_device(dev_priv->dev); vmw_kms_lost_device(dev_priv->dev);
ttm_write_lock(&dev_priv->reservation_sem, false); ttm_write_lock(&dev_priv->reservation_sem, false);
spin_lock(&dev_priv->svga_lock); spin_lock(&dev_priv->svga_lock);
if (man->use_type) { if (ttm_mem_type_manager_used(man)) {
man->use_type = false; ttm_mem_type_manager_set_used(man, false);
spin_unlock(&dev_priv->svga_lock); spin_unlock(&dev_priv->svga_lock);
if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM)) if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
DRM_ERROR("Failed evicting VRAM buffers.\n"); DRM_ERROR("Failed evicting VRAM buffers.\n");
......
...@@ -689,6 +689,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma ...@@ -689,6 +689,20 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
man->use_type = used; 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 * ttm_mem_type_manager_cleanup
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment