summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-08 19:58:25 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-28 12:39:07 -0400
commit2e15a2d1accb8303c2363122c638e08ae7b70a50 (patch)
treefd967e64059e4b868f26de0aab56828984c52139
parent8a15e02ca92b83aa5a216ea9cd42680373212ecd (diff)
gpu: nvgpu: Use new kmem API functions (vgpu/*)
Use the new kmem API functions in vgpu/*. Also reshuffle the order of some allocs in the vgpu init code to allow usage of the nvgpu kmem APIs. Bug 1799159 Bug 1823380 Change-Id: I6c6dcff03b406a260dffbf89a59b368d31a4cb2c Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1318318 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c8
-rw-r--r--drivers/gpu/nvgpu/vgpu/fifo_vgpu.c40
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c4
-rw-r--r--drivers/gpu/nvgpu/vgpu/gr_vgpu.c35
-rw-r--r--drivers/gpu/nvgpu/vgpu/mm_vgpu.c11
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c23
6 files changed, 68 insertions, 53 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c b/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
index 6396ee4c..398e26b2 100644
--- a/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/fecs_trace_vgpu.c
@@ -16,6 +16,8 @@
16#include <linux/tegra_vgpu.h> 16#include <linux/tegra_vgpu.h>
17#include <linux/version.h> 17#include <linux/version.h>
18 18
19#include <nvgpu/kmem.h>
20
19#include "gk20a/gk20a.h" 21#include "gk20a/gk20a.h"
20#include "gk20a/ctxsw_trace_gk20a.h" 22#include "gk20a/ctxsw_trace_gk20a.h"
21#include "vgpu.h" 23#include "vgpu.h"
@@ -42,7 +44,7 @@ static int vgpu_fecs_trace_init(struct gk20a *g)
42 44
43 gk20a_dbg_fn(""); 45 gk20a_dbg_fn("");
44 46
45 vcst = kzalloc(sizeof(*vcst), GFP_KERNEL); 47 vcst = nvgpu_kzalloc(g, sizeof(*vcst));
46 if (!vcst) 48 if (!vcst)
47 return -ENOMEM; 49 return -ENOMEM;
48 50
@@ -91,7 +93,7 @@ fail:
91 iounmap(vcst->buf); 93 iounmap(vcst->buf);
92 if (vcst->cookie) 94 if (vcst->cookie)
93 tegra_hv_mempool_unreserve(vcst->cookie); 95 tegra_hv_mempool_unreserve(vcst->cookie);
94 kfree(vcst); 96 nvgpu_kfree(g, vcst);
95 return err; 97 return err;
96} 98}
97 99
@@ -101,7 +103,7 @@ static int vgpu_fecs_trace_deinit(struct gk20a *g)
101 103
102 iounmap(vcst->buf); 104 iounmap(vcst->buf);
103 tegra_hv_mempool_unreserve(vcst->cookie); 105 tegra_hv_mempool_unreserve(vcst->cookie);
104 kfree(vcst); 106 nvgpu_kfree(g, vcst);
105 return 0; 107 return 0;
106} 108}
107 109
diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
index 0655ea15..0c93a2ed 100644
--- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
@@ -16,6 +16,8 @@
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <trace/events/gk20a.h> 17#include <trace/events/gk20a.h>
18 18
19#include <nvgpu/kmem.h>
20
19#include "vgpu/vgpu.h" 21#include "vgpu/vgpu.h"
20#include "gk20a/ctxsw_trace_gk20a.h" 22#include "gk20a/ctxsw_trace_gk20a.h"
21 23
@@ -192,8 +194,9 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f)
192 gk20a_dbg_fn(""); 194 gk20a_dbg_fn("");
193 195
194 f->max_runlists = g->ops.fifo.eng_runlist_base_size(); 196 f->max_runlists = g->ops.fifo.eng_runlist_base_size();
195 f->runlist_info = kzalloc(sizeof(struct fifo_runlist_info_gk20a) * 197 f->runlist_info = nvgpu_kzalloc(g,
196 f->max_runlists, GFP_KERNEL); 198 sizeof(struct fifo_runlist_info_gk20a) *
199 f->max_runlists);
197 if (!f->runlist_info) 200 if (!f->runlist_info)
198 goto clean_up_runlist; 201 goto clean_up_runlist;
199 202
@@ -204,8 +207,8 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f)
204 runlist = &f->runlist_info[runlist_id]; 207 runlist = &f->runlist_info[runlist_id];
205 208
206 runlist->active_channels = 209 runlist->active_channels =
207 kzalloc(DIV_ROUND_UP(f->num_channels, BITS_PER_BYTE), 210 nvgpu_kzalloc(g, DIV_ROUND_UP(f->num_channels,
208 GFP_KERNEL); 211 BITS_PER_BYTE));
209 if (!runlist->active_channels) 212 if (!runlist->active_channels)
210 goto clean_up_runlist; 213 goto clean_up_runlist;
211 214
@@ -276,12 +279,11 @@ static int vgpu_init_fifo_setup_sw(struct gk20a *g)
276 279
277 gk20a_dbg(gpu_dbg_map_v, "userd bar1 va = 0x%llx", f->userd.gpu_va); 280 gk20a_dbg(gpu_dbg_map_v, "userd bar1 va = 0x%llx", f->userd.gpu_va);
278 281
279 f->channel = vzalloc(f->num_channels * sizeof(*f->channel)); 282 f->channel = nvgpu_vzalloc(g, f->num_channels * sizeof(*f->channel));
280 f->tsg = vzalloc(f->num_channels * sizeof(*f->tsg)); 283 f->tsg = nvgpu_vzalloc(g, f->num_channels * sizeof(*f->tsg));
281 f->engine_info = kzalloc(f->max_engines * sizeof(*f->engine_info), 284 f->engine_info = nvgpu_kzalloc(g, f->max_engines *
282 GFP_KERNEL); 285 sizeof(*f->engine_info));
283 f->active_engines_list = kzalloc(f->max_engines * sizeof(u32), 286 f->active_engines_list = nvgpu_kzalloc(g, f->max_engines * sizeof(u32));
284 GFP_KERNEL);
285 287
286 if (!(f->channel && f->tsg && f->engine_info && f->active_engines_list)) { 288 if (!(f->channel && f->tsg && f->engine_info && f->active_engines_list)) {
287 err = -ENOMEM; 289 err = -ENOMEM;
@@ -327,13 +329,13 @@ clean_up:
327 329
328 memset(&f->userd, 0, sizeof(f->userd)); 330 memset(&f->userd, 0, sizeof(f->userd));
329 331
330 vfree(f->channel); 332 nvgpu_vfree(g, f->channel);
331 f->channel = NULL; 333 f->channel = NULL;
332 vfree(f->tsg); 334 nvgpu_vfree(g, f->tsg);
333 f->tsg = NULL; 335 f->tsg = NULL;
334 kfree(f->engine_info); 336 nvgpu_kfree(g, f->engine_info);
335 f->engine_info = NULL; 337 f->engine_info = NULL;
336 kfree(f->active_engines_list); 338 nvgpu_kfree(g, f->active_engines_list);
337 f->active_engines_list = NULL; 339 f->active_engines_list = NULL;
338 340
339 return err; 341 return err;
@@ -453,8 +455,8 @@ static int vgpu_fifo_preempt_tsg(struct gk20a *g, u32 tsgid)
453 return err; 455 return err;
454} 456}
455 457
456static int vgpu_submit_runlist(u64 handle, u8 runlist_id, u16 *runlist, 458static int vgpu_submit_runlist(struct gk20a *g, u64 handle, u8 runlist_id,
457 u32 num_entries) 459 u16 *runlist, u32 num_entries)
458{ 460{
459 struct tegra_vgpu_cmd_msg *msg; 461 struct tegra_vgpu_cmd_msg *msg;
460 struct tegra_vgpu_runlist_params *p; 462 struct tegra_vgpu_runlist_params *p;
@@ -462,7 +464,7 @@ static int vgpu_submit_runlist(u64 handle, u8 runlist_id, u16 *runlist,
462 char *ptr; 464 char *ptr;
463 int err; 465 int err;
464 466
465 msg = kmalloc(size, GFP_KERNEL); 467 msg = nvgpu_kmalloc(g, size);
466 if (!msg) 468 if (!msg)
467 return -1; 469 return -1;
468 470
@@ -477,7 +479,7 @@ static int vgpu_submit_runlist(u64 handle, u8 runlist_id, u16 *runlist,
477 err = vgpu_comm_sendrecv(msg, size, sizeof(*msg)); 479 err = vgpu_comm_sendrecv(msg, size, sizeof(*msg));
478 480
479 err = (err || msg->ret) ? -1 : 0; 481 err = (err || msg->ret) ? -1 : 0;
480 kfree(msg); 482 nvgpu_kfree(g, msg);
481 return err; 483 return err;
482} 484}
483 485
@@ -523,7 +525,7 @@ static int vgpu_fifo_update_runlist_locked(struct gk20a *g, u32 runlist_id,
523 } else /* suspend to remove all channels */ 525 } else /* suspend to remove all channels */
524 count = 0; 526 count = 0;
525 527
526 return vgpu_submit_runlist(vgpu_get_handle(g), runlist_id, 528 return vgpu_submit_runlist(g, vgpu_get_handle(g), runlist_id,
527 runlist->mem[0].cpu_va, count); 529 runlist->mem[0].cpu_va, count);
528} 530}
529 531
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c
index 749d6a15..91e06138 100644
--- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c
@@ -11,6 +11,8 @@
11 * more details. 11 * more details.
12 */ 12 */
13 13
14#include <nvgpu/kmem.h>
15
14#include "vgpu/vgpu.h" 16#include "vgpu/vgpu.h"
15#include "vgpu/gm20b/vgpu_gr_gm20b.h" 17#include "vgpu/gm20b/vgpu_gr_gm20b.h"
16 18
@@ -44,7 +46,7 @@ static void vgpu_gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
44 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer); 46 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer);
45 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer); 47 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer);
46 48
47 kfree(gr_ctx); 49 nvgpu_kfree(g, gr_ctx);
48} 50}
49 51
50static int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, 52static int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g,
diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
index a98c9d38..c6a51719 100644
--- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
@@ -13,6 +13,8 @@
13 * more details. 13 * more details.
14 */ 14 */
15 15
16#include <nvgpu/kmem.h>
17
16#include "vgpu/vgpu.h" 18#include "vgpu/vgpu.h"
17#include "gk20a/dbg_gpu_gk20a.h" 19#include "gk20a/dbg_gpu_gk20a.h"
18 20
@@ -269,7 +271,7 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g,
269 gr->ctx_vars.buffer_size = gr->ctx_vars.golden_image_size; 271 gr->ctx_vars.buffer_size = gr->ctx_vars.golden_image_size;
270 gr->ctx_vars.buffer_total_size = gr->ctx_vars.golden_image_size; 272 gr->ctx_vars.buffer_total_size = gr->ctx_vars.golden_image_size;
271 273
272 gr_ctx = kzalloc(sizeof(*gr_ctx), GFP_KERNEL); 274 gr_ctx = nvgpu_kzalloc(g, sizeof(*gr_ctx));
273 if (!gr_ctx) 275 if (!gr_ctx)
274 return -ENOMEM; 276 return -ENOMEM;
275 277
@@ -279,7 +281,7 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g,
279 gmmu_page_size_kernel); 281 gmmu_page_size_kernel);
280 282
281 if (!gr_ctx->mem.gpu_va) { 283 if (!gr_ctx->mem.gpu_va) {
282 kfree(gr_ctx); 284 nvgpu_kfree(g, gr_ctx);
283 return -ENOMEM; 285 return -ENOMEM;
284 } 286 }
285 287
@@ -295,7 +297,7 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g,
295 gk20a_err(dev_from_gk20a(g), "fail to alloc gr_ctx"); 297 gk20a_err(dev_from_gk20a(g), "fail to alloc gr_ctx");
296 gk20a_vm_free_va(vm, gr_ctx->mem.gpu_va, 298 gk20a_vm_free_va(vm, gr_ctx->mem.gpu_va,
297 gr_ctx->mem.size, gmmu_page_size_kernel); 299 gr_ctx->mem.size, gmmu_page_size_kernel);
298 kfree(gr_ctx); 300 nvgpu_kfree(g, gr_ctx);
299 } else { 301 } else {
300 gr_ctx->virt_ctx = p->gr_ctx_handle; 302 gr_ctx->virt_ctx = p->gr_ctx_handle;
301 *__gr_ctx = gr_ctx; 303 *__gr_ctx = gr_ctx;
@@ -322,7 +324,7 @@ void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
322 324
323 gk20a_vm_free_va(vm, gr_ctx->mem.gpu_va, gr_ctx->mem.size, 325 gk20a_vm_free_va(vm, gr_ctx->mem.gpu_va, gr_ctx->mem.size,
324 gmmu_page_size_kernel); 326 gmmu_page_size_kernel);
325 kfree(gr_ctx); 327 nvgpu_kfree(g, gr_ctx);
326 } 328 }
327} 329}
328 330
@@ -617,16 +619,17 @@ static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr)
617 619
618 gr->max_tpc_count = gr->max_gpc_count * gr->max_tpc_per_gpc_count; 620 gr->max_tpc_count = gr->max_gpc_count * gr->max_tpc_per_gpc_count;
619 621
620 gr->gpc_tpc_count = kzalloc(gr->gpc_count * sizeof(u32), GFP_KERNEL); 622 gr->gpc_tpc_count = nvgpu_kzalloc(g, gr->gpc_count * sizeof(u32));
621 if (!gr->gpc_tpc_count) 623 if (!gr->gpc_tpc_count)
622 goto cleanup; 624 goto cleanup;
623 625
624 gr->gpc_tpc_mask = kzalloc(gr->gpc_count * sizeof(u32), GFP_KERNEL); 626 gr->gpc_tpc_mask = nvgpu_kzalloc(g, gr->gpc_count * sizeof(u32));
625 if (!gr->gpc_tpc_mask) 627 if (!gr->gpc_tpc_mask)
626 goto cleanup; 628 goto cleanup;
627 629
628 gr->sm_to_cluster = kzalloc(gr->gpc_count * gr->max_tpc_per_gpc_count * 630 gr->sm_to_cluster = nvgpu_kzalloc(g, gr->gpc_count *
629 sizeof(struct sm_info), GFP_KERNEL); 631 gr->max_tpc_per_gpc_count *
632 sizeof(struct sm_info));
630 if (!gr->sm_to_cluster) 633 if (!gr->sm_to_cluster)
631 goto cleanup; 634 goto cleanup;
632 635
@@ -650,10 +653,10 @@ static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr)
650cleanup: 653cleanup:
651 gk20a_err(dev_from_gk20a(g), "%s: out of memory", __func__); 654 gk20a_err(dev_from_gk20a(g), "%s: out of memory", __func__);
652 655
653 kfree(gr->gpc_tpc_count); 656 nvgpu_kfree(g, gr->gpc_tpc_count);
654 gr->gpc_tpc_count = NULL; 657 gr->gpc_tpc_count = NULL;
655 658
656 kfree(gr->gpc_tpc_mask); 659 nvgpu_kfree(g, gr->gpc_tpc_mask);
657 gr->gpc_tpc_mask = NULL; 660 gr->gpc_tpc_mask = NULL;
658 661
659 return -ENOMEM; 662 return -ENOMEM;
@@ -838,16 +841,16 @@ static void vgpu_remove_gr_support(struct gr_gk20a *gr)
838 841
839 gk20a_comptag_allocator_destroy(&gr->comp_tags); 842 gk20a_comptag_allocator_destroy(&gr->comp_tags);
840 843
841 kfree(gr->sm_error_states); 844 nvgpu_kfree(gr->g, gr->sm_error_states);
842 gr->sm_error_states = NULL; 845 gr->sm_error_states = NULL;
843 846
844 kfree(gr->gpc_tpc_mask); 847 nvgpu_kfree(gr->g, gr->gpc_tpc_mask);
845 gr->gpc_tpc_mask = NULL; 848 gr->gpc_tpc_mask = NULL;
846 849
847 kfree(gr->sm_to_cluster); 850 nvgpu_kfree(gr->g, gr->sm_to_cluster);
848 gr->sm_to_cluster = NULL; 851 gr->sm_to_cluster = NULL;
849 852
850 kfree(gr->gpc_tpc_count); 853 nvgpu_kfree(gr->g, gr->gpc_tpc_count);
851 gr->gpc_tpc_count = NULL; 854 gr->gpc_tpc_count = NULL;
852} 855}
853 856
@@ -887,9 +890,9 @@ static int vgpu_gr_init_gr_setup_sw(struct gk20a *g)
887 890
888 nvgpu_mutex_init(&gr->ctx_mutex); 891 nvgpu_mutex_init(&gr->ctx_mutex);
889 892
890 gr->sm_error_states = kzalloc( 893 gr->sm_error_states = nvgpu_kzalloc(g,
891 sizeof(struct nvgpu_dbg_gpu_sm_error_state_record) * 894 sizeof(struct nvgpu_dbg_gpu_sm_error_state_record) *
892 gr->no_of_sm, GFP_KERNEL); 895 gr->no_of_sm);
893 if (!gr->sm_error_states) { 896 if (!gr->sm_error_states) {
894 err = -ENOMEM; 897 err = -ENOMEM;
895 goto clean_up; 898 goto clean_up;
diff --git a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c
index 1bcdc17b..494bbe66 100644
--- a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c
@@ -14,6 +14,9 @@
14 */ 14 */
15 15
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17
18#include <nvgpu/kmem.h>
19
17#include "vgpu/vgpu.h" 20#include "vgpu/vgpu.h"
18#include "gk20a/mm_gk20a.h" 21#include "gk20a/mm_gk20a.h"
19 22
@@ -220,7 +223,7 @@ static void vgpu_vm_remove_support(struct vm_gk20a *vm)
220 list_for_each_entry_safe(va_node, va_node_tmp, &vm->reserved_va_list, 223 list_for_each_entry_safe(va_node, va_node_tmp, &vm->reserved_va_list,
221 reserved_va_list) { 224 reserved_va_list) {
222 list_del(&va_node->reserved_va_list); 225 list_del(&va_node->reserved_va_list);
223 kfree(va_node); 226 nvgpu_kfree(g, va_node);
224 } 227 }
225 228
226 msg.cmd = TEGRA_VGPU_CMD_AS_FREE_SHARE; 229 msg.cmd = TEGRA_VGPU_CMD_AS_FREE_SHARE;
@@ -237,7 +240,7 @@ static void vgpu_vm_remove_support(struct vm_gk20a *vm)
237 nvgpu_mutex_release(&vm->update_gmmu_lock); 240 nvgpu_mutex_release(&vm->update_gmmu_lock);
238 241
239 /* vm is not used anymore. release it. */ 242 /* vm is not used anymore. release it. */
240 kfree(vm); 243 nvgpu_kfree(g, vm);
241} 244}
242 245
243u64 vgpu_bar1_map(struct gk20a *g, struct sg_table **sgt, u64 size) 246u64 vgpu_bar1_map(struct gk20a *g, struct sg_table **sgt, u64 size)
@@ -297,7 +300,7 @@ static int vgpu_vm_alloc_share(struct gk20a_as_share *as_share,
297 300
298 big_page_size = gmmu_page_sizes[gmmu_page_size_big]; 301 big_page_size = gmmu_page_sizes[gmmu_page_size_big];
299 302
300 vm = kzalloc(sizeof(*vm), GFP_KERNEL); 303 vm = nvgpu_kzalloc(g, sizeof(*vm));
301 if (!vm) 304 if (!vm)
302 return -ENOMEM; 305 return -ENOMEM;
303 306
@@ -421,7 +424,7 @@ clean_up_share:
421 p->handle = vm->handle; 424 p->handle = vm->handle;
422 WARN_ON(vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)) || msg.ret); 425 WARN_ON(vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)) || msg.ret);
423clean_up: 426clean_up:
424 kfree(vm); 427 nvgpu_kfree(g, vm);
425 as_share->vm = NULL; 428 as_share->vm = NULL;
426 return err; 429 return err;
427} 430}
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index df793be7..49f0fb39 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -198,7 +198,7 @@ static void vgpu_remove_support(struct gk20a *g)
198 int err; 198 int err;
199 199
200 if (g->dbg_regops_tmp_buf) 200 if (g->dbg_regops_tmp_buf)
201 kfree(g->dbg_regops_tmp_buf); 201 nvgpu_kfree(g, g->dbg_regops_tmp_buf);
202 202
203 if (g->pmu.remove_support) 203 if (g->pmu.remove_support)
204 g->pmu.remove_support(&g->pmu); 204 g->pmu.remove_support(&g->pmu);
@@ -252,7 +252,7 @@ static int vgpu_init_support(struct platform_device *pdev)
252 252
253 INIT_LIST_HEAD(&g->profiler_objects); 253 INIT_LIST_HEAD(&g->profiler_objects);
254 254
255 g->dbg_regops_tmp_buf = kzalloc(SZ_4K, GFP_KERNEL); 255 g->dbg_regops_tmp_buf = nvgpu_kzalloc(g, SZ_4K);
256 if (!g->dbg_regops_tmp_buf) { 256 if (!g->dbg_regops_tmp_buf) {
257 dev_err(g->dev, "couldn't allocate regops tmp buf"); 257 dev_err(g->dev, "couldn't allocate regops tmp buf");
258 return -ENOMEM; 258 return -ENOMEM;
@@ -474,7 +474,7 @@ static int vgpu_pm_qos_init(struct device *dev)
474 struct gk20a *g = get_gk20a(dev); 474 struct gk20a *g = get_gk20a(dev);
475 struct gk20a_scale_profile *profile; 475 struct gk20a_scale_profile *profile;
476 476
477 profile = kzalloc(sizeof(*profile), GFP_KERNEL); 477 profile = nvgpu_kzalloc(g, sizeof(*profile));
478 if (!profile) 478 if (!profile)
479 return -ENOMEM; 479 return -ENOMEM;
480 480
@@ -493,7 +493,7 @@ static void vgpu_pm_qos_remove(struct device *dev)
493 493
494 pm_qos_remove_max_notifier(PM_QOS_GPU_FREQ_BOUNDS, 494 pm_qos_remove_max_notifier(PM_QOS_GPU_FREQ_BOUNDS,
495 &g->scale_profile->qos_notify_block); 495 &g->scale_profile->qos_notify_block);
496 kfree(g->scale_profile); 496 nvgpu_kfree(g, g->scale_profile);
497 g->scale_profile = NULL; 497 g->scale_profile = NULL;
498} 498}
499 499
@@ -556,24 +556,27 @@ int vgpu_probe(struct platform_device *pdev)
556 556
557 gk20a_dbg_fn(""); 557 gk20a_dbg_fn("");
558 558
559 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
560 if (!priv)
561 return -ENOMEM;
562
563 gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); 559 gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL);
564 if (!gk20a) { 560 if (!gk20a) {
565 dev_err(dev, "couldn't allocate gk20a support"); 561 dev_err(dev, "couldn't allocate gk20a support");
566 return -ENOMEM; 562 return -ENOMEM;
567 } 563 }
568 564
569 platform->g = gk20a;
570 platform->vgpu_priv = priv;
571 gk20a->dev = dev; 565 gk20a->dev = dev;
572 566
573 gk20a->is_fmodel = platform->is_fmodel; 567 gk20a->is_fmodel = platform->is_fmodel;
574 568
575 nvgpu_kmem_init(gk20a); 569 nvgpu_kmem_init(gk20a);
576 570
571 priv = nvgpu_kzalloc(gk20a, sizeof(*priv));
572 if (!priv) {
573 kfree(gk20a);
574 return -ENOMEM;
575 }
576
577 platform->g = gk20a;
578 platform->vgpu_priv = priv;
579
577 err = gk20a_user_init(dev, INTERFACE_NAME, &nvgpu_class); 580 err = gk20a_user_init(dev, INTERFACE_NAME, &nvgpu_class);
578 if (err) 581 if (err)
579 return err; 582 return err;