summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Zhao <rizhao@nvidia.com>2017-04-10 18:32:59 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-30 01:34:37 -0400
commit6a25181882cdda68dfa4680b35f12c11b47ea036 (patch)
tree86f3f89e979f14e7c0ca94eb37458d7aed59b515
parent7346122ae66d35a39ebbdcb423de5bfc4fb66f4e (diff)
gpu: nvgpu: vgpu: add basic t19x HALs
- Added t19x vgpu platform data - Added basic vgpu HAL for gv11b. - Added subctx header HAL. Jira VFND-3796 Change-Id: I2b99364801b41d042b53e057f1a30e1194f354c3 Signed-off-by: Richard Zhao <rizhao@nvidia.com> Reviewed-on: https://git-master/r/1474729 GVS: Gerrit_Virtual_Submit Reviewed-by: Aingara Paramakuru <aparamakuru@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/Makefile7
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c80
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c26
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h21
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.c40
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.h19
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c40
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c70
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.h22
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu_t19x.h27
-rw-r--r--include/linux/tegra_vgpu_t19x.h34
11 files changed, 386 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 244b3ed3..8a7c768e 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -21,3 +21,10 @@ nvgpu-y += \
21 21
22nvgpu-$(CONFIG_TEGRA_GK20A) += $(nvgpu-t19x)/gv11b/platform_gv11b_tegra.o 22nvgpu-$(CONFIG_TEGRA_GK20A) += $(nvgpu-t19x)/gv11b/platform_gv11b_tegra.o
23nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += $(nvgpu-t19x)/common/linux/nvhost_t19x.o 23nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += $(nvgpu-t19x)/common/linux/nvhost_t19x.o
24
25nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \
26 $(nvgpu-t19x)/vgpu/gv11b/platform_gv11b_vgpu_tegra.o \
27 $(nvgpu-t19x)/vgpu/gv11b/vgpu_hal_gv11b.o \
28 $(nvgpu-t19x)/vgpu/gv11b/vgpu_gr_gv11b.o \
29 $(nvgpu-t19x)/vgpu/gv11b/vgpu_fifo_gv11b.o \
30 $(nvgpu-t19x)/vgpu/gv11b/vgpu_subctx_gv11b.o
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c b/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
new file mode 100644
index 00000000..a6ed67b2
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
@@ -0,0 +1,80 @@
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 "gk20a/hal_gk20a.h"
16#include "gk20a/platform_gk20a.h"
17#include "vgpu/clk_vgpu.h"
18
19#include <nvgpu/nvhost.h>
20#include <linux/platform_device.h>
21
22static int gv11b_vgpu_probe(struct device *dev)
23{
24 struct platform_device *pdev = to_platform_device(dev);
25 struct gk20a_platform *platform = dev_get_drvdata(dev);
26 struct resource *r;
27 void __iomem *regs;
28 struct fifo_gk20a *f = &platform->g->fifo;
29 int ret;
30
31 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usermode");
32 if (!r) {
33 dev_err(dev, "failed to get usermode regs\n");
34 return -ENXIO;
35 }
36 regs = devm_ioremap_resource(dev, r);
37 if (IS_ERR(regs)) {
38 dev_err(dev, "failed to map usermode regs\n");
39 return PTR_ERR(regs);
40 }
41 f->t19x.usermode_regs = regs;
42
43#ifdef CONFIG_TEGRA_GK20A_NVHOST
44 ret = nvgpu_get_nvhost_dev(platform->g);
45 if (ret) {
46 f->t19x.usermode_regs = NULL;
47 return ret;
48 }
49#endif
50 vgpu_init_clk_support(platform->g);
51
52 return 0;
53}
54
55struct gk20a_platform gv11b_vgpu_tegra_platform = {
56 .has_syncpoints = false,
57 .aggressive_sync_destroy_thresh = 64,
58
59 /* power management configuration */
60 .can_railgate_init = false,
61 .can_elpg_init = false,
62 .enable_slcg = false,
63 .enable_blcg = false,
64 .enable_elcg = false,
65 .enable_elpg = false,
66 .enable_aelpg = false,
67
68 .ch_wdt_timeout_ms = 5000,
69
70 .probe = gv11b_vgpu_probe,
71 .default_big_page_size = SZ_64K,
72
73 .clk_round_rate = vgpu_clk_round_rate,
74 .get_clk_freqs = vgpu_clk_get_freqs,
75
76 /* frequency scaling configuration */
77 .devfreq_governor = "userspace",
78
79 .virtual_dev = true,
80};
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c
new file mode 100644
index 00000000..b9df58ec
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c
@@ -0,0 +1,26 @@
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/gp10b/vgpu_fifo_gp10b.h>
16
17#include "vgpu_fifo_gv11b.h"
18#include "vgpu_subctx_gv11b.h"
19
20void vgpu_gv11b_init_fifo_ops(struct gpu_ops *gops)
21{
22 vgpu_gp10b_init_fifo_ops(gops);
23
24 gops->fifo.init_fifo_setup_hw = NULL;
25 gops->fifo.free_channel_ctx_header = vgpu_gv11b_free_subctx_header;
26}
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h
new file mode 100644
index 00000000..a9c13b5f
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h
@@ -0,0 +1,21 @@
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#ifndef _VGPU_FIFO_GV11B_H_
15#define _VGPU_FIFO_GV11B_H_
16
17struct gpu_ops;
18
19void vgpu_gv11b_init_fifo_ops(struct gpu_ops *gops);
20
21#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.c
new file mode 100644
index 00000000..fcd31d20
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.c
@@ -0,0 +1,40 @@
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/gr_vgpu.h>
16#include <vgpu/gp10b/vgpu_gr_gp10b.h>
17
18#include "vgpu_gr_gv11b.h"
19#include "vgpu_subctx_gv11b.h"
20
21static int vgpu_gr_gv11b_commit_inst(struct channel_gk20a *c, u64 gpu_va)
22{
23 int err;
24
25 err = vgpu_gv11b_alloc_subctx_header(c);
26 if (err)
27 return err;
28
29 err = vgpu_gr_commit_inst(c, gpu_va);
30 if (err)
31 vgpu_gv11b_free_subctx_header(c);
32
33 return err;
34}
35
36void vgpu_gv11b_init_gr_ops(struct gpu_ops *gops)
37{
38 vgpu_gp10b_init_gr_ops(gops);
39 gops->gr.commit_inst = vgpu_gr_gv11b_commit_inst;
40}
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.h b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.h
new file mode 100644
index 00000000..cc3171d4
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_gr_gv11b.h
@@ -0,0 +1,19 @@
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#ifndef _VGPU_GR_GV11B_H_
15#define _VGPU_GR_GV11B_H_
16
17void vgpu_gv11b_init_gr_ops(struct gpu_ops *gops);
18
19#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
new file mode 100644
index 00000000..fff1a386
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
@@ -0,0 +1,40 @@
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 <gv11b/hal_gv11b.h>
16#include <vgpu/vgpu.h>
17#include <vgpu/vgpu_t19x.h>
18#include <vgpu/gp10b/vgpu_mm_gp10b.h>
19
20#include "vgpu_gr_gv11b.h"
21#include "vgpu_fifo_gv11b.h"
22
23int vgpu_gv11b_init_hal(struct gk20a *g)
24{
25 int err;
26
27 gk20a_dbg_fn("");
28
29 err = gv11b_init_hal(g);
30 if (err)
31 return err;
32
33 vgpu_init_hal_common(g);
34 vgpu_gp10b_init_mm_ops(&g->ops);
35
36 vgpu_gv11b_init_gr_ops(&g->ops);
37 vgpu_gv11b_init_fifo_ops(&g->ops);
38
39 return 0;
40}
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
18int 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
50void 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}
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.h b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.h
new file mode 100644
index 00000000..bfcfe65c
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.h
@@ -0,0 +1,22 @@
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#ifndef _VGPU_SUBCTX_GV11B_H_
15#define _VGPU_SUBCTX_GV11B_H_
16
17struct channel_gk20a;
18
19int vgpu_gv11b_alloc_subctx_header(struct channel_gk20a *c);
20void vgpu_gv11b_free_subctx_header(struct channel_gk20a *c);
21
22#endif
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu_t19x.h b/drivers/gpu/nvgpu/vgpu/vgpu_t19x.h
new file mode 100644
index 00000000..de3e0f80
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/vgpu_t19x.h
@@ -0,0 +1,27 @@
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#ifndef _VGPU_T19X_H_
15#define _VGPU_T19X_H_
16
17struct gk20a;
18
19int vgpu_gv11b_init_hal(struct gk20a *g);
20
21#define vgpu_t19x_init_hal(g) vgpu_gv11b_init_hal(g)
22
23#define TEGRA_19x_VGPU_COMPAT_TEGRA "nvidia,gv11b-vgpu"
24extern struct gk20a_platform gv11b_vgpu_tegra_platform;
25#define t19x_vgpu_tegra_platform gv11b_vgpu_tegra_platform
26
27#endif
diff --git a/include/linux/tegra_vgpu_t19x.h b/include/linux/tegra_vgpu_t19x.h
new file mode 100644
index 00000000..f473275d
--- /dev/null
+++ b/include/linux/tegra_vgpu_t19x.h
@@ -0,0 +1,34 @@
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#ifndef __TEGRA_VGPU_T19X_H
15#define __TEGRA_VGPU_T19X_H
16
17#define TEGRA_VGPU_CMD_ALLOC_CTX_HEADER 100
18#define TEGRA_VGPU_CMD_FREE_CTX_HEADER 101
19
20struct tegra_vgpu_alloc_ctx_header_params {
21 u64 ch_handle;
22 u64 ctx_header_va;
23};
24
25struct tegra_vgpu_free_ctx_header_params {
26 u64 ch_handle;
27};
28
29union tegra_vgpu_t19x_params {
30 struct tegra_vgpu_alloc_ctx_header_params alloc_ctx_header;
31 struct tegra_vgpu_free_ctx_header_params free_ctx_header;
32};
33
34#endif