summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h')
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h188
1 files changed, 188 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h b/drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h
new file mode 100644
index 00000000..ac65dba3
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/vgpu/vgpu.h
@@ -0,0 +1,188 @@
1/*
2 * Virtualized GPU Interfaces
3 *
4 * Copyright (c) 2014-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 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef _VIRT_H_
20#define _VIRT_H_
21
22struct device;
23struct tegra_vgpu_gr_intr_info;
24struct tegra_vgpu_fifo_intr_info;
25struct tegra_vgpu_cmd_msg;
26struct gk20a_platform;
27
28#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
29#include <linux/tegra_gr_comm.h>
30#include <linux/tegra_vgpu.h>
31#include "gk20a/gk20a.h"
32#include "common/linux/platform_gk20a.h"
33#include "common/linux/os_linux.h"
34
35#include <nvgpu/thread.h>
36
37struct vgpu_priv_data {
38 u64 virt_handle;
39 struct nvgpu_thread intr_handler;
40 struct tegra_vgpu_constants_params constants;
41};
42
43static inline
44struct vgpu_priv_data *vgpu_get_priv_data_from_dev(struct device *dev)
45{
46 struct gk20a_platform *plat = gk20a_get_platform(dev);
47
48 return (struct vgpu_priv_data *)plat->vgpu_priv;
49}
50
51static inline struct vgpu_priv_data *vgpu_get_priv_data(struct gk20a *g)
52{
53 return vgpu_get_priv_data_from_dev(dev_from_gk20a(g));
54}
55
56static inline u64 vgpu_get_handle_from_dev(struct device *dev)
57{
58 struct vgpu_priv_data *priv = vgpu_get_priv_data_from_dev(dev);
59
60 if (unlikely(!priv)) {
61 dev_err(dev, "invalid vgpu_priv_data in %s\n", __func__);
62 return INT_MAX;
63 }
64
65 return priv->virt_handle;
66}
67
68static inline u64 vgpu_get_handle(struct gk20a *g)
69{
70 return vgpu_get_handle_from_dev(dev_from_gk20a(g));
71}
72
73int vgpu_pm_prepare_poweroff(struct device *dev);
74int vgpu_pm_finalize_poweron(struct device *dev);
75int vgpu_probe(struct platform_device *dev);
76int vgpu_remove(struct platform_device *dev);
77u64 vgpu_bar1_map(struct gk20a *g, struct sg_table **sgt, u64 size);
78int vgpu_gr_isr(struct gk20a *g, struct tegra_vgpu_gr_intr_info *info);
79int vgpu_gr_nonstall_isr(struct gk20a *g,
80 struct tegra_vgpu_gr_nonstall_intr_info *info);
81int vgpu_gr_alloc_gr_ctx(struct gk20a *g,
82 struct gr_ctx_desc **__gr_ctx,
83 struct vm_gk20a *vm,
84 u32 class,
85 u32 flags);
86void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
87 struct gr_ctx_desc *gr_ctx);
88void vgpu_gr_handle_sm_esr_event(struct gk20a *g,
89 struct tegra_vgpu_sm_esr_info *info);
90int vgpu_gr_init_ctx_state(struct gk20a *g);
91int vgpu_fifo_isr(struct gk20a *g, struct tegra_vgpu_fifo_intr_info *info);
92int vgpu_fifo_nonstall_isr(struct gk20a *g,
93 struct tegra_vgpu_fifo_nonstall_intr_info *info);
94int vgpu_ce2_nonstall_isr(struct gk20a *g,
95 struct tegra_vgpu_ce2_nonstall_intr_info *info);
96u32 vgpu_ce_get_num_pce(struct gk20a *g);
97int vgpu_init_mm_support(struct gk20a *g);
98int vgpu_init_gr_support(struct gk20a *g);
99int vgpu_init_fifo_support(struct gk20a *g);
100
101int vgpu_get_attribute(u64 handle, u32 attrib, u32 *value);
102int vgpu_comm_sendrecv(struct tegra_vgpu_cmd_msg *msg, size_t size_in,
103 size_t size_out);
104
105int vgpu_gm20b_init_hal(struct gk20a *g);
106int vgpu_gp10b_init_hal(struct gk20a *g);
107
108int vgpu_init_gpu_characteristics(struct gk20a *g);
109
110void vgpu_create_sysfs(struct device *dev);
111void vgpu_remove_sysfs(struct device *dev);
112int vgpu_read_ptimer(struct gk20a *g, u64 *value);
113int vgpu_get_timestamps_zipper(struct gk20a *g,
114 u32 source_id, u32 count,
115 struct nvgpu_cpu_time_correlation_sample *samples);
116#else
117static inline int vgpu_pm_prepare_poweroff(struct device *dev)
118{
119 return -ENOSYS;
120}
121static inline int vgpu_pm_finalize_poweron(struct device *dev)
122{
123 return -ENOSYS;
124}
125static inline int vgpu_probe(struct platform_device *dev)
126{
127 return -ENOSYS;
128}
129static inline int vgpu_remove(struct platform_device *dev)
130{
131 return -ENOSYS;
132}
133static inline u64 vgpu_bar1_map(struct gk20a *g, struct sg_table **sgt,
134 u64 size)
135{
136 return 0;
137}
138static inline int vgpu_gr_isr(struct gk20a *g,
139 struct tegra_vgpu_gr_intr_info *info)
140{
141 return 0;
142}
143static inline int vgpu_gr_alloc_gr_ctx(struct gk20a *g,
144 struct gr_ctx_desc **__gr_ctx,
145 struct vm_gk20a *vm,
146 u32 class,
147 u32 flags)
148{
149 return -ENOSYS;
150}
151static inline void vgpu_gr_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
152 struct gr_ctx_desc *gr_ctx)
153{
154}
155static inline int vgpu_gr_init_ctx_state(struct gk20a *g)
156{
157 return -ENOSYS;
158}
159static inline int vgpu_fifo_isr(struct gk20a *g,
160 struct tegra_vgpu_fifo_intr_info *info)
161{
162 return 0;
163}
164static inline int vgpu_init_mm_support(struct gk20a *g)
165{
166 return -ENOSYS;
167}
168static inline int vgpu_init_gr_support(struct gk20a *g)
169{
170 return -ENOSYS;
171}
172static inline int vgpu_init_fifo_support(struct gk20a *g)
173{
174 return -ENOSYS;
175}
176
177static inline int vgpu_get_attribute(u64 handle, u32 attrib, u32 *value)
178{
179 return -ENOSYS;
180}
181static inline int vgpu_comm_sendrecv(struct tegra_vgpu_cmd_msg *msg, size_t size_in,
182 size_t size_out)
183{
184 return -ENOSYS;
185}
186#endif
187
188#endif