1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef __RADEON_OBJECT_H__
29#define __RADEON_OBJECT_H__
30
31#include <drm/radeon_drm.h>
32#include "radeon.h"
33
34
35
36
37
38
39
40static inline unsigned radeon_mem_type_to_domain(u32 mem_type)
41{
42 switch (mem_type) {
43 case TTM_PL_VRAM:
44 return RADEON_GEM_DOMAIN_VRAM;
45 case TTM_PL_TT:
46 return RADEON_GEM_DOMAIN_GTT;
47 case TTM_PL_SYSTEM:
48 return RADEON_GEM_DOMAIN_CPU;
49 default:
50 break;
51 }
52 return 0;
53}
54
55int radeon_bo_reserve(struct radeon_bo *bo, bool no_wait);
56
57static inline void radeon_bo_unreserve(struct radeon_bo *bo)
58{
59 ttm_bo_unreserve(&bo->tbo);
60}
61
62
63
64
65
66
67
68
69
70
71static inline u64 radeon_bo_gpu_offset(struct radeon_bo *bo)
72{
73 return bo->tbo.offset;
74}
75
76static inline unsigned long radeon_bo_size(struct radeon_bo *bo)
77{
78 return bo->tbo.num_pages << PAGE_SHIFT;
79}
80
81static inline bool radeon_bo_is_reserved(struct radeon_bo *bo)
82{
83 return !!atomic_read(&bo->tbo.reserved);
84}
85
86static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo)
87{
88 return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE;
89}
90
91static inline unsigned radeon_bo_gpu_page_alignment(struct radeon_bo *bo)
92{
93 return (bo->tbo.mem.page_alignment << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE;
94}
95
96
97
98
99
100
101
102
103
104
105static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo)
106{
107 return bo->tbo.addr_space_offset;
108}
109
110extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
111 bool no_wait);
112
113extern int radeon_bo_create(struct radeon_device *rdev,
114 unsigned long size, int byte_align,
115 bool kernel, u32 domain,
116 struct sg_table *sg,
117 struct radeon_bo **bo_ptr);
118extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
119extern void radeon_bo_kunmap(struct radeon_bo *bo);
120extern void radeon_bo_unref(struct radeon_bo **bo);
121extern int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr);
122extern int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain,
123 u64 max_offset, u64 *gpu_addr);
124extern int radeon_bo_unpin(struct radeon_bo *bo);
125extern int radeon_bo_evict_vram(struct radeon_device *rdev);
126extern void radeon_bo_force_delete(struct radeon_device *rdev);
127extern int radeon_bo_init(struct radeon_device *rdev);
128extern void radeon_bo_fini(struct radeon_device *rdev);
129extern void radeon_bo_list_add_object(struct radeon_bo_list *lobj,
130 struct list_head *head);
131extern int radeon_bo_list_validate(struct list_head *head);
132extern int radeon_bo_fbdev_mmap(struct radeon_bo *bo,
133 struct vm_area_struct *vma);
134extern int radeon_bo_set_tiling_flags(struct radeon_bo *bo,
135 u32 tiling_flags, u32 pitch);
136extern void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
137 u32 *tiling_flags, u32 *pitch);
138extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
139 bool force_drop);
140extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
141 struct ttm_mem_reg *mem);
142extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
143extern int radeon_bo_get_surface_reg(struct radeon_bo *bo);
144extern struct radeon_bo_va *radeon_bo_va(struct radeon_bo *rbo,
145 struct radeon_vm *vm);
146
147
148
149
150
151static inline uint64_t radeon_sa_bo_gpu_addr(struct radeon_sa_bo *sa_bo)
152{
153 return sa_bo->manager->gpu_addr + sa_bo->soffset;
154}
155
156static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo)
157{
158 return sa_bo->manager->cpu_ptr + sa_bo->soffset;
159}
160
161extern int radeon_sa_bo_manager_init(struct radeon_device *rdev,
162 struct radeon_sa_manager *sa_manager,
163 unsigned size, u32 domain);
164extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev,
165 struct radeon_sa_manager *sa_manager);
166extern int radeon_sa_bo_manager_start(struct radeon_device *rdev,
167 struct radeon_sa_manager *sa_manager);
168extern int radeon_sa_bo_manager_suspend(struct radeon_device *rdev,
169 struct radeon_sa_manager *sa_manager);
170extern int radeon_sa_bo_new(struct radeon_device *rdev,
171 struct radeon_sa_manager *sa_manager,
172 struct radeon_sa_bo **sa_bo,
173 unsigned size, unsigned align, bool block);
174extern void radeon_sa_bo_free(struct radeon_device *rdev,
175 struct radeon_sa_bo **sa_bo,
176 struct radeon_fence *fence);
177#if defined(CONFIG_DEBUG_FS)
178extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager,
179 struct seq_file *m);
180#endif
181
182
183#endif
184