summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r--drivers/gpu/nvgpu/common/linux/io_t19x.c29
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c33
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h23
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c115
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h21
-rw-r--r--drivers/gpu/nvgpu/common/linux/module_t19x.c62
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvhost_t19x.c35
-rw-r--r--drivers/gpu/nvgpu/common/linux/pci_t19x.c24
-rw-r--r--drivers/gpu/nvgpu/common/mm/gmmu_t19x.c31
9 files changed, 373 insertions, 0 deletions
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/ioctl_ctrl_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c
new file mode 100644
index 00000000..a04fb5c9
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c
@@ -0,0 +1,33 @@
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 <uapi/linux/nvgpu.h>
15
16#include <nvgpu/types.h>
17#include <nvgpu/enabled.h>
18#include <nvgpu/enabled_t19x.h>
19
20#include "ioctl_ctrl_t19x.h"
21#include "common/linux/os_linux.h"
22#include "gk20a/gk20a.h"
23
24u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags_t19x(struct gk20a *g)
25{
26 u64 ioctl_flags = 0;
27
28 if (nvgpu_is_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS))
29 ioctl_flags |= NVGPU_GPU_FLAGS_SUPPORT_TSG_SUBCONTEXTS;
30
31 return ioctl_flags;
32}
33
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h
new file mode 100644
index 00000000..64141223
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h
@@ -0,0 +1,23 @@
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 _NVGPU_IOCTL_CTRL_T19X
15#define _NVGPU_IOCTL_CTRL_T19X
16
17#include <nvgpu/types.h>
18
19struct gk20a;
20
21u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags_t19x(struct gk20a *g);
22
23#endif
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c
new file mode 100644
index 00000000..1c96db69
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c
@@ -0,0 +1,115 @@
1/*
2 * GV11B TSG IOCTL Handler
3 *
4 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17#include <uapi/linux/nvgpu.h>
18
19#include "gk20a/gk20a.h"
20
21#include "gv11b/fifo_gv11b.h"
22#include "gv11b/subctx_gv11b.h"
23#include "ioctl_tsg_t19x.h"
24#include "common/linux/os_linux.h"
25
26static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g,
27 struct tsg_gk20a *tsg, struct nvgpu_tsg_bind_channel_ex_args *arg)
28{
29 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
30 struct gk20a_sched_ctrl *sched = &l->sched_ctrl;
31 struct channel_gk20a *ch;
32 struct gr_gk20a *gr = &g->gr;
33 int err = 0;
34
35 nvgpu_log(g, gpu_dbg_fn | gpu_dbg_sched, "tsgid=%u", tsg->tsgid);
36
37 nvgpu_mutex_acquire(&sched->control_lock);
38 if (sched->control_locked) {
39 err = -EPERM;
40 goto mutex_release;
41 }
42 err = gk20a_busy(g);
43 if (err) {
44 nvgpu_err(g, "failed to power on gpu");
45 goto mutex_release;
46 }
47
48 ch = gk20a_get_channel_from_file(arg->channel_fd);
49 if (!ch) {
50 err = -EINVAL;
51 goto idle;
52 }
53
54 if (arg->tpc_pg_enabled && (!tsg->t19x.tpc_num_initialized)) {
55 if ((arg->num_active_tpcs > gr->max_tpc_count) ||
56 !(arg->num_active_tpcs)) {
57 nvgpu_err(g, "Invalid num of active TPCs");
58 err = -EINVAL;
59 goto ch_put;
60 }
61 tsg->t19x.tpc_num_initialized = true;
62 tsg->t19x.num_active_tpcs = arg->num_active_tpcs;
63 tsg->t19x.tpc_pg_enabled = true;
64 } else {
65 tsg->t19x.tpc_pg_enabled = false;
66 nvgpu_log(g, gpu_dbg_info, "dynamic TPC-PG not enabled");
67 }
68
69 if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) {
70 ch->t19x.subctx_id = arg->subcontext_id;
71 } else {
72 err = -EINVAL;
73 goto ch_put;
74 }
75
76 nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d",
77 ch->chid, ch->t19x.subctx_id);
78
79 /* Use runqueue selector 1 for all ASYNC ids */
80 if (ch->t19x.subctx_id > CHANNEL_INFO_VEID0)
81 ch->t19x.runqueue_sel = 1;
82
83 err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch);
84ch_put:
85 gk20a_channel_put(ch);
86idle:
87 gk20a_idle(g);
88mutex_release:
89 nvgpu_mutex_release(&sched->control_lock);
90 return err;
91}
92
93int t19x_tsg_ioctl_handler(struct gk20a *g, struct tsg_gk20a *tsg,
94 unsigned int cmd, u8 *buf)
95{
96 int err = 0;
97
98 nvgpu_log(g, gpu_dbg_fn, "t19x_tsg_ioctl_handler");
99
100 switch (cmd) {
101 case NVGPU_TSG_IOCTL_BIND_CHANNEL_EX:
102 {
103 err = gv11b_tsg_ioctl_bind_channel_ex(g, tsg,
104 (struct nvgpu_tsg_bind_channel_ex_args *)buf);
105 break;
106 }
107
108 default:
109 nvgpu_err(g, "unrecognized tsg gpu ioctl cmd: 0x%x",
110 cmd);
111 err = -ENOTTY;
112 break;
113 }
114 return err;
115}
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h
new file mode 100644
index 00000000..3376ffce
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h
@@ -0,0 +1,21 @@
1/*
2 * GV11B TSG IOCTL handler
3 *
4 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_IOCTL_TSG_T19X
17#define _NVGPU_IOCTL_TSG_T19X
18
19int t19x_tsg_ioctl_handler(struct gk20a *g, struct tsg_gk20a *tsg,
20 unsigned int cmd, u8 *arg);
21#endif
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/common/linux/nvhost_t19x.c b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c
new file mode 100644
index 00000000..21cf62ec
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c
@@ -0,0 +1,35 @@
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 <linux/nvhost.h>
18#include <linux/nvhost_t194.h>
19
20#include <nvgpu/nvhost_t19x.h>
21
22#include "common/linux/nvhost_priv.h"
23
24int nvgpu_nvhost_syncpt_unit_interface_get_aperture(
25 struct nvgpu_nvhost_dev *nvhost_dev,
26 u64 *base, size_t *size)
27{
28 return nvhost_syncpt_unit_interface_get_aperture(
29 nvhost_dev->host1x_pdev, (phys_addr_t *)base, size);
30}
31
32u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id)
33{
34 return nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id);
35}
diff --git a/drivers/gpu/nvgpu/common/linux/pci_t19x.c b/drivers/gpu/nvgpu/common/linux/pci_t19x.c
new file mode 100644
index 00000000..54efd68e
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/pci_t19x.c
@@ -0,0 +1,24 @@
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/types.h>
15
16#include <nvgpu/hw/gv11b/hw_usermode_gv11b.h>
17
18#include "common/linux/os_linux.h"
19
20void t19x_nvgpu_pci_init_support(struct nvgpu_os_linux *l)
21{
22 l->t19x.usermode_regs = l->regs + usermode_cfg0_r();
23 l->t19x.usermode_regs_saved = l->t19x.usermode_regs;
24}
diff --git a/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c b/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c
new file mode 100644
index 00000000..9f9c188d
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c
@@ -0,0 +1,31 @@
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
23#include <uapi/linux/nvgpu.h>
24
25#include <nvgpu/gmmu.h>
26
27void nvgpu_gmmu_add_t19x_attrs(struct nvgpu_gmmu_attrs *attrs, u32 flags)
28{
29 attrs->t19x_attrs.l3_alloc = (bool)(flags &
30 NVGPU_AS_MAP_BUFFER_FLAGS_L3_ALLOC);
31}