mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: Use new kmem API functions (gm20b/*)
Use the new kmem API functions in gm20b/*. Also add a struct gk20a pointer to lsfm_free_ucode_img_res() lsfm_free_nonpmu_ucode_img_res() so nvgpu_kfree() works. Bug 1799159 Bug 1823380 Change-Id: I3373600455553710adb14e0fb5743bf197095a03 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1318320 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
555e44b283
commit
c363253c45
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <nvgpu/timers.h>
|
||||
#include <nvgpu/nvgpu_common.h>
|
||||
#include <nvgpu/kmem.h>
|
||||
#include <nvgpu/acr/nvgpu_acr.h>
|
||||
|
||||
#include "gk20a/gk20a.h"
|
||||
@@ -52,8 +53,10 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
|
||||
struct ls_flcn_mgr *plsfm);
|
||||
static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
|
||||
struct flcn_ucode_img *ucode_image, u32 falcon_id);
|
||||
static void lsfm_free_ucode_img_res(struct flcn_ucode_img *p_img);
|
||||
static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img *p_img);
|
||||
static void lsfm_free_ucode_img_res(struct gk20a *g,
|
||||
struct flcn_ucode_img *p_img);
|
||||
static void lsfm_free_nonpmu_ucode_img_res(struct gk20a *g,
|
||||
struct flcn_ucode_img *p_img);
|
||||
static int lsf_gen_wpr_requirements(struct gk20a *g, struct ls_flcn_mgr *plsfm);
|
||||
static void lsfm_init_wpr_contents(struct gk20a *g, struct ls_flcn_mgr *plsfm,
|
||||
struct mem_desc *nonwpr);
|
||||
@@ -159,7 +162,7 @@ static int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
goto release_sig;
|
||||
}
|
||||
|
||||
lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL);
|
||||
lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
|
||||
if (!lsf_desc) {
|
||||
err = -ENOMEM;
|
||||
goto release_sig;
|
||||
@@ -196,7 +199,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
gk20a_err(dev_from_gk20a(g), "failed to load fecs sig");
|
||||
return -ENOENT;
|
||||
}
|
||||
lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL);
|
||||
lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
|
||||
if (!lsf_desc) {
|
||||
err = -ENOMEM;
|
||||
goto rel_sig;
|
||||
@@ -204,7 +207,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
memcpy(lsf_desc, (void *)fecs_sig->data, sizeof(struct lsf_ucode_desc));
|
||||
lsf_desc->falcon_id = LSF_FALCON_ID_FECS;
|
||||
|
||||
p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc), GFP_KERNEL);
|
||||
p_img->desc = nvgpu_kzalloc(g, sizeof(struct pmu_ucode_desc));
|
||||
if (p_img->desc == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto free_lsf_desc;
|
||||
@@ -247,7 +250,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
release_firmware(fecs_sig);
|
||||
return 0;
|
||||
free_lsf_desc:
|
||||
kfree(lsf_desc);
|
||||
nvgpu_kfree(g, lsf_desc);
|
||||
rel_sig:
|
||||
release_firmware(fecs_sig);
|
||||
return err;
|
||||
@@ -266,7 +269,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
gk20a_err(dev_from_gk20a(g), "failed to load gpccs sig");
|
||||
return -ENOENT;
|
||||
}
|
||||
lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL);
|
||||
lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
|
||||
if (!lsf_desc) {
|
||||
err = -ENOMEM;
|
||||
goto rel_sig;
|
||||
@@ -275,7 +278,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
sizeof(struct lsf_ucode_desc));
|
||||
lsf_desc->falcon_id = LSF_FALCON_ID_GPCCS;
|
||||
|
||||
p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc), GFP_KERNEL);
|
||||
p_img->desc = nvgpu_kzalloc(g, sizeof(struct pmu_ucode_desc));
|
||||
if (p_img->desc == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto free_lsf_desc;
|
||||
@@ -318,7 +321,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
|
||||
release_firmware(gpccs_sig);
|
||||
return 0;
|
||||
free_lsf_desc:
|
||||
kfree(lsf_desc);
|
||||
nvgpu_kfree(g, lsf_desc);
|
||||
rel_sig:
|
||||
release_firmware(gpccs_sig);
|
||||
return err;
|
||||
@@ -406,7 +409,7 @@ int prepare_ucode_blob(struct gk20a *g)
|
||||
gm20b_dbg_pmu("wpr carveout base:%llx\n", wpr_inf.wpr_base);
|
||||
gm20b_dbg_pmu("wpr carveout size :%x\n", wprsize);
|
||||
|
||||
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
|
||||
sgt = nvgpu_kzalloc(g, sizeof(*sgt));
|
||||
if (!sgt) {
|
||||
gk20a_err(dev_from_gk20a(g), "failed to allocate memory\n");
|
||||
return -ENOMEM;
|
||||
@@ -502,7 +505,7 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
|
||||
/*Free any ucode image resources if not managing this falcon*/
|
||||
if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) {
|
||||
gm20b_dbg_pmu("pmu is not LSFM managed\n");
|
||||
lsfm_free_ucode_img_res(&ucode_img);
|
||||
lsfm_free_ucode_img_res(g, &ucode_img);
|
||||
}
|
||||
|
||||
/* Enumerate all constructed falcon objects,
|
||||
@@ -534,7 +537,7 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
|
||||
} else {
|
||||
gm20b_dbg_pmu("not managed %d\n",
|
||||
ucode_img.lsf_desc->falcon_id);
|
||||
lsfm_free_nonpmu_ucode_img_res(
|
||||
lsfm_free_nonpmu_ucode_img_res(g,
|
||||
&ucode_img);
|
||||
}
|
||||
}
|
||||
@@ -912,7 +915,7 @@ static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
|
||||
{
|
||||
|
||||
struct lsfm_managed_ucode_img *pnode;
|
||||
pnode = kzalloc(sizeof(struct lsfm_managed_ucode_img), GFP_KERNEL);
|
||||
pnode = nvgpu_kzalloc(g, sizeof(struct lsfm_managed_ucode_img));
|
||||
if (pnode == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -936,24 +939,26 @@ static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Free any ucode image structure resources*/
|
||||
static void lsfm_free_ucode_img_res(struct flcn_ucode_img *p_img)
|
||||
/* Free any ucode image structure resources. */
|
||||
static void lsfm_free_ucode_img_res(struct gk20a *g,
|
||||
struct flcn_ucode_img *p_img)
|
||||
{
|
||||
if (p_img->lsf_desc != NULL) {
|
||||
kfree(p_img->lsf_desc);
|
||||
nvgpu_kfree(g, p_img->lsf_desc);
|
||||
p_img->lsf_desc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free any ucode image structure resources*/
|
||||
static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img *p_img)
|
||||
/* Free any ucode image structure resources. */
|
||||
static void lsfm_free_nonpmu_ucode_img_res(struct gk20a *g,
|
||||
struct flcn_ucode_img *p_img)
|
||||
{
|
||||
if (p_img->lsf_desc != NULL) {
|
||||
kfree(p_img->lsf_desc);
|
||||
nvgpu_kfree(g, p_img->lsf_desc);
|
||||
p_img->lsf_desc = NULL;
|
||||
}
|
||||
if (p_img->desc != NULL) {
|
||||
kfree(p_img->desc);
|
||||
nvgpu_kfree(g, p_img->desc);
|
||||
p_img->desc = NULL;
|
||||
}
|
||||
}
|
||||
@@ -966,12 +971,12 @@ static void free_acr_resources(struct gk20a *g, struct ls_flcn_mgr *plsfm)
|
||||
mg_ucode_img = plsfm->ucode_img_list;
|
||||
if (mg_ucode_img->ucode_img.lsf_desc->falcon_id ==
|
||||
LSF_FALCON_ID_PMU)
|
||||
lsfm_free_ucode_img_res(&mg_ucode_img->ucode_img);
|
||||
lsfm_free_ucode_img_res(g, &mg_ucode_img->ucode_img);
|
||||
else
|
||||
lsfm_free_nonpmu_ucode_img_res(
|
||||
lsfm_free_nonpmu_ucode_img_res(g,
|
||||
&mg_ucode_img->ucode_img);
|
||||
plsfm->ucode_img_list = mg_ucode_img->next;
|
||||
kfree(mg_ucode_img);
|
||||
nvgpu_kfree(g, mg_ucode_img);
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <dt-bindings/soc/gm20b-fuse.h>
|
||||
|
||||
#include <nvgpu/kmem.h>
|
||||
|
||||
#include "gk20a/gk20a.h"
|
||||
#include "gk20a/gr_gk20a.h"
|
||||
|
||||
@@ -593,7 +595,7 @@ static int gr_gm20b_load_smid_config(struct gk20a *g)
|
||||
u32 i, j;
|
||||
u32 tpc_index, gpc_index;
|
||||
|
||||
tpc_sm_id = kcalloc(gr_cwd_sm_id__size_1_v(), sizeof(u32), GFP_KERNEL);
|
||||
tpc_sm_id = nvgpu_kcalloc(g, gr_cwd_sm_id__size_1_v(), sizeof(u32));
|
||||
if (!tpc_sm_id)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -625,7 +627,7 @@ static int gr_gm20b_load_smid_config(struct gk20a *g)
|
||||
for (i = 0; i < gr_cwd_sm_id__size_1_v(); i++)
|
||||
gk20a_writel(g, gr_cwd_sm_id_r(i), tpc_sm_id[i]);
|
||||
|
||||
kfree(tpc_sm_id);
|
||||
nvgpu_kfree(g, tpc_sm_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1420,7 +1422,7 @@ static int gm20b_gr_fuse_override(struct gk20a *g)
|
||||
if (count <= 0)
|
||||
return count;
|
||||
|
||||
fuses = kmalloc(sizeof(u32) * count * 2, GFP_KERNEL);
|
||||
fuses = nvgpu_kmalloc(g, sizeof(u32) * count * 2);
|
||||
if (!fuses)
|
||||
return -ENOMEM;
|
||||
of_property_read_u32_array(np, "fuse-overrides", fuses, count * 2);
|
||||
@@ -1440,7 +1442,7 @@ static int gm20b_gr_fuse_override(struct gk20a *g)
|
||||
}
|
||||
}
|
||||
|
||||
kfree(fuses);
|
||||
nvgpu_kfree(g, fuses);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user