summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c18
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c76
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h2
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c2
-rw-r--r--include/linux/tegra_vgpu_t19x.h10
5 files changed, 105 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c b/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
index 6adbd46b..d48d1308 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
@@ -26,6 +26,8 @@
26#include "common/linux/os_linux.h" 26#include "common/linux/os_linux.h"
27 27
28#include <nvgpu/nvhost.h> 28#include <nvgpu/nvhost.h>
29#include <nvgpu/nvhost_t19x.h>
30
29#include <linux/platform_device.h> 31#include <linux/platform_device.h>
30 32
31static int gv11b_vgpu_probe(struct device *dev) 33static int gv11b_vgpu_probe(struct device *dev)
@@ -35,6 +37,7 @@ static int gv11b_vgpu_probe(struct device *dev)
35 struct resource *r; 37 struct resource *r;
36 void __iomem *regs; 38 void __iomem *regs;
37 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(platform->g); 39 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(platform->g);
40 struct gk20a *g = platform->g;
38 int ret; 41 int ret;
39 42
40 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usermode"); 43 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usermode");
@@ -50,11 +53,22 @@ static int gv11b_vgpu_probe(struct device *dev)
50 l->t19x.usermode_regs = regs; 53 l->t19x.usermode_regs = regs;
51 54
52#ifdef CONFIG_TEGRA_GK20A_NVHOST 55#ifdef CONFIG_TEGRA_GK20A_NVHOST
53 ret = nvgpu_get_nvhost_dev(platform->g); 56 ret = nvgpu_get_nvhost_dev(g);
54 if (ret) { 57 if (ret) {
55 l->t19x.usermode_regs = NULL; 58 l->t19x.usermode_regs = NULL;
56 return ret; 59 return ret;
57 } 60 }
61
62 ret = nvgpu_nvhost_syncpt_unit_interface_get_aperture(g->nvhost_dev,
63 &g->syncpt_unit_base,
64 &g->syncpt_unit_size);
65 if (ret) {
66 dev_err(dev, "Failed to get syncpt interface");
67 return -ENOSYS;
68 }
69 g->syncpt_size = nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(1);
70 nvgpu_info(g, "syncpt_unit_base %llx syncpt_unit_size %zx size %x\n",
71 g->syncpt_unit_base, g->syncpt_unit_size, g->syncpt_size);
58#endif 72#endif
59 vgpu_init_clk_support(platform->g); 73 vgpu_init_clk_support(platform->g);
60 74
@@ -62,7 +76,7 @@ static int gv11b_vgpu_probe(struct device *dev)
62} 76}
63 77
64struct gk20a_platform gv11b_vgpu_tegra_platform = { 78struct gk20a_platform gv11b_vgpu_tegra_platform = {
65 .has_syncpoints = false, 79 .has_syncpoints = true,
66 .aggressive_sync_destroy_thresh = 64, 80 .aggressive_sync_destroy_thresh = 64,
67 81
68 /* power management configuration */ 82 /* power management configuration */
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c
index 048a4c64..ae9d52a7 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c
@@ -23,6 +23,82 @@
23#include <gk20a/gk20a.h> 23#include <gk20a/gk20a.h>
24 24
25#include "vgpu/vgpu.h" 25#include "vgpu/vgpu.h"
26#include "gv11b/fifo_gv11b.h"
27#include <nvgpu/nvhost_t19x.h>
28
29#include <linux/tegra_vgpu.h>
30
31#ifdef CONFIG_TEGRA_GK20A_NVHOST
32int vgpu_gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c,
33 u32 syncpt_id, struct nvgpu_mem *syncpt_buf)
34{
35 int err;
36 struct gk20a *g = c->g;
37 struct vm_gk20a *vm = c->vm;
38 struct tegra_vgpu_cmd_msg msg = {};
39 struct tegra_vgpu_map_syncpt_params *p = &msg.params.t19x.map_syncpt;
40
41 /*
42 * Add ro map for complete sync point shim range in vm.
43 * All channels sharing same vm will share same ro mapping.
44 * Create rw map for current channel sync point.
45 */
46 if (!vm->syncpt_ro_map_gpu_va) {
47 vm->syncpt_ro_map_gpu_va = __nvgpu_vm_alloc_va(vm,
48 g->syncpt_unit_size,
49 gmmu_page_size_kernel);
50 if (!vm->syncpt_ro_map_gpu_va) {
51 nvgpu_err(g, "allocating read-only va space failed");
52 return -ENOMEM;
53 }
54
55 msg.cmd = TEGRA_VGPU_CMD_MAP_SYNCPT;
56 msg.handle = vgpu_get_handle(g);
57 p->as_handle = c->vm->handle;
58 p->gpu_va = vm->syncpt_ro_map_gpu_va;
59 p->len = g->syncpt_unit_size;
60 p->offset = 0;
61 p->prot = TEGRA_VGPU_MAP_PROT_READ_ONLY;
62 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
63 err = err ? err : msg.ret;
64 if (err) {
65 nvgpu_err(g,
66 "mapping read-only va space failed err %d",
67 err);
68 __nvgpu_vm_free_va(c->vm, vm->syncpt_ro_map_gpu_va,
69 gmmu_page_size_kernel);
70 vm->syncpt_ro_map_gpu_va = 0;
71 return err;
72 }
73 }
74
75 syncpt_buf->gpu_va = __nvgpu_vm_alloc_va(c->vm, g->syncpt_size,
76 gmmu_page_size_kernel);
77 if (!syncpt_buf->gpu_va) {
78 nvgpu_err(g, "allocating syncpt va space failed");
79 return -ENOMEM;
80 }
81
82 msg.cmd = TEGRA_VGPU_CMD_MAP_SYNCPT;
83 msg.handle = vgpu_get_handle(g);
84 p->as_handle = c->vm->handle;
85 p->gpu_va = syncpt_buf->gpu_va;
86 p->len = g->syncpt_size;
87 p->offset =
88 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id);
89 p->prot = TEGRA_VGPU_MAP_PROT_NONE;
90 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
91 err = err ? err : msg.ret;
92 if (err) {
93 nvgpu_err(g, "mapping syncpt va space failed err %d", err);
94 __nvgpu_vm_free_va(c->vm, syncpt_buf->gpu_va,
95 gmmu_page_size_kernel);
96 return err;
97 }
98
99 return 0;
100}
101#endif /* CONFIG_TEGRA_GK20A_NVHOST */
26 102
27int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g) 103int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g)
28{ 104{
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h
index 03404542..bea935d3 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.h
@@ -26,4 +26,6 @@
26struct gk20a; 26struct gk20a;
27 27
28int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g); 28int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g);
29int vgpu_gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c,
30 u32 syncpt_id, struct nvgpu_mem *syncpt_buf);
29#endif 31#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
index 9226206a..2cd8018c 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
@@ -378,7 +378,7 @@ static const struct gpu_ops vgpu_gv11b_ops = {
378 .tsg_bind_channel = vgpu_tsg_bind_channel, 378 .tsg_bind_channel = vgpu_tsg_bind_channel,
379 .tsg_unbind_channel = vgpu_tsg_unbind_channel, 379 .tsg_unbind_channel = vgpu_tsg_unbind_channel,
380#ifdef CONFIG_TEGRA_GK20A_NVHOST 380#ifdef CONFIG_TEGRA_GK20A_NVHOST
381 .alloc_syncpt_buf = gv11b_fifo_alloc_syncpt_buf, 381 .alloc_syncpt_buf = vgpu_gv11b_fifo_alloc_syncpt_buf,
382 .free_syncpt_buf = gv11b_fifo_free_syncpt_buf, 382 .free_syncpt_buf = gv11b_fifo_free_syncpt_buf,
383 .add_syncpt_wait_cmd = gv11b_fifo_add_syncpt_wait_cmd, 383 .add_syncpt_wait_cmd = gv11b_fifo_add_syncpt_wait_cmd,
384 .get_syncpt_wait_cmd_size = gv11b_fifo_get_syncpt_wait_cmd_size, 384 .get_syncpt_wait_cmd_size = gv11b_fifo_get_syncpt_wait_cmd_size,
diff --git a/include/linux/tegra_vgpu_t19x.h b/include/linux/tegra_vgpu_t19x.h
index c2814f16..fe39230e 100644
--- a/include/linux/tegra_vgpu_t19x.h
+++ b/include/linux/tegra_vgpu_t19x.h
@@ -16,6 +16,7 @@
16 16
17#define TEGRA_VGPU_CMD_ALLOC_CTX_HEADER 100 17#define TEGRA_VGPU_CMD_ALLOC_CTX_HEADER 100
18#define TEGRA_VGPU_CMD_FREE_CTX_HEADER 101 18#define TEGRA_VGPU_CMD_FREE_CTX_HEADER 101
19#define TEGRA_VGPU_CMD_MAP_SYNCPT 102
19 20
20struct tegra_vgpu_alloc_ctx_header_params { 21struct tegra_vgpu_alloc_ctx_header_params {
21 u64 ch_handle; 22 u64 ch_handle;
@@ -26,9 +27,18 @@ struct tegra_vgpu_free_ctx_header_params {
26 u64 ch_handle; 27 u64 ch_handle;
27}; 28};
28 29
30struct tegra_vgpu_map_syncpt_params {
31 u64 as_handle;
32 u64 gpu_va;
33 u64 len;
34 u64 offset;
35 u8 prot;
36};
37
29union tegra_vgpu_t19x_params { 38union tegra_vgpu_t19x_params {
30 struct tegra_vgpu_alloc_ctx_header_params alloc_ctx_header; 39 struct tegra_vgpu_alloc_ctx_header_params alloc_ctx_header;
31 struct tegra_vgpu_free_ctx_header_params free_ctx_header; 40 struct tegra_vgpu_free_ctx_header_params free_ctx_header;
41 struct tegra_vgpu_map_syncpt_params map_syncpt;
32}; 42};
33 43
34#define TEGRA_VGPU_ATTRIB_MAX_SUBCTX_COUNT 100 44#define TEGRA_VGPU_ATTRIB_MAX_SUBCTX_COUNT 100