Commit | Line | Data |
---|---|---|
6579324a TB |
1 | /* |
2 | * Tegra host1x Job | |
3 | * | |
4 | * Copyright (c) 2011-2013, NVIDIA Corporation. | |
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 __HOST1X_JOB_H | |
20 | #define __HOST1X_JOB_H | |
21 | ||
22 | struct host1x_job_gather { | |
23 | u32 words; | |
24 | dma_addr_t base; | |
25 | struct host1x_bo *bo; | |
26 | int offset; | |
27 | bool handled; | |
28 | }; | |
29 | ||
30 | struct host1x_cmdbuf { | |
31 | u32 handle; | |
32 | u32 offset; | |
33 | u32 words; | |
34 | u32 pad; | |
35 | }; | |
36 | ||
37 | struct host1x_reloc { | |
38 | struct host1x_bo *cmdbuf; | |
39 | u32 cmdbuf_offset; | |
40 | struct host1x_bo *target; | |
41 | u32 target_offset; | |
42 | u32 shift; | |
43 | u32 pad; | |
44 | }; | |
45 | ||
46 | struct host1x_waitchk { | |
47 | struct host1x_bo *bo; | |
48 | u32 offset; | |
49 | u32 syncpt_id; | |
50 | u32 thresh; | |
51 | }; | |
52 | ||
53 | struct host1x_job_unpin_data { | |
54 | struct host1x_bo *bo; | |
55 | struct sg_table *sgt; | |
56 | }; | |
57 | ||
58 | /* | |
59 | * Each submit is tracked as a host1x_job. | |
60 | */ | |
61 | struct host1x_job { | |
62 | /* When refcount goes to zero, job can be freed */ | |
63 | struct kref ref; | |
64 | ||
65 | /* List entry */ | |
66 | struct list_head list; | |
67 | ||
68 | /* Channel where job is submitted to */ | |
69 | struct host1x_channel *channel; | |
70 | ||
71 | u32 client; | |
72 | ||
73 | /* Gathers and their memory */ | |
74 | struct host1x_job_gather *gathers; | |
75 | unsigned int num_gathers; | |
76 | ||
77 | /* Wait checks to be processed at submit time */ | |
78 | struct host1x_waitchk *waitchk; | |
79 | unsigned int num_waitchk; | |
80 | u32 waitchk_mask; | |
81 | ||
82 | /* Array of handles to be pinned & unpinned */ | |
83 | struct host1x_reloc *relocarray; | |
84 | unsigned int num_relocs; | |
85 | struct host1x_job_unpin_data *unpins; | |
86 | unsigned int num_unpins; | |
87 | ||
88 | dma_addr_t *addr_phys; | |
89 | dma_addr_t *gather_addr_phys; | |
90 | dma_addr_t *reloc_addr_phys; | |
91 | ||
92 | /* Sync point id, number of increments and end related to the submit */ | |
93 | u32 syncpt_id; | |
94 | u32 syncpt_incrs; | |
95 | u32 syncpt_end; | |
96 | ||
97 | /* Maximum time to wait for this job */ | |
98 | unsigned int timeout; | |
99 | ||
100 | /* Index and number of slots used in the push buffer */ | |
101 | unsigned int first_get; | |
102 | unsigned int num_slots; | |
103 | ||
104 | /* Copy of gathers */ | |
105 | size_t gather_copy_size; | |
106 | dma_addr_t gather_copy; | |
107 | u8 *gather_copy_mapped; | |
108 | ||
109 | /* Check if register is marked as an address reg */ | |
110 | int (*is_addr_reg)(struct device *dev, u32 reg, u32 class); | |
111 | ||
112 | /* Request a SETCLASS to this class */ | |
113 | u32 class; | |
114 | ||
115 | /* Add a channel wait for previous ops to complete */ | |
116 | bool serialize; | |
117 | }; | |
118 | /* | |
119 | * Allocate memory for a job. Just enough memory will be allocated to | |
120 | * accomodate the submit. | |
121 | */ | |
122 | struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, | |
123 | u32 num_cmdbufs, u32 num_relocs, | |
124 | u32 num_waitchks); | |
125 | ||
126 | /* | |
127 | * Add a gather to a job. | |
128 | */ | |
129 | void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id, | |
130 | u32 words, u32 offset); | |
131 | ||
132 | /* | |
133 | * Increment reference going to host1x_job. | |
134 | */ | |
135 | struct host1x_job *host1x_job_get(struct host1x_job *job); | |
136 | ||
137 | /* | |
138 | * Decrement reference job, free if goes to zero. | |
139 | */ | |
140 | void host1x_job_put(struct host1x_job *job); | |
141 | ||
142 | /* | |
143 | * Pin memory related to job. This handles relocation of addresses to the | |
144 | * host1x address space. Handles both the gather memory and any other memory | |
145 | * referred to from the gather buffers. | |
146 | * | |
147 | * Handles also patching out host waits that would wait for an expired sync | |
148 | * point value. | |
149 | */ | |
150 | int host1x_job_pin(struct host1x_job *job, struct device *dev); | |
151 | ||
152 | /* | |
153 | * Unpin memory related to job. | |
154 | */ | |
155 | void host1x_job_unpin(struct host1x_job *job); | |
156 | ||
157 | /* | |
158 | * Dump contents of job to debug output. | |
159 | */ | |
160 | void host1x_job_dump(struct device *dev, struct host1x_job *job); | |
161 | ||
162 | #endif |