summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gm20b/acr_gm20b.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-08 19:59:25 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-28 12:39:07 -0400
commitc363253c4575b59466e9390943c6b8b5ccfd068f (patch)
treee9102715e24f8cea222f5a2be51caf8360f9b2da /drivers/gpu/nvgpu/gm20b/acr_gm20b.c
parent555e44b283175ef740a689442a508b2faf62f247 (diff)
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>
Diffstat (limited to 'drivers/gpu/nvgpu/gm20b/acr_gm20b.c')
-rw-r--r--drivers/gpu/nvgpu/gm20b/acr_gm20b.c51
1 files changed, 28 insertions, 23 deletions
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 @@
22 22
23#include <nvgpu/timers.h> 23#include <nvgpu/timers.h>
24#include <nvgpu/nvgpu_common.h> 24#include <nvgpu/nvgpu_common.h>
25#include <nvgpu/kmem.h>
25#include <nvgpu/acr/nvgpu_acr.h> 26#include <nvgpu/acr/nvgpu_acr.h>
26 27
27#include "gk20a/gk20a.h" 28#include "gk20a/gk20a.h"
@@ -52,8 +53,10 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
52 struct ls_flcn_mgr *plsfm); 53 struct ls_flcn_mgr *plsfm);
53static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm, 54static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
54 struct flcn_ucode_img *ucode_image, u32 falcon_id); 55 struct flcn_ucode_img *ucode_image, u32 falcon_id);
55static void lsfm_free_ucode_img_res(struct flcn_ucode_img *p_img); 56static void lsfm_free_ucode_img_res(struct gk20a *g,
56static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img *p_img); 57 struct flcn_ucode_img *p_img);
58static void lsfm_free_nonpmu_ucode_img_res(struct gk20a *g,
59 struct flcn_ucode_img *p_img);
57static int lsf_gen_wpr_requirements(struct gk20a *g, struct ls_flcn_mgr *plsfm); 60static int lsf_gen_wpr_requirements(struct gk20a *g, struct ls_flcn_mgr *plsfm);
58static void lsfm_init_wpr_contents(struct gk20a *g, struct ls_flcn_mgr *plsfm, 61static void lsfm_init_wpr_contents(struct gk20a *g, struct ls_flcn_mgr *plsfm,
59 struct mem_desc *nonwpr); 62 struct mem_desc *nonwpr);
@@ -159,7 +162,7 @@ static int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
159 goto release_sig; 162 goto release_sig;
160 } 163 }
161 164
162 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL); 165 lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
163 if (!lsf_desc) { 166 if (!lsf_desc) {
164 err = -ENOMEM; 167 err = -ENOMEM;
165 goto release_sig; 168 goto release_sig;
@@ -196,7 +199,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
196 gk20a_err(dev_from_gk20a(g), "failed to load fecs sig"); 199 gk20a_err(dev_from_gk20a(g), "failed to load fecs sig");
197 return -ENOENT; 200 return -ENOENT;
198 } 201 }
199 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL); 202 lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
200 if (!lsf_desc) { 203 if (!lsf_desc) {
201 err = -ENOMEM; 204 err = -ENOMEM;
202 goto rel_sig; 205 goto rel_sig;
@@ -204,7 +207,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
204 memcpy(lsf_desc, (void *)fecs_sig->data, sizeof(struct lsf_ucode_desc)); 207 memcpy(lsf_desc, (void *)fecs_sig->data, sizeof(struct lsf_ucode_desc));
205 lsf_desc->falcon_id = LSF_FALCON_ID_FECS; 208 lsf_desc->falcon_id = LSF_FALCON_ID_FECS;
206 209
207 p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc), GFP_KERNEL); 210 p_img->desc = nvgpu_kzalloc(g, sizeof(struct pmu_ucode_desc));
208 if (p_img->desc == NULL) { 211 if (p_img->desc == NULL) {
209 err = -ENOMEM; 212 err = -ENOMEM;
210 goto free_lsf_desc; 213 goto free_lsf_desc;
@@ -247,7 +250,7 @@ static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
247 release_firmware(fecs_sig); 250 release_firmware(fecs_sig);
248 return 0; 251 return 0;
249free_lsf_desc: 252free_lsf_desc:
250 kfree(lsf_desc); 253 nvgpu_kfree(g, lsf_desc);
251rel_sig: 254rel_sig:
252 release_firmware(fecs_sig); 255 release_firmware(fecs_sig);
253 return err; 256 return err;
@@ -266,7 +269,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
266 gk20a_err(dev_from_gk20a(g), "failed to load gpccs sig"); 269 gk20a_err(dev_from_gk20a(g), "failed to load gpccs sig");
267 return -ENOENT; 270 return -ENOENT;
268 } 271 }
269 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc), GFP_KERNEL); 272 lsf_desc = nvgpu_kzalloc(g, sizeof(struct lsf_ucode_desc));
270 if (!lsf_desc) { 273 if (!lsf_desc) {
271 err = -ENOMEM; 274 err = -ENOMEM;
272 goto rel_sig; 275 goto rel_sig;
@@ -275,7 +278,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
275 sizeof(struct lsf_ucode_desc)); 278 sizeof(struct lsf_ucode_desc));
276 lsf_desc->falcon_id = LSF_FALCON_ID_GPCCS; 279 lsf_desc->falcon_id = LSF_FALCON_ID_GPCCS;
277 280
278 p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc), GFP_KERNEL); 281 p_img->desc = nvgpu_kzalloc(g, sizeof(struct pmu_ucode_desc));
279 if (p_img->desc == NULL) { 282 if (p_img->desc == NULL) {
280 err = -ENOMEM; 283 err = -ENOMEM;
281 goto free_lsf_desc; 284 goto free_lsf_desc;
@@ -318,7 +321,7 @@ static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img)
318 release_firmware(gpccs_sig); 321 release_firmware(gpccs_sig);
319 return 0; 322 return 0;
320free_lsf_desc: 323free_lsf_desc:
321 kfree(lsf_desc); 324 nvgpu_kfree(g, lsf_desc);
322rel_sig: 325rel_sig:
323 release_firmware(gpccs_sig); 326 release_firmware(gpccs_sig);
324 return err; 327 return err;
@@ -406,7 +409,7 @@ int prepare_ucode_blob(struct gk20a *g)
406 gm20b_dbg_pmu("wpr carveout base:%llx\n", wpr_inf.wpr_base); 409 gm20b_dbg_pmu("wpr carveout base:%llx\n", wpr_inf.wpr_base);
407 gm20b_dbg_pmu("wpr carveout size :%x\n", wprsize); 410 gm20b_dbg_pmu("wpr carveout size :%x\n", wprsize);
408 411
409 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); 412 sgt = nvgpu_kzalloc(g, sizeof(*sgt));
410 if (!sgt) { 413 if (!sgt) {
411 gk20a_err(dev_from_gk20a(g), "failed to allocate memory\n"); 414 gk20a_err(dev_from_gk20a(g), "failed to allocate memory\n");
412 return -ENOMEM; 415 return -ENOMEM;
@@ -502,7 +505,7 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
502 /*Free any ucode image resources if not managing this falcon*/ 505 /*Free any ucode image resources if not managing this falcon*/
503 if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) { 506 if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) {
504 gm20b_dbg_pmu("pmu is not LSFM managed\n"); 507 gm20b_dbg_pmu("pmu is not LSFM managed\n");
505 lsfm_free_ucode_img_res(&ucode_img); 508 lsfm_free_ucode_img_res(g, &ucode_img);
506 } 509 }
507 510
508 /* Enumerate all constructed falcon objects, 511 /* Enumerate all constructed falcon objects,
@@ -534,7 +537,7 @@ static int lsfm_discover_ucode_images(struct gk20a *g,
534 } else { 537 } else {
535 gm20b_dbg_pmu("not managed %d\n", 538 gm20b_dbg_pmu("not managed %d\n",
536 ucode_img.lsf_desc->falcon_id); 539 ucode_img.lsf_desc->falcon_id);
537 lsfm_free_nonpmu_ucode_img_res( 540 lsfm_free_nonpmu_ucode_img_res(g,
538 &ucode_img); 541 &ucode_img);
539 } 542 }
540 } 543 }
@@ -912,7 +915,7 @@ static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
912{ 915{
913 916
914 struct lsfm_managed_ucode_img *pnode; 917 struct lsfm_managed_ucode_img *pnode;
915 pnode = kzalloc(sizeof(struct lsfm_managed_ucode_img), GFP_KERNEL); 918 pnode = nvgpu_kzalloc(g, sizeof(struct lsfm_managed_ucode_img));
916 if (pnode == NULL) 919 if (pnode == NULL)
917 return -ENOMEM; 920 return -ENOMEM;
918 921
@@ -936,24 +939,26 @@ static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr *plsfm,
936 return 0; 939 return 0;
937} 940}
938 941
939/* Free any ucode image structure resources*/ 942/* Free any ucode image structure resources. */
940static void lsfm_free_ucode_img_res(struct flcn_ucode_img *p_img) 943static void lsfm_free_ucode_img_res(struct gk20a *g,
944 struct flcn_ucode_img *p_img)
941{ 945{
942 if (p_img->lsf_desc != NULL) { 946 if (p_img->lsf_desc != NULL) {
943 kfree(p_img->lsf_desc); 947 nvgpu_kfree(g, p_img->lsf_desc);
944 p_img->lsf_desc = NULL; 948 p_img->lsf_desc = NULL;
945 } 949 }
946} 950}
947 951
948/* Free any ucode image structure resources*/ 952/* Free any ucode image structure resources. */
949static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img *p_img) 953static void lsfm_free_nonpmu_ucode_img_res(struct gk20a *g,
954 struct flcn_ucode_img *p_img)
950{ 955{
951 if (p_img->lsf_desc != NULL) { 956 if (p_img->lsf_desc != NULL) {
952 kfree(p_img->lsf_desc); 957 nvgpu_kfree(g, p_img->lsf_desc);
953 p_img->lsf_desc = NULL; 958 p_img->lsf_desc = NULL;
954 } 959 }
955 if (p_img->desc != NULL) { 960 if (p_img->desc != NULL) {
956 kfree(p_img->desc); 961 nvgpu_kfree(g, p_img->desc);
957 p_img->desc = NULL; 962 p_img->desc = NULL;
958 } 963 }
959} 964}
@@ -966,12 +971,12 @@ static void free_acr_resources(struct gk20a *g, struct ls_flcn_mgr *plsfm)
966 mg_ucode_img = plsfm->ucode_img_list; 971 mg_ucode_img = plsfm->ucode_img_list;
967 if (mg_ucode_img->ucode_img.lsf_desc->falcon_id == 972 if (mg_ucode_img->ucode_img.lsf_desc->falcon_id ==
968 LSF_FALCON_ID_PMU) 973 LSF_FALCON_ID_PMU)
969 lsfm_free_ucode_img_res(&mg_ucode_img->ucode_img); 974 lsfm_free_ucode_img_res(g, &mg_ucode_img->ucode_img);
970 else 975 else
971 lsfm_free_nonpmu_ucode_img_res( 976 lsfm_free_nonpmu_ucode_img_res(g,
972 &mg_ucode_img->ucode_img); 977 &mg_ucode_img->ucode_img);
973 plsfm->ucode_img_list = mg_ucode_img->next; 978 plsfm->ucode_img_list = mg_ucode_img->next;
974 kfree(mg_ucode_img); 979 nvgpu_kfree(g, mg_ucode_img);
975 cnt--; 980 cnt--;
976 } 981 }
977} 982}