From: Dave Airlie Date: Tue, 4 Aug 2020 02:55:58 +0000 (+1000) Subject: drm/ttm: make some inline helper functions for cleanup paths. (v2) X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4265accbfc724a68894f91737e765e2cce43fe4e;p=linux.git drm/ttm: make some inline helper functions for cleanup paths. (v2) The disable path is just temporary for now, it will be dropped once has_type is gone in a later patch. v2: add docs. rename to ttm_mem_type_manager namespace Reviewed-by: Christian König Reviewed-by: Ben Skeggs Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-26-airlied@gmail.com --- diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 53017cf065274..be0c0a01b929a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1466,8 +1466,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) return ret; } - man->use_type = false; - man->has_type = false; + ttm_mem_type_manager_disable(man); ret = 0; if (mem_type > 0) { @@ -1480,8 +1479,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = (*man->func->takedown)(man); } - dma_fence_put(man->move); - man->move = NULL; + ttm_mem_type_manager_cleanup(man); return ret; } diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 303014250767f..30dfb9d5f6c94 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -691,6 +691,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma man->use_type = used; } +/** + * ttm_mem_type_manager_disable. + * + * @man: A memory manager object. + * + * Indicate the manager is not to be used and deregistered. (temporary during rework). + */ +static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man) +{ + man->has_type = false; + man->use_type = false; +} + +/** + * ttm_mem_type_manager_cleanup + * + * @man: A memory manager object. + * + * Cleanup the move fences from the memory manager object. + */ +static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man) +{ + dma_fence_put(man->move); + man->move = NULL; +} + /* * ttm_bo_util.c */