summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ce2_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/ce2_gk20a.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h
new file mode 100644
index 00000000..1d9d8c72
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h
@@ -0,0 +1,159 @@
1/*
2 * drivers/video/tegra/host/gk20a/fifo_gk20a.h
3 *
4 * GK20A graphics copy engine (gr host)
5 *
6 * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26#ifndef __CE2_GK20A_H__
27#define __CE2_GK20A_H__
28
29#include "channel_gk20a.h"
30#include "tsg_gk20a.h"
31
32void gk20a_ce2_isr(struct gk20a *g, u32 inst_id, u32 pri_base);
33int gk20a_ce2_nonstall_isr(struct gk20a *g, u32 inst_id, u32 pri_base);
34
35/* CE command utility macros */
36#define NVGPU_CE_LOWER_ADDRESS_OFFSET_MASK 0xffffffff
37#define NVGPU_CE_UPPER_ADDRESS_OFFSET_MASK 0xff
38
39#define NVGPU_CE_COMMAND_BUF_SIZE 8192
40#define NVGPU_CE_MAX_COMMAND_BUFF_SIZE_PER_KICKOFF 256
41#define NVGPU_CE_MAX_COMMAND_BUFF_SIZE_FOR_TRACING 8
42
43/* dma launch_flags */
44enum {
45 /* location */
46 NVGPU_CE_SRC_LOCATION_COHERENT_SYSMEM = (1 << 0),
47 NVGPU_CE_SRC_LOCATION_NONCOHERENT_SYSMEM = (1 << 1),
48 NVGPU_CE_SRC_LOCATION_LOCAL_FB = (1 << 2),
49 NVGPU_CE_DST_LOCATION_COHERENT_SYSMEM = (1 << 3),
50 NVGPU_CE_DST_LOCATION_NONCOHERENT_SYSMEM = (1 << 4),
51 NVGPU_CE_DST_LOCATION_LOCAL_FB = (1 << 5),
52
53 /* memory layout */
54 NVGPU_CE_SRC_MEMORY_LAYOUT_PITCH = (1 << 6),
55 NVGPU_CE_SRC_MEMORY_LAYOUT_BLOCKLINEAR = (1 << 7),
56 NVGPU_CE_DST_MEMORY_LAYOUT_PITCH = (1 << 8),
57 NVGPU_CE_DST_MEMORY_LAYOUT_BLOCKLINEAR = (1 << 9),
58
59 /* transfer type */
60 NVGPU_CE_DATA_TRANSFER_TYPE_PIPELINED = (1 << 10),
61 NVGPU_CE_DATA_TRANSFER_TYPE_NON_PIPELINED = (1 << 11),
62};
63
64/* CE operation mode */
65enum {
66 NVGPU_CE_PHYS_MODE_TRANSFER = (1 << 0),
67 NVGPU_CE_MEMSET = (1 << 1),
68};
69
70/* CE app state machine flags */
71enum {
72 NVGPU_CE_ACTIVE = (1 << 0),
73 NVGPU_CE_SUSPEND = (1 << 1),
74};
75
76/* gpu context state machine flags */
77enum {
78 NVGPU_CE_GPU_CTX_ALLOCATED = (1 << 0),
79 NVGPU_CE_GPU_CTX_DELETED = (1 << 1),
80};
81
82/* global ce app db */
83struct gk20a_ce_app {
84 bool initialised;
85 struct nvgpu_mutex app_mutex;
86 int app_state;
87
88 struct nvgpu_list_node allocated_contexts;
89 u32 ctx_count;
90 u32 next_ctx_id;
91};
92
93/* ce context db */
94struct gk20a_gpu_ctx {
95 struct gk20a *g;
96 u32 ctx_id;
97 struct nvgpu_mutex gpu_ctx_mutex;
98 int gpu_ctx_state;
99
100 /* tsg related data */
101 struct tsg_gk20a *tsg;
102
103 /* channel related data */
104 struct channel_gk20a *ch;
105 struct vm_gk20a *vm;
106
107 /* cmd buf mem_desc */
108 struct nvgpu_mem cmd_buf_mem;
109
110 struct nvgpu_list_node list;
111
112 u32 cmd_buf_read_queue_offset;
113 u32 cmd_buf_end_queue_offset;
114};
115
116static inline struct gk20a_gpu_ctx *
117gk20a_gpu_ctx_from_list(struct nvgpu_list_node *node)
118{
119 return (struct gk20a_gpu_ctx *)
120 ((uintptr_t)node - offsetof(struct gk20a_gpu_ctx, list));
121};
122
123/* global CE app related apis */
124int gk20a_init_ce_support(struct gk20a *g);
125void gk20a_ce_suspend(struct gk20a *g);
126void gk20a_ce_destroy(struct gk20a *g);
127
128/* CE app utility functions */
129u32 gk20a_ce_create_context(struct gk20a *g,
130 int runlist_id,
131 int timeslice,
132 int runlist_level);
133int gk20a_ce_execute_ops(struct gk20a *g,
134 u32 ce_ctx_id,
135 u64 src_buf,
136 u64 dst_buf,
137 u64 size,
138 unsigned int payload,
139 int launch_flags,
140 int request_operation,
141 struct gk20a_fence *gk20a_fence_in,
142 u32 submit_flags,
143 struct gk20a_fence **gk20a_fence_out);
144void gk20a_ce_delete_context_priv(struct gk20a *g,
145 u32 ce_ctx_id);
146void gk20a_ce_delete_context(struct gk20a *g,
147 u32 ce_ctx_id);
148int gk20a_ce_prepare_submit(u64 src_buf,
149 u64 dst_buf,
150 u64 size,
151 u32 *cmd_buf_cpu_va,
152 u32 max_cmd_buf_size,
153 unsigned int payload,
154 int launch_flags,
155 int request_operation,
156 u32 dma_copy_class,
157 struct gk20a_fence *gk20a_fence_in);
158
159#endif /*__CE2_GK20A_H__*/