<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">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Would be better to add a is-null check for 'tmp_topology' after kzalloc(). With that fixed, patch is</p>
<p style="margin-top:0;margin-bottom:0">Reviewed-by: Xiaojie Yuan <xiaojie.yuan@amd.com><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Regards,</p>
<p style="margin-top:0;margin-bottom:0">Xiaojie<br>
</p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Hawking Zhang <Hawking.Zhang@amd.com><br>
<b>Sent:</b> Wednesday, November 7, 2018 11:29 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhang, Hawking<br>
<b>Subject:</b> [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Instead of stack-allocated psp_xgmi_topology_info in function<br>
amdgpu_xgmi_add_device, dynamically allocated this structure to<br>
avoid the frame size of this function excceed 1024 bytes.<br>
<br>
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 ++++++-----<br>
 1 file changed, 6 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
index e92b454..1c0ed13 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
@@ -63,7 +63,7 @@ static struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)<br>
 <br>
 int amdgpu_xgmi_add_device(struct amdgpu_device *adev)<br>
 {<br>
-       struct psp_xgmi_topology_info tmp_topology;<br>
+       struct psp_xgmi_topology_info *tmp_topology;<br>
         struct amdgpu_hive_info *hive;<br>
         struct amdgpu_xgmi      *entry;<br>
         struct amdgpu_device     *tmp_adev;<br>
@@ -76,7 +76,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)<br>
         adev->gmc.xgmi.node_id = psp_xgmi_get_node_id(&adev->psp);<br>
         adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp);<br>
 <br>
-       memset(&tmp_topology, 0, sizeof(tmp_topology));<br>
+       tmp_topology = kzalloc(sizeof(struct psp_xgmi_topology_info), GFP_KERNEL);<br>
         mutex_lock(&xgmi_mutex);<br>
         hive = amdgpu_get_xgmi_hive(adev);<br>
         if (!hive)<br>
@@ -84,9 +84,9 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)<br>
 <br>
         list_add_tail(&adev->gmc.xgmi.head, &hive->device_list);<br>
         list_for_each_entry(entry, &hive->device_list, head)<br>
-               tmp_topology.nodes[count++].node_id = entry->node_id;<br>
+               tmp_topology->nodes[count++].node_id = entry->node_id;<br>
 <br>
-       ret = psp_xgmi_get_topology_info(&adev->psp, count, &tmp_topology);<br>
+       ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);<br>
         if (ret) {<br>
                 dev_err(adev->dev,<br>
                         "XGMI: Get topology failure on device %llx, hive %llx, ret %d",<br>
@@ -96,7 +96,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)<br>
         }<br>
         /* Each psp need to set the latest topology */<br>
         list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {<br>
-               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, &tmp_topology);<br>
+               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, tmp_topology);<br>
                 if (ret) {<br>
                         dev_err(tmp_adev->dev,<br>
                                 "XGMI: Set topology failure on device %llx, hive %llx, ret %d",<br>
@@ -113,5 +113,6 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)<br>
 <br>
 exit:<br>
         mutex_unlock(&xgmi_mutex);<br>
+       kfree(tmp_topology);<br>
         return ret;<br>
 }<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk690877" class="OWAAutoLink" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>