diff options
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c new file mode 100644 index 00000000..93341427 --- /dev/null +++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | */ | ||
13 | |||
14 | #include <gk20a/gk20a.h> | ||
15 | #include <vgpu/vgpu.h> | ||
16 | #include <linux/tegra_vgpu.h> | ||
17 | |||
18 | int vgpu_gv11b_alloc_subctx_header(struct channel_gk20a *c) | ||
19 | { | ||
20 | struct ctx_header_desc *ctx = &c->ch_ctx.ctx_header; | ||
21 | struct tegra_vgpu_cmd_msg msg = {}; | ||
22 | struct tegra_vgpu_alloc_ctx_header_params *p = | ||
23 | &msg.params.t19x.alloc_ctx_header; | ||
24 | struct gr_gk20a *gr = &c->g->gr; | ||
25 | int err; | ||
26 | |||
27 | msg.cmd = TEGRA_VGPU_CMD_ALLOC_CTX_HEADER; | ||
28 | msg.handle = vgpu_get_handle(c->g); | ||
29 | p->ch_handle = c->virt_ctx; | ||
30 | p->ctx_header_va = __nvgpu_vm_alloc_va(c->vm, | ||
31 | gr->ctx_vars.golden_image_size, | ||
32 | gmmu_page_size_kernel); | ||
33 | if (!p->ctx_header_va) { | ||
34 | nvgpu_err(c->g, "alloc va failed for ctx_header"); | ||
35 | return -ENOMEM; | ||
36 | } | ||
37 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
38 | err = err ? err : msg.ret; | ||
39 | if (unlikely(err)) { | ||
40 | nvgpu_err(c->g, "alloc ctx_header failed err %d", err); | ||
41 | __nvgpu_vm_free_va(c->vm, p->ctx_header_va, | ||
42 | gmmu_page_size_kernel); | ||
43 | return err; | ||
44 | } | ||
45 | ctx->mem.gpu_va = p->ctx_header_va; | ||
46 | |||
47 | return err; | ||
48 | } | ||
49 | |||
50 | void vgpu_gv11b_free_subctx_header(struct channel_gk20a *c) | ||
51 | { | ||
52 | struct ctx_header_desc *ctx = &c->ch_ctx.ctx_header; | ||
53 | struct tegra_vgpu_cmd_msg msg = {}; | ||
54 | struct tegra_vgpu_free_ctx_header_params *p = | ||
55 | &msg.params.t19x.free_ctx_header; | ||
56 | int err; | ||
57 | |||
58 | if (ctx->mem.gpu_va) { | ||
59 | msg.cmd = TEGRA_VGPU_CMD_FREE_CTX_HEADER; | ||
60 | msg.handle = vgpu_get_handle(c->g); | ||
61 | p->ch_handle = c->virt_ctx; | ||
62 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
63 | err = err ? err : msg.ret; | ||
64 | if (unlikely(err)) | ||
65 | nvgpu_err(c->g, "free ctx_header failed err %d", err); | ||
66 | __nvgpu_vm_free_va(c->vm, ctx->mem.gpu_va, | ||
67 | gmmu_page_size_kernel); | ||
68 | ctx->mem.gpu_va = 0; | ||
69 | } | ||
70 | } | ||