* [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
@ 2022-04-21 12:34 Yang Wang
2022-04-21 12:48 ` Christian König
0 siblings, 1 reply; 3+ messages in thread
From: Yang Wang @ 2022-04-21 12:34 UTC (permalink / raw)
To: amd-gfx, dri-devel
Cc: felix.kuehling, lijo.lazar, christian.koenig, Yang Wang
simplify programming with existing functions.
Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
---
drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 79c870a3bef8..cbb3d1fb4caf 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -96,19 +96,20 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
*/
static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
{
- ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
- GFP_KERNEL | __GFP_ZERO);
+ ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),
+ GFP_KERNEL);
if (!ttm->pages)
return -ENOMEM;
+
return 0;
}
static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
{
- ttm->pages = kvmalloc_array(ttm->num_pages,
- sizeof(*ttm->pages) +
- sizeof(*ttm->dma_address),
- GFP_KERNEL | __GFP_ZERO);
+ ttm->pages = kvcalloc(ttm->num_pages,
+ sizeof(*ttm->pages) +
+ sizeof(*ttm->dma_address),
+ GFP_KERNEL);
if (!ttm->pages)
return -ENOMEM;
@@ -118,11 +119,13 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
{
- ttm->dma_address = kvmalloc_array(ttm->num_pages,
- sizeof(*ttm->dma_address),
- GFP_KERNEL | __GFP_ZERO);
+ ttm->dma_address = kvcalloc(ttm->num_pages,
+ sizeof(*ttm->dma_address),
+ GFP_KERNEL);
if (!ttm->dma_address)
return -ENOMEM;
+
+
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
2022-04-21 12:34 [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt Yang Wang
@ 2022-04-21 12:48 ` Christian König
2022-04-21 13:03 ` Wang, Yang(Kevin)
0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2022-04-21 12:48 UTC (permalink / raw)
To: Yang Wang, amd-gfx, dri-devel; +Cc: felix.kuehling, lijo.lazar
Am 21.04.22 um 14:34 schrieb Yang Wang:
> simplify programming with existing functions.
>
> Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
With a minimal style change reviewed and pushed to drm-misc-next.
Thanks,
Christian.
> ---
> drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 79c870a3bef8..cbb3d1fb4caf 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -96,19 +96,20 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
> */
> static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),
> + GFP_KERNEL);
> if (!ttm->pages)
> return -ENOMEM;
> +
> return 0;
> }
>
> static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->pages = kvmalloc_array(ttm->num_pages,
> - sizeof(*ttm->pages) +
> - sizeof(*ttm->dma_address),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->pages = kvcalloc(ttm->num_pages,
> + sizeof(*ttm->pages) +
> + sizeof(*ttm->dma_address),
> + GFP_KERNEL);
> if (!ttm->pages)
> return -ENOMEM;
>
> @@ -118,11 +119,13 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
>
> static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->dma_address = kvmalloc_array(ttm->num_pages,
> - sizeof(*ttm->dma_address),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->dma_address = kvcalloc(ttm->num_pages,
> + sizeof(*ttm->dma_address),
> + GFP_KERNEL);
> if (!ttm->dma_address)
> return -ENOMEM;
> +
> +
> return 0;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
2022-04-21 12:48 ` Christian König
@ 2022-04-21 13:03 ` Wang, Yang(Kevin)
0 siblings, 0 replies; 3+ messages in thread
From: Wang, Yang(Kevin) @ 2022-04-21 13:03 UTC (permalink / raw)
To: Koenig, Christian, amd-gfx, dri-devel; +Cc: Kuehling, Felix, Lazar, Lijo
[-- Attachment #1: Type: text/plain, Size: 2820 bytes --]
[AMD Official Use Only]
________________________________
From: Koenig, Christian <Christian.Koenig@amd.com>
Sent: Thursday, April 21, 2022 8:48 PM
To: Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>
Cc: Kuehling, Felix <Felix.Kuehling@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>
Subject: Re: [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
Am 21.04.22 um 14:34 schrieb Yang Wang:
> simplify programming with existing functions.
>
> Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
With a minimal style change reviewed and pushed to drm-misc-next.
Thanks,
Christian.
[kevin]:
it is ok, thanks.
Best Regards,
Kevin
> ---
> drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 79c870a3bef8..cbb3d1fb4caf 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -96,19 +96,20 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
> */
> static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),
> + GFP_KERNEL);
> if (!ttm->pages)
> return -ENOMEM;
> +
> return 0;
> }
>
> static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->pages = kvmalloc_array(ttm->num_pages,
> - sizeof(*ttm->pages) +
> - sizeof(*ttm->dma_address),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->pages = kvcalloc(ttm->num_pages,
> + sizeof(*ttm->pages) +
> + sizeof(*ttm->dma_address),
> + GFP_KERNEL);
> if (!ttm->pages)
> return -ENOMEM;
>
> @@ -118,11 +119,13 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
>
> static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
> {
> - ttm->dma_address = kvmalloc_array(ttm->num_pages,
> - sizeof(*ttm->dma_address),
> - GFP_KERNEL | __GFP_ZERO);
> + ttm->dma_address = kvcalloc(ttm->num_pages,
> + sizeof(*ttm->dma_address),
> + GFP_KERNEL);
> if (!ttm->dma_address)
> return -ENOMEM;
> +
> +
> return 0;
> }
>
[-- Attachment #2: Type: text/html, Size: 7055 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-21 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 12:34 [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt Yang Wang
2022-04-21 12:48 ` Christian König
2022-04-21 13:03 ` Wang, Yang(Kevin)
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.