From 2204f2a524af40d8e5fa0f3d764b61fefa397989 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Sat, 21 Mar 2015 08:10:59 -0700 Subject: gpu: nvgpu: Use common allocator for patch Reduce amount of duplicate code around memory allocation by using common helpers, and common data structure for storing results of allocations. Bug 1605769 Change-Id: Idf51831e8be9cabe1ab9122b18317137fde6339f Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/721030 Reviewed-on: http://git-master/r/737530 Reviewed-by: Alexander Van Brunt Tested-by: Alexander Van Brunt --- drivers/gpu/nvgpu/vgpu/gr_vgpu.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu/gr_vgpu.c') diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c index fd8bb81b..8d0bb6cf 100644 --- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c @@ -321,18 +321,20 @@ static int vgpu_gr_alloc_channel_patch_ctx(struct gk20a *g, gk20a_dbg_fn(""); - patch_ctx->size = 128 * sizeof(u32); - patch_ctx->gpu_va = gk20a_vm_alloc_va(ch_vm, patch_ctx->size, 0); - if (!patch_ctx->gpu_va) + patch_ctx->mem.size = 128 * sizeof(u32); + patch_ctx->mem.gpu_va = gk20a_vm_alloc_va(ch_vm, + patch_ctx->mem.size, 0); + if (!patch_ctx->mem.gpu_va) return -ENOMEM; msg.cmd = TEGRA_VGPU_CMD_CHANNEL_ALLOC_GR_PATCH_CTX; msg.handle = platform->virt_handle; p->handle = c->virt_ctx; - p->patch_ctx_va = patch_ctx->gpu_va; + p->patch_ctx_va = patch_ctx->mem.gpu_va; err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); if (err || msg.ret) { - gk20a_vm_free_va(ch_vm, patch_ctx->gpu_va, patch_ctx->size, 0); + gk20a_vm_free_va(ch_vm, patch_ctx->mem.gpu_va, + patch_ctx->mem.size, 0); err = -ENOMEM; } @@ -347,7 +349,7 @@ static void vgpu_gr_free_channel_patch_ctx(struct channel_gk20a *c) gk20a_dbg_fn(""); - if (patch_ctx->gpu_va) { + if (patch_ctx->mem.gpu_va) { struct tegra_vgpu_cmd_msg msg; struct tegra_vgpu_gr_ctx_params *p = &msg.params.gr_ctx; int err; @@ -358,8 +360,9 @@ static void vgpu_gr_free_channel_patch_ctx(struct channel_gk20a *c) err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); WARN_ON(err || msg.ret); - gk20a_vm_free_va(ch_vm, patch_ctx->gpu_va, patch_ctx->size, 0); - patch_ctx->gpu_va = 0; + gk20a_vm_free_va(ch_vm, patch_ctx->mem.gpu_va, + patch_ctx->mem.size, 0); + patch_ctx->mem.gpu_va = 0; } } @@ -438,7 +441,7 @@ static int vgpu_gr_alloc_obj_ctx(struct channel_gk20a *c, } /* allocate patch buffer */ - if (ch_ctx->patch_ctx.pages == NULL) { + if (ch_ctx->patch_ctx.mem.pages == NULL) { err = vgpu_gr_alloc_channel_patch_ctx(g, c); if (err) { gk20a_err(dev_from_gk20a(g), -- cgit v1.2.2