xref: /linux/drivers/gpu/drm/lima/lima_gem.h (revision dd9a41bc61cc62d38306465ed62373b98df0049e)
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
3 
4 #ifndef __LIMA_GEM_H__
5 #define __LIMA_GEM_H__
6 
7 #include <drm/drm_gem_shmem_helper.h>
8 
9 struct lima_submit;
10 struct lima_vm;
11 
12 struct lima_bo {
13 	struct drm_gem_shmem_object base;
14 
15 	struct mutex lock;
16 	struct list_head va;
17 
18 	size_t heap_size;
19 };
20 
21 static inline struct lima_bo *
22 to_lima_bo(struct drm_gem_object *obj)
23 {
24 	return container_of(to_drm_gem_shmem_obj(obj), struct lima_bo, base);
25 }
26 
27 static inline size_t lima_bo_size(struct lima_bo *bo)
28 {
29 	return bo->base.base.size;
30 }
31 
32 static inline struct dma_resv *lima_bo_resv(struct lima_bo *bo)
33 {
34 	return bo->base.base.resv;
35 }
36 
37 int lima_heap_alloc(struct lima_bo *bo, struct lima_vm *vm);
38 struct drm_gem_object *lima_gem_create_object(struct drm_device *dev, size_t size);
39 int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file,
40 			   u32 size, u32 flags, u32 *handle);
41 int lima_gem_get_info(struct drm_file *file, u32 handle, u32 *va, u64 *offset);
42 int lima_gem_submit(struct drm_file *file, struct lima_submit *submit);
43 int lima_gem_wait(struct drm_file *file, u32 handle, u32 op, s64 timeout_ns);
44 
45 void lima_set_vma_flags(struct vm_area_struct *vma);
46 
47 #endif
48