Commit de3688e4 authored by Christian König's avatar Christian König
Browse files

drm/ttm: add ttm_resource_fini v2



Make sure we call the common cleanup function in all
implementations of the resource manager.

v2: fix missing case in i915, rudimentary kerneldoc, should be
    filled in more when we add more functionality

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220124122514.1832-2-christian.koenig@amd.com
parent 2343bcdb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
	return 0;

err_free:
	ttm_resource_fini(man, &node->base.base);
	kfree(node);

err_out:
@@ -200,6 +201,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
	if (!(res->placement & TTM_PL_FLAG_TEMPORARY))
		atomic64_sub(res->num_pages, &mgr->used);

	ttm_resource_fini(man, res);
	kfree(node);
}

+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ static void amdgpu_preempt_mgr_del(struct ttm_resource_manager *man,
	struct amdgpu_preempt_mgr *mgr = to_preempt_mgr(man);

	atomic64_sub(res->num_pages, &mgr->used);
	ttm_resource_fini(man, res);
	kfree(res);
}

+2 −0
Original line number Diff line number Diff line
@@ -476,6 +476,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
	while (i--)
		drm_mm_remove_node(&node->mm_nodes[i]);
	spin_unlock(&mgr->lock);
	ttm_resource_fini(man, &node->base);
	kvfree(node);

error_sub:
@@ -515,6 +516,7 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
	atomic64_sub(usage, &mgr->usage);
	atomic64_sub(vis_usage, &mgr->vis_usage);

	ttm_resource_fini(man, res);
	kvfree(node);
}

+2 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
	drm_buddy_free_list(mm, &bman_res->blocks);
	mutex_unlock(&bman->lock);
err_free_res:
	ttm_resource_fini(man, &bman_res->base);
	kfree(bman_res);
	return err;
}
@@ -124,6 +125,7 @@ static void i915_ttm_buddy_man_free(struct ttm_resource_manager *man,
	drm_buddy_free_list(&bman->mm, &bman_res->blocks);
	mutex_unlock(&bman->lock);

	ttm_resource_fini(man, res);
	kfree(bman_res);
}

+2 −1
Original line number Diff line number Diff line
@@ -162,11 +162,12 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
}

void
nouveau_mem_del(struct ttm_resource *reg)
nouveau_mem_del(struct ttm_resource_manager *man, struct ttm_resource *reg)
{
	struct nouveau_mem *mem = nouveau_mem(reg);

	nouveau_mem_fini(mem);
	ttm_resource_fini(man, reg);
	kfree(mem);
}

Loading