Rev 4065 | Rev 5056 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4065 | Rev 4568 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | 39 | ||
40 | #include |
40 | #include |
41 | #include |
41 | #include |
42 | #include |
42 | #include |
- | 43 | //#include |
|
43 | //#include |
44 | #include |
Line 44... | Line 45... | ||
44 | #include |
45 | #include |
45 | 46 | ||
46 | /** |
47 | /** |
Line 75... | Line 76... | ||
75 | 76 | ||
76 | enum ttm_object_type { |
77 | enum ttm_object_type { |
77 | ttm_fence_type, |
78 | ttm_fence_type, |
78 | ttm_buffer_type, |
79 | ttm_buffer_type, |
- | 80 | ttm_lock_type, |
|
79 | ttm_lock_type, |
81 | ttm_prime_type, |
80 | ttm_driver_type0 = 256, |
82 | ttm_driver_type0 = 256, |
81 | ttm_driver_type1, |
83 | ttm_driver_type1, |
82 | ttm_driver_type2, |
84 | ttm_driver_type2, |
83 | ttm_driver_type3, |
85 | ttm_driver_type3, |
Line 130... | Line 132... | ||
130 | void (*refcount_release) (struct ttm_base_object **base); |
132 | void (*refcount_release) (struct ttm_base_object **base); |
131 | void (*ref_obj_release) (struct ttm_base_object *base, |
133 | void (*ref_obj_release) (struct ttm_base_object *base, |
132 | enum ttm_ref_type ref_type); |
134 | enum ttm_ref_type ref_type); |
133 | }; |
135 | }; |
Line -... | Line 136... | ||
- | 136 | ||
- | 137 | ||
- | 138 | /** |
|
- | 139 | * struct ttm_prime_object - Modified base object that is prime-aware |
|
- | 140 | * |
|
- | 141 | * @base: struct ttm_base_object that we derive from |
|
- | 142 | * @mutex: Mutex protecting the @dma_buf member. |
|
- | 143 | * @size: Size of the dma_buf associated with this object |
|
- | 144 | * @real_type: Type of the underlying object. Needed since we're setting |
|
- | 145 | * the value of @base::object_type to ttm_prime_type |
|
- | 146 | * @dma_buf: Non ref-coutned pointer to a struct dma_buf created from this |
|
- | 147 | * object. |
|
- | 148 | * @refcount_release: The underlying object's release method. Needed since |
|
- | 149 | * we set @base::refcount_release to our own release method. |
|
- | 150 | */ |
|
- | 151 | ||
- | 152 | struct ttm_prime_object { |
|
- | 153 | struct ttm_base_object base; |
|
- | 154 | struct mutex mutex; |
|
- | 155 | size_t size; |
|
- | 156 | enum ttm_object_type real_type; |
|
- | 157 | struct dma_buf *dma_buf; |
|
- | 158 | void (*refcount_release) (struct ttm_base_object **); |
|
- | 159 | }; |
|
134 | 160 | ||
135 | /** |
161 | /** |
136 | * ttm_base_object_init |
162 | * ttm_base_object_init |
137 | * |
163 | * |
138 | * @tfile: Pointer to a struct ttm_object_file. |
164 | * @tfile: Pointer to a struct ttm_object_file. |
Line 162... | Line 188... | ||
162 | * |
188 | * |
163 | * @tfile: Pointer to a struct ttm_object_file. |
189 | * @tfile: Pointer to a struct ttm_object_file. |
164 | * @key: Hash key |
190 | * @key: Hash key |
165 | * |
191 | * |
166 | * Looks up a struct ttm_base_object with the key @key. |
192 | * Looks up a struct ttm_base_object with the key @key. |
167 | * Also verifies that the object is visible to the application, by |
- | |
168 | * comparing the @tfile argument and checking the object shareable flag. |
- | |
169 | */ |
193 | */ |
Line 170... | Line 194... | ||
170 | 194 | ||
171 | extern struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file |
195 | extern struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file |
Line 172... | Line 196... | ||
172 | *tfile, uint32_t key); |
196 | *tfile, uint32_t key); |
- | 197 | ||
- | 198 | /** |
|
- | 199 | * ttm_base_object_lookup_for_ref |
|
- | 200 | * |
|
- | 201 | * @tdev: Pointer to a struct ttm_object_device. |
|
- | 202 | * @key: Hash key |
|
- | 203 | * |
|
- | 204 | * Looks up a struct ttm_base_object with the key @key. |
|
- | 205 | * This function should only be used when the struct tfile associated with the |
|
- | 206 | * caller doesn't yet have a reference to the base object. |
|
- | 207 | */ |
|
- | 208 | ||
- | 209 | extern struct ttm_base_object * |
|
- | 210 | ttm_base_object_lookup_for_ref(struct ttm_object_device *tdev, uint32_t key); |
|
173 | 211 | ||
174 | /** |
212 | /** |
175 | * ttm_base_object_unref |
213 | * ttm_base_object_unref |
176 | * |
214 | * |
177 | * @p_base: Pointer to a pointer referencing a struct ttm_base_object. |
215 | * @p_base: Pointer to a pointer referencing a struct ttm_base_object. |
Line 190... | Line 228... | ||
190 | * @base: The base object to reference. |
228 | * @base: The base object to reference. |
191 | * @ref_type: The type of reference. |
229 | * @ref_type: The type of reference. |
192 | * @existed: Upon completion, indicates that an identical reference object |
230 | * @existed: Upon completion, indicates that an identical reference object |
193 | * already existed, and the refcount was upped on that object instead. |
231 | * already existed, and the refcount was upped on that object instead. |
194 | * |
232 | * |
- | 233 | * Checks that the base object is shareable and adds a ref object to it. |
|
- | 234 | * |
|
195 | * Adding a ref object to a base object is basically like referencing the |
235 | * Adding a ref object to a base object is basically like referencing the |
196 | * base object, but a user-space application holds the reference. When the |
236 | * base object, but a user-space application holds the reference. When the |
197 | * file corresponding to @tfile is closed, all its reference objects are |
237 | * file corresponding to @tfile is closed, all its reference objects are |
198 | * deleted. A reference object can have different types depending on what |
238 | * deleted. A reference object can have different types depending on what |
199 | * it's intended for. It can be refcounting to prevent object destruction, |
239 | * it's intended for. It can be refcounting to prevent object destruction, |
Line 246... | Line 286... | ||
246 | extern void ttm_object_file_release(struct ttm_object_file **p_tfile); |
286 | extern void ttm_object_file_release(struct ttm_object_file **p_tfile); |
Line 247... | Line 287... | ||
247 | 287 | ||
248 | /** |
288 | /** |
249 | * ttm_object device init - initialize a struct ttm_object_device |
289 | * ttm_object device init - initialize a struct ttm_object_device |
- | 290 | * |
|
250 | * |
291 | * @mem_glob: struct ttm_mem_global for memory accounting. |
- | 292 | * @hash_order: Order of hash table used to hash the base objects. |
|
251 | * @hash_order: Order of hash table used to hash the base objects. |
293 | * @ops: DMA buf ops for prime objects of this device. |
252 | * |
294 | * |
253 | * This function is typically called on device initialization to prepare |
295 | * This function is typically called on device initialization to prepare |
254 | * data structures needed for ttm base and ref objects. |
296 | * data structures needed for ttm base and ref objects. |
Line 255... | Line 297... | ||
255 | */ |
297 | */ |
- | 298 | ||
256 | 299 | extern struct ttm_object_device * |
|
- | 300 | ttm_object_device_init(struct ttm_mem_global *mem_glob, |
|
Line 257... | Line 301... | ||
257 | extern struct ttm_object_device *ttm_object_device_init |
301 | unsigned int hash_order, |
258 | (struct ttm_mem_global *mem_glob, unsigned int hash_order); |
302 | const struct dma_buf_ops *ops); |
259 | 303 | ||
260 | /** |
304 | /** |
Line 270... | Line 314... | ||
270 | 314 | ||
Line 271... | Line 315... | ||
271 | extern void ttm_object_device_release(struct ttm_object_device **p_tdev); |
315 | extern void ttm_object_device_release(struct ttm_object_device **p_tdev); |
272 | 316 | ||
- | 317 | #define ttm_base_object_kfree(__object, __base)\ |
|
- | 318 | kfree_rcu(__object, __base.rhead) |
|
- | 319 | ||
- | 320 | extern int ttm_prime_object_init(struct ttm_object_file *tfile, |
|
- | 321 | size_t size, |
|
- | 322 | struct ttm_prime_object *prime, |
|
- | 323 | bool shareable, |
|
- | 324 | enum ttm_object_type type, |
|
- | 325 | void (*refcount_release) |
|
- | 326 | (struct ttm_base_object **), |
|
- | 327 | void (*ref_obj_release) |
|
- | 328 | (struct ttm_base_object *, |
|
- | 329 | enum ttm_ref_type ref_type)); |
|
- | 330 | ||
- | 331 | static inline enum ttm_object_type |
|
- | 332 | ttm_base_object_type(struct ttm_base_object *base) |
|
- | 333 | { |
|
- | 334 | return (base->object_type == ttm_prime_type) ? |
|
- | 335 | container_of(base, struct ttm_prime_object, base)->real_type : |
|
- | 336 | base->object_type; |
|
- | 337 | } |
|
- | 338 | extern int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, |
|
- | 339 | int fd, u32 *handle); |
|
- | 340 | extern int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, |
|
- | 341 | uint32_t handle, uint32_t flags, |
|
- | 342 | int *prime_fd); |
|
- | 343 | ||
273 | #define ttm_base_object_kfree(__object, __base)\ |
344 | //#define ttm_prime_object_kfree(__obj, __prime) \ |