From: Dave Airlie <airlied@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel