diff mbox

[3/5] drm/amd/amdgpu: add amdgpu_bo_gpu_accessible helper function

Message ID 1481821815-9971-4-git-send-email-nhaehnle@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nicolai Hähnle Dec. 15, 2016, 5:10 p.m. UTC
From: Nicolai Hähnle <nicolai.haehnle@amd.com>

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Chunming Zhou Dec. 16, 2016, 2:48 a.m. UTC | #1
On 2016年12月16日 01:10, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>
> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 4306b2f..15a723a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -107,20 +107,29 @@ static inline unsigned amdgpu_bo_gpu_page_alignment(struct amdgpu_bo *bo)
>    * amdgpu_bo_mmap_offset - return mmap offset of bo
>    * @bo:	amdgpu object for which we query the offset
>    *
>    * Returns mmap offset of the object.
>    */
>   static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)
>   {
>   	return drm_vma_node_offset_addr(&bo->tbo.vma_node);
>   }
>   
> +/**
> + * amdgpu_bo_gpu_accessible - return whether the bo is currently in memory that
> + * is accessible to the GPU.
> + */
> +static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)
> +{
> +	return bo->tbo.mem.mem_type != TTM_PL_SYSTEM;
> +}
> +
>   int amdgpu_bo_create(struct amdgpu_device *adev,
>   			    unsigned long size, int byte_align,
>   			    bool kernel, u32 domain, u64 flags,
>   			    struct sg_table *sg,
>   			    struct reservation_object *resv,
>   			    struct amdgpu_bo **bo_ptr);
>   int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
>   				unsigned long size, int byte_align,
>   				bool kernel, u32 domain, u64 flags,
>   				struct sg_table *sg,
diff mbox

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 4306b2f..15a723a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -107,20 +107,29 @@  static inline unsigned amdgpu_bo_gpu_page_alignment(struct amdgpu_bo *bo)
  * amdgpu_bo_mmap_offset - return mmap offset of bo
  * @bo:	amdgpu object for which we query the offset
  *
  * Returns mmap offset of the object.
  */
 static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)
 {
 	return drm_vma_node_offset_addr(&bo->tbo.vma_node);
 }
 
+/**
+ * amdgpu_bo_gpu_accessible - return whether the bo is currently in memory that
+ * is accessible to the GPU.
+ */
+static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)
+{
+	return bo->tbo.mem.mem_type != TTM_PL_SYSTEM;
+}
+
 int amdgpu_bo_create(struct amdgpu_device *adev,
 			    unsigned long size, int byte_align,
 			    bool kernel, u32 domain, u64 flags,
 			    struct sg_table *sg,
 			    struct reservation_object *resv,
 			    struct amdgpu_bo **bo_ptr);
 int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
 				unsigned long size, int byte_align,
 				bool kernel, u32 domain, u64 flags,
 				struct sg_table *sg,