All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes
@ 2018-11-07  3:29 Hawking Zhang
       [not found] ` <1541561360-6230-1-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Hawking Zhang @ 2018-11-07  3:29 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Hawking Zhang

Instead of stack-allocated psp_xgmi_topology_info in function
amdgpu_xgmi_add_device, dynamically allocated this structure to
avoid the frame size of this function excceed 1024 bytes.

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index e92b454..1c0ed13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -63,7 +63,7 @@ static struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)
 
 int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 {
-	struct psp_xgmi_topology_info tmp_topology;
+	struct psp_xgmi_topology_info *tmp_topology;
 	struct amdgpu_hive_info *hive;
 	struct amdgpu_xgmi	*entry;
 	struct amdgpu_device 	*tmp_adev;
@@ -76,7 +76,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 	adev->gmc.xgmi.node_id = psp_xgmi_get_node_id(&adev->psp);
 	adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp);
 
-	memset(&tmp_topology, 0, sizeof(tmp_topology));
+	tmp_topology = kzalloc(sizeof(struct psp_xgmi_topology_info), GFP_KERNEL);
 	mutex_lock(&xgmi_mutex);
 	hive = amdgpu_get_xgmi_hive(adev);
 	if (!hive)
@@ -84,9 +84,9 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 
 	list_add_tail(&adev->gmc.xgmi.head, &hive->device_list);
 	list_for_each_entry(entry, &hive->device_list, head)
-		tmp_topology.nodes[count++].node_id = entry->node_id;
+		tmp_topology->nodes[count++].node_id = entry->node_id;
 
-	ret = psp_xgmi_get_topology_info(&adev->psp, count, &tmp_topology);
+	ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);
 	if (ret) {
 		dev_err(adev->dev,
 			"XGMI: Get topology failure on device %llx, hive %llx, ret %d",
@@ -96,7 +96,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 	}
 	/* Each psp need to set the latest topology */
 	list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
-		ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, &tmp_topology);
+		ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, tmp_topology);
 		if (ret) {
 			dev_err(tmp_adev->dev,
 				"XGMI: Set topology failure on device %llx, hive %llx, ret %d",
@@ -113,5 +113,6 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 
 exit:
 	mutex_unlock(&xgmi_mutex);
+	kfree(tmp_topology);
 	return ret;
 }
-- 
2.7.4

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

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

* Re: [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes
       [not found] ` <1541561360-6230-1-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-07  3:51   ` Yuan, Xiaojie
       [not found]     ` <CY4PR12MB1639EBB0B71AE8BDC8A8B46089C40-rpdhrqHFk06fceQzjBI1oAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan, Xiaojie @ 2018-11-07  3:51 UTC (permalink / raw)
  To: Zhang, Hawking, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 3675 bytes --]

Would be better to add a is-null check for 'tmp_topology' after kzalloc(). With that fixed, patch is

Reviewed-by: Xiaojie Yuan <xiaojie.yuan-5C7GfCeVMHo@public.gmane.org>


Regards,

Xiaojie

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Hawking Zhang <Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
Sent: Wednesday, November 7, 2018 11:29 AM
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Zhang, Hawking
Subject: [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes

Instead of stack-allocated psp_xgmi_topology_info in function
amdgpu_xgmi_add_device, dynamically allocated this structure to
avoid the frame size of this function excceed 1024 bytes.

Signed-off-by: Hawking Zhang <Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index e92b454..1c0ed13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -63,7 +63,7 @@ static struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)

 int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 {
-       struct psp_xgmi_topology_info tmp_topology;
+       struct psp_xgmi_topology_info *tmp_topology;
         struct amdgpu_hive_info *hive;
         struct amdgpu_xgmi      *entry;
         struct amdgpu_device     *tmp_adev;
@@ -76,7 +76,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
         adev->gmc.xgmi.node_id = psp_xgmi_get_node_id(&adev->psp);
         adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp);

-       memset(&tmp_topology, 0, sizeof(tmp_topology));
+       tmp_topology = kzalloc(sizeof(struct psp_xgmi_topology_info), GFP_KERNEL);
         mutex_lock(&xgmi_mutex);
         hive = amdgpu_get_xgmi_hive(adev);
         if (!hive)
@@ -84,9 +84,9 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)

         list_add_tail(&adev->gmc.xgmi.head, &hive->device_list);
         list_for_each_entry(entry, &hive->device_list, head)
-               tmp_topology.nodes[count++].node_id = entry->node_id;
+               tmp_topology->nodes[count++].node_id = entry->node_id;

