drm/amdgpu: fix metadata_size for ubo ioctl queries
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix metadata_size for ubo ioctl queries
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -3
@@ -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;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 15 lines · Shiwu Zhang
Although the
kfd_ioctl_get_dmabuf_info()still fail it will indicate the caller rightmetadat_sizeuseful for the same kfd ioctl next time.v2: free the metadata buffer for sg type when to destroy BOs.
Signed-off-by Shiwu Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) · line 101
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -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.
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-0@@ -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 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, · line 1229
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-2@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/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 <[email protected]>
Sent: Tuesday, May 25, 2021 8:15 PM
To: Zhang, Morris <[email protected]>; [email protected]; Das, Nirmoy <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix metadata_size for ubo ioctl queries
Quoted 16 lines · Shiwu Zhang
Although the
kfd_ioctl_get_dmabuf_info()still fail it will indicate the caller rightmetadat_sizeuseful for the same kfd ioctl next time.v2: free the metadata buffer for sg type when to destroy BOs.
Signed-off-by Shiwu Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) · line 101
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -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.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-0@@ -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;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, · line 1229
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-2@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx