diff mbox series

[3/3] drm/amdgpu: use tiling_flags of struct amdgpu_bo_user

Message ID 20210305125659.9923-3-nirmoy.das@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/amdgpu: introduce struct amdgpu_bo_user | expand

Commit Message

Nirmoy Das March 5, 2021, 12:56 p.m. UTC
This flag is only needed for BOs created by amdgpu_gem_object_create(),
so we can remove tiling_flags from the base class.

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  1 -
 2 files changed, 17 insertions(+), 3 deletions(-)

Comments

Christian König March 5, 2021, 1:08 p.m. UTC | #1
Am 05.03.21 um 13:56 schrieb Nirmoy Das:
> This flag is only needed for BOs created by amdgpu_gem_object_create(),
> so we can remove tiling_flags from the base class.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++++++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  1 -
>   2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index f21679f38383..c19cb6863966 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1190,12 +1190,19 @@ int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
>   int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> +	struct amdgpu_bo_user *ubo;
> +
> +	if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {

You don't need the AMDGPU_GEM_CREATE_USER flag, just test TTMs BO type.

> +		DRM_ERROR("can not set tiling_flags for a non-amdgpu_bo_user type BO\n");
> +		return -EINVAL;
> +	}
>   
>   	if (adev->family <= AMDGPU_FAMILY_CZ &&
>   	    AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6)
>   		return -EINVAL;
>   
> -	bo->tiling_flags = tiling_flags;
> +	ubo = container_of((bo), struct amdgpu_bo_user, bo);
> +	ubo->tiling_flags = tiling_flags;
>   	return 0;
>   }
>   
> @@ -1209,10 +1216,18 @@ int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
>    */
>   void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)
>   {
> +	struct amdgpu_bo_user *ubo;
> +
> +	if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {
> +		DRM_ERROR("can not get tiling_flags for a non-amdgpu_bo_user type BO\n");
> +		return;
> +	}
> +
>   	dma_resv_assert_held(bo->tbo.base.resv);
> +	ubo = container_of((bo), struct amdgpu_bo_user, bo);
>   
>   	if (tiling_flags)
> -		*tiling_flags = bo->tiling_flags;
> +		*tiling_flags = ubo->tiling_flags;
>   }
>   
>   /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 332e269c3fd1..7164c0799534 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -91,7 +91,6 @@ struct amdgpu_bo {
>   	struct ttm_bo_kmap_obj		kmap;
>   	u64				flags;
>   	unsigned			pin_count;
> -	u64				tiling_flags;
>   	u64				metadata_flags;
>   	void				*metadata;
>   	u32				metadata_size;

BTW: The metadata can be moved to the user BOs as well!

Thanks,
Christian.
Nirmoy March 5, 2021, 1:27 p.m. UTC | #2
On 3/5/21 2:08 PM, Christian König wrote:
> Am 05.03.21 um 13:56 schrieb Nirmoy Das:
>> This flag is only needed for BOs created by amdgpu_gem_object_create(),
>> so we can remove tiling_flags from the base class.
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++++++--
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  1 -
>>   2 files changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> index f21679f38383..c19cb6863966 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> @@ -1190,12 +1190,19 @@ int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
>>   int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
>>   {
>>       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
>> +    struct amdgpu_bo_user *ubo;
>> +
>> +    if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {
>
> You don't need the AMDGPU_GEM_CREATE_USER flag, just test TTMs BO type.


Okay I will remove AMDGPU_GEM_CREATE_USER flag completely.


>
>> +        DRM_ERROR("can not set tiling_flags for a non-amdgpu_bo_user 
>> type BO\n");
>> +        return -EINVAL;
>> +    }
>>         if (adev->family <= AMDGPU_FAMILY_CZ &&
>>           AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6)
>>           return -EINVAL;
>>   -    bo->tiling_flags = tiling_flags;
>> +    ubo = container_of((bo), struct amdgpu_bo_user, bo);
>> +    ubo->tiling_flags = tiling_flags;
>>       return 0;
>>   }
>>   @@ -1209,10 +1216,18 @@ int amdgpu_bo_set_tiling_flags(struct 
>> amdgpu_bo *bo, u64 tiling_flags)
>>    */
>>   void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 
>> *tiling_flags)
>>   {
>> +    struct amdgpu_bo_user *ubo;
>> +
>> +    if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {
>> +        DRM_ERROR("can not get tiling_flags for a non-amdgpu_bo_user 
>> type BO\n");
>> +        return;
>> +    }
>> +
>>       dma_resv_assert_held(bo->tbo.base.resv);
>> +    ubo = container_of((bo), struct amdgpu_bo_user, bo);
>>         if (tiling_flags)
>> -        *tiling_flags = bo->tiling_flags;
>> +        *tiling_flags = ubo->tiling_flags;
>>   }
>>     /**
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> index 332e269c3fd1..7164c0799534 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> @@ -91,7 +91,6 @@ struct amdgpu_bo {
>>       struct ttm_bo_kmap_obj        kmap;
>>       u64                flags;
>>       unsigned            pin_count;
>> -    u64                tiling_flags;
>>       u64                metadata_flags;
>>       void                *metadata;
>>       u32                metadata_size;
>
> BTW: The metadata can be moved to the user BOs as well!


I resend with metadata members moved to the user BO.


Thanks,

Nirmoy

>
> Thanks,
> Christian.
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index f21679f38383..c19cb6863966 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1190,12 +1190,19 @@  int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
 int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+	struct amdgpu_bo_user *ubo;
+
+	if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {
+		DRM_ERROR("can not set tiling_flags for a non-amdgpu_bo_user type BO\n");
+		return -EINVAL;
+	}
 
 	if (adev->family <= AMDGPU_FAMILY_CZ &&
 	    AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6)
 		return -EINVAL;
 
-	bo->tiling_flags = tiling_flags;
+	ubo = container_of((bo), struct amdgpu_bo_user, bo);
+	ubo->tiling_flags = tiling_flags;
 	return 0;
 }
 
@@ -1209,10 +1216,18 @@  int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
  */
 void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)
 {
+	struct amdgpu_bo_user *ubo;
+
+	if (!(bo->flags & AMDGPU_GEM_CREATE_USER)) {
+		DRM_ERROR("can not get tiling_flags for a non-amdgpu_bo_user type BO\n");
+		return;
+	}
+
 	dma_resv_assert_held(bo->tbo.base.resv);
+	ubo = container_of((bo), struct amdgpu_bo_user, bo);
 
 	if (tiling_flags)
-		*tiling_flags = bo->tiling_flags;
+		*tiling_flags = ubo->tiling_flags;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 332e269c3fd1..7164c0799534 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -91,7 +91,6 @@  struct amdgpu_bo {
 	struct ttm_bo_kmap_obj		kmap;
 	u64				flags;
 	unsigned			pin_count;
-	u64				tiling_flags;
 	u64				metadata_flags;
 	void				*metadata;
 	u32				metadata_size;