From 0cf0a7984268c64e906b63a96df3e331ca61f989 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 4 Aug 2020 12:56:08 +1000 Subject: [PATCH] drm/ttm: make TTM responsible for cleaning system only. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Drivers should all be cleaning up their memory managers themselves now, so let the core just clean the system one up. Remove the legacy cleaning interface. Reviewed-by: Christian König Reviewed-by: Ben Skeggs Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-36-airlied@gmail.com --- drivers/gpu/drm/ttm/ttm_bo.c | 54 +++-------------------------------------- include/drm/ttm/ttm_bo_api.h | 28 --------------------- include/drm/ttm/ttm_bo_driver.h | 10 -------- 3 files changed, 4 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 480d23f..400f025 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1450,42 +1450,6 @@ int ttm_mem_type_manager_force_list_clean(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_mem_type_manager_force_list_clean); -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) -{ - struct ttm_mem_type_manager *man; - int ret = -EINVAL; - - if (mem_type >= TTM_NUM_MEM_TYPES) { - pr_err("Illegal memory type %d\n", mem_type); - return ret; - } - man = &bdev->man[mem_type]; - - if (!man->has_type) { - pr_err("Trying to take down uninitialized memory manager type %u\n", - mem_type); - return ret; - } - - ttm_mem_type_manager_disable(man); - - ret = 0; - if (mem_type > 0) { - ret = ttm_mem_type_manager_force_list_clean(bdev, man); - if (ret) { - pr_err("Cleanup eviction failed\n"); - return ret; - } - - if (man->func->takedown) - ret = (*man->func->takedown)(man); - } - - ttm_mem_type_manager_cleanup(man); - - return ret; -} -EXPORT_SYMBOL(ttm_bo_clean_mm); int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) { @@ -1589,21 +1553,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) { struct ttm_bo_global *glob = &ttm_bo_glob; int ret = 0; - unsigned i = TTM_NUM_MEM_TYPES; + unsigned i; struct ttm_mem_type_manager *man; - while (i--) { - man = &bdev->man[i]; - if (man->has_type) { - man->use_type = false; - if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) { - ret = -EBUSY; - pr_err("DRM memory manager type %d is not clean\n", - i); - } - man->has_type = false; - } - } + man = &bdev->man[TTM_PL_SYSTEM]; + ttm_mem_type_manager_disable(man); mutex_lock(&ttm_global_mutex); list_del(&bdev->device_list); @@ -1616,7 +1570,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) spin_lock(&glob->lru_lock); for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) - if (list_empty(&bdev->man[0].lru[0])) + if (list_empty(&man->lru[0])) pr_debug("Swap list %d was clean\n", i); spin_unlock(&glob->lru_lock); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 56d207b..045f283 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -547,34 +547,6 @@ void ttm_mem_type_manager_init(struct ttm_bo_device *bdev, unsigned long p_size); /** - * ttm_bo_clean_mm - * - * @bdev: Pointer to a ttm_bo_device struct. - * @mem_type: The memory type. - * - * Take down a manager for a given memory type after first walking - * the LRU list to evict any buffers left alive. - * - * Normally, this function is part of lastclose() or unload(), and at that - * point there shouldn't be any buffers left created by user-space, since - * there should've been removed by the file descriptor release() method. - * However, before this function is run, make sure to signal all sync objects, - * and verify that the delayed delete queue is empty. The driver must also - * make sure that there are no NO_EVICT buffers present in this memory type - * when the call is made. - * - * If this function is part of a VT switch, the caller must make sure that - * there are no appications currently validating buffers before this - * function is called. The caller can do that by first taking the - * struct ttm_bo_device::ttm_lock in write mode. - * - * Returns: - * -EINVAL: invalid or uninitialized memory type. - * -EBUSY: There are still buffers left in this memory type. - */ -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); - -/** * ttm_bo_evict_mm * * @bdev: Pointer to a ttm_bo_device struct. diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 811ace1..c76301a 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -49,16 +49,6 @@ struct ttm_mem_type_manager; struct ttm_mem_type_manager_func { /** - * struct ttm_mem_type_manager member takedown - * - * @man: Pointer to a memory type manager. - * - * Called to undo the setup done in init. All allocated resources - * should be freed. - */ - int (*takedown)(struct ttm_mem_type_manager *man); - - /** * struct ttm_mem_type_manager member get_node * * @man: Pointer to a memory type manager. -- 2.7.4