diff options
author | Thomas Fleury <tfleury@nvidia.com> | 2017-10-26 19:41:24 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-06 16:41:36 -0500 |
commit | 94feb18de8a687bef7c94999161b6bebaa382709 (patch) | |
tree | 8bea74e24b9e29e5e0a920b956abbe73e90edff3 /drivers/gpu/nvgpu/boardobj | |
parent | 4e7c9c3008e8bd354afa471e1d97ba88b12194da (diff) |
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 <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1586596
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/boardobj')
-rw-r--r-- | drivers/gpu/nvgpu/boardobj/boardobj.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/boardobj/boardobj.h | 10 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/boardobj/boardobjgrp.c | 4 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/boardobj/boardobjgrp.h | 9 |
4 files changed, 31 insertions, 1 deletions
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, | |||
41 | *ppboardobj = nvgpu_kzalloc(g, size); | 41 | *ppboardobj = nvgpu_kzalloc(g, size); |
42 | if (*ppboardobj == NULL) | 42 | if (*ppboardobj == NULL) |
43 | return -ENOMEM; | 43 | return -ENOMEM; |
44 | (*ppboardobj)->allocated = true; | ||
44 | } | 45 | } |
45 | 46 | ||
46 | pboardobj = *ppboardobj; | 47 | pboardobj = *ppboardobj; |
@@ -53,6 +54,8 @@ u32 boardobj_construct_super(struct gk20a *g, struct boardobj **ppboardobj, | |||
53 | pboardobj->destruct = boardobj_destruct_super; | 54 | pboardobj->destruct = boardobj_destruct_super; |
54 | pboardobj->pmudatainit = boardobj_pmudatainit_super; | 55 | pboardobj->pmudatainit = boardobj_pmudatainit_super; |
55 | 56 | ||
57 | nvgpu_list_add(&pboardobj->node, &g->boardobj_head); | ||
58 | |||
56 | return 0; | 59 | return 0; |
57 | } | 60 | } |
58 | 61 | ||
@@ -61,7 +64,11 @@ u32 boardobj_destruct_super(struct boardobj *pboardobj) | |||
61 | gk20a_dbg_info(""); | 64 | gk20a_dbg_info(""); |
62 | if (pboardobj == NULL) | 65 | if (pboardobj == NULL) |
63 | return -EINVAL; | 66 | return -EINVAL; |
64 | nvgpu_kfree(pboardobj->g, pboardobj); | 67 | |
68 | nvgpu_list_del(&pboardobj->node); | ||
69 | if (pboardobj->allocated) | ||
70 | nvgpu_kfree(pboardobj->g, pboardobj); | ||
71 | |||
65 | return 0; | 72 | return 0; |
66 | } | 73 | } |
67 | 74 | ||
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 { | |||
71 | 71 | ||
72 | u8 type; /*type of the device*/ | 72 | u8 type; /*type of the device*/ |
73 | u8 idx; /*index of boardobj within in its group*/ | 73 | u8 idx; /*index of boardobj within in its group*/ |
74 | /* true if allocated in constructor. destructor should free */ | ||
75 | u8 allocated; | ||
74 | u32 type_mask; /*mask of types this boardobjimplements*/ | 76 | u32 type_mask; /*mask of types this boardobjimplements*/ |
75 | boardobj_implements *implements; | 77 | boardobj_implements *implements; |
76 | boardobj_destruct *destruct; | 78 | boardobj_destruct *destruct; |
@@ -79,6 +81,7 @@ struct boardobj { | |||
79 | * that inherit from BOARDOBJ | 81 | * that inherit from BOARDOBJ |
80 | */ | 82 | */ |
81 | boardobj_pmudatainit *pmudatainit; | 83 | boardobj_pmudatainit *pmudatainit; |
84 | struct nvgpu_list_node node; | ||
82 | }; | 85 | }; |
83 | 86 | ||
84 | boardobj_construct boardobj_construct_super; | 87 | boardobj_construct boardobj_construct_super; |
@@ -89,4 +92,11 @@ boardobj_pmudatainit boardobj_pmudatainit_super; | |||
89 | #define BOARDOBJ_GET_TYPE(pobj) (((struct boardobj *)(pobj))->type) | 92 | #define BOARDOBJ_GET_TYPE(pobj) (((struct boardobj *)(pobj))->type) |
90 | #define BOARDOBJ_GET_IDX(pobj) (((struct boardobj *)(pobj))->idx) | 93 | #define BOARDOBJ_GET_IDX(pobj) (((struct boardobj *)(pobj))->idx) |
91 | 94 | ||
95 | static inline struct boardobj * | ||
96 | boardobj_from_node(struct nvgpu_list_node *node) | ||
97 | { | ||
98 | return (struct boardobj *) | ||
99 | ((uintptr_t)node - offsetof(struct boardobj, node)); | ||
100 | }; | ||
101 | |||
92 | #endif | 102 | #endif |
diff --git a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c index 66c87e08..caed11e9 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c +++ b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c | |||
@@ -86,6 +86,8 @@ u32 boardobjgrp_construct_super(struct gk20a *g, struct boardobjgrp *pboardobjgr | |||
86 | pboardobjgrp->objmaxidx = CTRL_BOARDOBJ_IDX_INVALID; | 86 | pboardobjgrp->objmaxidx = CTRL_BOARDOBJ_IDX_INVALID; |
87 | pboardobjgrp->bconstructed = true; | 87 | pboardobjgrp->bconstructed = true; |
88 | 88 | ||
89 | nvgpu_list_add(&pboardobjgrp->node, &g->boardobjgrp_head); | ||
90 | |||
89 | return 0; | 91 | return 0; |
90 | } | 92 | } |
91 | 93 | ||
@@ -144,6 +146,8 @@ u32 boardobjgrp_destruct_super(struct boardobjgrp *pboardobjgrp) | |||
144 | if (status == 0) | 146 | if (status == 0) |
145 | status = stat; | 147 | status = stat; |
146 | 148 | ||
149 | nvgpu_list_del(&pboardobjgrp->node); | ||
150 | |||
147 | pboardobjgrp->bconstructed = false; | 151 | pboardobjgrp->bconstructed = false; |
148 | 152 | ||
149 | return status; | 153 | return status; |
diff --git a/drivers/gpu/nvgpu/boardobj/boardobjgrp.h b/drivers/gpu/nvgpu/boardobj/boardobjgrp.h index 14d7c1bb..32e92ae0 100644 --- a/drivers/gpu/nvgpu/boardobj/boardobjgrp.h +++ b/drivers/gpu/nvgpu/boardobj/boardobjgrp.h | |||
@@ -199,6 +199,7 @@ struct boardobjgrp { | |||
199 | 199 | ||
200 | boardobjgrp_pmudatainstget *pmudatainstget; | 200 | boardobjgrp_pmudatainstget *pmudatainstget; |
201 | boardobjgrp_pmustatusinstget *pmustatusinstget; | 201 | boardobjgrp_pmustatusinstget *pmustatusinstget; |
202 | struct nvgpu_list_node node; | ||
202 | }; | 203 | }; |
203 | 204 | ||
204 | /* | 205 | /* |
@@ -404,4 +405,12 @@ void boardobjgrpe32hdrset(struct nv_pmu_boardobjgrp *hdr, u32 objmask); | |||
404 | idx += 1; \ | 405 | idx += 1; \ |
405 | (n32) = idx; \ | 406 | (n32) = idx; \ |
406 | } | 407 | } |
408 | |||
409 | static inline struct boardobjgrp * | ||
410 | boardobjgrp_from_node(struct nvgpu_list_node *node) | ||
411 | { | ||
412 | return (struct boardobjgrp *) | ||
413 | ((uintptr_t)node - offsetof(struct boardobjgrp, node)); | ||
414 | }; | ||
415 | |||
407 | #endif | 416 | #endif |