From 94feb18de8a687bef7c94999161b6bebaa382709 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Thu, 26 Oct 2017 16:41:24 -0700 Subject: gpu: nvgpu: call destructor for boardobj and boardobjgrp Maintain a list of boardobj and boardobjgrp, so that we can free related objects when removing pmu support. A flag is added in boardobj so that the destructor can determine if it should free the object. This 'allocated' flag is false when the object is embedded into another structure, which should be freed through other means. JIRA EVLR-1959 Bug 200352099 Change-Id: I6a3ff3c57f7428dd145deacf98f2992a9be9796d Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1586596 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/boardobj/boardobj.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/boardobj/boardobj.c') diff --git a/drivers/gpu/nvgpu/boardobj/boardobj.c b/drivers/gpu/nvgpu/boardobj/boardobj.c index c0646eb4..f9be6981 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobj.c +++ b/drivers/gpu/nvgpu/boardobj/boardobj.c @@ -41,6 +41,7 @@ u32 boardobj_construct_super(struct gk20a *g, struct boardobj **ppboardobj, *ppboardobj = nvgpu_kzalloc(g, size); if (*ppboardobj == NULL) return -ENOMEM; + (*ppboardobj)->allocated = true; } pboardobj = *ppboardobj; @@ -53,6 +54,8 @@ u32 boardobj_construct_super(struct gk20a *g, struct boardobj **ppboardobj, pboardobj->destruct = boardobj_destruct_super; pboardobj->pmudatainit = boardobj_pmudatainit_super; + nvgpu_list_add(&pboardobj->node, &g->boardobj_head); + return 0; } @@ -61,7 +64,11 @@ u32 boardobj_destruct_super(struct boardobj *pboardobj) gk20a_dbg_info(""); if (pboardobj == NULL) return -EINVAL; - nvgpu_kfree(pboardobj->g, pboardobj); + + nvgpu_list_del(&pboardobj->node); + if (pboardobj->allocated) + nvgpu_kfree(pboardobj->g, pboardobj); + return 0; } -- cgit v1.2.2