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.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/gpu/nvgpu/boardobj/boardobj.h') diff --git a/drivers/gpu/nvgpu/boardobj/boardobj.h b/drivers/gpu/nvgpu/boardobj/boardobj.h index 5c1b4b81..a433fda8 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobj.h +++ b/drivers/gpu/nvgpu/boardobj/boardobj.h @@ -71,6 +71,8 @@ struct boardobj { u8 type; /*type of the device*/ u8 idx; /*index of boardobj within in its group*/ + /* true if allocated in constructor. destructor should free */ + u8 allocated; u32 type_mask; /*mask of types this boardobjimplements*/ boardobj_implements *implements; boardobj_destruct *destruct; @@ -79,6 +81,7 @@ struct boardobj { * that inherit from BOARDOBJ */ boardobj_pmudatainit *pmudatainit; + struct nvgpu_list_node node; }; boardobj_construct boardobj_construct_super; @@ -89,4 +92,11 @@ boardobj_pmudatainit boardobj_pmudatainit_super; #define BOARDOBJ_GET_TYPE(pobj) (((struct boardobj *)(pobj))->type) #define BOARDOBJ_GET_IDX(pobj) (((struct boardobj *)(pobj))->idx) +static inline struct boardobj * +boardobj_from_node(struct nvgpu_list_node *node) +{ + return (struct boardobj *) + ((uintptr_t)node - offsetof(struct boardobj, node)); +}; + #endif -- cgit v1.2.2