summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
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 /drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
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>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/fifo_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/fifo_vgpu.c40
1 files changed, 21 insertions, 19 deletions
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