diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
5 files changed, 25 insertions, 46 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.c index fe85e113..ed61f16b 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.c | |||
@@ -26,34 +26,6 @@ | |||
26 | 26 | ||
27 | #include <nvgpu/hw/gp10b/hw_gr_gp10b.h> | 27 | #include <nvgpu/hw/gp10b/hw_gr_gp10b.h> |
28 | 28 | ||
29 | void vgpu_gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, | ||
30 | struct gr_ctx_desc *gr_ctx) | ||
31 | { | ||
32 | struct tegra_vgpu_cmd_msg msg = {0}; | ||
33 | struct tegra_vgpu_gr_ctx_params *p = &msg.params.gr_ctx; | ||
34 | int err; | ||
35 | |||
36 | gk20a_dbg_fn(""); | ||
37 | |||
38 | if (!gr_ctx || !gr_ctx->mem.gpu_va) | ||
39 | return; | ||
40 | |||
41 | msg.cmd = TEGRA_VGPU_CMD_GR_CTX_FREE; | ||
42 | msg.handle = vgpu_get_handle(g); | ||
43 | p->gr_ctx_handle = gr_ctx->virt_ctx; | ||
44 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
45 | WARN_ON(err || msg.ret); | ||
46 | |||
47 | __nvgpu_vm_free_va(vm, gr_ctx->mem.gpu_va, gmmu_page_size_kernel); | ||
48 | |||
49 | nvgpu_dma_unmap_free(vm, &gr_ctx->pagepool_ctxsw_buffer); | ||
50 | nvgpu_dma_unmap_free(vm, &gr_ctx->betacb_ctxsw_buffer); | ||
51 | nvgpu_dma_unmap_free(vm, &gr_ctx->spill_ctxsw_buffer); | ||
52 | nvgpu_dma_unmap_free(vm, &gr_ctx->preempt_ctxsw_buffer); | ||
53 | |||
54 | nvgpu_kfree(g, gr_ctx); | ||
55 | } | ||
56 | |||
57 | int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, | 29 | int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, |
58 | struct gr_ctx_desc **__gr_ctx, | 30 | struct gr_ctx_desc **__gr_ctx, |
59 | struct vm_gk20a *vm, | 31 | struct vm_gk20a *vm, |
@@ -107,7 +79,7 @@ int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, | |||
107 | return err; | 79 | return err; |
108 | 80 | ||
109 | fail: | 81 | fail: |
110 | vgpu_gr_gp10b_free_gr_ctx(g, vm, gr_ctx); | 82 | vgpu_gr_free_gr_ctx(g, vm, gr_ctx); |
111 | return err; | 83 | return err; |
112 | } | 84 | } |
113 | 85 | ||
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.h b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.h index a11dab7d..31b88d19 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.h +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.h | |||
@@ -19,8 +19,6 @@ | |||
19 | 19 | ||
20 | #include "gk20a/gk20a.h" | 20 | #include "gk20a/gk20a.h" |
21 | 21 | ||
22 | void vgpu_gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, | ||
23 | struct gr_ctx_desc *gr_ctx); | ||
24 | int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, | 22 | int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, |
25 | struct gr_ctx_desc **__gr_ctx, | 23 | struct gr_ctx_desc **__gr_ctx, |
26 | struct vm_gk20a *vm, | 24 | struct vm_gk20a *vm, |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c index aa520690..e8cb96b4 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c | |||
@@ -128,7 +128,7 @@ static const struct gpu_ops vgpu_gp10b_ops = { | |||
128 | .pagepool_default_size = gr_gp10b_pagepool_default_size, | 128 | .pagepool_default_size = gr_gp10b_pagepool_default_size, |
129 | .init_ctx_state = vgpu_gr_gp10b_init_ctx_state, | 129 | .init_ctx_state = vgpu_gr_gp10b_init_ctx_state, |
130 | .alloc_gr_ctx = vgpu_gr_gp10b_alloc_gr_ctx, | 130 | .alloc_gr_ctx = vgpu_gr_gp10b_alloc_gr_ctx, |
131 | .free_gr_ctx = vgpu_gr_gp10b_free_gr_ctx, | 131 | .free_gr_ctx = vgpu_gr_free_gr_ctx, |
132 | .update_ctxsw_preemption_mode = | 132 | .update_ctxsw_preemption_mode = |
133 | gr_gp10b_update_ctxsw_preemption_mode, | 133 | gr_gp10b_update_ctxsw_preemption_mode, |
134 | .dump_gr_regs = NULL, | 134 | .dump_gr_regs = NULL, |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/common/linux/vgpu/gr_vgpu.c index a0662956..e8790587 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gr_vgpu.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <nvgpu/kmem.h> | 21 | #include <nvgpu/kmem.h> |
22 | #include <nvgpu/bug.h> | 22 | #include <nvgpu/bug.h> |
23 | #include <nvgpu/error_notifier.h> | 23 | #include <nvgpu/error_notifier.h> |
24 | #include <nvgpu/dma.h> | ||
24 | 25 | ||
25 | #include "vgpu.h" | 26 | #include "vgpu.h" |
26 | #include "gr_vgpu.h" | 27 | #include "gr_vgpu.h" |
@@ -317,23 +318,31 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g, | |||
317 | void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, | 318 | void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, |
318 | struct gr_ctx_desc *gr_ctx) | 319 | struct gr_ctx_desc *gr_ctx) |
319 | { | 320 | { |
321 | struct tegra_vgpu_cmd_msg msg; | ||
322 | struct tegra_vgpu_gr_ctx_params *p = &msg.params.gr_ctx; | ||
323 | int err; | ||
324 | |||
320 | gk20a_dbg_fn(""); | 325 | gk20a_dbg_fn(""); |
321 | 326 | ||
322 | if (gr_ctx && gr_ctx->mem.gpu_va) { | 327 | if (!gr_ctx || !gr_ctx->mem.gpu_va) |
323 | struct tegra_vgpu_cmd_msg msg; | 328 | return; |
324 | struct tegra_vgpu_gr_ctx_params *p = &msg.params.gr_ctx; | ||
325 | int err; | ||
326 | 329 | ||
327 | msg.cmd = TEGRA_VGPU_CMD_GR_CTX_FREE; | ||
328 | msg.handle = vgpu_get_handle(g); | ||
329 | p->gr_ctx_handle = gr_ctx->virt_ctx; | ||
330 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
331 | WARN_ON(err || msg.ret); | ||
332 | 330 | ||
333 | __nvgpu_vm_free_va(vm, gr_ctx->mem.gpu_va, | 331 | msg.cmd = TEGRA_VGPU_CMD_GR_CTX_FREE; |
334 | gmmu_page_size_kernel); | 332 | msg.handle = vgpu_get_handle(g); |
335 | nvgpu_kfree(g, gr_ctx); | 333 | p->gr_ctx_handle = gr_ctx->virt_ctx; |
336 | } | 334 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); |
335 | WARN_ON(err || msg.ret); | ||
336 | |||
337 | __nvgpu_vm_free_va(vm, gr_ctx->mem.gpu_va, | ||
338 | gmmu_page_size_kernel); | ||
339 | |||
340 | nvgpu_dma_unmap_free(vm, &gr_ctx->pagepool_ctxsw_buffer); | ||
341 | nvgpu_dma_unmap_free(vm, &gr_ctx->betacb_ctxsw_buffer); | ||
342 | nvgpu_dma_unmap_free(vm, &gr_ctx->spill_ctxsw_buffer); | ||
343 | nvgpu_dma_unmap_free(vm, &gr_ctx->preempt_ctxsw_buffer); | ||
344 | |||
345 | nvgpu_kfree(g, gr_ctx); | ||
337 | } | 346 | } |
338 | 347 | ||
339 | static void vgpu_gr_free_channel_gr_ctx(struct channel_gk20a *c) | 348 | static void vgpu_gr_free_channel_gr_ctx(struct channel_gk20a *c) |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c index 6f85b4ee..f6302d15 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c | |||
@@ -148,7 +148,7 @@ static const struct gpu_ops vgpu_gv11b_ops = { | |||
148 | .pagepool_default_size = gr_gv11b_pagepool_default_size, | 148 | .pagepool_default_size = gr_gv11b_pagepool_default_size, |
149 | .init_ctx_state = vgpu_gr_gp10b_init_ctx_state, | 149 | .init_ctx_state = vgpu_gr_gp10b_init_ctx_state, |
150 | .alloc_gr_ctx = vgpu_gr_gp10b_alloc_gr_ctx, | 150 | .alloc_gr_ctx = vgpu_gr_gp10b_alloc_gr_ctx, |
151 | .free_gr_ctx = vgpu_gr_gp10b_free_gr_ctx, | 151 | .free_gr_ctx = vgpu_gr_free_gr_ctx, |
152 | .update_ctxsw_preemption_mode = | 152 | .update_ctxsw_preemption_mode = |
153 | gr_gp10b_update_ctxsw_preemption_mode, | 153 | gr_gp10b_update_ctxsw_preemption_mode, |
154 | .dump_gr_regs = NULL, | 154 | .dump_gr_regs = NULL, |