Skip to contentSkip to conversation

drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

PATCH In review Guchun Chen 3 participants 6 messages Jul 13, 2022 – Jul 14, 2022

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

PATCH 1/2 drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -0
index e9411c28d88b..de59dc051340 100644
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct psp_context *psp)
 			&adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
 	struct amdgpu_ras *ras = psp->ras_context.ras;
 
+	/* Skip SMU FW reloading in case of using BACO for runpm only,
+	 * as SMU is always alive.
+	 */
+	if (adev->in_runpm &&
+	    !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+	    amdgpu_device_supports_baco(adev_to_drm(adev)))
+		return 0;
+
 	if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
 		return 0;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · Guchun Chen

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index e9411c28d88b..de59dc051340 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct psp_context *psp) · line 2356

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct psp_context *psp)
                        &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
        struct amdgpu_ras *ras = psp->ras_context.ras;
 
+       /* Skip SMU FW reloading in case of using BACO for runpm only,
+        * as SMU is always alive.
+        */
+       if (adev->in_runpm &&
+           !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+           amdgpu_device_supports_baco(adev_to_drm(adev)))

I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Alex

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
+               return 0;
+
        if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
                return 0;
 
--

2.17.1

#2 lore raw

Re: I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Yes, patch 2 in this series addresses it. Patch 1 intends to fix SMU reloading, while patch 2 focus on fixing race issue when getting feature mask during runtime cycle.

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, July 13, 2022 11:31 PM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 19 lines · Guchun Chen

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index e9411c28d88b..de59dc051340 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct psp_context *psp) · line 2356

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct psp_context *psp)
                        &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
        struct amdgpu_ras *ras = psp->ras_context.ras;
 
+       /* Skip SMU FW reloading in case of using BACO for runpm only,
+        * as SMU is always alive.
+        */
+       if (adev->in_runpm &&
+           !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+           amdgpu_device_supports_baco(adev_to_drm(adev)))

I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Alex

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
+               return 0;
+
        if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
                return 0;
 
--

2.17.1

#3 lore raw
Quoted 5 lines · Guchun

Re: I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Yes, patch 2 in this series addresses it. Patch 1 intends to fix SMU reloading, while patch 2 focus on fixing race issue when getting feature mask during runtime cycle.

I get that, but I think it would be better to switch the order of the patches and then use the rpm_mode in this patch as well. That way we are consistent and we don't miss some case if we change the BACO or BOCO logic in the future.

Alex

Quoted 54 lines

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, July 13, 2022 11:31 PM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 19 lines · Guchun Chen

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index e9411c28d88b..de59dc051340 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct psp_context *psp) · line 2356

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct psp_context *psp)
                        &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
        struct amdgpu_ras *ras = psp->ras_context.ras;
 
+       /* Skip SMU FW reloading in case of using BACO for runpm only,
+        * as SMU is always alive.
+        */
+       if (adev->in_runpm &&
+           !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+           amdgpu_device_supports_baco(adev_to_drm(adev)))

I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Alex

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
+               return 0;
+
        if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
                return 0;
 
--

2.17.1

#4 lore raw

Sounds good, Alex. Let me update it soon.

Also, after a discussion with Lijo, once we introduce rpm mode, we think it's fine to drop adev->runpm indicator by rpm mode, as it's a bit overlapped with latter one. So for the check like adev->runpm, we can use 'rpm_mode != AMDGPU_RUNPM_NONE' instead.
If it makes sense, I will provide a follow up patch as well to optimize it.

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, July 14, 2022 11:44 AM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 5 lines · Guchun

Re: I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Yes, patch 2 in this series addresses it. Patch 1 intends to fix SMU reloading, while patch 2 focus on fixing race issue when getting feature mask during runtime cycle.

I get that, but I think it would be better to switch the order of the patches and then use the rpm_mode in this patch as well. That way we are consistent and we don't miss some case if we change the BACO or BOCO logic in the future.

Alex

Quoted 58 lines

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, July 13, 2022 11:31 PM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 19 lines · Guchun Chen

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index e9411c28d88b..de59dc051340 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct psp_context *psp) · line 2356

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct psp_context *psp)
                        &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
        struct amdgpu_ras *ras = psp->ras_context.ras;
 
+       /* Skip SMU FW reloading in case of using BACO for runpm only,
+        * as SMU is always alive.
+        */
+       if (adev->in_runpm &&
+           !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+           amdgpu_device_supports_baco(adev_to_drm(adev)))

I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO)) or something like that.

Alex

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
+               return 0;
+
        if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
                return 0;
 
--

2.17.1

#5 lore raw

[AMD Official Use Only - General]

Quoted 11 lines

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Wednesday, July 13, 2022 11:53 PM
To: Alex Deucher <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 8 lines

Sounds good, Alex. Let me update it soon.

Also, after a discussion with Lijo, once we introduce rpm mode, we think it's fine to drop adev->runpm indicator by rpm mode, as it's a bit overlapped with latter one.
So for the check like adev->runpm, we can use 'rpm_mode != AMDGPU_RUNPM_NONE' instead.
If it makes sense, I will provide a follow up patch as well to optimize it.

Sure. Sounds good.

Alex

Quoted 94 lines

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, July 14, 2022 11:44 AM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

Quoted 3 lines · Guchun

Re: I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO))

or something like that.

Quoted 2 lines

Yes, patch 2 in this series addresses it. Patch 1 intends to fix SMU reloading,

while patch 2 focus on fixing race issue when getting feature mask during runtime cycle.

I get that, but I think it would be better to switch the order of the patches and then use the rpm_mode in this patch as well. That way we are consistent and we don't miss some case if we change the BACO or BOCO logic in the future.

Alex

Quoted 10 lines

Regards,
Guchun

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, July 13, 2022 11:31 PM
To: Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking

<[email protected]>;

Quoted 6 lines

Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: skip SMU FW reloading in runpm BACO case (v2)

On Tue, Jul 12, 2022 at 11:18 PM Guchun Chen <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines

SMU is always alive, so it's fine to skip SMU FW reloading when runpm resumed from BACO, this can avoid some race issues when resuming SMU FW.

v2: Exclude boco case if an ASIC supports both boco and baco

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index e9411c28d88b..de59dc051340 100644
@@ -2348,6 +2348,14 @@ static int psp_load_smu_fw(struct

psp_context *psp)

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_smu_fw(struct psp_context *psp) · line 2356

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
                        &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
        struct amdgpu_ras *ras = psp->ras_context.ras;
 
+       /* Skip SMU FW reloading in case of using BACO for runpm only,
+        * as SMU is always alive.
+        */
+       if (adev->in_runpm &&
+           !amdgpu_device_supports_boco(adev_to_drm(adev)) &&
+           amdgpu_device_supports_baco(adev_to_drm(adev)))
Quoted 2 lines

I think this would be better as:
if (adev->in_runpm && (adev->pm.rpm_mode != AMDGPU_RUNPM_BOCO))

or something like that.

Quoted 11 lines

Alex

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
+               return 0;
+
        if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
                return 0;
 
--

2.17.1