All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries
@ 2021-05-24 11:52 Shiwu Zhang
  2021-05-25 12:14 ` Nirmoy
  0 siblings, 1 reply; 3+ messages in thread
From: Shiwu Zhang @ 2021-05-24 11:52 UTC (permalink / raw)
  To: amd-gfx, nirmoy.das

Although the kfd_ioctl_get_dmabuf_info() still fail it will indicate
the caller right metadat_size useful for the same kfd ioctl next time.

v2: free the metadata buffer for sg type when to destroy BOs.

Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 3f85ba8222ef..e9f8701fd046 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -95,7 +95,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
 	}
 	amdgpu_bo_unref(&bo->parent);
 
-	if (bo->tbo.type == ttm_bo_type_device) {
+	if (bo->tbo.type != ttm_bo_type_kernel) {
 		ubo = to_amdgpu_bo_user(bo);
 		kfree(ubo->metadata);
 	}
@@ -1213,6 +1213,9 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
 
 	BUG_ON(bo->tbo.type == ttm_bo_type_kernel);
 	ubo = to_amdgpu_bo_user(bo);
+	if (metadata_size)
+		*metadata_size = ubo->metadata_size;
+
 	if (buffer) {
 		if (buffer_size < ubo->metadata_size)
 			return -EINVAL;
@@ -1221,8 +1224,6 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
 			memcpy(buffer, ubo->metadata, ubo->metadata_size);
 	}
 
-	if (metadata_size)
-		*metadata_size = ubo->metadata_size;
 	if (flags)
 		*flags = ubo->metadata_flags;
 
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries
  2021-05-24 11:52 [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries Shiwu Zhang
@ 2021-05-25 12:14 ` Nirmoy
  2021-05-26  3:08   ` Zhang, Morris
  0 siblings, 1 reply; 3+ messages in thread
From: Nirmoy @ 2021-05-25 12:14 UTC (permalink / raw)
  To: Shiwu Zhang, amd-gfx, nirmoy.das


On 5/24/21 1:52 PM, Shiwu Zhang wrote:
> Although the kfd_ioctl_get_dmabuf_info() still fail it will indicate
> the caller right metadat_size useful for the same kfd ioctl next time.
>
> v2: free the metadata buffer for sg type when to destroy BOs.
>
> Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 3f85ba8222ef..e9f8701fd046 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -95,7 +95,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
>   	}
>   	amdgpu_bo_unref(&bo->parent);
>   
> -	if (bo->tbo.type == ttm_bo_type_device) {
> +	if (bo->tbo.type != ttm_bo_type_kernel) {
>   		ubo = to_amdgpu_bo_user(bo);
>   		kfree(ubo->metadata);
>   	}


This should be a separate patch, it is unrelated to the below hunk.


> @@ -1213,6 +1213,9 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
>   
>   	BUG_ON(bo->tbo.type == ttm_bo_type_kernel);
>   	ubo = to_amdgpu_bo_user(bo);
> +	if (metadata_size)
> +		*metadata_size = ubo->metadata_size;
> +
>   	if (buffer) {
>   		if (buffer_size < ubo->metadata_size)
>   			return -EINVAL;
> @@ -1221,8 +1224,6 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
>   			memcpy(buffer, ubo->metadata, ubo->metadata_size);
>   	}
>   
> -	if (metadata_size)
> -		*metadata_size = ubo->metadata_size;
>   	if (flags)
>   		*flags = ubo->metadata_flags;
>   
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries
  2021-05-25 12:14 ` Nirmoy
@ 2021-05-26  3:08   ` Zhang, Morris
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Morris @ 2021-05-26  3:08 UTC (permalink / raw)
  To: Das, Nirmoy, amd-gfx

[AMD Official Use Only - Internal Distribution Only]

Thanks for the comments! I'll separate it into two patches.

--Brs,
Morris Zhang
MLSE Linux  ML SRDC
Ext. 25147

-----Original Message-----
From: Das, Nirmoy <Nirmoy.Das@amd.com> 
Sent: Tuesday, May 25, 2021 8:15 PM
To: Zhang, Morris <Shiwu.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; Das, Nirmoy <Nirmoy.Das@amd.com>
Subject: Re: [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries


On 5/24/21 1:52 PM, Shiwu Zhang wrote:
> Although the kfd_ioctl_get_dmabuf_info() still fail it will indicate 
> the caller right metadat_size useful for the same kfd ioctl next time.
>
> v2: free the metadata buffer for sg type when to destroy BOs.
>
> Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 3f85ba8222ef..e9f8701fd046 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -95,7 +95,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
>   	}
>   	amdgpu_bo_unref(&bo->parent);
>   
> -	if (bo->tbo.type == ttm_bo_type_device) {
> +	if (bo->tbo.type != ttm_bo_type_kernel) {
>   		ubo = to_amdgpu_bo_user(bo);
>   		kfree(ubo->metadata);
>   	}


This should be a separate patch, it is unrelated to the below hunk.


> @@ -1213,6 +1213,9 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, 
> void *buffer,
>   
>   	BUG_ON(bo->tbo.type == ttm_bo_type_kernel);
>   	ubo = to_amdgpu_bo_user(bo);
> +	if (metadata_size)
> +		*metadata_size = ubo->metadata_size;
> +
>   	if (buffer) {
>   		if (buffer_size < ubo->metadata_size)
>   			return -EINVAL;
> @@ -1221,8 +1224,6 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,
>   			memcpy(buffer, ubo->metadata, ubo->metadata_size);
>   	}
>   
> -	if (metadata_size)
> -		*metadata_size = ubo->metadata_size;
>   	if (flags)
>   		*flags = ubo->metadata_flags;
>   
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26  3:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 11:52 [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries Shiwu Zhang
2021-05-25 12:14 ` Nirmoy
2021-05-26  3:08   ` Zhang, Morris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.