summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2018-01-09 13:47:40 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-01-12 15:42:57 -0500
commitece3d958b306f00dad76ed6f9b83ce136b4769f2 (patch)
tree81d1bdce3311575661e3f30d7dbf957d1d1c330f
parent44a1208fecab46f6e660d0315579c86cb6f32d0a (diff)
gpu: nvgpu: Combine gk20a and gp10b free_gr_ctx
gp10b version of free_gr_ctx was created to keep gp10b source code changes out from the mainline. gp10b was merged back to mainline a while ago, so this separation is no longer needed. Merge the two variants. Change-Id: I954b3b677e98e4248f95641ea22e0def4e583c66 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1635127 Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.c30
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_gr_gp10b.h2
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gr_vgpu.c35
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c2
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c8
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.c21
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.h2
-rw-r--r--drivers/gpu/nvgpu/gp10b/hal_gp10b.c2
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c2
-rw-r--r--drivers/gpu/nvgpu/gv11b/hal_gv11b.c2
12 files changed, 37 insertions, 73 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
29void 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
57int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, 29int 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
109fail: 81fail:
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
22void vgpu_gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
23 struct gr_ctx_desc *gr_ctx);
24int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g, 22int 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,
317void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm, 318void 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
339static void vgpu_gr_free_channel_gr_ctx(struct channel_gk20a *c) 348static 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,
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index 0f6bebe7..263ae030 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -2786,6 +2786,14 @@ void gr_gk20a_free_gr_ctx(struct gk20a *g,
2786 if (!gr_ctx || !gr_ctx->mem.gpu_va) 2786 if (!gr_ctx || !gr_ctx->mem.gpu_va)
2787 return; 2787 return;
2788 2788
2789 if (g->ops.gr.dump_ctxsw_stats &&
2790 g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close)
2791 g->ops.gr.dump_ctxsw_stats(g, vm, gr_ctx);
2792
2793 nvgpu_dma_unmap_free(vm, &gr_ctx->pagepool_ctxsw_buffer);
2794 nvgpu_dma_unmap_free(vm, &gr_ctx->betacb_ctxsw_buffer);
2795 nvgpu_dma_unmap_free(vm, &gr_ctx->spill_ctxsw_buffer);
2796 nvgpu_dma_unmap_free(vm, &gr_ctx->preempt_ctxsw_buffer);
2789 nvgpu_gmmu_unmap(vm, &gr_ctx->mem, gr_ctx->mem.gpu_va); 2797 nvgpu_gmmu_unmap(vm, &gr_ctx->mem, gr_ctx->mem.gpu_va);
2790 nvgpu_dma_free(g, &gr_ctx->mem); 2798 nvgpu_dma_free(g, &gr_ctx->mem);
2791 nvgpu_kfree(g, gr_ctx); 2799 nvgpu_kfree(g, gr_ctx);
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
index dc3b7868..1498d1c0 100644
--- a/drivers/gpu/nvgpu/gp106/hal_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -292,7 +292,7 @@ static const struct gpu_ops gp106_ops = {
292 .pagepool_default_size = gr_gp106_pagepool_default_size, 292 .pagepool_default_size = gr_gp106_pagepool_default_size,
293 .init_ctx_state = gr_gp10b_init_ctx_state, 293 .init_ctx_state = gr_gp10b_init_ctx_state,
294 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx, 294 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx,
295 .free_gr_ctx = gr_gp10b_free_gr_ctx, 295 .free_gr_ctx = gr_gk20a_free_gr_ctx,
296 .update_ctxsw_preemption_mode = 296 .update_ctxsw_preemption_mode =
297 gr_gp10b_update_ctxsw_preemption_mode, 297 gr_gp10b_update_ctxsw_preemption_mode,
298 .dump_gr_regs = gr_gp10b_dump_gr_status_regs, 298 .dump_gr_regs = gr_gp10b_dump_gr_status_regs,
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
index ca2bc52b..56acc732 100644
--- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
@@ -1167,27 +1167,6 @@ void gr_gp10b_dump_ctxsw_stats(struct gk20a *g, struct vm_gk20a *vm,
1167 nvgpu_mem_end(g, mem); 1167 nvgpu_mem_end(g, mem);
1168} 1168}
1169 1169
1170void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
1171 struct gr_ctx_desc *gr_ctx)
1172{
1173 gk20a_dbg_fn("");
1174
1175 if (!gr_ctx)
1176 return;
1177
1178 if (g->ops.gr.dump_ctxsw_stats &&
1179 g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close)
1180 g->ops.gr.dump_ctxsw_stats(g, vm, gr_ctx);
1181
1182 nvgpu_dma_unmap_free(vm, &gr_ctx->pagepool_ctxsw_buffer);
1183 nvgpu_dma_unmap_free(vm, &gr_ctx->betacb_ctxsw_buffer);
1184 nvgpu_dma_unmap_free(vm, &gr_ctx->spill_ctxsw_buffer);
1185 nvgpu_dma_unmap_free(vm, &gr_ctx->preempt_ctxsw_buffer);
1186 gr_gk20a_free_gr_ctx(g, vm, gr_ctx);
1187 gk20a_dbg_fn("done");
1188}
1189
1190
1191void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, 1170void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g,
1192 struct channel_ctx_gk20a *ch_ctx, 1171 struct channel_ctx_gk20a *ch_ctx,
1193 struct nvgpu_mem *mem) 1172 struct nvgpu_mem *mem)
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h
index 64a076ef..e3ef6304 100644
--- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h
@@ -101,8 +101,6 @@ int gr_gp10b_alloc_gr_ctx(struct gk20a *g,
101 struct gr_ctx_desc **gr_ctx, struct vm_gk20a *vm, 101 struct gr_ctx_desc **gr_ctx, struct vm_gk20a *vm,
102 u32 class, 102 u32 class,
103 u32 flags); 103 u32 flags);
104void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
105 struct gr_ctx_desc *gr_ctx);
106void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g, 104void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g,
107 struct channel_ctx_gk20a *ch_ctx, 105 struct channel_ctx_gk20a *ch_ctx,
108 struct nvgpu_mem *mem); 106 struct nvgpu_mem *mem);
diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
index 7ca9e313..aaee595d 100644
--- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
@@ -256,7 +256,7 @@ static const struct gpu_ops gp10b_ops = {
256 .pagepool_default_size = gr_gp10b_pagepool_default_size, 256 .pagepool_default_size = gr_gp10b_pagepool_default_size,
257 .init_ctx_state = gr_gp10b_init_ctx_state, 257 .init_ctx_state = gr_gp10b_init_ctx_state,
258 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx, 258 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx,
259 .free_gr_ctx = gr_gp10b_free_gr_ctx, 259 .free_gr_ctx = gr_gk20a_free_gr_ctx,
260 .update_ctxsw_preemption_mode = 260 .update_ctxsw_preemption_mode =
261 gr_gp10b_update_ctxsw_preemption_mode, 261 gr_gp10b_update_ctxsw_preemption_mode,
262 .dump_gr_regs = gr_gp10b_dump_gr_status_regs, 262 .dump_gr_regs = gr_gp10b_dump_gr_status_regs,
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index e935b2e5..b29a73d4 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -325,7 +325,7 @@ static const struct gpu_ops gv100_ops = {
325 .pagepool_default_size = gr_gv11b_pagepool_default_size, 325 .pagepool_default_size = gr_gv11b_pagepool_default_size,
326 .init_ctx_state = gr_gp10b_init_ctx_state, 326 .init_ctx_state = gr_gp10b_init_ctx_state,
327 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx, 327 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx,
328 .free_gr_ctx = gr_gp10b_free_gr_ctx, 328 .free_gr_ctx = gr_gk20a_free_gr_ctx,
329 .update_ctxsw_preemption_mode = 329 .update_ctxsw_preemption_mode =
330 gr_gp10b_update_ctxsw_preemption_mode, 330 gr_gp10b_update_ctxsw_preemption_mode,
331 .dump_gr_regs = gr_gv11b_dump_gr_status_regs, 331 .dump_gr_regs = gr_gv11b_dump_gr_status_regs,
diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
index 7c22448d..aa3d52af 100644
--- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
@@ -292,7 +292,7 @@ static const struct gpu_ops gv11b_ops = {
292 .pagepool_default_size = gr_gv11b_pagepool_default_size, 292 .pagepool_default_size = gr_gv11b_pagepool_default_size,
293 .init_ctx_state = gr_gp10b_init_ctx_state, 293 .init_ctx_state = gr_gp10b_init_ctx_state,
294 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx, 294 .alloc_gr_ctx = gr_gp10b_alloc_gr_ctx,
295 .free_gr_ctx = gr_gp10b_free_gr_ctx, 295 .free_gr_ctx = gr_gk20a_free_gr_ctx,
296 .update_ctxsw_preemption_mode = 296 .update_ctxsw_preemption_mode =
297 gr_gv11b_update_ctxsw_preemption_mode, 297 gr_gv11b_update_ctxsw_preemption_mode,
298 .dump_gr_regs = gr_gv11b_dump_gr_status_regs, 298 .dump_gr_regs = gr_gv11b_dump_gr_status_regs,