<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Sent:</b> Thursday, April 21, 2022 8:48 PM<br>
<b>To:</b> 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><br>
<b>Cc:</b> Kuehling, Felix <Felix.Kuehling@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText elementToProof">Am 21.04.22 um 14:34 schrieb Yang Wang:<br>
> simplify programming with existing functions.<br>
><br>
> Signed-off-by: Yang Wang <KevinYang.Wang@amd.com><br>
<br>
With a minimal style change reviewed and pushed to drm-misc-next.<br>
<br>
Thanks,<br>
Christian.</div>
<div class="PlainText elementToProof"><br>
</div>
<div class="PlainText elementToProof">[kevin]:</div>
<div class="PlainText elementToProof"><span style="margin:0px;font-size:12pt;font-family:Calibri, Arial, Helvetica, sans-serif">it is ok, thanks.</span>
<div style="margin:0px;font-size:12pt;font-family:Calibri, Arial, Helvetica, sans-serif">
<br>
</div>
<div style="margin:0px;font-size:12pt;font-family:Calibri, Arial, Helvetica, sans-serif">
Best Regards,</div>
<span style="margin:0px;font-size:12pt;font-family:Calibri, Arial, Helvetica, sans-serif">Kevin</span><br>
<br>
> ---<br>
> drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------<br>
> 1 file changed, 12 insertions(+), 9 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c<br>
> index 79c870a3bef8..cbb3d1fb4caf 100644<br>
> --- a/drivers/gpu/drm/ttm/ttm_tt.c<br>
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c<br>
> @@ -96,19 +96,20 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)<br>
> */<br>
> static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)<br>
> {<br>
> - ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),<br>
> - GFP_KERNEL | __GFP_ZERO);<br>
> + ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),<br>
> + GFP_KERNEL);<br>
> if (!ttm->pages)<br>
> return -ENOMEM;<br>
> +<br>
> return 0;<br>
> }<br>
> <br>
> static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)<br>
> {<br>
> - ttm->pages = kvmalloc_array(ttm->num_pages,<br>
> - sizeof(*ttm->pages) +<br>
> - sizeof(*ttm->dma_address),<br>
> - GFP_KERNEL | __GFP_ZERO);<br>
> + ttm->pages = kvcalloc(ttm->num_pages,<br>
> + sizeof(*ttm->pages) +<br>
> + sizeof(*ttm->dma_address),<br>
> + GFP_KERNEL);<br>
> if (!ttm->pages)<br>
> return -ENOMEM;<br>
> <br>
> @@ -118,11 +119,13 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)<br>
> <br>
> static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)<br>
> {<br>
> - ttm->dma_address = kvmalloc_array(ttm->num_pages,<br>
> - sizeof(*ttm->dma_address),<br>
> - GFP_KERNEL | __GFP_ZERO);<br>
> + ttm->dma_address = kvcalloc(ttm->num_pages,<br>
> + sizeof(*ttm->dma_address),<br>
> + GFP_KERNEL);<br>
> if (!ttm->dma_address)<br>
> return -ENOMEM;<br>
> +<br>
> +<br>
> return 0;<br>
> }<br>
> <br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>