From c363253c4575b59466e9390943c6b8b5ccfd068f Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 8 Mar 2017 16:59:25 -0800 Subject: 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 Reviewed-on: http://git-master/r/1318320 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gm20b/acr_gm20b.c | 51 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'drivers/gpu/nvgpu/gm20b/acr_gm20b.c') diff --git a/drivers/gpu/nvgpu/gm20b/acr_gm20b.c b/drivers/gpu/nvgpu/gm20b/acr_gm20b.c index e613e65f..db8ef919 100644 --- a/drivers/gpu/nvgpu/gm20b/acr_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/acr_gm20b.c @@ -22,6 +22,7 @@ #include #include +#include #include #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--; } } -- cgit v1.2.2