Rev 1963 | Rev 5078 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1963 | Rev 2997 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #define __RADEON_OBJECT_H__ |
29 | #define __RADEON_OBJECT_H__ |
Line 30... | Line 30... | ||
30 | 30 | ||
31 | #include |
31 | #include |
Line -... | Line 32... | ||
- | 32 | #include "radeon.h" |
|
- | 33 | ||
32 | #include "radeon.h" |
34 | struct sg_table; |
33 | 35 | ||
34 | /** |
36 | /** |
35 | * radeon_mem_type_to_domain - return domain corresponding to mem_type |
37 | * radeon_mem_type_to_domain - return domain corresponding to mem_type |
36 | * @mem_type: ttm memory type |
38 | * @mem_type: ttm memory type |
Line 50... | Line 52... | ||
50 | break; |
52 | break; |
51 | } |
53 | } |
52 | return 0; |
54 | return 0; |
53 | } |
55 | } |
Line 54... | Line -... | ||
54 | - | ||
55 | /** |
56 | |
56 | * radeon_bo_reserve - reserve bo |
- | |
57 | * @bo: bo structure |
- | |
58 | * @no_wait: don't sleep while trying to reserve (return -EBUSY) |
- | |
59 | * |
- | |
60 | * Returns: |
- | |
61 | * -EBUSY: buffer is busy and @no_wait is true |
- | |
62 | * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by |
- | |
63 | * a signal. Release all buffer reservations and return to user-space. |
- | |
Line 64... | Line 57... | ||
64 | */ |
57 | int radeon_bo_reserve(struct radeon_bo *bo, bool no_intr); |
65 | 58 | ||
66 | static inline void radeon_bo_unreserve(struct radeon_bo *bo) |
59 | static inline void radeon_bo_unreserve(struct radeon_bo *bo) |
67 | { |
60 | { |
Line 90... | Line 83... | ||
90 | static inline bool radeon_bo_is_reserved(struct radeon_bo *bo) |
83 | static inline bool radeon_bo_is_reserved(struct radeon_bo *bo) |
91 | { |
84 | { |
92 | return !!atomic_read(&bo->tbo.reserved); |
85 | return !!atomic_read(&bo->tbo.reserved); |
93 | } |
86 | } |
Line -... | Line 87... | ||
- | 87 | ||
- | 88 | static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo) |
|
- | 89 | { |
|
- | 90 | return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE; |
|
- | 91 | } |
|
- | 92 | ||
- | 93 | static inline unsigned radeon_bo_gpu_page_alignment(struct radeon_bo *bo) |
|
- | 94 | { |
|
- | 95 | return (bo->tbo.mem.page_alignment << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE; |
|
- | 96 | } |
|
94 | 97 | ||
95 | /** |
98 | /** |
96 | * radeon_bo_mmap_offset - return mmap offset of bo |
99 | * radeon_bo_mmap_offset - return mmap offset of bo |
97 | * @bo: radeon object for which we query the offset |
100 | * @bo: radeon object for which we query the offset |
98 | * |
101 | * |
Line 104... | Line 107... | ||
104 | static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo) |
107 | static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo) |
105 | { |
108 | { |
106 | return bo->tbo.addr_space_offset; |
109 | return bo->tbo.addr_space_offset; |
107 | } |
110 | } |
Line 108... | Line 111... | ||
108 | 111 | ||
109 | static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, |
112 | extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, |
110 | bool no_wait) |
- | |
111 | { |
- | |
112 | int r; |
- | |
113 | - | ||
114 | r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0); |
- | |
115 | if (unlikely(r != 0)) |
- | |
116 | return r; |
- | |
117 | // spin_lock(&bo->tbo.bdev->fence_lock); |
- | |
118 | if (mem_type) |
- | |
119 | *mem_type = bo->tbo.mem.mem_type; |
- | |
120 | if (bo->tbo.sync_obj) |
- | |
121 | r = ttm_bo_wait(&bo->tbo, true, true, no_wait); |
- | |
122 | // spin_unlock(&bo->tbo.bdev->fence_lock); |
- | |
123 | ttm_bo_unreserve(&bo->tbo); |
- | |
124 | return r; |
- | |
Line 125... | Line 113... | ||
125 | } |
113 | bool no_wait); |
126 | 114 | ||
127 | extern int radeon_bo_create(struct radeon_device *rdev, |
115 | extern int radeon_bo_create(struct radeon_device *rdev, |
- | 116 | unsigned long size, int byte_align, |
|
128 | unsigned long size, int byte_align, |
117 | bool kernel, u32 domain, |
129 | bool kernel, u32 domain, |
118 | struct sg_table *sg, |
130 | struct radeon_bo **bo_ptr); |
119 | struct radeon_bo **bo_ptr); |
131 | extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); |
120 | extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); |
132 | extern void radeon_bo_kunmap(struct radeon_bo *bo); |
121 | extern void radeon_bo_kunmap(struct radeon_bo *bo); |
- | 122 | extern void radeon_bo_unref(struct radeon_bo **bo); |
|
- | 123 | extern int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr); |
|
133 | extern void radeon_bo_unref(struct radeon_bo **bo); |
124 | extern int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, |
134 | extern int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr); |
125 | u64 max_offset, u64 *gpu_addr); |
135 | extern int radeon_bo_unpin(struct radeon_bo *bo); |
126 | extern int radeon_bo_unpin(struct radeon_bo *bo); |
136 | extern int radeon_bo_evict_vram(struct radeon_device *rdev); |
127 | extern int radeon_bo_evict_vram(struct radeon_device *rdev); |
137 | extern void radeon_bo_force_delete(struct radeon_device *rdev); |
128 | extern void radeon_bo_force_delete(struct radeon_device *rdev); |
Line 150... | Line 141... | ||
150 | bool force_drop); |
141 | bool force_drop); |
151 | extern void radeon_bo_move_notify(struct ttm_buffer_object *bo, |
142 | extern void radeon_bo_move_notify(struct ttm_buffer_object *bo, |
152 | struct ttm_mem_reg *mem); |
143 | struct ttm_mem_reg *mem); |
153 | extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo); |
144 | extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo); |
154 | extern int radeon_bo_get_surface_reg(struct radeon_bo *bo); |
145 | extern int radeon_bo_get_surface_reg(struct radeon_bo *bo); |
- | 146 | ||
- | 147 | /* |
|
- | 148 | * sub allocation |
|
- | 149 | */ |
|
- | 150 | ||
- | 151 | static 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 | ||
- | 156 | static 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 | ||
- | 161 | extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, |
|
- | 162 | struct radeon_sa_manager *sa_manager, |
|
- | 163 | unsigned size, u32 domain); |
|
- | 164 | extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev, |
|
- | 165 | struct radeon_sa_manager *sa_manager); |
|
- | 166 | extern int radeon_sa_bo_manager_start(struct radeon_device *rdev, |
|
- | 167 | struct radeon_sa_manager *sa_manager); |
|
- | 168 | extern int radeon_sa_bo_manager_suspend(struct radeon_device *rdev, |
|
- | 169 | struct radeon_sa_manager *sa_manager); |
|
- | 170 | extern 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); |
|
- | 174 | extern 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) |
|
- | 178 | extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager, |
|
- | 179 | struct seq_file *m); |
|
- | 180 | #endif |
|
- | 181 | ||
- | 182 | ||
155 | #endif><> |
183 | #endif><>><>><> |