mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
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: Christian König <christian.koenig@amd.com> Reviewed-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-57-airlied@gmail.com
This commit is contained in:
parent
90a0489a71
commit
3f48f938ad
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1000,7 +1000,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))
|
||||
|
@ -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");
|
||||
|
@ -689,6 +689,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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user