mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: Fix boardobj allocation size
In current implementation we are allocating boardobj in nvgpu_boardobj_construct_super for all units and assigning that pointer to boardobj type, as the size differe for different units assigning the boardobj pointer to a common type will give violations. Fixing them by allocating mem a head and later call construct_super for elements initialization. NVGPU-4484 Change-Id: I9b5ed1a6d8418fec48a29eee38d55fc7d83fcfab Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2335989 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Mahantesh Kumbar <mkumbar@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
Alex Waterman
parent
0115c26f1b
commit
8e545ef04b
@@ -115,20 +115,26 @@ static int pstate_init_pmudata(struct gk20a *g,
|
||||
return status;
|
||||
}
|
||||
|
||||
static int pstate_construct_super(struct gk20a *g, struct boardobj **ppboardobj,
|
||||
size_t size, void *args)
|
||||
static int pstate_construct_super(struct gk20a *g, struct boardobj *ppboardobj,
|
||||
void *args)
|
||||
{
|
||||
return nvgpu_boardobj_construct_super(g, ppboardobj, size, args);
|
||||
int status;
|
||||
|
||||
status = pmu_boardobj_construct_super(g, ppboardobj, args);
|
||||
if (status != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pstate_construct_35(struct gk20a *g, struct boardobj **ppboardobj,
|
||||
u16 size, void *args)
|
||||
static int pstate_construct_35(struct gk20a *g, struct boardobj *ppboardobj,
|
||||
void *args)
|
||||
{
|
||||
struct boardobj *ptmpobj = (struct boardobj *)args;
|
||||
|
||||
ptmpobj->type_mask |= BIT32(CTRL_PERF_PSTATE_TYPE_35);
|
||||
return pstate_construct_super(g, ppboardobj, size, args);
|
||||
return pstate_construct_super(g, ppboardobj, args);
|
||||
}
|
||||
|
||||
static struct pstate *pstate_construct(struct gk20a *g, void *args)
|
||||
@@ -138,8 +144,12 @@ static struct pstate *pstate_construct(struct gk20a *g, void *args)
|
||||
int status;
|
||||
u32 clkidx;
|
||||
|
||||
status = pstate_construct_35(g, (struct boardobj **)&pstate,
|
||||
(u16)sizeof(struct pstate), args);
|
||||
pstate = nvgpu_kzalloc(g, sizeof(struct pstate));
|
||||
if (pstate == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = pstate_construct_35(g, (struct boardobj *)(void *)pstate, args);
|
||||
if (status != 0) {
|
||||
nvgpu_err(g,
|
||||
"error constructing pstate num=%u", ptmppstate->num);
|
||||
|
||||
@@ -290,13 +290,19 @@ static int vfe_equ_construct_super(struct gk20a *g,
|
||||
struct vfe_equ *ptmpequ = (struct vfe_equ *)pargs;
|
||||
int status = 0;
|
||||
|
||||
status = nvgpu_boardobj_construct_super(g, ppboardobj,
|
||||
size, pargs);
|
||||
pvfeequ = nvgpu_kzalloc(g, size);
|
||||
if (pvfeequ == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
status = pmu_boardobj_construct_super(g,
|
||||
(struct boardobj *)(void *)pvfeequ, pargs);
|
||||
if (status != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pvfeequ = (struct vfe_equ *)(void *)*ppboardobj;
|
||||
*ppboardobj = (struct boardobj *)(void *)pvfeequ;
|
||||
|
||||
status = boardobjgrpmask_e32_init(&pvfeequ->mask_depending_vars, NULL);
|
||||
pvfeequ->super.pmudatainit =
|
||||
vfe_equ_pmudatainit_super;
|
||||
|
||||
@@ -344,12 +344,18 @@ static int vfe_var_construct_super(struct gk20a *g,
|
||||
struct vfe_var *ptmpvar = (struct vfe_var *)pargs;
|
||||
int status;
|
||||
|
||||
status = nvgpu_boardobj_construct_super(g, ppboardobj, size, pargs);
|
||||
pvfevar = nvgpu_kzalloc(g, size);
|
||||
if (pvfevar == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
status = pmu_boardobj_construct_super(g,
|
||||
(struct boardobj *)(void *)pvfevar, pargs);
|
||||
if (status != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pvfevar = (struct vfe_var *)(void *)*ppboardobj;
|
||||
*ppboardobj = (struct boardobj *)(void *)pvfevar;
|
||||
|
||||
pvfevar->super.pmudatainit =
|
||||
vfe_var_pmudatainit_super;
|
||||
|
||||
Reference in New Issue
Block a user