From 8c66aef3bdbfbbeb1d3c3ef3bd6b1bee3ac05411 Mon Sep 17 00:00:00 2001 From: Mahantesh Kumbar Date: Fri, 12 May 2017 11:24:31 +0530 Subject: gpu: nvgpu: reorganize PMU FB alloc/free Moved PMU FB access related code from pmu_gk20a.c to "drivers/gpu/nvgpu/common/pmu/pmu.c" file - Prepended with nvgpu_ for global functions & replaced wherever used. JIRA NVGPU-56 JIRA NVGPU-94 Change-Id: I42bfd9d216e6b35672a9738f01302d954b32b69e Signed-off-by: Mahantesh Kumbar Reviewed-on: http://git-master/r/1480551 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/common/pmu/pmu.c | 47 ++++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/common/pmu/pmu_ipc.c | 12 ++++----- 2 files changed, 53 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/pmu/pmu.c b/drivers/gpu/nvgpu/common/pmu/pmu.c index 90db07b4..ca532049 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu.c @@ -423,3 +423,50 @@ int nvgpu_pmu_destroy(struct gk20a *g) nvgpu_log_fn(g, "done"); return 0; } + +void nvgpu_pmu_surface_describe(struct gk20a *g, struct nvgpu_mem *mem, + struct flcn_mem_desc_v0 *fb) +{ + fb->address.lo = u64_lo32(mem->gpu_va); + fb->address.hi = u64_hi32(mem->gpu_va); + fb->params = ((u32)mem->size & 0xFFFFFF); + fb->params |= (GK20A_PMU_DMAIDX_VIRT << 24); +} + +int nvgpu_pmu_vidmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem, + u32 size) +{ + struct mm_gk20a *mm = &g->mm; + struct vm_gk20a *vm = mm->pmu.vm; + int err; + + err = nvgpu_dma_alloc_map_vid(vm, size, mem); + if (err) { + nvgpu_err(g, "memory allocation failed"); + return -ENOMEM; + } + + return 0; +} + +int nvgpu_pmu_sysmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem, + u32 size) +{ + struct mm_gk20a *mm = &g->mm; + struct vm_gk20a *vm = mm->pmu.vm; + int err; + + err = nvgpu_dma_alloc_map_sys(vm, size, mem); + if (err) { + nvgpu_err(g, "failed to allocate memory\n"); + return -ENOMEM; + } + + return 0; +} + +void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem) +{ + nvgpu_dma_free(g, mem); + memset(mem, 0, sizeof(struct nvgpu_mem)); +} diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c index 74966f2d..e45a6182 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c @@ -552,9 +552,9 @@ int gk20a_pmu_cmd_post(struct gk20a *g, struct pmu_cmd *cmd, goto clean_up; } - gk20a_pmu_vidmem_surface_alloc(g, seq->in_mem, + nvgpu_pmu_vidmem_surface_alloc(g, seq->in_mem, payload->in.fb_size); - gk20a_pmu_surface_describe(g, seq->in_mem, + nvgpu_pmu_surface_describe(g, seq->in_mem, (struct flcn_mem_desc_v0 *) pv->pmu_allocation_get_fb_addr(pmu, in)); @@ -595,9 +595,9 @@ int gk20a_pmu_cmd_post(struct gk20a *g, struct pmu_cmd *cmd, err = -ENOMEM; goto clean_up; } - gk20a_pmu_vidmem_surface_alloc(g, seq->out_mem, + nvgpu_pmu_vidmem_surface_alloc(g, seq->out_mem, payload->out.fb_size); - gk20a_pmu_surface_describe(g, seq->out_mem, + nvgpu_pmu_surface_describe(g, seq->out_mem, (struct flcn_mem_desc_v0 *) pv->pmu_allocation_get_fb_addr(pmu, out)); @@ -699,7 +699,7 @@ static int pmu_response_handle(struct nvgpu_pmu *pmu, pv->pmu_allocation_get_fb_size(pmu, pv->get_pmu_seq_out_a_ptr(seq))); - gk20a_pmu_surface_free(g, seq->out_mem); + nvgpu_pmu_surface_free(g, seq->out_mem); if (seq->out_mem != seq->in_mem) nvgpu_kfree(g, seq->out_mem); else @@ -712,7 +712,7 @@ static int pmu_response_handle(struct nvgpu_pmu *pmu, pv->pmu_allocation_get_fb_size(pmu, pv->get_pmu_seq_in_a_ptr(seq))); - gk20a_pmu_surface_free(g, seq->in_mem); + nvgpu_pmu_surface_free(g, seq->in_mem); nvgpu_kfree(g, seq->in_mem); seq->in_mem = NULL; } -- cgit v1.2.2