-       ret = psp_xgmi_get_topology_info(&adev->psp, count, &tmp_topology);
+       ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);
         if (ret) {
                 dev_err(adev->dev,
                         "XGMI: Get topology failure on device %llx, hive %llx, ret %d",
@@ -96,7 +96,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
         }
         /* Each psp need to set the latest topology */
         list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
-               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, &tmp_topology);
+               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, tmp_topology);
                 if (ret) {
                         dev_err(tmp_adev->dev,
                                 "XGMI: Set topology failure on device %llx, hive %llx, ret %d",
@@ -113,5 +113,6 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)

 exit:
         mutex_unlock(&xgmi_mutex);
+       kfree(tmp_topology);
         return ret;
 }
--
2.7.4

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

[-- Attachment #1.2: Type: text/html, Size: 7280 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* RE: [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes
       [not found]     ` <CY4PR12MB1639EBB0B71AE8BDC8A8B46089C40-rpdhrqHFk06fceQzjBI1oAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2018-11-07  4:23       ` Zhang, Hawking
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Hawking @ 2018-11-07  4:23 UTC (permalink / raw)
  To: Yuan, Xiaojie, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Zhang, Hawking


[-- Attachment #1.1: Type: text/plain, Size: 4034 bytes --]

Fixed and pushed. Thanks.

Regards,
Hawking
From: Yuan, Xiaojie <Xiaojie.Yuan@amd.com>
Sent: 2018年11月7日 11:51
To: Zhang, Hawking <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes


Would be better to add a is-null check for 'tmp_topology' after kzalloc(). With that fixed, patch is

Reviewed-by: Xiaojie Yuan <xiaojie.yuan@amd.com<mailto:xiaojie.yuan@amd.com>>



Regards,

Xiaojie

________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org<mailto:amd-gfx-bounces@lists.freedesktop.org>> on behalf of Hawking Zhang <Hawking.Zhang@amd.com<mailto:Hawking.Zhang@amd.com>>
Sent: Wednesday, November 7, 2018 11:29 AM
To: amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>
Cc: Zhang, Hawking
Subject: [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes

Instead of stack-allocated psp_xgmi_topology_info in function
amdgpu_xgmi_add_device, dynamically allocated this structure to
avoid the frame size of this function excceed 1024 bytes.

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com<mailto:Hawking.Zhang@amd.com>>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index e92b454..1c0ed13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -63,7 +63,7 @@ static struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)

 int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 {
-       struct psp_xgmi_topology_info tmp_topology;
+       struct psp_xgmi_topology_info *tmp_topology;
         struct amdgpu_hive_info *hive;
         struct amdgpu_xgmi      *entry;
         struct amdgpu_device     *tmp_adev;
@@ -76,7 +76,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
         adev->gmc.xgmi.node_id = psp_xgmi_get_node_id(&adev->psp);
         adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp);

-       memset(&tmp_topology, 0, sizeof(tmp_topology));
+       tmp_topology = kzalloc(sizeof(struct psp_xgmi_topology_info), GFP_KERNEL);
         mutex_lock(&xgmi_mutex);
         hive = amdgpu_get_xgmi_hive(adev);
         if (!hive)
@@ -84,9 +84,9 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)

         list_add_tail(&adev->gmc.xgmi.head, &hive->device_list);
         list_for_each_entry(entry, &hive->device_list, head)
-               tmp_topology.nodes[count++].node_id = entry->node_id;
+               tmp_topology->nodes[count++].node_id = entry->node_id;

-       ret = psp_xgmi_get_topology_info(&adev->psp, count, &tmp_topology);
+       ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);
         if (ret) {
                 dev_err(adev->dev,
                         "XGMI: Get topology failure on device %llx, hive %llx, ret %d",
@@ -96,7 +96,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
         }
         /* Each psp need to set the latest topology */
         list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
-               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, &tmp_topology);
+               ret = psp_xgmi_set_topology_info(&tmp_adev->psp, count, tmp_topology);
                 if (ret) {
                         dev_err(tmp_adev->dev,
                                 "XGMI: Set topology failure on device %llx, hive %llx, ret %d",
@@ -113,5 +113,6 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)

 exit:
         mutex_unlock(&xgmi_mutex);
+       kfree(tmp_topology);
         return ret;
 }
--
2.7.4

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

[-- Attachment #1.2: Type: text/html, Size: 10617 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

end of thread, other threads:[~2018-11-07  4:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07  3:29 [PATCH] drm/amdgpu: fix frame size of amdgpu_xgmi_add_devices excceed 1024 bytes Hawking Zhang
     [not found] ` <1541561360-6230-1-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
2018-11-07  3:51   ` Yuan, Xiaojie
     [not found]     ` <CY4PR12MB1639EBB0B71AE8BDC8A8B46089C40-rpdhrqHFk06fceQzjBI1oAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-11-07  4:23       ` Zhang, Hawking

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.