1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
3 
4 #ifndef __LIMA_OBJECT_H__
5 #define __LIMA_OBJECT_H__
6 
7 #include <drm/drm_gem.h>
8 
9 #include "lima_device.h"
10 
11 struct lima_bo {
12 	struct drm_gem_object gem;
13 
14 	struct page **pages;
15 	dma_addr_t *pages_dma_addr;
16 	struct sg_table *sgt;
17 	void *vaddr;
18 
19 	struct mutex lock;
20 	struct list_head va;
21 };
22 
23 static inline struct lima_bo *
to_lima_bo(struct drm_gem_object * obj)24 to_lima_bo(struct drm_gem_object *obj)
25 {
26 	return container_of(obj, struct lima_bo, gem);
27 }
28 
29 struct lima_bo *lima_bo_create(struct lima_device *dev, u32 size,
30 			       u32 flags, struct sg_table *sgt);
31 void lima_bo_destroy(struct lima_bo *bo);
32 void *lima_bo_vmap(struct lima_bo *bo);
33 void lima_bo_vunmap(struct lima_bo *bo);
34 
35 #endif
36