diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-30 16:16:51 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-04 19:57:03 -0400 |
commit | c86e940e1169be32e92297f6dfb07d0c2cade135 (patch) | |
tree | 86fc119bc20f6db09eda52ace9a2d76c6bf9ef53 /drivers/gpu | |
parent | e3bd4ae2a59fef37a85fbca168fc479dd5514023 (diff) |
gpu: nvgpu: Remove last Linux kmem usage
Replace the last of the Linux kmem API usage with nvgpu kmem
calls instead. Several places are left alone - allocating the
struct gk20a in particular.
Also one function was updated in the clk code to take a struct
gk20a as an argument so that it could use nvgpu_kmalloc().
Bug 1799159
Bug 1823380
Change-Id: I84fc3f8e19c63d6265bac6098dc727d93e3ff613
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1331702
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/clk/clk_arb.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/semaphore.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 17 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/debug_gk20a.c | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 7 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/gr_vgpu.c | 4 |
13 files changed, 32 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_arb.c b/drivers/gpu/nvgpu/clk/clk_arb.c index dc063709..b8be3334 100644 --- a/drivers/gpu/nvgpu/clk/clk_arb.c +++ b/drivers/gpu/nvgpu/clk/clk_arb.c | |||
@@ -472,12 +472,12 @@ void nvgpu_clk_arb_cleanup_arbiter(struct gk20a *g) | |||
472 | destroy_workqueue(arb->update_work_queue); | 472 | destroy_workqueue(arb->update_work_queue); |
473 | arb->update_work_queue = NULL; | 473 | arb->update_work_queue = NULL; |
474 | 474 | ||
475 | kfree(arb->gpc2clk_f_points); | 475 | nvgpu_kfree(g, arb->gpc2clk_f_points); |
476 | kfree(arb->mclk_f_points); | 476 | nvgpu_kfree(g, arb->mclk_f_points); |
477 | 477 | ||
478 | for (index = 0; index < 2; index++) { | 478 | for (index = 0; index < 2; index++) { |
479 | kfree(arb->vf_table_pool[index].gpc2clk_points); | 479 | nvgpu_kfree(g, arb->vf_table_pool[index].gpc2clk_points); |
480 | kfree(arb->vf_table_pool[index].mclk_points); | 480 | nvgpu_kfree(g, arb->vf_table_pool[index].mclk_points); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 722dad20..0d7c05de 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -712,7 +712,7 @@ static int gk20a_channel_event_id_enable(struct channel_gk20a *ch, | |||
712 | return 0; | 712 | return 0; |
713 | 713 | ||
714 | clean_up_free: | 714 | clean_up_free: |
715 | kfree(event_id_data); | 715 | nvgpu_kfree(g, event_id_data); |
716 | clean_up_file: | 716 | clean_up_file: |
717 | fput(file); | 717 | fput(file); |
718 | clean_up: | 718 | clean_up: |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c index 75231c71..c98d9873 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c | |||
@@ -161,7 +161,7 @@ static int gk20a_tsg_event_id_enable(struct tsg_gk20a *tsg, | |||
161 | return 0; | 161 | return 0; |
162 | 162 | ||
163 | clean_up_free: | 163 | clean_up_free: |
164 | kfree(event_id_data); | 164 | nvgpu_kfree(g, event_id_data); |
165 | clean_up_file: | 165 | clean_up_file: |
166 | fput(file); | 166 | fput(file); |
167 | clean_up: | 167 | clean_up: |
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 6fd9bc48..19368339 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |||
@@ -106,7 +106,7 @@ static void nvgpu_lockless_alloc_destroy(struct nvgpu_allocator *a) | |||
106 | 106 | ||
107 | nvgpu_fini_alloc_debug(a); | 107 | nvgpu_fini_alloc_debug(a); |
108 | 108 | ||
109 | vfree(pa->next); | 109 | nvgpu_vfree(a->g, pa->next); |
110 | nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa); | 110 | nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa); |
111 | } | 111 | } |
112 | 112 | ||
diff --git a/drivers/gpu/nvgpu/common/semaphore.c b/drivers/gpu/nvgpu/common/semaphore.c index 675794d1..5d526e64 100644 --- a/drivers/gpu/nvgpu/common/semaphore.c +++ b/drivers/gpu/nvgpu/common/semaphore.c | |||
@@ -74,7 +74,7 @@ void gk20a_semaphore_sea_destroy(struct gk20a *g) | |||
74 | return; | 74 | return; |
75 | 75 | ||
76 | nvgpu_mutex_destroy(&g->sema_sea->sea_lock); | 76 | nvgpu_mutex_destroy(&g->sema_sea->sea_lock); |
77 | kfree(g->sema_sea); | 77 | nvgpu_kfree(g, g->sema_sea); |
78 | g->sema_sea = NULL; | 78 | g->sema_sea = NULL; |
79 | } | 79 | } |
80 | 80 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index cce7a769..7aae2584 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | |||
@@ -436,7 +436,7 @@ u32 gk20a_ce_create_context_with_cb(struct device *dev, | |||
436 | 436 | ||
437 | err = nvgpu_mutex_init(&ce_ctx->gpu_ctx_mutex); | 437 | err = nvgpu_mutex_init(&ce_ctx->gpu_ctx_mutex); |
438 | if (err) { | 438 | if (err) { |
439 | kfree(ce_ctx); | 439 | nvgpu_kfree(g, ce_ctx); |
440 | return ctx_id; | 440 | return ctx_id; |
441 | } | 441 | } |
442 | 442 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 7054e2a2..1ebb1900 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | |||
@@ -85,14 +85,15 @@ static int alloc_session(struct gk20a *g, struct dbg_session_gk20a **_dbg_s) | |||
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | static int alloc_profiler(struct dbg_profiler_object_data **_prof) | 88 | static int alloc_profiler(struct gk20a *g, |
89 | struct dbg_profiler_object_data **_prof) | ||
89 | { | 90 | { |
90 | struct dbg_profiler_object_data *prof; | 91 | struct dbg_profiler_object_data *prof; |
91 | *_prof = NULL; | 92 | *_prof = NULL; |
92 | 93 | ||
93 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, ""); | 94 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, ""); |
94 | 95 | ||
95 | prof = kzalloc(sizeof(*prof), GFP_KERNEL); | 96 | prof = nvgpu_kzalloc(g, sizeof(*prof)); |
96 | if (!prof) | 97 | if (!prof) |
97 | return -ENOMEM; | 98 | return -ENOMEM; |
98 | 99 | ||
@@ -152,7 +153,7 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, | |||
152 | err_destroy_lock: | 153 | err_destroy_lock: |
153 | nvgpu_mutex_destroy(&dbg_session->ch_list_lock); | 154 | nvgpu_mutex_destroy(&dbg_session->ch_list_lock); |
154 | err_free_session: | 155 | err_free_session: |
155 | kfree(dbg_session); | 156 | nvgpu_kfree(g, dbg_session); |
156 | free_ref: | 157 | free_ref: |
157 | gk20a_put(g); | 158 | gk20a_put(g); |
158 | return err; | 159 | return err; |
@@ -435,7 +436,7 @@ int dbg_unbind_single_channel_gk20a(struct dbg_session_gk20a *dbg_s, | |||
435 | release_profiler_reservation(dbg_s, prof_obj); | 436 | release_profiler_reservation(dbg_s, prof_obj); |
436 | } | 437 | } |
437 | list_del(&prof_obj->prof_obj_entry); | 438 | list_del(&prof_obj->prof_obj_entry); |
438 | kfree(prof_obj); | 439 | nvgpu_kfree(g, prof_obj); |
439 | } | 440 | } |
440 | } | 441 | } |
441 | 442 | ||
@@ -537,7 +538,7 @@ int gk20a_dbg_gpu_dev_release(struct inode *inode, struct file *filp) | |||
537 | g->ops.dbg_session_ops. | 538 | g->ops.dbg_session_ops. |
538 | release_profiler_reservation(dbg_s, prof_obj); | 539 | release_profiler_reservation(dbg_s, prof_obj); |
539 | list_del(&prof_obj->prof_obj_entry); | 540 | list_del(&prof_obj->prof_obj_entry); |
540 | kfree(prof_obj); | 541 | nvgpu_kfree(g, prof_obj); |
541 | } | 542 | } |
542 | } | 543 | } |
543 | nvgpu_mutex_release(&g->dbg_sessions_lock); | 544 | nvgpu_mutex_release(&g->dbg_sessions_lock); |
@@ -1527,7 +1528,7 @@ static int nvgpu_ioctl_allocate_profiler_object( | |||
1527 | 1528 | ||
1528 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); | 1529 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); |
1529 | 1530 | ||
1530 | err = alloc_profiler(&prof_obj); | 1531 | err = alloc_profiler(g, &prof_obj); |
1531 | if (err) | 1532 | if (err) |
1532 | goto clean_up; | 1533 | goto clean_up; |
1533 | 1534 | ||
@@ -1540,7 +1541,7 @@ static int nvgpu_ioctl_allocate_profiler_object( | |||
1540 | if (prof_obj->ch == NULL) { | 1541 | if (prof_obj->ch == NULL) { |
1541 | gk20a_err(dev_from_gk20a(g), | 1542 | gk20a_err(dev_from_gk20a(g), |
1542 | "bind a channel for dbg session"); | 1543 | "bind a channel for dbg session"); |
1543 | kfree(prof_obj); | 1544 | nvgpu_kfree(g, prof_obj); |
1544 | err = -EINVAL; | 1545 | err = -EINVAL; |
1545 | goto clean_up; | 1546 | goto clean_up; |
1546 | } | 1547 | } |
@@ -1586,7 +1587,7 @@ static int nvgpu_ioctl_free_profiler_object( | |||
1586 | g->ops.dbg_session_ops. | 1587 | g->ops.dbg_session_ops. |
1587 | release_profiler_reservation(dbg_s, prof_obj); | 1588 | release_profiler_reservation(dbg_s, prof_obj); |
1588 | list_del(&prof_obj->prof_obj_entry); | 1589 | list_del(&prof_obj->prof_obj_entry); |
1589 | kfree(prof_obj); | 1590 | nvgpu_kfree(g, prof_obj); |
1590 | obj_found = true; | 1591 | obj_found = true; |
1591 | break; | 1592 | break; |
1592 | } | 1593 | } |
diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c index a8b9c5fb..7e7c9cb8 100644 --- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c | |||
@@ -61,8 +61,7 @@ static void gk20a_debug_dump_all_channel_status_ramfc(struct gk20a *g, | |||
61 | u32 chid; | 61 | u32 chid; |
62 | struct ch_state **ch_state; | 62 | struct ch_state **ch_state; |
63 | 63 | ||
64 | ch_state = kzalloc(sizeof(*ch_state) | 64 | ch_state = nvgpu_kzalloc(g, sizeof(*ch_state) * f->num_channels); |
65 | * f->num_channels, GFP_KERNEL); | ||
66 | if (!ch_state) { | 65 | if (!ch_state) { |
67 | gk20a_debug_output(o, "cannot alloc memory for channels\n"); | 66 | gk20a_debug_output(o, "cannot alloc memory for channels\n"); |
68 | return; | 67 | return; |
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index f7f39207..b2a6b1a0 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | |||
@@ -3489,8 +3489,8 @@ static void __gk20a_fifo_profile_free(struct kref *ref) | |||
3489 | { | 3489 | { |
3490 | struct fifo_gk20a *f = container_of(ref, struct fifo_gk20a, | 3490 | struct fifo_gk20a *f = container_of(ref, struct fifo_gk20a, |
3491 | profile.ref); | 3491 | profile.ref); |
3492 | vfree(f->profile.data); | 3492 | nvgpu_vfree(f->g, f->profile.data); |
3493 | vfree(f->profile.sorted); | 3493 | nvgpu_vfree(f->g, f->profile.sorted); |
3494 | } | 3494 | } |
3495 | 3495 | ||
3496 | static int gk20a_fifo_profile_enable(void *data, u64 val) | 3496 | static int gk20a_fifo_profile_enable(void *data, u64 val) |
@@ -3518,8 +3518,8 @@ static int gk20a_fifo_profile_enable(void *data, u64 val) | |||
3518 | FIFO_PROFILING_ENTRIES * | 3518 | FIFO_PROFILING_ENTRIES * |
3519 | sizeof(u64)); | 3519 | sizeof(u64)); |
3520 | if (!(f->profile.data && f->profile.sorted)) { | 3520 | if (!(f->profile.data && f->profile.sorted)) { |
3521 | vfree(f->profile.data); | 3521 | nvgpu_vfree(g, f->profile.data); |
3522 | vfree(f->profile.sorted); | 3522 | nvgpu_vfree(g, f->profile.sorted); |
3523 | nvgpu_mutex_release(&f->profile.lock); | 3523 | nvgpu_mutex_release(&f->profile.lock); |
3524 | return -ENOMEM; | 3524 | return -ENOMEM; |
3525 | } | 3525 | } |
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 0e3bcdbe..3e9a388b 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c | |||
@@ -3343,13 +3343,16 @@ int gk20a_comptag_allocator_init(struct gk20a_comptag_allocator *allocator, | |||
3343 | 3343 | ||
3344 | void gk20a_comptag_allocator_destroy(struct gk20a_comptag_allocator *allocator) | 3344 | void gk20a_comptag_allocator_destroy(struct gk20a_comptag_allocator *allocator) |
3345 | { | 3345 | { |
3346 | struct gr_gk20a *gr = container_of(allocator, | ||
3347 | struct gr_gk20a, comp_tags); | ||
3348 | |||
3346 | /* | 3349 | /* |
3347 | * called only when exiting the driver (gk20a_remove, or unwinding the | 3350 | * called only when exiting the driver (gk20a_remove, or unwinding the |
3348 | * init stage); no users should be active, so taking the mutex is | 3351 | * init stage); no users should be active, so taking the mutex is |
3349 | * unnecessary here. | 3352 | * unnecessary here. |
3350 | */ | 3353 | */ |
3351 | allocator->size = 0; | 3354 | allocator->size = 0; |
3352 | vfree(allocator->bitmap); | 3355 | nvgpu_vfree(gr->g, allocator->bitmap); |
3353 | } | 3356 | } |
3354 | 3357 | ||
3355 | static void gk20a_remove_gr_support(struct gr_gk20a *gr) | 3358 | static void gk20a_remove_gr_support(struct gr_gk20a *gr) |
@@ -3419,7 +3422,7 @@ static void gk20a_remove_gr_support(struct gr_gk20a *gr) | |||
3419 | nvgpu_kfree(g, gr->ctx_vars.ctxsw_regs.pm_ltc.l); | 3422 | nvgpu_kfree(g, gr->ctx_vars.ctxsw_regs.pm_ltc.l); |
3420 | nvgpu_kfree(g, gr->ctx_vars.ctxsw_regs.pm_fbpa.l); | 3423 | nvgpu_kfree(g, gr->ctx_vars.ctxsw_regs.pm_fbpa.l); |
3421 | 3424 | ||
3422 | vfree(gr->ctx_vars.local_golden_image); | 3425 | nvgpu_vfree(g, gr->ctx_vars.local_golden_image); |
3423 | gr->ctx_vars.local_golden_image = NULL; | 3426 | gr->ctx_vars.local_golden_image = NULL; |
3424 | 3427 | ||
3425 | if (gr->ctx_vars.hwpm_ctxsw_buffer_offset_map) | 3428 | if (gr->ctx_vars.hwpm_ctxsw_buffer_offset_map) |
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 9a2dbeb9..461cf324 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -4188,7 +4188,7 @@ static int init_vm_page_tables(struct vm_gk20a *vm) | |||
4188 | err = gk20a_zalloc_gmmu_page_table(vm, 0, &vm->mmu_levels[0], | 4188 | err = gk20a_zalloc_gmmu_page_table(vm, 0, &vm->mmu_levels[0], |
4189 | &vm->pdb, NULL); | 4189 | &vm->pdb, NULL); |
4190 | if (err) { | 4190 | if (err) { |
4191 | vfree(vm->pdb.entries); | 4191 | nvgpu_vfree(vm->mm->g, vm->pdb.entries); |
4192 | return err; | 4192 | return err; |
4193 | } | 4193 | } |
4194 | 4194 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index 70e40099..6281e4ad 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | |||
@@ -260,7 +260,7 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g) | |||
260 | if (g->ops.fifo.tsg_open) { | 260 | if (g->ops.fifo.tsg_open) { |
261 | err = g->ops.fifo.tsg_open(tsg); | 261 | err = g->ops.fifo.tsg_open(tsg); |
262 | if (err) { | 262 | if (err) { |
263 | gk20a_err(dev_from_gk20a(g), | 263 | gk20a_err(dev_from_gk20a(g), |
264 | "tsg %d fifo open failed %d", | 264 | "tsg %d fifo open failed %d", |
265 | tsg->tsgid, err); | 265 | tsg->tsgid, err); |
266 | goto clean_up; | 266 | goto clean_up; |
diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c index c6a51719..612e50e7 100644 --- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c | |||
@@ -1126,7 +1126,7 @@ static int vgpu_gr_suspend_resume_contexts(struct gk20a *g, | |||
1126 | 1126 | ||
1127 | size_in = size_out + n * sizeof(u16); | 1127 | size_in = size_out + n * sizeof(u16); |
1128 | 1128 | ||
1129 | msg = kmalloc(size_in, GFP_KERNEL); | 1129 | msg = nvgpu_kmalloc(g, size_in); |
1130 | if (!msg) | 1130 | if (!msg) |
1131 | return -ENOMEM; | 1131 | return -ENOMEM; |
1132 | 1132 | ||
@@ -1159,7 +1159,7 @@ fail: | |||
1159 | nvgpu_mutex_release(&g->dbg_sessions_lock); | 1159 | nvgpu_mutex_release(&g->dbg_sessions_lock); |
1160 | 1160 | ||
1161 | *ctx_resident_ch_fd = channel_fd; | 1161 | *ctx_resident_ch_fd = channel_fd; |
1162 | kfree(msg); | 1162 | nvgpu_kfree(g, msg); |
1163 | 1163 | ||
1164 | return err; | 1164 | return err; |
1165 | } | 1165 | } |