1fb4d8502Sjsg /*
2fb4d8502Sjsg * Copyright 2008 Advanced Micro Devices, Inc.
3fb4d8502Sjsg * Copyright 2008 Red Hat Inc.
4fb4d8502Sjsg * Copyright 2009 Jerome Glisse.
5fb4d8502Sjsg *
6fb4d8502Sjsg * Permission is hereby granted, free of charge, to any person obtaining a
7fb4d8502Sjsg * copy of this software and associated documentation files (the "Software"),
8fb4d8502Sjsg * to deal in the Software without restriction, including without limitation
9fb4d8502Sjsg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10fb4d8502Sjsg * and/or sell copies of the Software, and to permit persons to whom the
11fb4d8502Sjsg * Software is furnished to do so, subject to the following conditions:
12fb4d8502Sjsg *
13fb4d8502Sjsg * The above copyright notice and this permission notice shall be included in
14fb4d8502Sjsg * all copies or substantial portions of the Software.
15fb4d8502Sjsg *
16fb4d8502Sjsg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17fb4d8502Sjsg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18fb4d8502Sjsg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19fb4d8502Sjsg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20fb4d8502Sjsg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21fb4d8502Sjsg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22fb4d8502Sjsg * OTHER DEALINGS IN THE SOFTWARE.
23fb4d8502Sjsg *
24fb4d8502Sjsg * Authors: Dave Airlie
25fb4d8502Sjsg * Alex Deucher
26fb4d8502Sjsg * Jerome Glisse
27fb4d8502Sjsg */
28fb4d8502Sjsg #ifndef __AMDGPU_OBJECT_H__
29fb4d8502Sjsg #define __AMDGPU_OBJECT_H__
30fb4d8502Sjsg
31fb4d8502Sjsg #include <drm/amdgpu_drm.h>
32fb4d8502Sjsg #include "amdgpu.h"
335ca02815Sjsg #include "amdgpu_res_cursor.h"
345ca02815Sjsg
35c349dbc7Sjsg #ifdef CONFIG_MMU_NOTIFIER
36c349dbc7Sjsg #include <linux/mmu_notifier.h>
37c349dbc7Sjsg #endif
38fb4d8502Sjsg
39fb4d8502Sjsg #define AMDGPU_BO_INVALID_OFFSET LONG_MAX
40fb4d8502Sjsg #define AMDGPU_BO_MAX_PLACEMENTS 3
41fb4d8502Sjsg
425ca02815Sjsg /* BO flag to indicate a KFD userptr BO */
435ca02815Sjsg #define AMDGPU_AMDKFD_CREATE_USERPTR_BO (1ULL << 63)
445ca02815Sjsg
455ca02815Sjsg #define to_amdgpu_bo_user(abo) container_of((abo), struct amdgpu_bo_user, bo)
465ca02815Sjsg #define to_amdgpu_bo_vm(abo) container_of((abo), struct amdgpu_bo_vm, bo)
475ca02815Sjsg
48fb4d8502Sjsg struct amdgpu_bo_param {
49fb4d8502Sjsg unsigned long size;
50fb4d8502Sjsg int byte_align;
515ca02815Sjsg u32 bo_ptr_size;
52fb4d8502Sjsg u32 domain;
53fb4d8502Sjsg u32 preferred_domain;
54fb4d8502Sjsg u64 flags;
55fb4d8502Sjsg enum ttm_bo_type type;
56c349dbc7Sjsg bool no_wait_gpu;
57c349dbc7Sjsg struct dma_resv *resv;
585ca02815Sjsg void (*destroy)(struct ttm_buffer_object *bo);
59f005ef32Sjsg /* xcp partition number plus 1, 0 means any partition */
60f005ef32Sjsg int8_t xcp_id_plus1;
61fb4d8502Sjsg };
62fb4d8502Sjsg
63fb4d8502Sjsg /* bo virtual addresses in a vm */
64fb4d8502Sjsg struct amdgpu_bo_va_mapping {
65fb4d8502Sjsg struct amdgpu_bo_va *bo_va;
66fb4d8502Sjsg struct list_head list;
67fb4d8502Sjsg struct rb_node rb;
68fb4d8502Sjsg uint64_t start;
69fb4d8502Sjsg uint64_t last;
70fb4d8502Sjsg uint64_t __subtree_last;
71fb4d8502Sjsg uint64_t offset;
72fb4d8502Sjsg uint64_t flags;
73fb4d8502Sjsg };
74fb4d8502Sjsg
75fb4d8502Sjsg /* User space allocated BO in a VM */
76fb4d8502Sjsg struct amdgpu_bo_va {
77fb4d8502Sjsg struct amdgpu_vm_bo_base base;
78fb4d8502Sjsg
79fb4d8502Sjsg /* protected by bo being reserved */
80fb4d8502Sjsg unsigned ref_count;
81fb4d8502Sjsg
82fb4d8502Sjsg /* all other members protected by the VM PD being reserved */
83fb4d8502Sjsg struct dma_fence *last_pt_update;
84fb4d8502Sjsg
85fb4d8502Sjsg /* mappings for this bo_va */
86fb4d8502Sjsg struct list_head invalids;
87fb4d8502Sjsg struct list_head valids;
88fb4d8502Sjsg
89fb4d8502Sjsg /* If the mappings are cleared or filled */
90fb4d8502Sjsg bool cleared;
91c349dbc7Sjsg
92c349dbc7Sjsg bool is_xgmi;
93fb4d8502Sjsg };
94fb4d8502Sjsg
95fb4d8502Sjsg struct amdgpu_bo {
96fb4d8502Sjsg /* Protected by tbo.reserved */
97fb4d8502Sjsg u32 preferred_domains;
98fb4d8502Sjsg u32 allowed_domains;
99fb4d8502Sjsg struct ttm_place placements[AMDGPU_BO_MAX_PLACEMENTS];
100fb4d8502Sjsg struct ttm_placement placement;
101fb4d8502Sjsg struct ttm_buffer_object tbo;
102fb4d8502Sjsg struct ttm_bo_kmap_obj kmap;
103fb4d8502Sjsg u64 flags;
104c349dbc7Sjsg /* per VM structure for page tables and with virtual addresses */
105c349dbc7Sjsg struct amdgpu_vm_bo_base *vm_bo;
106fb4d8502Sjsg /* Constant after initialization */
107fb4d8502Sjsg struct amdgpu_device *adev;
108fb4d8502Sjsg struct amdgpu_bo *parent;
109c349dbc7Sjsg
110c349dbc7Sjsg #ifdef CONFIG_MMU_NOTIFIER
111c349dbc7Sjsg struct mmu_interval_notifier notifier;
112c349dbc7Sjsg #endif
113fb4d8502Sjsg struct kgd_mem *kfd_bo;
114f005ef32Sjsg
115f005ef32Sjsg /*
116f005ef32Sjsg * For GPUs with spatial partitioning, xcp partition number, -1 means
117f005ef32Sjsg * any partition. For other ASICs without spatial partition, always 0
118f005ef32Sjsg * for memory accounting.
119f005ef32Sjsg */
120f005ef32Sjsg int8_t xcp_id;
121fb4d8502Sjsg };
122fb4d8502Sjsg
1235ca02815Sjsg struct amdgpu_bo_user {
1245ca02815Sjsg struct amdgpu_bo bo;
1255ca02815Sjsg u64 tiling_flags;
1265ca02815Sjsg u64 metadata_flags;
1275ca02815Sjsg void *metadata;
1285ca02815Sjsg u32 metadata_size;
1295ca02815Sjsg
1305ca02815Sjsg };
1315ca02815Sjsg
1325ca02815Sjsg struct amdgpu_bo_vm {
1335ca02815Sjsg struct amdgpu_bo bo;
1345ca02815Sjsg struct amdgpu_bo *shadow;
1355ca02815Sjsg struct list_head shadow_list;
1365ca02815Sjsg struct amdgpu_vm_bo_base entries[];
1375ca02815Sjsg };
1385ca02815Sjsg
139f005ef32Sjsg struct amdgpu_mem_stats {
140f005ef32Sjsg /* current VRAM usage, includes visible VRAM */
141f005ef32Sjsg uint64_t vram;
1427a3ad55eSjsg /* current shared VRAM usage, includes visible VRAM */
1437a3ad55eSjsg uint64_t vram_shared;
144f005ef32Sjsg /* current visible VRAM usage */
145f005ef32Sjsg uint64_t visible_vram;
146f005ef32Sjsg /* current GTT usage */
147f005ef32Sjsg uint64_t gtt;
1487a3ad55eSjsg /* current shared GTT usage */
1497a3ad55eSjsg uint64_t gtt_shared;
150f005ef32Sjsg /* current system memory usage */
151f005ef32Sjsg uint64_t cpu;
1527a3ad55eSjsg /* current shared system memory usage */
1537a3ad55eSjsg uint64_t cpu_shared;
154f005ef32Sjsg /* sum of evicted buffers, includes visible VRAM */
155f005ef32Sjsg uint64_t evicted_vram;
156f005ef32Sjsg /* sum of evicted buffers due to CPU access */
157f005ef32Sjsg uint64_t evicted_visible_vram;
158f005ef32Sjsg /* how much userspace asked for, includes vis.VRAM */
159f005ef32Sjsg uint64_t requested_vram;
160f005ef32Sjsg /* how much userspace asked for */
161f005ef32Sjsg uint64_t requested_visible_vram;
162f005ef32Sjsg /* how much userspace asked for */
163f005ef32Sjsg uint64_t requested_gtt;
164f005ef32Sjsg };
165f005ef32Sjsg
ttm_to_amdgpu_bo(struct ttm_buffer_object * tbo)166fb4d8502Sjsg static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)
167fb4d8502Sjsg {
168fb4d8502Sjsg return container_of(tbo, struct amdgpu_bo, tbo);
169fb4d8502Sjsg }
170fb4d8502Sjsg
171fb4d8502Sjsg /**
172fb4d8502Sjsg * amdgpu_mem_type_to_domain - return domain corresponding to mem_type
173fb4d8502Sjsg * @mem_type: ttm memory type
174fb4d8502Sjsg *
175fb4d8502Sjsg * Returns corresponding domain of the ttm mem_type
176fb4d8502Sjsg */
amdgpu_mem_type_to_domain(u32 mem_type)177fb4d8502Sjsg static inline unsigned amdgpu_mem_type_to_domain(u32 mem_type)
178fb4d8502Sjsg {
179fb4d8502Sjsg switch (mem_type) {
180fb4d8502Sjsg case TTM_PL_VRAM:
181fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_VRAM;
182fb4d8502Sjsg case TTM_PL_TT:
183fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_GTT;
184fb4d8502Sjsg case TTM_PL_SYSTEM:
185fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_CPU;
186fb4d8502Sjsg case AMDGPU_PL_GDS:
187fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_GDS;
188fb4d8502Sjsg case AMDGPU_PL_GWS:
189fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_GWS;
190fb4d8502Sjsg case AMDGPU_PL_OA:
191fb4d8502Sjsg return AMDGPU_GEM_DOMAIN_OA;
192f005ef32Sjsg case AMDGPU_PL_DOORBELL:
193f005ef32Sjsg return AMDGPU_GEM_DOMAIN_DOORBELL;
194fb4d8502Sjsg default:
195fb4d8502Sjsg break;
196fb4d8502Sjsg }
197fb4d8502Sjsg return 0;
198fb4d8502Sjsg }
199fb4d8502Sjsg
200fb4d8502Sjsg /**
201fb4d8502Sjsg * amdgpu_bo_reserve - reserve bo
202fb4d8502Sjsg * @bo: bo structure
203fb4d8502Sjsg * @no_intr: don't return -ERESTARTSYS on pending signal
204fb4d8502Sjsg *
205fb4d8502Sjsg * Returns:
206fb4d8502Sjsg * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
207fb4d8502Sjsg * a signal. Release all buffer reservations and return to user-space.
208fb4d8502Sjsg */
amdgpu_bo_reserve(struct amdgpu_bo * bo,bool no_intr)209fb4d8502Sjsg static inline int amdgpu_bo_reserve(struct amdgpu_bo *bo, bool no_intr)
210fb4d8502Sjsg {
211fb4d8502Sjsg struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
212fb4d8502Sjsg int r;
213fb4d8502Sjsg
214ad8b1aafSjsg r = ttm_bo_reserve(&bo->tbo, !no_intr, false, NULL);
215fb4d8502Sjsg if (unlikely(r != 0)) {
216fb4d8502Sjsg if (r != -ERESTARTSYS)
217fb4d8502Sjsg dev_err(adev->dev, "%p reserve failed\n", bo);
218fb4d8502Sjsg return r;
219fb4d8502Sjsg }
220fb4d8502Sjsg return 0;
221fb4d8502Sjsg }
222fb4d8502Sjsg
amdgpu_bo_unreserve(struct amdgpu_bo * bo)223fb4d8502Sjsg static inline void amdgpu_bo_unreserve(struct amdgpu_bo *bo)
224fb4d8502Sjsg {
225fb4d8502Sjsg ttm_bo_unreserve(&bo->tbo);
226fb4d8502Sjsg }
227fb4d8502Sjsg
amdgpu_bo_size(struct amdgpu_bo * bo)228fb4d8502Sjsg static inline unsigned long amdgpu_bo_size(struct amdgpu_bo *bo)
229fb4d8502Sjsg {
2305ca02815Sjsg return bo->tbo.base.size;
231fb4d8502Sjsg }
232fb4d8502Sjsg
amdgpu_bo_ngpu_pages(struct amdgpu_bo * bo)233fb4d8502Sjsg static inline unsigned amdgpu_bo_ngpu_pages(struct amdgpu_bo *bo)
234fb4d8502Sjsg {
2355ca02815Sjsg return bo->tbo.base.size / AMDGPU_GPU_PAGE_SIZE;
236fb4d8502Sjsg }
237fb4d8502Sjsg
amdgpu_bo_gpu_page_alignment(struct amdgpu_bo * bo)238fb4d8502Sjsg static inline unsigned amdgpu_bo_gpu_page_alignment(struct amdgpu_bo *bo)
239fb4d8502Sjsg {
2405ca02815Sjsg return (bo->tbo.page_alignment << PAGE_SHIFT) / AMDGPU_GPU_PAGE_SIZE;
241fb4d8502Sjsg }
242fb4d8502Sjsg
243fb4d8502Sjsg /**
244fb4d8502Sjsg * amdgpu_bo_mmap_offset - return mmap offset of bo
245fb4d8502Sjsg * @bo: amdgpu object for which we query the offset
246fb4d8502Sjsg *
247fb4d8502Sjsg * Returns mmap offset of the object.
248fb4d8502Sjsg */
amdgpu_bo_mmap_offset(struct amdgpu_bo * bo)249fb4d8502Sjsg static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)
250fb4d8502Sjsg {
251c349dbc7Sjsg return drm_vma_node_offset_addr(&bo->tbo.base.vma_node);
252fb4d8502Sjsg }
253fb4d8502Sjsg
254fb4d8502Sjsg /**
255fb4d8502Sjsg * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced
256fb4d8502Sjsg */
amdgpu_bo_explicit_sync(struct amdgpu_bo * bo)257fb4d8502Sjsg static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo)
258fb4d8502Sjsg {
259fb4d8502Sjsg return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
260fb4d8502Sjsg }
261fb4d8502Sjsg
262ad8b1aafSjsg /**
263ad8b1aafSjsg * amdgpu_bo_encrypted - test if the BO is encrypted
264ad8b1aafSjsg * @bo: pointer to a buffer object
265ad8b1aafSjsg *
266ad8b1aafSjsg * Return true if the buffer object is encrypted, false otherwise.
267ad8b1aafSjsg */
amdgpu_bo_encrypted(struct amdgpu_bo * bo)268ad8b1aafSjsg static inline bool amdgpu_bo_encrypted(struct amdgpu_bo *bo)
269ad8b1aafSjsg {
270ad8b1aafSjsg return bo->flags & AMDGPU_GEM_CREATE_ENCRYPTED;
271ad8b1aafSjsg }
272ad8b1aafSjsg
2735ca02815Sjsg /**
2745ca02815Sjsg * amdgpu_bo_shadowed - check if the BO is shadowed
2755ca02815Sjsg *
2765ca02815Sjsg * @bo: BO to be tested.
2775ca02815Sjsg *
2785ca02815Sjsg * Returns:
2795ca02815Sjsg * NULL if not shadowed or else return a BO pointer.
2805ca02815Sjsg */
amdgpu_bo_shadowed(struct amdgpu_bo * bo)2815ca02815Sjsg static inline struct amdgpu_bo *amdgpu_bo_shadowed(struct amdgpu_bo *bo)
2825ca02815Sjsg {
2835ca02815Sjsg if (bo->tbo.type == ttm_bo_type_kernel)
2845ca02815Sjsg return to_amdgpu_bo_vm(bo)->shadow;
2855ca02815Sjsg
2865ca02815Sjsg return NULL;
2875ca02815Sjsg }
2885ca02815Sjsg
289fb4d8502Sjsg bool amdgpu_bo_is_amdgpu_bo(struct ttm_buffer_object *bo);
290fb4d8502Sjsg void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);
291fb4d8502Sjsg
292fb4d8502Sjsg int amdgpu_bo_create(struct amdgpu_device *adev,
293fb4d8502Sjsg struct amdgpu_bo_param *bp,
294fb4d8502Sjsg struct amdgpu_bo **bo_ptr);
295fb4d8502Sjsg int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
296fb4d8502Sjsg unsigned long size, int align,
297fb4d8502Sjsg u32 domain, struct amdgpu_bo **bo_ptr,
298fb4d8502Sjsg u64 *gpu_addr, void **cpu_addr);
299fb4d8502Sjsg int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
300fb4d8502Sjsg unsigned long size, int align,
301fb4d8502Sjsg u32 domain, struct amdgpu_bo **bo_ptr,
302fb4d8502Sjsg u64 *gpu_addr, void **cpu_addr);
303c349dbc7Sjsg int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,
304c6bf6107Sjsg uint64_t offset, uint64_t size,
305c349dbc7Sjsg struct amdgpu_bo **bo_ptr, void **cpu_addr);
3065ca02815Sjsg int amdgpu_bo_create_user(struct amdgpu_device *adev,
3075ca02815Sjsg struct amdgpu_bo_param *bp,
3085ca02815Sjsg struct amdgpu_bo_user **ubo_ptr);
3095ca02815Sjsg int amdgpu_bo_create_vm(struct amdgpu_device *adev,
3105ca02815Sjsg struct amdgpu_bo_param *bp,
3115ca02815Sjsg struct amdgpu_bo_vm **ubo_ptr);
312fb4d8502Sjsg void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
313fb4d8502Sjsg void **cpu_addr);
314fb4d8502Sjsg int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr);
315fb4d8502Sjsg void *amdgpu_bo_kptr(struct amdgpu_bo *bo);
316fb4d8502Sjsg void amdgpu_bo_kunmap(struct amdgpu_bo *bo);
317fb4d8502Sjsg struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo);
318fb4d8502Sjsg void amdgpu_bo_unref(struct amdgpu_bo **bo);
319fb4d8502Sjsg int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain);
320fb4d8502Sjsg int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
321fb4d8502Sjsg u64 min_offset, u64 max_offset);
3225ca02815Sjsg void amdgpu_bo_unpin(struct amdgpu_bo *bo);
323fb4d8502Sjsg int amdgpu_bo_init(struct amdgpu_device *adev);
324fb4d8502Sjsg void amdgpu_bo_fini(struct amdgpu_device *adev);
325fb4d8502Sjsg int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags);
326fb4d8502Sjsg void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags);
327fb4d8502Sjsg int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata,
328fb4d8502Sjsg uint32_t metadata_size, uint64_t flags);
329fb4d8502Sjsg int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
330fb4d8502Sjsg size_t buffer_size, uint32_t *metadata_size,
331fb4d8502Sjsg uint64_t *flags);
332*f551e2ecSjsg void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
333*f551e2ecSjsg bool evict,
334*f551e2ecSjsg struct ttm_resource *new_mem);
335c349dbc7Sjsg void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
3365ca02815Sjsg vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
337fb4d8502Sjsg void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
338fb4d8502Sjsg bool shared);
339c349dbc7Sjsg int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
340c349dbc7Sjsg enum amdgpu_sync_mode sync_mode, void *owner,
341c349dbc7Sjsg bool intr);
342c349dbc7Sjsg int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
343fb4d8502Sjsg u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
344ad8b1aafSjsg u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo);
345f005ef32Sjsg void amdgpu_bo_get_memory(struct amdgpu_bo *bo,
346f005ef32Sjsg struct amdgpu_mem_stats *stats);
3475ca02815Sjsg void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo);
348c349dbc7Sjsg int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow,
349c349dbc7Sjsg struct dma_fence **fence);
3505ca02815Sjsg uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev,
351fb4d8502Sjsg uint32_t domain);
352fb4d8502Sjsg
353fb4d8502Sjsg /*
354fb4d8502Sjsg * sub allocation
355fb4d8502Sjsg */
356f005ef32Sjsg static inline struct amdgpu_sa_manager *
to_amdgpu_sa_manager(struct drm_suballoc_manager * manager)357f005ef32Sjsg to_amdgpu_sa_manager(struct drm_suballoc_manager *manager)
358fb4d8502Sjsg {
359f005ef32Sjsg return container_of(manager, struct amdgpu_sa_manager, base);
360fb4d8502Sjsg }
361fb4d8502Sjsg
amdgpu_sa_bo_gpu_addr(struct drm_suballoc * sa_bo)362f005ef32Sjsg static inline uint64_t amdgpu_sa_bo_gpu_addr(struct drm_suballoc *sa_bo)
363fb4d8502Sjsg {
364f005ef32Sjsg return to_amdgpu_sa_manager(sa_bo->manager)->gpu_addr +
365f005ef32Sjsg drm_suballoc_soffset(sa_bo);
366f005ef32Sjsg }
367f005ef32Sjsg
amdgpu_sa_bo_cpu_addr(struct drm_suballoc * sa_bo)368f005ef32Sjsg static inline void *amdgpu_sa_bo_cpu_addr(struct drm_suballoc *sa_bo)
369f005ef32Sjsg {
370f005ef32Sjsg return to_amdgpu_sa_manager(sa_bo->manager)->cpu_ptr +
371f005ef32Sjsg drm_suballoc_soffset(sa_bo);
372fb4d8502Sjsg }
373fb4d8502Sjsg
374fb4d8502Sjsg int amdgpu_sa_bo_manager_init(struct amdgpu_device *adev,
375fb4d8502Sjsg struct amdgpu_sa_manager *sa_manager,
376fb4d8502Sjsg unsigned size, u32 align, u32 domain);
377fb4d8502Sjsg void amdgpu_sa_bo_manager_fini(struct amdgpu_device *adev,
378fb4d8502Sjsg struct amdgpu_sa_manager *sa_manager);
379fb4d8502Sjsg int amdgpu_sa_bo_manager_start(struct amdgpu_device *adev,
380fb4d8502Sjsg struct amdgpu_sa_manager *sa_manager);
381fb4d8502Sjsg int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,
382f005ef32Sjsg struct drm_suballoc **sa_bo,
383f005ef32Sjsg unsigned int size);
384fb4d8502Sjsg void amdgpu_sa_bo_free(struct amdgpu_device *adev,
385f005ef32Sjsg struct drm_suballoc **sa_bo,
386fb4d8502Sjsg struct dma_fence *fence);
387fb4d8502Sjsg #if defined(CONFIG_DEBUG_FS)
388fb4d8502Sjsg void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
389fb4d8502Sjsg struct seq_file *m);
3905ca02815Sjsg u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m);
391fb4d8502Sjsg #endif
3925ca02815Sjsg void amdgpu_debugfs_sa_init(struct amdgpu_device *adev);
393c349dbc7Sjsg
394c349dbc7Sjsg bool amdgpu_bo_support_uswc(u64 bo_flags);
395fb4d8502Sjsg
396fb4d8502Sjsg
397fb4d8502Sjsg #endif
398