<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Kent Russell <kent.russell@amd.com><br>
<b>Sent:</b> Monday, September 21, 2020 10:27 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Russell, Kent <Kent.Russell@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdkfd: Use kvmalloc instead of kmalloc for VCRAT</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Since we're dynamically allocating the CPU VCRAT, use kvmalloc in case<br>
the allocation size is huge.<br>
<br>
Signed-off-by: Kent Russell <kent.russell@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 9 +++++----<br>
 1 file changed, 5 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
index 99182b8e9152..c50e9f634d6c 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
@@ -797,7 +797,8 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)<br>
                 return -ENODATA;<br>
         }<br>
 <br>
-       pcrat_image = kmemdup(crat_table, crat_table->length, GFP_KERNEL);<br>
+       pcrat_image = kvmalloc(crat_table->length, GFP_KERNEL);<br>
+       memcpy(pcrat_image, crat_table, crat_table->length);<br>
         if (!pcrat_image)<br>
                 return -ENOMEM;<br>
 <br>
@@ -1383,7 +1384,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,<br>
                         num_nodes * (sizeof(struct crat_subtype_computeunit) +<br>
                         sizeof(struct crat_subtype_memory) +<br>
                         (num_nodes - 1) * sizeof(struct crat_subtype_iolink));<br>
-               pcrat_image = kmalloc(dyn_size, GFP_KERNEL);<br>
+               pcrat_image = kvmalloc(dyn_size, GFP_KERNEL);<br>
                 if (!pcrat_image)<br>
                         return -ENOMEM;<br>
                 *size = dyn_size;<br>
@@ -1393,7 +1394,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,<br>
         case COMPUTE_UNIT_GPU:<br>
                 if (!kdev)<br>
                         return -EINVAL;<br>
-               pcrat_image = kmalloc(VCRAT_SIZE_FOR_GPU, GFP_KERNEL);<br>
+               pcrat_image = kvmalloc(VCRAT_SIZE_FOR_GPU, GFP_KERNEL);<br>
                 if (!pcrat_image)<br>
                         return -ENOMEM;<br>
                 *size = VCRAT_SIZE_FOR_GPU;<br>
@@ -1412,7 +1413,7 @@ int kfd_create_crat_image_virtual(void **crat_image, size_t *size,<br>
         if (!ret)<br>
                 *crat_image = pcrat_image;<br>
         else<br>
-               kfree(pcrat_image);<br>
+               kvfree(pcrat_image);<br>
 <br>
         return ret;<br>
 }<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calexander.deucher%40amd.com%7C2c0550686c55482e784108d85e3a79b9%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637362952855598708&amp;sdata=juwKVfB3gvGU5TkLKf9KYPdy90sgT80810dh91hpZSw%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calexander.deucher%40amd.com%7C2c0550686c55482e784108d85e3a79b9%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637362952855598708&amp;sdata=juwKVfB3gvGU5TkLKf9KYPdy90sgT80810dh91hpZSw%3D&amp;reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>