xref: /dragonfly/sys/dev/drm/amd/amdgpu/amdgpu_object.h (revision b843c749)
1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2008 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev  * Copyright 2008 Red Hat Inc.
4*b843c749SSergey Zigachev  * Copyright 2009 Jerome Glisse.
5*b843c749SSergey Zigachev  *
6*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
7*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
8*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
9*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
11*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
12*b843c749SSergey Zigachev  *
13*b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
14*b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
15*b843c749SSergey Zigachev  *
16*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19*b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
23*b843c749SSergey Zigachev  *
24*b843c749SSergey Zigachev  * Authors: Dave Airlie
25*b843c749SSergey Zigachev  *          Alex Deucher
26*b843c749SSergey Zigachev  *          Jerome Glisse
27*b843c749SSergey Zigachev  */
28*b843c749SSergey Zigachev #ifndef __AMDGPU_OBJECT_H__
29*b843c749SSergey Zigachev #define __AMDGPU_OBJECT_H__
30*b843c749SSergey Zigachev 
31*b843c749SSergey Zigachev #include <drm/amdgpu_drm.h>
32*b843c749SSergey Zigachev #include "amdgpu.h"
33*b843c749SSergey Zigachev 
34*b843c749SSergey Zigachev #define AMDGPU_BO_INVALID_OFFSET	LONG_MAX
35*b843c749SSergey Zigachev #define AMDGPU_BO_MAX_PLACEMENTS	3
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev struct amdgpu_bo_param {
38*b843c749SSergey Zigachev 	unsigned long			size;
39*b843c749SSergey Zigachev 	int				byte_align;
40*b843c749SSergey Zigachev 	u32				domain;
41*b843c749SSergey Zigachev 	u32				preferred_domain;
42*b843c749SSergey Zigachev 	u64				flags;
43*b843c749SSergey Zigachev 	enum ttm_bo_type		type;
44*b843c749SSergey Zigachev 	struct reservation_object	*resv;
45*b843c749SSergey Zigachev };
46*b843c749SSergey Zigachev 
47*b843c749SSergey Zigachev /* bo virtual addresses in a vm */
48*b843c749SSergey Zigachev struct amdgpu_bo_va_mapping {
49*b843c749SSergey Zigachev 	struct amdgpu_bo_va		*bo_va;
50*b843c749SSergey Zigachev 	struct list_head		list;
51*b843c749SSergey Zigachev 	struct rb_node			rb;
52*b843c749SSergey Zigachev 	uint64_t			start;
53*b843c749SSergey Zigachev 	uint64_t			last;
54*b843c749SSergey Zigachev 	uint64_t			__subtree_last;
55*b843c749SSergey Zigachev 	uint64_t			offset;
56*b843c749SSergey Zigachev 	uint64_t			flags;
57*b843c749SSergey Zigachev };
58*b843c749SSergey Zigachev 
59*b843c749SSergey Zigachev /* User space allocated BO in a VM */
60*b843c749SSergey Zigachev struct amdgpu_bo_va {
61*b843c749SSergey Zigachev 	struct amdgpu_vm_bo_base	base;
62*b843c749SSergey Zigachev 
63*b843c749SSergey Zigachev 	/* protected by bo being reserved */
64*b843c749SSergey Zigachev 	unsigned			ref_count;
65*b843c749SSergey Zigachev 
66*b843c749SSergey Zigachev 	/* all other members protected by the VM PD being reserved */
67*b843c749SSergey Zigachev 	struct dma_fence	        *last_pt_update;
68*b843c749SSergey Zigachev 
69*b843c749SSergey Zigachev 	/* mappings for this bo_va */
70*b843c749SSergey Zigachev 	struct list_head		invalids;
71*b843c749SSergey Zigachev 	struct list_head		valids;
72*b843c749SSergey Zigachev 
73*b843c749SSergey Zigachev 	/* If the mappings are cleared or filled */
74*b843c749SSergey Zigachev 	bool				cleared;
75*b843c749SSergey Zigachev };
76*b843c749SSergey Zigachev 
77*b843c749SSergey Zigachev struct amdgpu_bo {
78*b843c749SSergey Zigachev 	/* Protected by tbo.reserved */
79*b843c749SSergey Zigachev 	u32				preferred_domains;
80*b843c749SSergey Zigachev 	u32				allowed_domains;
81*b843c749SSergey Zigachev 	struct ttm_place		placements[AMDGPU_BO_MAX_PLACEMENTS];
82*b843c749SSergey Zigachev 	struct ttm_placement		placement;
83*b843c749SSergey Zigachev 	struct ttm_buffer_object	tbo;
84*b843c749SSergey Zigachev 	struct ttm_bo_kmap_obj		kmap;
85*b843c749SSergey Zigachev 	u64				flags;
86*b843c749SSergey Zigachev 	unsigned			pin_count;
87*b843c749SSergey Zigachev 	u64				tiling_flags;
88*b843c749SSergey Zigachev 	u64				metadata_flags;
89*b843c749SSergey Zigachev 	void				*metadata;
90*b843c749SSergey Zigachev 	u32				metadata_size;
91*b843c749SSergey Zigachev 	unsigned			prime_shared_count;
92*b843c749SSergey Zigachev 	/* list of all virtual address to which this bo is associated to */
93*b843c749SSergey Zigachev 	struct list_head		va;
94*b843c749SSergey Zigachev 	/* Constant after initialization */
95*b843c749SSergey Zigachev 	struct drm_gem_object		gem_base;
96*b843c749SSergey Zigachev 	struct amdgpu_bo		*parent;
97*b843c749SSergey Zigachev 	struct amdgpu_bo		*shadow;
98*b843c749SSergey Zigachev 
99*b843c749SSergey Zigachev 	struct ttm_bo_kmap_obj		dma_buf_vmap;
100*b843c749SSergey Zigachev 	struct amdgpu_mn		*mn;
101*b843c749SSergey Zigachev 
102*b843c749SSergey Zigachev 	union {
103*b843c749SSergey Zigachev 		struct list_head	mn_list;
104*b843c749SSergey Zigachev 		struct list_head	shadow_list;
105*b843c749SSergey Zigachev 	};
106*b843c749SSergey Zigachev 
107*b843c749SSergey Zigachev 	struct kgd_mem                  *kfd_bo;
108*b843c749SSergey Zigachev };
109*b843c749SSergey Zigachev 
ttm_to_amdgpu_bo(struct ttm_buffer_object * tbo)110*b843c749SSergey Zigachev static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)
111*b843c749SSergey Zigachev {
112*b843c749SSergey Zigachev 	return container_of(tbo, struct amdgpu_bo, tbo);
113*b843c749SSergey Zigachev }
114*b843c749SSergey Zigachev 
115*b843c749SSergey Zigachev /**
116*b843c749SSergey Zigachev  * amdgpu_mem_type_to_domain - return domain corresponding to mem_type
117*b843c749SSergey Zigachev  * @mem_type:	ttm memory type
118*b843c749SSergey Zigachev  *
119*b843c749SSergey Zigachev  * Returns corresponding domain of the ttm mem_type
120*b843c749SSergey Zigachev  */
amdgpu_mem_type_to_domain(u32 mem_type)121*b843c749SSergey Zigachev static inline unsigned amdgpu_mem_type_to_domain(u32 mem_type)
122*b843c749SSergey Zigachev {
123*b843c749SSergey Zigachev 	switch (mem_type) {
124*b843c749SSergey Zigachev 	case TTM_PL_VRAM:
125*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_VRAM;
126*b843c749SSergey Zigachev 	case TTM_PL_TT:
127*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_GTT;
128*b843c749SSergey Zigachev 	case TTM_PL_SYSTEM:
129*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_CPU;
130*b843c749SSergey Zigachev 	case AMDGPU_PL_GDS:
131*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_GDS;
132*b843c749SSergey Zigachev 	case AMDGPU_PL_GWS:
133*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_GWS;
134*b843c749SSergey Zigachev 	case AMDGPU_PL_OA:
135*b843c749SSergey Zigachev 		return AMDGPU_GEM_DOMAIN_OA;
136*b843c749SSergey Zigachev 	default:
137*b843c749SSergey Zigachev 		break;
138*b843c749SSergey Zigachev 	}
139*b843c749SSergey Zigachev 	return 0;
140*b843c749SSergey Zigachev }
141*b843c749SSergey Zigachev 
142*b843c749SSergey Zigachev /**
143*b843c749SSergey Zigachev  * amdgpu_bo_reserve - reserve bo
144*b843c749SSergey Zigachev  * @bo:		bo structure
145*b843c749SSergey Zigachev  * @no_intr:	don't return -ERESTARTSYS on pending signal
146*b843c749SSergey Zigachev  *
147*b843c749SSergey Zigachev  * Returns:
148*b843c749SSergey Zigachev  * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
149*b843c749SSergey Zigachev  * a signal. Release all buffer reservations and return to user-space.
150*b843c749SSergey Zigachev  */
amdgpu_bo_reserve(struct amdgpu_bo * bo,bool no_intr)151*b843c749SSergey Zigachev static inline int amdgpu_bo_reserve(struct amdgpu_bo *bo, bool no_intr)
152*b843c749SSergey Zigachev {
153*b843c749SSergey Zigachev 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
154*b843c749SSergey Zigachev 	int r;
155*b843c749SSergey Zigachev 
156*b843c749SSergey Zigachev 	r = ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
157*b843c749SSergey Zigachev 	if (unlikely(r != 0)) {
158*b843c749SSergey Zigachev 		if (r != -ERESTARTSYS)
159*b843c749SSergey Zigachev 			dev_err(adev->dev, "%p reserve failed\n", bo);
160*b843c749SSergey Zigachev 		return r;
161*b843c749SSergey Zigachev 	}
162*b843c749SSergey Zigachev 	return 0;
163*b843c749SSergey Zigachev }
164*b843c749SSergey Zigachev 
amdgpu_bo_unreserve(struct amdgpu_bo * bo)165*b843c749SSergey Zigachev static inline void amdgpu_bo_unreserve(struct amdgpu_bo *bo)
166*b843c749SSergey Zigachev {
167*b843c749SSergey Zigachev 	ttm_bo_unreserve(&bo->tbo);
168*b843c749SSergey Zigachev }
169*b843c749SSergey Zigachev 
amdgpu_bo_size(struct amdgpu_bo * bo)170*b843c749SSergey Zigachev static inline unsigned long amdgpu_bo_size(struct amdgpu_bo *bo)
171*b843c749SSergey Zigachev {
172*b843c749SSergey Zigachev 	return bo->tbo.num_pages << PAGE_SHIFT;
173*b843c749SSergey Zigachev }
174*b843c749SSergey Zigachev 
amdgpu_bo_ngpu_pages(struct amdgpu_bo * bo)175*b843c749SSergey Zigachev static inline unsigned amdgpu_bo_ngpu_pages(struct amdgpu_bo *bo)
176*b843c749SSergey Zigachev {
177*b843c749SSergey Zigachev 	return (bo->tbo.num_pages << PAGE_SHIFT) / AMDGPU_GPU_PAGE_SIZE;
178*b843c749SSergey Zigachev }
179*b843c749SSergey Zigachev 
amdgpu_bo_gpu_page_alignment(struct amdgpu_bo * bo)180*b843c749SSergey Zigachev static inline unsigned amdgpu_bo_gpu_page_alignment(struct amdgpu_bo *bo)
181*b843c749SSergey Zigachev {
182*b843c749SSergey Zigachev 	return (bo->tbo.mem.page_alignment << PAGE_SHIFT) / AMDGPU_GPU_PAGE_SIZE;
183*b843c749SSergey Zigachev }
184*b843c749SSergey Zigachev 
185*b843c749SSergey Zigachev /**
186*b843c749SSergey Zigachev  * amdgpu_bo_mmap_offset - return mmap offset of bo
187*b843c749SSergey Zigachev  * @bo:	amdgpu object for which we query the offset
188*b843c749SSergey Zigachev  *
189*b843c749SSergey Zigachev  * Returns mmap offset of the object.
190*b843c749SSergey Zigachev  */
amdgpu_bo_mmap_offset(struct amdgpu_bo * bo)191*b843c749SSergey Zigachev static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)
192*b843c749SSergey Zigachev {
193*b843c749SSergey Zigachev 	return drm_vma_node_offset_addr(&bo->tbo.vma_node);
194*b843c749SSergey Zigachev }
195*b843c749SSergey Zigachev 
196*b843c749SSergey Zigachev /**
197*b843c749SSergey Zigachev  * amdgpu_bo_gpu_accessible - return whether the bo is currently in memory that
198*b843c749SSergey Zigachev  * is accessible to the GPU.
199*b843c749SSergey Zigachev  */
amdgpu_bo_gpu_accessible(struct amdgpu_bo * bo)200*b843c749SSergey Zigachev static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)
201*b843c749SSergey Zigachev {
202*b843c749SSergey Zigachev 	switch (bo->tbo.mem.mem_type) {
203*b843c749SSergey Zigachev 	case TTM_PL_TT: return amdgpu_gtt_mgr_has_gart_addr(&bo->tbo.mem);
204*b843c749SSergey Zigachev 	case TTM_PL_VRAM: return true;
205*b843c749SSergey Zigachev 	default: return false;
206*b843c749SSergey Zigachev 	}
207*b843c749SSergey Zigachev }
208*b843c749SSergey Zigachev 
209*b843c749SSergey Zigachev /**
210*b843c749SSergey Zigachev  * amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM
211*b843c749SSergey Zigachev  */
amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo * bo)212*b843c749SSergey Zigachev static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)
213*b843c749SSergey Zigachev {
214*b843c749SSergey Zigachev 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
215*b843c749SSergey Zigachev 	unsigned fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT;
216*b843c749SSergey Zigachev 	struct drm_mm_node *node = bo->tbo.mem.mm_node;
217*b843c749SSergey Zigachev 	unsigned long pages_left;
218*b843c749SSergey Zigachev 
219*b843c749SSergey Zigachev 	if (bo->tbo.mem.mem_type != TTM_PL_VRAM)
220*b843c749SSergey Zigachev 		return false;
221*b843c749SSergey Zigachev 
222*b843c749SSergey Zigachev 	for (pages_left = bo->tbo.mem.num_pages; pages_left;
223*b843c749SSergey Zigachev 	     pages_left -= node->size, node++)
224*b843c749SSergey Zigachev 		if (node->start < fpfn)
225*b843c749SSergey Zigachev 			return true;
226*b843c749SSergey Zigachev 
227*b843c749SSergey Zigachev 	return false;
228*b843c749SSergey Zigachev }
229*b843c749SSergey Zigachev 
230*b843c749SSergey Zigachev /**
231*b843c749SSergey Zigachev  * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced
232*b843c749SSergey Zigachev  */
amdgpu_bo_explicit_sync(struct amdgpu_bo * bo)233*b843c749SSergey Zigachev static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo)
234*b843c749SSergey Zigachev {
235*b843c749SSergey Zigachev 	return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
236*b843c749SSergey Zigachev }
237*b843c749SSergey Zigachev 
238*b843c749SSergey Zigachev bool amdgpu_bo_is_amdgpu_bo(struct ttm_buffer_object *bo);
239*b843c749SSergey Zigachev void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);
240*b843c749SSergey Zigachev 
241*b843c749SSergey Zigachev int amdgpu_bo_create(struct amdgpu_device *adev,
242*b843c749SSergey Zigachev 		     struct amdgpu_bo_param *bp,
243*b843c749SSergey Zigachev 		     struct amdgpu_bo **bo_ptr);
244*b843c749SSergey Zigachev int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
245*b843c749SSergey Zigachev 			      unsigned long size, int align,
246*b843c749SSergey Zigachev 			      u32 domain, struct amdgpu_bo **bo_ptr,
247*b843c749SSergey Zigachev 			      u64 *gpu_addr, void **cpu_addr);
248*b843c749SSergey Zigachev int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
249*b843c749SSergey Zigachev 			    unsigned long size, int align,
250*b843c749SSergey Zigachev 			    u32 domain, struct amdgpu_bo **bo_ptr,
251*b843c749SSergey Zigachev 			    u64 *gpu_addr, void **cpu_addr);
252*b843c749SSergey Zigachev void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
253*b843c749SSergey Zigachev 			   void **cpu_addr);
254*b843c749SSergey Zigachev int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr);
255*b843c749SSergey Zigachev void *amdgpu_bo_kptr(struct amdgpu_bo *bo);
256*b843c749SSergey Zigachev void amdgpu_bo_kunmap(struct amdgpu_bo *bo);
257*b843c749SSergey Zigachev struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo);
258*b843c749SSergey Zigachev void amdgpu_bo_unref(struct amdgpu_bo **bo);
259*b843c749SSergey Zigachev int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain);
260*b843c749SSergey Zigachev int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
261*b843c749SSergey Zigachev 			     u64 min_offset, u64 max_offset);
262*b843c749SSergey Zigachev int amdgpu_bo_unpin(struct amdgpu_bo *bo);
263*b843c749SSergey Zigachev int amdgpu_bo_evict_vram(struct amdgpu_device *adev);
264*b843c749SSergey Zigachev int amdgpu_bo_init(struct amdgpu_device *adev);
265*b843c749SSergey Zigachev int amdgpu_bo_late_init(struct amdgpu_device *adev);
266*b843c749SSergey Zigachev void amdgpu_bo_fini(struct amdgpu_device *adev);
267*b843c749SSergey Zigachev int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
268*b843c749SSergey Zigachev 				struct vm_area_struct *vma);
269*b843c749SSergey Zigachev int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags);
270*b843c749SSergey Zigachev void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags);
271*b843c749SSergey Zigachev int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata,
272*b843c749SSergey Zigachev 			    uint32_t metadata_size, uint64_t flags);
273*b843c749SSergey Zigachev int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
274*b843c749SSergey Zigachev 			   size_t buffer_size, uint32_t *metadata_size,
275*b843c749SSergey Zigachev 			   uint64_t *flags);
276*b843c749SSergey Zigachev void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
277*b843c749SSergey Zigachev 			   bool evict,
278*b843c749SSergey Zigachev 			   struct ttm_mem_reg *new_mem);
279*b843c749SSergey Zigachev int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
280*b843c749SSergey Zigachev void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
281*b843c749SSergey Zigachev 		     bool shared);
282*b843c749SSergey Zigachev u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
283*b843c749SSergey Zigachev int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
284*b843c749SSergey Zigachev 			       struct amdgpu_ring *ring,
285*b843c749SSergey Zigachev 			       struct amdgpu_bo *bo,
286*b843c749SSergey Zigachev 			       struct reservation_object *resv,
287*b843c749SSergey Zigachev 			       struct dma_fence **fence, bool direct);
288*b843c749SSergey Zigachev int amdgpu_bo_validate(struct amdgpu_bo *bo);
289*b843c749SSergey Zigachev int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
290*b843c749SSergey Zigachev 				  struct amdgpu_ring *ring,
291*b843c749SSergey Zigachev 				  struct amdgpu_bo *bo,
292*b843c749SSergey Zigachev 				  struct reservation_object *resv,
293*b843c749SSergey Zigachev 				  struct dma_fence **fence,
294*b843c749SSergey Zigachev 				  bool direct);
295*b843c749SSergey Zigachev uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
296*b843c749SSergey Zigachev 					    uint32_t domain);
297*b843c749SSergey Zigachev 
298*b843c749SSergey Zigachev /*
299*b843c749SSergey Zigachev  * sub allocation
300*b843c749SSergey Zigachev  */
301*b843c749SSergey Zigachev 
amdgpu_sa_bo_gpu_addr(struct amdgpu_sa_bo * sa_bo)302*b843c749SSergey Zigachev static inline uint64_t amdgpu_sa_bo_gpu_addr(struct amdgpu_sa_bo *sa_bo)
303*b843c749SSergey Zigachev {
304*b843c749SSergey Zigachev 	return sa_bo->manager->gpu_addr + sa_bo->soffset;
305*b843c749SSergey Zigachev }
306*b843c749SSergey Zigachev 
amdgpu_sa_bo_cpu_addr(struct amdgpu_sa_bo * sa_bo)307*b843c749SSergey Zigachev static inline void * amdgpu_sa_bo_cpu_addr(struct amdgpu_sa_bo *sa_bo)
308*b843c749SSergey Zigachev {
309*b843c749SSergey Zigachev 	return sa_bo->manager->cpu_ptr + sa_bo->soffset;
310*b843c749SSergey Zigachev }
311*b843c749SSergey Zigachev 
312*b843c749SSergey Zigachev int amdgpu_sa_bo_manager_init(struct amdgpu_device *adev,
313*b843c749SSergey Zigachev 				     struct amdgpu_sa_manager *sa_manager,
314*b843c749SSergey Zigachev 				     unsigned size, u32 align, u32 domain);
315*b843c749SSergey Zigachev void amdgpu_sa_bo_manager_fini(struct amdgpu_device *adev,
316*b843c749SSergey Zigachev 				      struct amdgpu_sa_manager *sa_manager);
317*b843c749SSergey Zigachev int amdgpu_sa_bo_manager_start(struct amdgpu_device *adev,
318*b843c749SSergey Zigachev 				      struct amdgpu_sa_manager *sa_manager);
319*b843c749SSergey Zigachev int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,
320*b843c749SSergey Zigachev 		     struct amdgpu_sa_bo **sa_bo,
321*b843c749SSergey Zigachev 		     unsigned size, unsigned align);
322*b843c749SSergey Zigachev void amdgpu_sa_bo_free(struct amdgpu_device *adev,
323*b843c749SSergey Zigachev 			      struct amdgpu_sa_bo **sa_bo,
324*b843c749SSergey Zigachev 			      struct dma_fence *fence);
325*b843c749SSergey Zigachev #if defined(CONFIG_DEBUG_FS)
326*b843c749SSergey Zigachev void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
327*b843c749SSergey Zigachev 					 struct seq_file *m);
328*b843c749SSergey Zigachev #endif
329*b843c749SSergey Zigachev 
330*b843c749SSergey Zigachev 
331*b843c749SSergey Zigachev #endif
332