Skip to contentSkip to conversation

drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

PATCH In review YiPeng Chai 2 participants 7 messages Aug 12, 2022 – Aug 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
 	amdgpu_amdkfd_suspend(adev, false);
 
+	if (adev->gmc.xgmi.num_physical_nodes > 1)
+		amdgpu_xgmi_remove_device(adev);
+
 	/* Workaroud for ASICs need to disable SMC first */
 	amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 	if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
 		amdgpu_virt_release_ras_err_handler_data(adev);
 
-	if (adev->gmc.xgmi.num_physical_nodes > 1)
-		amdgpu_xgmi_remove_device(adev);
-
 	amdgpu_amdkfd_device_fini_sw(adev);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 drm/amdgpu: fix hive reference leak when adding xgmi device

Only amdgpu_get_xgmi_hive but no amdgpu_put_xgmi_hive which will leak the hive reference.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 2445255bbf01..4cdc50873621 100644
@@ -2456,12 +2456,14 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 			if (!hive->reset_domain ||
 			    !amdgpu_reset_get_reset_domain(hive->reset_domain)) {
 				r = -ENOENT;
+				amdgpu_put_xgmi_hive(hive);
 				goto init_failed;
 			}
 
 			/* Drop the early temporary reset domain we created for device */
 			amdgpu_reset_put_reset_domain(adev->reset_domain);
 			adev->reset_domain = hive->reset_domain;
+			amdgpu_put_xgmi_hive(hive);
 		}
 	}
 
Signature · 1 line
2.25.1
#2 lore raw
In reply to YiPeng Chai

[AMD Official Use Only - General]

Ping on this series.

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Friday, August 12, 2022 5:13 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
 	amdgpu_amdkfd_suspend(adev, false);
 
+	if (adev->gmc.xgmi.num_physical_nodes > 1)
+		amdgpu_xgmi_remove_device(adev);
+
 	/* Workaroud for ASICs need to disable SMC first */
 	amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 	if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
 		amdgpu_virt_release_ras_err_handler_data(adev);
 
