1 /* Public domain. */
2
3 #include <sys/types.h>
4 #include <sys/param.h>
5 #include <uvm/uvm_extern.h>
6
7 #include <linux/kernel.h>
8 #include <linux/iosys-map.h>
9 #include <drm/drm_gem.h>
10 #include <drm/ttm/ttm_bo.h>
11
12 int
drm_gem_ttm_mmap(struct drm_gem_object * obj,vm_prot_t accessprot,voff_t off,vsize_t size)13 drm_gem_ttm_mmap(struct drm_gem_object *obj,
14 vm_prot_t accessprot, voff_t off, vsize_t size)
15 {
16 struct ttm_buffer_object *tbo =
17 container_of(obj, struct ttm_buffer_object, base);
18 int r = ttm_bo_mmap_obj(tbo);
19 if (r >= 0)
20 drm_gem_object_put(obj);
21 return r;
22 }
23
24 int
drm_gem_ttm_vmap(struct drm_gem_object * obj,struct iosys_map * ism)25 drm_gem_ttm_vmap(struct drm_gem_object *obj, struct iosys_map *ism)
26 {
27 struct ttm_buffer_object *tbo =
28 container_of(obj, struct ttm_buffer_object, base);
29
30 return ttm_bo_vmap(tbo, ism);
31 }
32
33 void
drm_gem_ttm_vunmap(struct drm_gem_object * obj,struct iosys_map * ism)34 drm_gem_ttm_vunmap(struct drm_gem_object *obj, struct iosys_map *ism)
35 {
36 struct ttm_buffer_object *tbo =
37 container_of(obj, struct ttm_buffer_object, base);
38
39 ttm_bo_vunmap(tbo, ism);
40 }
41