aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.h')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 546f77cb7882..540e03fa159f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -33,6 +33,16 @@
33 33
34#define AMDGPU_BO_INVALID_OFFSET LONG_MAX 34#define AMDGPU_BO_INVALID_OFFSET LONG_MAX
35 35
36struct amdgpu_bo_param {
37 unsigned long size;
38 int byte_align;
39 u32 domain;
40 u32 preferred_domain;
41 u64 flags;
42 enum ttm_bo_type type;
43 struct reservation_object *resv;
44};
45
36/* bo virtual addresses in a vm */ 46/* bo virtual addresses in a vm */
37struct amdgpu_bo_va_mapping { 47struct amdgpu_bo_va_mapping {
38 struct amdgpu_bo_va *bo_va; 48 struct amdgpu_bo_va *bo_va;
@@ -196,6 +206,27 @@ static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)
196} 206}
197 207
198/** 208/**
209 * amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM
210 */
211static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)
212{
213 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
214 unsigned fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT;
215 struct drm_mm_node *node = bo->tbo.mem.mm_node;
216 unsigned long pages_left;
217
218 if (bo->tbo.mem.mem_type != TTM_PL_VRAM)
219 return false;
220
221 for (pages_left = bo->tbo.mem.num_pages; pages_left;
222 pages_left -= node->size, node++)
223 if (node->start < fpfn)
224 return true;
225
226 return false;
227}
228
229/**
199 * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced 230 * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced
200 */ 231 */
201static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo) 232static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo)
@@ -203,10 +234,8 @@ static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo)
203 return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC; 234 return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
204} 235}
205 236
206int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, 237int amdgpu_bo_create(struct amdgpu_device *adev,
207 int byte_align, u32 domain, 238 struct amdgpu_bo_param *bp,
208 u64 flags, enum ttm_bo_type type,
209 struct reservation_object *resv,
210 struct amdgpu_bo **bo_ptr); 239 struct amdgpu_bo **bo_ptr);
211int amdgpu_bo_create_reserved(struct amdgpu_device *adev, 240int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
212 unsigned long size, int align, 241 unsigned long size, int align,
@@ -230,6 +259,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
230int amdgpu_bo_unpin(struct amdgpu_bo *bo); 259int amdgpu_bo_unpin(struct amdgpu_bo *bo);
231int amdgpu_bo_evict_vram(struct amdgpu_device *adev); 260int amdgpu_bo_evict_vram(struct amdgpu_device *adev);
232int amdgpu_bo_init(struct amdgpu_device *adev); 261int amdgpu_bo_init(struct amdgpu_device *adev);
262int amdgpu_bo_late_init(struct amdgpu_device *adev);
233void amdgpu_bo_fini(struct amdgpu_device *adev); 263void amdgpu_bo_fini(struct amdgpu_device *adev);
234int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo, 264int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
235 struct vm_area_struct *vma); 265 struct vm_area_struct *vma);