diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.h')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 41 | 
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 546f77cb7882..731748033878 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -33,6 +33,16 @@  #define AMDGPU_BO_INVALID_OFFSET	LONG_MAX +struct amdgpu_bo_param { +	unsigned long			size; +	int				byte_align; +	u32				domain; +	u32				preferred_domain; +	u64				flags; +	enum ttm_bo_type		type; +	struct reservation_object	*resv; +}; +  /* bo virtual addresses in a vm */  struct amdgpu_bo_va_mapping {  	struct amdgpu_bo_va		*bo_va; @@ -196,6 +206,27 @@ static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)  }  /** + * amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM + */ +static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo) +{ +	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); +	unsigned fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT; +	struct drm_mm_node *node = bo->tbo.mem.mm_node; +	unsigned long pages_left; + +	if (bo->tbo.mem.mem_type != TTM_PL_VRAM) +		return false; + +	for (pages_left = bo->tbo.mem.num_pages; pages_left; +	     pages_left -= node->size, node++) +		if (node->start < fpfn) +			return true; + +	return false; +} + +/**   * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced   */  static 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)  	return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC;  } -int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, -		     int byte_align, u32 domain, -		     u64 flags, enum ttm_bo_type type, -		     struct reservation_object *resv, +int amdgpu_bo_create(struct amdgpu_device *adev, +		     struct amdgpu_bo_param *bp,  		     struct amdgpu_bo **bo_ptr);  int amdgpu_bo_create_reserved(struct amdgpu_device *adev,  			      unsigned long size, int align, @@ -230,6 +259,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,  int amdgpu_bo_unpin(struct amdgpu_bo *bo);  int amdgpu_bo_evict_vram(struct amdgpu_device *adev);  int amdgpu_bo_init(struct amdgpu_device *adev); +int amdgpu_bo_late_init(struct amdgpu_device *adev);  void amdgpu_bo_fini(struct amdgpu_device *adev);  int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,  				struct vm_area_struct *vma); @@ -259,7 +289,8 @@ int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,  				  struct reservation_object *resv,  				  struct dma_fence **fence,  				  bool direct); - +uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev, +					    uint32_t domain);  /*   * sub allocation  |