All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: switch kzalloc to kvmalloc in amdgpu_bo_create
@ 2021-06-02 14:09 Changfeng
  2021-06-02 14:11 ` Christian König
  0 siblings, 1 reply; 2+ messages in thread
From: Changfeng @ 2021-06-02 14:09 UTC (permalink / raw)
  To: Ray.Huang, amd-gfx, Nirmoy.Das, Christian.Koenig; +Cc: changzhu

From: changzhu <Changfeng.Zhu@amd.com>

From: Changfeng <Changfeng.Zhu@amd.com>

It will cause error when alloc memory larger than 128KB in
amdgpu_bo_create->kzalloc. So it needs to switch kzalloc to kvmalloc.

Call Trace:
   alloc_pages_current+0x6a/0xe0
   kmalloc_order+0x32/0xb0
   kmalloc_order_trace+0x1e/0x80
   __kmalloc+0x249/0x2d0
   amdgpu_bo_create+0x102/0x500 [amdgpu]
   ? xas_create+0x264/0x3e0
   amdgpu_bo_create_vm+0x32/0x60 [amdgpu]
   amdgpu_vm_pt_create+0xf5/0x260 [amdgpu]
   amdgpu_vm_init+0x1fd/0x4d0 [amdgpu]

Change-Id: If4082b0f7ba4fcd566af759e010840bc1a779747
Signed-off-by: Changfeng <Changfeng.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 15cee49f11e2..e5f62ca047a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -100,7 +100,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
 		kfree(ubo->metadata);
 	}
 
-	kfree(bo);
+	kvfree(bo);
 }
 
 /**
@@ -565,7 +565,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
 	BUG_ON(bp->bo_ptr_size < sizeof(struct amdgpu_bo));
 
 	*bo_ptr = NULL;
-	bo = kzalloc(bp->bo_ptr_size, GFP_KERNEL);
+	bo = kvmalloc(bp->bo_ptr_size, GFP_KERNEL | __GFP_ZERO);
 	if (bo == NULL)
 		return -ENOMEM;
 	drm_gem_private_object_init(adev_to_drm(adev), &bo->tbo.base, size);
-- 
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] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: switch kzalloc to kvmalloc in amdgpu_bo_create
  2021-06-02 14:09 [PATCH] drm/amdgpu: switch kzalloc to kvmalloc in amdgpu_bo_create Changfeng
@ 2021-06-02 14:11 ` Christian König
  0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2021-06-02 14:11 UTC (permalink / raw)
  To: Changfeng, Ray.Huang, amd-gfx, Nirmoy.Das

Am 02.06.21 um 16:09 schrieb Changfeng:
> From: changzhu <Changfeng.Zhu@amd.com>
>
> From: Changfeng <Changfeng.Zhu@amd.com>
>
> It will cause error when alloc memory larger than 128KB in
> amdgpu_bo_create->kzalloc. So it needs to switch kzalloc to kvmalloc.
>
> Call Trace:
>     alloc_pages_current+0x6a/0xe0
>     kmalloc_order+0x32/0xb0
>     kmalloc_order_trace+0x1e/0x80
>     __kmalloc+0x249/0x2d0
>     amdgpu_bo_create+0x102/0x500 [amdgpu]
>     ? xas_create+0x264/0x3e0
>     amdgpu_bo_create_vm+0x32/0x60 [amdgpu]
>     amdgpu_vm_pt_create+0xf5/0x260 [amdgpu]
>     amdgpu_vm_init+0x1fd/0x4d0 [amdgpu]
>
> Change-Id: If4082b0f7ba4fcd566af759e010840bc1a779747
> Signed-off-by: Changfeng <Changfeng.Zhu@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 15cee49f11e2..e5f62ca047a6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -100,7 +100,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
>   		kfree(ubo->metadata);
>   	}
>   
> -	kfree(bo);
> +	kvfree(bo);
>   }
>   
>   /**
> @@ -565,7 +565,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
>   	BUG_ON(bp->bo_ptr_size < sizeof(struct amdgpu_bo));
>   
>   	*bo_ptr = NULL;
> -	bo = kzalloc(bp->bo_ptr_size, GFP_KERNEL);
> +	bo = kvmalloc(bp->bo_ptr_size, GFP_KERNEL | __GFP_ZERO);

Please use kvzalloc() here. It has identical functionality but is more 
convenient I think.

With that done the patch is Reviewed-by: Christian König 
<christian.koenig@amd.com>

>   	if (bo == NULL)
>   		return -ENOMEM;
>   	drm_gem_private_object_init(adev_to_drm(adev), &bo->tbo.base, size);

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

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

end of thread, other threads:[~2021-06-02 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 14:09 [PATCH] drm/amdgpu: switch kzalloc to kvmalloc in amdgpu_bo_create Changfeng
2021-06-02 14:11 ` Christian König

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.