summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/boardobj
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/boardobj')
-rw-r--r--drivers/gpu/nvgpu/boardobj/boardobj.c9
-rw-r--r--drivers/gpu/nvgpu/boardobj/boardobj.h10
-rw-r--r--drivers/gpu/nvgpu/boardobj/boardobjgrp.c4
-rw-r--r--drivers/gpu/nvgpu/boardobj/boardobjgrp.h9
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
84boardobj_construct boardobj_construct_super; 87boardobj_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
95static inline struct boardobj *
96boardobj_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
409static inline struct boardobjgrp *
410boardobjgrp_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