summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/cde_gk20a.h
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-09-07 13:43:47 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-11 18:10:52 -0400
commitc37c9baae65bcf0ef08a319488c09f57131026cc (patch)
treee3b4252bfff7436574a909dd625de49229d538da /drivers/gpu/nvgpu/gk20a/cde_gk20a.h
parent17451138cf60f5d64eed88cc5defd44981926d9d (diff)
gpu: nvgpu: Move CDE code to Linux module
CDE is only used in Linux platforms, and the code is highly dependent on Linux APIs. Move the common CDE code to Linux module and leave only the chip specific parts to HAL. Change-Id: I507fe7eceaf7607303dfdddcf438449a5f582ea7 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1554755 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/cde_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/cde_gk20a.h311
1 files changed, 0 insertions, 311 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.h b/drivers/gpu/nvgpu/gk20a/cde_gk20a.h
deleted file mode 100644
index 4f400bf3..00000000
--- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.h
+++ /dev/null
@@ -1,311 +0,0 @@
1/*
2 * GK20A color decompression engine support
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 _CDE_GK20A_H_
20#define _CDE_GK20A_H_
21
22#include "mm_gk20a.h"
23
24#define MAX_CDE_BUFS 10
25#define MAX_CDE_PARAMS 64
26#define MAX_CDE_USER_PARAMS 40
27#define MAX_CDE_ARRAY_ENTRIES 9
28
29/*
30 * The size of the context ring buffer that is dedicated for handling cde
31 * jobs. Re-using a context (=channel) for a differnt cde job forces a cpu
32 * wait on the previous job to that channel, so increasing this value
33 * reduces the likelihood of stalls.
34 */
35#define NUM_CDE_CONTEXTS 4
36
37struct dma_buf;
38struct gk20a;
39
40/*
41 * this element defines a buffer that is allocated and mapped into gpu address
42 * space. data_byte_offset defines the beginning of the buffer inside the
43 * firmare. num_bytes defines how many bytes the firmware contains.
44 *
45 * If data_byte_offset is zero, we allocate an empty buffer.
46 */
47
48struct gk20a_cde_hdr_buf {
49 u64 data_byte_offset;
50 u64 num_bytes;
51};
52
53/*
54 * this element defines a constant patching in buffers. It basically
55 * computes physical address to <source_buf>+source_byte_offset. The
56 * address is then modified into patch value as per:
57 * value = (current_value & ~mask) | (address << shift) & mask .
58 *
59 * The type field defines the register size as:
60 * 0=u32,
61 * 1=u64 (little endian),
62 * 2=u64 (big endian)
63 */
64
65struct gk20a_cde_hdr_replace {
66 u32 target_buf;
67 u32 source_buf;
68 s32 shift;
69 u32 type;
70 u64 target_byte_offset;
71 u64 source_byte_offset;
72 u64 mask;
73};
74
75enum {
76 TYPE_PARAM_TYPE_U32 = 0,
77 TYPE_PARAM_TYPE_U64_LITTLE,
78 TYPE_PARAM_TYPE_U64_BIG
79};
80
81/*
82 * this element defines a runtime patching in buffers. Parameters with id from
83 * 0 to 1024 are reserved for special usage as follows:
84 * 0 = comptags_per_cacheline,
85 * 1 = slices_per_fbp,
86 * 2 = num_fbps
87 * 3 = source buffer first page offset
88 * 4 = source buffer block height log2
89 * 5 = backing store memory address
90 * 6 = destination memory address
91 * 7 = destination size (bytes)
92 * 8 = backing store size (bytes)
93 * 9 = cache line size
94 *
95 * Parameters above id 1024 are user-specified. I.e. they determine where a
96 * parameters from user space should be placed in buffers, what is their
97 * type, etc.
98 *
99 * Once the value is available, we add data_offset to the value.
100 *
101 * The value address is then modified into patch value as per:
102 * value = (current_value & ~mask) | (address << shift) & mask .
103 *
104 * The type field defines the register size as:
105 * 0=u32,
106 * 1=u64 (little endian),
107 * 2=u64 (big endian)
108 */
109
110struct gk20a_cde_hdr_param {
111 u32 id;
112 u32 target_buf;
113 s32 shift;
114 u32 type;
115 s64 data_offset;
116 u64 target_byte_offset;
117 u64 mask;
118};
119
120enum {
121 TYPE_PARAM_COMPTAGS_PER_CACHELINE = 0,
122 TYPE_PARAM_GPU_CONFIGURATION,
123 TYPE_PARAM_FIRSTPAGEOFFSET,
124 TYPE_PARAM_NUMPAGES,
125 TYPE_PARAM_BACKINGSTORE,
126 TYPE_PARAM_DESTINATION,
127 TYPE_PARAM_DESTINATION_SIZE,
128 TYPE_PARAM_BACKINGSTORE_SIZE,
129 TYPE_PARAM_SOURCE_SMMU_ADDR,
130 TYPE_PARAM_BACKINGSTORE_BASE_HW,
131 TYPE_PARAM_GOBS_PER_COMPTAGLINE_PER_SLICE,
132 TYPE_PARAM_SCATTERBUFFER,
133 TYPE_PARAM_SCATTERBUFFER_SIZE,
134 NUM_RESERVED_PARAMS = 1024,
135};
136
137/*
138 * This header element defines a command. The op field determines whether the
139 * element is defining an init (0) or convert command (1). data_byte_offset
140 * denotes the beginning address of command elements in the file.
141 */
142
143struct gk20a_cde_hdr_command {
144 u32 op;
145 u32 num_entries;
146 u64 data_byte_offset;
147};
148
149enum {
150 TYPE_BUF_COMMAND_INIT = 0,
151 TYPE_BUF_COMMAND_CONVERT
152};
153
154/*
155 * This is a command element defines one entry inside push buffer. target_buf
156 * defines the buffer including the pushbuffer entries, target_byte_offset the
157 * offset inside the buffer and num_bytes the number of words in the buffer.
158 */
159
160struct gk20a_cde_cmd_elem {
161 u32 target_buf;
162 u32 padding;
163 u64 target_byte_offset;
164 u64 num_bytes;
165};
166
167/*
168 * This element is used for storing a small array of data.
169 */
170
171enum {
172 ARRAY_PROGRAM_OFFSET = 0,
173 ARRAY_REGISTER_COUNT,
174 ARRAY_LAUNCH_COMMAND,
175 NUM_CDE_ARRAYS
176};
177
178struct gk20a_cde_hdr_array {
179 u32 id;
180 u32 data[MAX_CDE_ARRAY_ENTRIES];
181};
182
183/*
184 * Following defines a single header element. Each element has a type and
185 * some of the data structures.
186 */
187
188struct gk20a_cde_hdr_elem {
189 u32 type;
190 u32 padding;
191 union {
192 struct gk20a_cde_hdr_buf buf;
193 struct gk20a_cde_hdr_replace replace;
194 struct gk20a_cde_hdr_param param;
195 u32 required_class;
196 struct gk20a_cde_hdr_command command;
197 struct gk20a_cde_hdr_array array;
198 };
199};
200
201enum {
202 TYPE_BUF = 0,
203 TYPE_REPLACE,
204 TYPE_PARAM,
205 TYPE_REQUIRED_CLASS,
206 TYPE_COMMAND,
207 TYPE_ARRAY
208};
209
210struct gk20a_cde_param {
211 u32 id;
212 u32 padding;
213 u64 value;
214};
215
216struct gk20a_cde_ctx {
217 struct gk20a *g;
218 struct device *dev;
219
220 /* channel related data */
221 struct channel_gk20a *ch;
222 struct vm_gk20a *vm;
223
224 /* buf converter configuration */
225 struct nvgpu_mem mem[MAX_CDE_BUFS];
226 unsigned int num_bufs;
227
228 /* buffer patching params (where should patching be done) */
229 struct gk20a_cde_hdr_param params[MAX_CDE_PARAMS];
230 unsigned int num_params;
231
232 /* storage for user space parameter values */
233 u32 user_param_values[MAX_CDE_USER_PARAMS];
234
235 u32 surf_param_offset;
236 u32 surf_param_lines;
237 u64 surf_vaddr;
238
239 u64 compbit_vaddr;
240 u64 compbit_size;
241
242 u64 scatterbuffer_vaddr;
243 u64 scatterbuffer_size;
244
245 u64 backing_store_vaddr;
246
247 struct nvgpu_gpfifo *init_convert_cmd;
248 int init_cmd_num_entries;
249
250 struct nvgpu_gpfifo *convert_cmd;
251 int convert_cmd_num_entries;
252
253 struct kobj_attribute attr;
254
255 bool init_cmd_executed;
256
257 struct nvgpu_list_node list;
258 bool is_temporary;
259 bool in_use;
260 struct delayed_work ctx_deleter_work;
261};
262
263static inline struct gk20a_cde_ctx *
264gk20a_cde_ctx_from_list(struct nvgpu_list_node *node)
265{
266 return (struct gk20a_cde_ctx *)
267 ((uintptr_t)node - offsetof(struct gk20a_cde_ctx, list));
268};
269
270struct gk20a_cde_app {
271 bool initialised;
272 struct nvgpu_mutex mutex;
273
274 struct nvgpu_list_node free_contexts;
275 struct nvgpu_list_node used_contexts;
276 unsigned int ctx_count;
277 unsigned int ctx_usecount;
278 unsigned int ctx_count_top;
279
280 u32 firmware_version;
281
282 u32 arrays[NUM_CDE_ARRAYS][MAX_CDE_ARRAY_ENTRIES];
283
284 u32 shader_parameter;
285};
286
287void gk20a_cde_destroy(struct gk20a *g);
288void gk20a_cde_suspend(struct gk20a *g);
289int gk20a_init_cde_support(struct gk20a *g);
290int gk20a_cde_reload(struct gk20a *g);
291int gk20a_cde_convert(struct gk20a *g,
292 struct dma_buf *compbits_buf,
293 u64 compbits_byte_offset,
294 u64 scatterbuffer_byte_offset,
295 struct nvgpu_fence *fence,
296 u32 __flags, struct gk20a_cde_param *params,
297 int num_params, struct gk20a_fence **fence_out);
298
299int gk20a_prepare_compressible_read(
300 struct gk20a *g, u32 buffer_fd, u32 request, u64 offset,
301 u64 compbits_hoffset, u64 compbits_voffset,
302 u64 scatterbuffer_offset,
303 u32 width, u32 height, u32 block_height_log2,
304 u32 submit_flags, struct nvgpu_fence *fence,
305 u32 *valid_compbits, u32 *zbc_color,
306 struct gk20a_fence **fence_out);
307int gk20a_mark_compressible_write(
308 struct gk20a *g, u32 buffer_fd, u32 valid_compbits, u64 offset,
309 u32 zbc_color);
310
311#endif