summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/nvgpu/Makefile2
-rw-r--r--drivers/gpu/nvgpu/common/linux/io_t19x.c29
-rw-r--r--drivers/gpu/nvgpu/common/linux/module_t19x.c62
-rw-r--r--drivers/gpu/nvgpu/fifo_t19x.h1
-rw-r--r--drivers/gpu/nvgpu/gv11b/fifo_gv11b.c10
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/io_t19x.h29
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/io_t19x.h26
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/module_t19x.h27
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/os_linux_t19x.h26
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c7
10 files changed, 205 insertions, 14 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 1ca21fb5..cc304df6 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -3,6 +3,8 @@ nvgpu-t19x := ../../../../nvgpu-t19x/drivers/gpu/nvgpu
3nvgpu-y += \ 3nvgpu-y += \
4 $(nvgpu-t19x)/common/mm/gmmu_t19x.o \ 4 $(nvgpu-t19x)/common/mm/gmmu_t19x.o \
5 $(nvgpu-t19x)/common/linux/ioctl_tsg_t19x.o \ 5 $(nvgpu-t19x)/common/linux/ioctl_tsg_t19x.o \
6 $(nvgpu-t19x)/common/linux/io_t19x.o \
7 $(nvgpu-t19x)/common/linux/module_t19x.o \
6 $(nvgpu-t19x)/gv11b/gv11b.o \ 8 $(nvgpu-t19x)/gv11b/gv11b.o \
7 $(nvgpu-t19x)/gv11b/mc_gv11b.o \ 9 $(nvgpu-t19x)/gv11b/mc_gv11b.o \
8 $(nvgpu-t19x)/gv11b/ltc_gv11b.o \ 10 $(nvgpu-t19x)/gv11b/ltc_gv11b.o \
diff --git a/drivers/gpu/nvgpu/common/linux/io_t19x.c b/drivers/gpu/nvgpu/common/linux/io_t19x.c
new file mode 100644
index 00000000..5c6b76ba
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/io_t19x.c
@@ -0,0 +1,29 @@
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 <nvgpu/io.h>
15#include <nvgpu/types.h>
16
17#include "common/linux/os_linux.h"
18#include "gk20a/gk20a.h"
19
20#include <nvgpu/hw/gv11b/hw_usermode_gv11b.h>
21
22void gv11b_usermode_writel(struct gk20a *g, u32 r, u32 v)
23{
24 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
25 void __iomem *reg = l->t19x.usermode_regs + (r - usermode_cfg0_r());
26
27 writel_relaxed(v, reg);
28 gk20a_dbg(gpu_dbg_reg, "usermode r=0x%x v=0x%x", r, v);
29}
diff --git a/drivers/gpu/nvgpu/common/linux/module_t19x.c b/drivers/gpu/nvgpu/common/linux/module_t19x.c
new file mode 100644
index 00000000..f0e3d438
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/module_t19x.c
@@ -0,0 +1,62 @@
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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <nvgpu/types.h>
18
19#include <nvgpu/hw/gv11b/hw_usermode_gv11b.h>
20
21#include "common/linux/os_linux.h"
22
23/*
24 * Locks out the driver from accessing GPU registers. This prevents access to
25 * thse registers after the GPU has been clock or power gated. This should help
26 * find annoying bugs where register reads and writes are silently dropped
27 * after the GPU has been turned off. On older chips these reads and writes can
28 * also lock the entire CPU up.
29 */
30void t19x_lockout_registers(struct gk20a *g)
31{
32 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
33
34 l->t19x.usermode_regs = NULL;
35}
36
37/*
38 * Undoes t19x_lockout_registers().
39 */
40void t19x_restore_registers(struct gk20a *g)
41{
42 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
43
44 l->t19x.usermode_regs = l->t19x.usermode_regs_saved;
45}
46
47void t19x_remove_support(struct gk20a *g)
48{
49 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
50
51 if (l->t19x.usermode_regs) {
52 l->t19x.usermode_regs = NULL;
53 }
54}
55
56void t19x_init_support(struct gk20a *g)
57{
58 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
59
60 l->t19x.usermode_regs = l->regs + usermode_cfg0_r();
61 l->t19x.usermode_regs_saved = l->t19x.usermode_regs;
62}
diff --git a/drivers/gpu/nvgpu/fifo_t19x.h b/drivers/gpu/nvgpu/fifo_t19x.h
index 6d508304..7274d1fe 100644
--- a/drivers/gpu/nvgpu/fifo_t19x.h
+++ b/drivers/gpu/nvgpu/fifo_t19x.h
@@ -24,7 +24,6 @@
24#define _FIFO_T19X_H_ 24#define _FIFO_T19X_H_
25 25
26struct fifo_t19x { 26struct fifo_t19x {
27 void __iomem *usermode_regs;
28 u32 max_subctx_count; 27 u32 max_subctx_count;
29}; 28};
30 29
diff --git a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
index b8798033..e9830c0e 100644
--- a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
@@ -61,15 +61,6 @@
61static void gv11b_fifo_init_ramfc_eng_method_buffer(struct gk20a *g, 61static void gv11b_fifo_init_ramfc_eng_method_buffer(struct gk20a *g,
62 struct channel_gk20a *ch, struct nvgpu_mem *mem); 62 struct channel_gk20a *ch, struct nvgpu_mem *mem);
63 63
64static inline void gv11b_usermode_writel(struct gk20a *g, u32 r, u32 v)
65{
66 struct fifo_gk20a *f = &g->fifo;
67 void __iomem *reg = f->t19x.usermode_regs + (r - usermode_cfg0_r());
68
69 writel_relaxed(v, reg);
70 gk20a_dbg(gpu_dbg_reg, "usermode r=0x%x v=0x%x", r, v);
71}
72
73void gv11b_get_tsg_runlist_entry(struct tsg_gk20a *tsg, u32 *runlist) 64void gv11b_get_tsg_runlist_entry(struct tsg_gk20a *tsg, u32 *runlist)
74{ 65{
75 66
@@ -1787,7 +1778,6 @@ int gv11b_init_fifo_setup_hw(struct gk20a *g)
1787{ 1778{
1788 struct fifo_gk20a *f = &g->fifo; 1779 struct fifo_gk20a *f = &g->fifo;
1789 1780
1790 f->t19x.usermode_regs = g->regs + usermode_cfg0_r();
1791 f->t19x.max_subctx_count = 1781 f->t19x.max_subctx_count =
1792 gr_pri_fe_chip_def_info_max_veid_count_init_v(); 1782 gr_pri_fe_chip_def_info_max_veid_count_init_v();
1793 return 0; 1783 return 0;
diff --git a/drivers/gpu/nvgpu/include/nvgpu/io_t19x.h b/drivers/gpu/nvgpu/include/nvgpu/io_t19x.h
new file mode 100644
index 00000000..f8c7dbbd
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/io_t19x.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22#ifndef __NVGPU_IO_T19X_H__
23#define __NVGPU_IO_T19X_H__
24
25#ifdef __KERNEL__
26#include "linux/io_t19x.h"
27#endif
28
29#endif
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/io_t19x.h b/drivers/gpu/nvgpu/include/nvgpu/linux/io_t19x.h
new file mode 100644
index 00000000..f71a6ecf
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/io_t19x.h
@@ -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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __NVGPU_IO_T19X_LINUX_H__
18#define __NVGPU_IO_T19X_LINUX_H__
19
20#include <nvgpu/types.h>
21
22struct gk20a;
23
24void gv11b_usermode_writel(struct gk20a *g, u32 r, u32 v);
25
26#endif
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/module_t19x.h b/drivers/gpu/nvgpu/include/nvgpu/linux/module_t19x.h
new file mode 100644
index 00000000..a105c6dc
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/module_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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __NVGPU_MODULE_T19X_H__
18#define __NVGPU_MODULE_T19X_H__
19
20struct gk20a;
21
22void t19x_init_support(struct gk20a *g);
23void t19x_remove_support(struct gk20a *g);
24void t19x_lockout_registers(struct gk20a *g);
25void t19x_restore_registers(struct gk20a *g);
26
27#endif
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/os_linux_t19x.h b/drivers/gpu/nvgpu/include/nvgpu/linux/os_linux_t19x.h
new file mode 100644
index 00000000..a306bfb8
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/os_linux_t19x.h
@@ -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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef NVGPU_OS_LINUX_T19X_H
17#define NVGPU_OS_LINUX_T19X_H
18
19#include <linux/compiler.h>
20
21struct nvgpu_os_linux_t19x {
22 void __iomem *usermode_regs;
23 void __iomem *usermode_regs_saved;
24};
25
26#endif
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 396359c3..6adbd46b 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/platform_gv11b_vgpu_tegra.c
@@ -23,6 +23,7 @@
23#include "gk20a/gk20a.h" 23#include "gk20a/gk20a.h"
24#include "gk20a/platform_gk20a.h" 24#include "gk20a/platform_gk20a.h"
25#include "vgpu/clk_vgpu.h" 25#include "vgpu/clk_vgpu.h"
26#include "common/linux/os_linux.h"
26 27
27#include <nvgpu/nvhost.h> 28#include <nvgpu/nvhost.h>
28#include <linux/platform_device.h> 29#include <linux/platform_device.h>
@@ -33,7 +34,7 @@ static int gv11b_vgpu_probe(struct device *dev)
33 struct gk20a_platform *platform = dev_get_drvdata(dev); 34 struct gk20a_platform *platform = dev_get_drvdata(dev);
34 struct resource *r; 35 struct resource *r;
35 void __iomem *regs; 36 void __iomem *regs;
36 struct fifo_gk20a *f = &platform->g->fifo; 37 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(platform->g);
37 int ret; 38 int ret;
38 39
39 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usermode"); 40 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usermode");
@@ -46,12 +47,12 @@ static int gv11b_vgpu_probe(struct device *dev)
46 dev_err(dev, "failed to map usermode regs\n"); 47 dev_err(dev, "failed to map usermode regs\n");
47 return PTR_ERR(regs); 48 return PTR_ERR(regs);
48 } 49 }
49 f->t19x.usermode_regs = regs; 50 l->t19x.usermode_regs = regs;
50 51
51#ifdef CONFIG_TEGRA_GK20A_NVHOST 52#ifdef CONFIG_TEGRA_GK20A_NVHOST
52 ret = nvgpu_get_nvhost_dev(platform->g); 53 ret = nvgpu_get_nvhost_dev(platform->g);
53 if (ret) { 54 if (ret) {
54 f->t19x.usermode_regs = NULL; 55 l->t19x.usermode_regs = NULL;
55 return ret; 56 return ret;
56 } 57 }
57#endif 58#endif