drm/ttm: remove TTM_MEMTYPE_FLAG_FIXED v2
Instead use a boolean field in the memory manager structure. Also invert the meaning of the field since the use of a TT structure is the special case here. v2: cleanup zero init. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/382079/
This commit is contained in:
parent
418d2ad1ac
commit
be1213a341
|
@ -87,15 +87,14 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
break;
|
||||
case TTM_PL_TT:
|
||||
/* GTT memory */
|
||||
man->use_tt = true;
|
||||
man->func = &amdgpu_gtt_mgr_func;
|
||||
man->available_caching = TTM_PL_MASK_CACHING;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
man->flags = 0;
|
||||
break;
|
||||
case TTM_PL_VRAM:
|
||||
/* "On-card" video ram */
|
||||
man->func = &amdgpu_vram_mgr_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
|
||||
man->default_caching = TTM_PL_FLAG_WC;
|
||||
break;
|
||||
|
@ -104,7 +103,6 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
case AMDGPU_PL_OA:
|
||||
/* On-chip GDS memory*/
|
||||
man->func = &ttm_bo_manager_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED;
|
||||
man->default_caching = TTM_PL_FLAG_UNCACHED;
|
||||
break;
|
||||
|
|
|
@ -1012,7 +1012,6 @@ static int bo_driver_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
break;
|
||||
case TTM_PL_VRAM:
|
||||
man->func = &ttm_bo_manager_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED |
|
||||
TTM_PL_FLAG_WC;
|
||||
man->default_caching = TTM_PL_FLAG_WC;
|
||||
|
|
|
@ -657,7 +657,6 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
case TTM_PL_SYSTEM:
|
||||
break;
|
||||
case TTM_PL_VRAM:
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED |
|
||||
TTM_PL_FLAG_WC;
|
||||
man->default_caching = TTM_PL_FLAG_WC;
|
||||
|
@ -685,13 +684,12 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
else
|
||||
man->func = &ttm_bo_manager_func;
|
||||
|
||||
man->use_tt = true;
|
||||
if (drm->agp.bridge) {
|
||||
man->flags = 0;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED |
|
||||
TTM_PL_FLAG_WC;
|
||||
man->default_caching = TTM_PL_FLAG_WC;
|
||||
} else {
|
||||
man->flags = 0;
|
||||
man->available_caching = TTM_PL_MASK_CACHING;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ static int qxl_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
case TTM_PL_PRIV:
|
||||
/* "On-card" video ram */
|
||||
man->func = &ttm_bo_manager_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_MASK_CACHING;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
break;
|
||||
|
|
|
@ -81,7 +81,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
man->func = &ttm_bo_manager_func;
|
||||
man->available_caching = TTM_PL_MASK_CACHING;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
man->flags = 0;
|
||||
man->use_tt = true;
|
||||
#if IS_ENABLED(CONFIG_AGP)
|
||||
if (rdev->flags & RADEON_IS_AGP) {
|
||||
if (!rdev->ddev->agp) {
|
||||
|
@ -98,7 +98,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
case TTM_PL_VRAM:
|
||||
/* "On-card" video ram */
|
||||
man->func = &ttm_bo_manager_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
|
||||
man->default_caching = TTM_PL_FLAG_WC;
|
||||
break;
|
||||
|
|
|
@ -84,7 +84,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p
|
|||
|
||||
drm_printf(p, " has_type: %d\n", man->has_type);
|
||||
drm_printf(p, " use_type: %d\n", man->use_type);
|
||||
drm_printf(p, " flags: 0x%08X\n", man->flags);
|
||||
drm_printf(p, " use_tt: %d\n", man->use_tt);
|
||||
drm_printf(p, " size: %llu\n", man->size);
|
||||
drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);
|
||||
drm_printf(p, " default_caching: 0x%08X\n", man->default_caching);
|
||||
|
@ -159,7 +159,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
|
|||
man = &bdev->man[mem->mem_type];
|
||||
list_add_tail(&bo->lru, &man->lru[bo->priority]);
|
||||
|
||||
if (!(man->flags & TTM_MEMTYPE_FLAG_FIXED) && bo->ttm &&
|
||||
if (man->use_tt && bo->ttm &&
|
||||
!(bo->ttm->page_flags & (TTM_PAGE_FLAG_SG |
|
||||
TTM_PAGE_FLAG_SWAPPED))) {
|
||||
list_add_tail(&bo->swap, &ttm_bo_glob.swap_lru[bo->priority]);
|
||||
|
@ -286,10 +286,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
|
|||
* Create and bind a ttm if required.
|
||||
*/
|
||||
|
||||
if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
|
||||
bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
|
||||
|
||||
ret = ttm_tt_create(bo, zero);
|
||||
if (new_man->use_tt) {
|
||||
/* Zero init the new TTM structure if the old location should
|
||||
* have used one as well.
|
||||
*/
|
||||
ret = ttm_tt_create(bo, old_man->use_tt);
|
||||
if (ret)
|
||||
goto out_err;
|
||||
|
||||
|
@ -314,8 +315,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
|
|||
if (bdev->driver->move_notify)
|
||||
bdev->driver->move_notify(bo, evict, mem);
|
||||
|
||||
if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
|
||||
!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
|
||||
if (old_man->use_tt && new_man->use_tt)
|
||||
ret = ttm_bo_move_ttm(bo, ctx, mem);
|
||||
else if (bdev->driver->move)
|
||||
ret = bdev->driver->move(bo, evict, ctx, mem);
|
||||
|
@ -340,7 +340,7 @@ moved:
|
|||
|
||||
out_err:
|
||||
new_man = &bdev->man[bo->mem.mem_type];
|
||||
if (new_man->flags & TTM_MEMTYPE_FLAG_FIXED) {
|
||||
if (!new_man->use_tt) {
|
||||
ttm_tt_destroy(bo->ttm);
|
||||
bo->ttm = NULL;
|
||||
}
|
||||
|
@ -1673,6 +1673,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
|
|||
* Initialize the system memory buffer type.
|
||||
* Other types need to be driver / IOCTL initialized.
|
||||
*/
|
||||
bdev->man[TTM_PL_SYSTEM].use_tt = true;
|
||||
bdev->man[TTM_PL_SYSTEM].available_caching = TTM_PL_MASK_CACHING;
|
||||
bdev->man[TTM_PL_SYSTEM].default_caching = TTM_PL_FLAG_CACHED;
|
||||
ret = ttm_bo_init_mm(bdev, TTM_PL_SYSTEM, 0);
|
||||
|
|
|
@ -384,7 +384,7 @@ out2:
|
|||
*old_mem = *new_mem;
|
||||
new_mem->mm_node = NULL;
|
||||
|
||||
if (man->flags & TTM_MEMTYPE_FLAG_FIXED) {
|
||||
if (!man->use_tt) {
|
||||
ttm_tt_destroy(ttm);
|
||||
bo->ttm = NULL;
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (man->flags & TTM_MEMTYPE_FLAG_FIXED) {
|
||||
if (!man->use_tt) {
|
||||
ttm_tt_destroy(bo->ttm);
|
||||
bo->ttm = NULL;
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
|
|||
* bo to be unbound and destroyed.
|
||||
*/
|
||||
|
||||
if (!(man->flags & TTM_MEMTYPE_FLAG_FIXED))
|
||||
if (man->use_tt)
|
||||
ghost_obj->ttm = NULL;
|
||||
else
|
||||
bo->ttm = NULL;
|
||||
|
@ -730,7 +730,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
|
|||
* bo to be unbound and destroyed.
|
||||
*/
|
||||
|
||||
if (!(to->flags & TTM_MEMTYPE_FLAG_FIXED))
|
||||
if (to->use_tt)
|
||||
ghost_obj->ttm = NULL;
|
||||
else
|
||||
bo->ttm = NULL;
|
||||
|
@ -738,7 +738,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
|
|||
dma_resv_unlock(&ghost_obj->base._resv);
|
||||
ttm_bo_put(ghost_obj);
|
||||
|
||||
} else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) {
|
||||
} else if (!from->use_tt) {
|
||||
|
||||
/**
|
||||
* BO doesn't have a TTM we need to bind/unbind. Just remember
|
||||
|
@ -768,7 +768,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (to->flags & TTM_MEMTYPE_FLAG_FIXED) {
|
||||
if (!to->use_tt) {
|
||||
ttm_tt_destroy(bo->ttm);
|
||||
bo->ttm = NULL;
|
||||
}
|
||||
|
|
|
@ -747,7 +747,6 @@ static int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
case TTM_PL_VRAM:
|
||||
/* "On-card" video ram */
|
||||
man->func = &vmw_thp_func;
|
||||
man->flags = TTM_MEMTYPE_FLAG_FIXED;
|
||||
man->available_caching = TTM_PL_FLAG_CACHED;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
break;
|
||||
|
@ -761,6 +760,8 @@ static int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
|
|||
man->func = &vmw_gmrid_manager_func;
|
||||
man->available_caching = TTM_PL_FLAG_CACHED;
|
||||
man->default_caching = TTM_PL_FLAG_CACHED;
|
||||
/* TODO: This is most likely not correct */
|
||||
man->use_tt = true;
|
||||
break;
|
||||
default:
|
||||
DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
|
||||
#define TTM_MAX_BO_PRIORITY 4U
|
||||
|
||||
#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
|
||||
|
||||
struct ttm_mem_type_manager;
|
||||
|
||||
struct ttm_mem_type_manager_func {
|
||||
|
@ -173,7 +171,7 @@ struct ttm_mem_type_manager {
|
|||
|
||||
bool has_type;
|
||||
bool use_type;
|
||||
uint32_t flags;
|
||||
bool use_tt;
|
||||
uint64_t size;
|
||||
uint32_t available_caching;
|
||||
uint32_t default_caching;
|
||||
|
|
Loading…
Reference in New Issue