-	if (adev->gmc.xgmi.num_physical_nodes > 1)
-		amdgpu_xgmi_remove_device(adev);
-
 	amdgpu_amdkfd_device_fini_sw(adev);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {

--
2.25.1

#3 lore raw

[AMD Official Use Only - General]

Alternatively, we might be better split xgmi ta terminate from xgmi_remove_device. In psp_hw_fini, check ta->fw and num_of_physical_mode to terminate xgmi ta. and make amdgpu_xgmi_remove_device only deal with software fini, like add_device.

Regards,
Hawking

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Monday, August 15, 2022 15:03
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

[AMD Official Use Only - General]

Ping on this series.

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Friday, August 12, 2022 5:13 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
 	amdgpu_amdkfd_suspend(adev, false);
 
+	if (adev->gmc.xgmi.num_physical_nodes > 1)
+		amdgpu_xgmi_remove_device(adev);
+
 	/* Workaroud for ASICs need to disable SMC first */
 	amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 	if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
 		amdgpu_virt_release_ras_err_handler_data(adev);
 
-	if (adev->gmc.xgmi.num_physical_nodes > 1)
-		amdgpu_xgmi_remove_device(adev);
-
 	amdgpu_amdkfd_device_fini_sw(adev);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {

--
2.25.1

#4 lore raw

Fixed typo

Regards,
Hawking

From: Zhang, Hawking <[email protected]>
Date: Tuesday, August 16, 2022 at 11:49
To: Chai, Thomas <[email protected]>, [email protected] <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini [AMD Official Use Only - General]

Alternatively, it might be better split xgmi ta terminate from xgmi_remove_device. In psp_hw_fini, check ta->fw and num_of_physical_mode to terminate xgmi ta. and make amdgpu_xgmi_remove_device only deal with software fini, like add_device.

Regards,
Hawking

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Monday, August 15, 2022 15:03
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

[AMD Official Use Only - General]

Ping on this series.

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Friday, August 12, 2022 5:13 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
         amdgpu_amdkfd_suspend(adev, false);
 
+       if (adev->gmc.xgmi.num_physical_nodes > 1)
+               amdgpu_xgmi_remove_device(adev);
+
         /* Workaroud for ASICs need to disable SMC first */
         amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
         if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
                 amdgpu_virt_release_ras_err_handler_data(adev);
 
-       if (adev->gmc.xgmi.num_physical_nodes > 1)
-               amdgpu_xgmi_remove_device(adev);
-
         amdgpu_amdkfd_device_fini_sw(adev);
 
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {

--
2.25.1

#5 lore raw

[AMD Official Use Only - General]

OK, I will update the patch.

From: Zhang, Hawking <[email protected]>
Sent: Tuesday, August 16, 2022 11:51 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Wang, Yang(Kevin) <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

Fixed typo

Regards,
Hawking

From: Zhang, Hawking <[email protected]<mailto:[email protected]>>
Date: Tuesday, August 16, 2022 at 11:49
To: Chai, Thomas <[email protected]<mailto:[email protected]>>, [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini
[AMD Official Use Only - General]

Alternatively, it might be better split xgmi ta terminate from xgmi_remove_device. In psp_hw_fini, check ta->fw and num_of_physical_mode to terminate xgmi ta. and make amdgpu_xgmi_remove_device only deal with software fini, like add_device.

Regards,
Hawking

-----Original Message-----
From: Chai, Thomas <[email protected]<mailto:[email protected]>>
Sent: Monday, August 15, 2022 15:03
To: [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking <[email protected]<mailto:[email protected]>>; Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

[AMD Official Use Only - General]

Ping on this series.

-----Original Message-----
From: Chai, Thomas <[email protected]<mailto:[email protected]>>
Sent: Friday, August 12, 2022 5:13 PM
To: [email protected]<mailto:[email protected]>
Cc: Chai, Thomas <[email protected]<mailto:[email protected]>>; Zhang, Hawking <[email protected]<mailto:[email protected]>>; Wang, Yang(Kevin) <[email protected]<mailto:[email protected]>>; Chai, Thomas <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
         amdgpu_amdkfd_suspend(adev, false);
 
+       if (adev->gmc.xgmi.num_physical_nodes > 1)
+               amdgpu_xgmi_remove_device(adev);
+
         /* Workaroud for ASICs need to disable SMC first */
         amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
         if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
                 amdgpu_virt_release_ras_err_handler_data(adev);
 
-       if (adev->gmc.xgmi.num_physical_nodes > 1)
-               amdgpu_xgmi_remove_device(adev);
-
         amdgpu_amdkfd_device_fini_sw(adev);
 
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {

--
2.25.1

#6 lore raw
In reply to Chai, Thomas

I thought I reviewed this one together with another one from you that fixed hive refcount leak. You sent them in series.

Anyway, go ahead to submit with my RB.

Thanks.

Regards,
Hawking

From: amd-gfx <[email protected]> on behalf of Chai, Thomas <[email protected]>
Date: Thursday, August 25, 2022 at 00:37
To: [email protected] <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>, Zhang, Hawking <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini [AMD Official Use Only - General]

Ping on this series.

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Friday, August 12, 2022 5:13 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: The call to amdgpu_xgmi_remove_device needs to be earlier than psp_hw_fini

The amdgpu_xgmi_remove_device function will send unload command to psp through psp ring to terminate xgmi, but psp ring has been destroyed in psp_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index c84fdef0ac45..2445255bbf01 100644
@@ -2787,6 +2787,9 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 
         amdgpu_amdkfd_suspend(adev, false);
 
+       if (adev->gmc.xgmi.num_physical_nodes > 1)
+               amdgpu_xgmi_remove_device(adev);
+
         /* Workaroud for ASICs need to disable SMC first */
         amdgpu_device_smu_fini_early(adev);
 
@@ -2830,9 +2833,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
         if (amdgpu_sriov_vf(adev) && adev->virt.ras_init_done)
                 amdgpu_virt_release_ras_err_handler_data(adev);
 
-       if (adev->gmc.xgmi.num_physical_nodes > 1)
-               amdgpu_xgmi_remove_device(adev);
-
         amdgpu_amdkfd_device_fini_sw(adev);
 
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {

--
2.25.1