drm/ttm: nuke ttm_bo_evict_mm and rename mgr function v3
Make it more clear what the resource manager function does and nuke the wrapper function. v2: nuke the wrapper v3: fix typo in radeon, rebased Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2) Link: https://patchwork.freedesktop.org/patch/393914/
This commit is contained in:
parent
3b53d30485
commit
4ce032d64c
|
@ -1319,6 +1319,7 @@ static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data)
|
|||
struct drm_info_node *node = (struct drm_info_node *)m->private;
|
||||
struct drm_device *dev = node->minor->dev;
|
||||
struct amdgpu_device *adev = drm_to_adev(dev);
|
||||
struct ttm_resource_manager *man;
|
||||
int r;
|
||||
|
||||
r = pm_runtime_get_sync(dev->dev);
|
||||
|
@ -1327,7 +1328,9 @@ static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data)
|
|||
return r;
|
||||
}
|
||||
|
||||
seq_printf(m, "(%d)\n", ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_TT));
|
||||
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
|
||||
r = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
|
||||
seq_printf(m, "(%d)\n", r);
|
||||
|
||||
pm_runtime_mark_last_busy(dev->dev);
|
||||
pm_runtime_put_autosuspend(dev->dev);
|
||||
|
|
|
@ -136,7 +136,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
|
|||
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
|
||||
ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
|
||||
ret = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1029,6 +1029,8 @@ void amdgpu_bo_unpin(struct amdgpu_bo *bo)
|
|||
*/
|
||||
int amdgpu_bo_evict_vram(struct amdgpu_device *adev)
|
||||
{
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
/* late 2.6.33 fix IGP hibernate - we need pm ops to do this correct */
|
||||
#ifndef CONFIG_HIBERNATION
|
||||
if (adev->flags & AMD_IS_APU) {
|
||||
|
@ -1036,7 +1038,9 @@ int amdgpu_bo_evict_vram(struct amdgpu_device *adev)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM);
|
||||
|
||||
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
|
||||
return ttm_resource_manager_evict_all(&adev->mman.bdev, man);
|
||||
}
|
||||
|
||||
static const char *amdgpu_vram_names[] = {
|
||||
|
|
|
@ -212,7 +212,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
|
|||
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
|
||||
ret = ttm_resource_manager_force_list_clean(&adev->mman.bdev, man);
|
||||
ret = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
|
|
|
@ -820,6 +820,7 @@ static int
|
|||
nouveau_do_suspend(struct drm_device *dev, bool runtime)
|
||||
{
|
||||
struct nouveau_drm *drm = nouveau_drm(dev);
|
||||
struct ttm_resource_manager *man;
|
||||
int ret;
|
||||
|
||||
nouveau_svm_suspend(drm);
|
||||
|
@ -836,7 +837,9 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
|
|||
}
|
||||
|
||||
NV_DEBUG(drm, "evicting buffers...\n");
|
||||
ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
|
||||
|
||||
man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
|
||||
ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
|
||||
|
||||
NV_DEBUG(drm, "waiting for kernel channels to go idle...\n");
|
||||
if (drm->cechan) {
|
||||
|
|
|
@ -222,7 +222,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)
|
|||
|
||||
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
|
||||
ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
|
||||
ttm_resource_manager_cleanup(man);
|
||||
ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
|
||||
kfree(man);
|
||||
|
@ -267,7 +267,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
|
|||
ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
|
||||
else {
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
ttm_resource_manager_force_list_clean(&drm->ttm.bdev, man);
|
||||
ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
|
||||
ttm_resource_manager_cleanup(man);
|
||||
ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
|
||||
kfree(man);
|
||||
|
|
|
@ -351,10 +351,16 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo)
|
|||
|
||||
int qxl_surf_evict(struct qxl_device *qdev)
|
||||
{
|
||||
return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV);
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
man = ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV);
|
||||
return ttm_resource_manager_evict_all(&qdev->mman.bdev, man);
|
||||
}
|
||||
|
||||
int qxl_vram_evict(struct qxl_device *qdev)
|
||||
{
|
||||
return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM);
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
man = ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM);
|
||||
return ttm_resource_manager_evict_all(&qdev->mman.bdev, man);
|
||||
}
|
||||
|
|
|
@ -402,6 +402,9 @@ void radeon_bo_unpin(struct radeon_bo *bo)
|
|||
|
||||
int radeon_bo_evict_vram(struct radeon_device *rdev)
|
||||
{
|
||||
struct ttm_bo_device *bdev = &rdev->mman.bdev;
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
/* late 2.6.33 fix IGP hibernate - we need pm ops to do this correct */
|
||||
#ifndef CONFIG_HIBERNATION
|
||||
if (rdev->flags & RADEON_IS_IGP) {
|
||||
|
@ -410,7 +413,8 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
return ttm_bo_evict_mm(&rdev->mman.bdev, TTM_PL_VRAM);
|
||||
man = ttm_manager_type(bdev, TTM_PL_VRAM);
|
||||
return ttm_resource_manager_evict_all(bdev, man);
|
||||
}
|
||||
|
||||
void radeon_bo_force_delete(struct radeon_device *rdev)
|
||||
|
|
|
@ -1249,24 +1249,6 @@ size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev,
|
|||
}
|
||||
EXPORT_SYMBOL(ttm_bo_dma_acc_size);
|
||||
|
||||
int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
|
||||
{
|
||||
struct ttm_resource_manager *man = ttm_manager_type(bdev, mem_type);
|
||||
|
||||
if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
|
||||
pr_err("Illegal memory manager memory type %u\n", mem_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!man) {
|
||||
pr_err("Memory type %u has not been initialized\n", mem_type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ttm_resource_manager_force_list_clean(bdev, man);
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_bo_evict_mm);
|
||||
|
||||
static void ttm_bo_global_kobj_release(struct kobject *kobj)
|
||||
{
|
||||
struct ttm_bo_global *glob =
|
||||
|
|
|
@ -149,7 +149,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev,
|
|||
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
|
||||
ret = ttm_resource_manager_force_list_clean(bdev, man);
|
||||
ret = ttm_resource_manager_evict_all(bdev, man);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -75,16 +75,16 @@ void ttm_resource_manager_init(struct ttm_resource_manager *man,
|
|||
EXPORT_SYMBOL(ttm_resource_manager_init);
|
||||
|
||||
/*
|
||||
* ttm_resource_manager_force_list_clean
|
||||
* ttm_resource_manager_evict_all
|
||||
*
|
||||
* @bdev - device to use
|
||||
* @man - manager to use
|
||||
*
|
||||
* Force all the objects out of a memory manager until clean.
|
||||
* Evict all the objects out of a memory manager until it is empty.
|
||||
* Part of memory manager cleanup sequence.
|
||||
*/
|
||||
int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
|
||||
struct ttm_resource_manager *man)
|
||||
int ttm_resource_manager_evict_all(struct ttm_bo_device *bdev,
|
||||
struct ttm_resource_manager *man)
|
||||
{
|
||||
struct ttm_operation_ctx ctx = {
|
||||
.interruptible = false,
|
||||
|
@ -126,7 +126,7 @@ int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
|
|||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_resource_manager_force_list_clean);
|
||||
EXPORT_SYMBOL(ttm_resource_manager_evict_all);
|
||||
|
||||
/**
|
||||
* ttm_resource_manager_debug
|
||||
|
|
|
@ -468,7 +468,10 @@ out_no_query_bo:
|
|||
if (dev_priv->cman)
|
||||
vmw_cmdbuf_remove_pool(dev_priv->cman);
|
||||
if (dev_priv->has_mob) {
|
||||
(void) ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB);
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
man = ttm_manager_type(&dev_priv->bdev, VMW_PL_MOB);
|
||||
ttm_resource_manager_evict_all(&dev_priv->bdev, man);
|
||||
vmw_otables_takedown(dev_priv);
|
||||
}
|
||||
if (dev_priv->cman)
|
||||
|
@ -501,7 +504,10 @@ static void vmw_release_device_early(struct vmw_private *dev_priv)
|
|||
vmw_cmdbuf_remove_pool(dev_priv->cman);
|
||||
|
||||
if (dev_priv->has_mob) {
|
||||
ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB);
|
||||
struct ttm_resource_manager *man;
|
||||
|
||||
man = ttm_manager_type(&dev_priv->bdev, VMW_PL_MOB);
|
||||
ttm_resource_manager_evict_all(&dev_priv->bdev, man);
|
||||
vmw_otables_takedown(dev_priv);
|
||||
}
|
||||
}
|
||||
|
@ -1257,7 +1263,7 @@ void vmw_svga_disable(struct vmw_private *dev_priv)
|
|||
if (ttm_resource_manager_used(man)) {
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
spin_unlock(&dev_priv->svga_lock);
|
||||
if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM))
|
||||
if (ttm_resource_manager_evict_all(&dev_priv->bdev, man))
|
||||
DRM_ERROR("Failed evicting VRAM buffers.\n");
|
||||
vmw_write(dev_priv, SVGA_REG_ENABLE,
|
||||
SVGA_REG_ENABLE_HIDE |
|
||||
|
|
|
@ -143,7 +143,7 @@ void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type)
|
|||
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
|
||||
ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
|
||||
ttm_resource_manager_evict_all(&dev_priv->bdev, man);
|
||||
|
||||
ttm_resource_manager_cleanup(man);
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void vmw_thp_fini(struct vmw_private *dev_priv)
|
|||
|
||||
ttm_resource_manager_set_used(man, false);
|
||||
|
||||
ret = ttm_resource_manager_force_list_clean(&dev_priv->bdev, man);
|
||||
ret = ttm_resource_manager_evict_all(&dev_priv->bdev, man);
|
||||
if (ret)
|
||||
return;
|
||||
spin_lock(&rman->lock);
|
||||
|
|
|
@ -448,26 +448,6 @@ int ttm_bo_init(struct ttm_bo_device *bdev, struct ttm_buffer_object *bo,
|
|||
struct sg_table *sg, struct dma_resv *resv,
|
||||
void (*destroy) (struct ttm_buffer_object *));
|
||||
|
||||
/**
|
||||
* ttm_bo_evict_mm
|
||||
*
|
||||
* @bdev: Pointer to a ttm_bo_device struct.
|
||||
* @mem_type: The memory type.
|
||||
*
|
||||
* Evicts all buffers on the lru list of the memory type.
|
||||
* This is normally part of a VT switch or an
|
||||
* out-of-memory-space-due-to-fragmentation handler.
|
||||
* The caller must make sure that there are no other processes
|
||||
* currently validating buffers, and can do that by taking the
|
||||
* struct ttm_bo_device::ttm_lock in write mode.
|
||||
*
|
||||
* Returns:
|
||||
* -EINVAL: Invalid or uninitialized memory type.
|
||||
* -ERESTARTSYS: The call was interrupted by a signal while waiting to
|
||||
* evict a buffer.
|
||||
*/
|
||||
int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type);
|
||||
|
||||
/**
|
||||
* ttm_kmap_obj_virtual
|
||||
*
|
||||
|
|
|
@ -228,8 +228,8 @@ void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource *res);
|
|||
void ttm_resource_manager_init(struct ttm_resource_manager *man,
|
||||
unsigned long p_size);
|
||||
|
||||
int ttm_resource_manager_force_list_clean(struct ttm_bo_device *bdev,
|
||||
struct ttm_resource_manager *man);
|
||||
int ttm_resource_manager_evict_all(struct ttm_bo_device *bdev,
|
||||
struct ttm_resource_manager *man);
|
||||
|
||||
void ttm_resource_manager_debug(struct ttm_resource_manager *man,
|
||||
struct drm_printer *p);
|
||||
|
|
Loading…
Reference in New Issue