Skip to contentSkip to conversation

drm/amdgpu: support new mode-1 reset interface

PATCH In review Tao Zhou 3 participants 5 messages Nov 16, 2021

Subsystems (3)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: support new mode-1 reset interface

If gpu reset is triggered by ras fatal error, tell it to smu in mode-1 reset message.

---
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 21 ++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +18 -3
index 35145db6eedf..6f3d064a8232 100644
@@ -1426,16 +1426,31 @@ int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)
 
 int smu_v13_0_mode1_reset(struct smu_context *smu)
 {
-	u32 smu_version;
+	u32 smu_version, fatal_err, param;
 	int ret = 0;
+	struct amdgpu_device *adev = smu->adev;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	fatal_err = 0;
+	param = SMU_RESET_MODE_1;
+
 	/*
 	* PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
 	*/
 	smu_cmn_get_smc_version(smu, NULL, &smu_version);
 	if (smu_version < 0x00440700)
 		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
-	else
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_1, NULL);
+	else {
+		/* fatal error triggered by ras, PMFW supports the flag
+		   from 68.44.0 */
+		if ((smu_version >= 0x00442c00) && ras &&
+		    atomic_read(&ras->in_recovery))
+			fatal_err = 1;
+
+		param |= (fatal_err << 16);
+		ret = smu_cmn_send_smc_msg_with_param(smu,
+					SMU_MSG_GfxDeviceDriverReset, param, NULL);
+	}
 
 	if (!ret)
 		msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only]

Regards,
Hawking
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Tuesday, November 16, 2021 15:24
To: [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Yang, Stanley <[email protected]>; Quan, Evan <[email protected]>
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH] drm/amdgpu: support new mode-1 reset interface

If gpu reset is triggered by ras fatal error, tell it to smu in mode-1 reset message.

---
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 21 ++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +18 -4
index 35145db6eedf..6f3d064a8232 100644
@@ -1426,16 +1426,31 @@ int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)
 
 int smu_v13_0_mode1_reset(struct smu_context *smu)  {
-	u32 smu_version;
+	u32 smu_version, fatal_err, param;
 	int ret = 0;
+	struct amdgpu_device *adev = smu->adev;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	fatal_err = 0;
+	param = SMU_RESET_MODE_1;
+
 	/*
 	* PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
 	*/
 	smu_cmn_get_smc_version(smu, NULL, &smu_version);
 	if (smu_version < 0x00440700)
 		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
-	else
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_1, NULL);
+	else {
+		/* fatal error triggered by ras, PMFW supports the flag
+		   from 68.44.0 */
+		if ((smu_version >= 0x00442c00) && ras &&
+		    atomic_read(&ras->in_recovery))
+			fatal_err = 1;
+
+		param |= (fatal_err << 16);
+		ret = smu_cmn_send_smc_msg_with_param(smu,
+					SMU_MSG_GfxDeviceDriverReset, param, NULL);
+	}
 
 	if (!ret)
 		msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);
--

2.17.1

#2 lore raw
In reply to Tao Zhou
Quoted 30 lines · Tao Zhou

If gpu reset is triggered by ras fatal error, tell it to smu in mode-1 reset message.

---
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 21 ++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +7 -1
index 35145db6eedf..6f3d064a8232 100644
@@ -1426,16 +1426,31 @@ int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)
 
  int smu_v13_0_mode1_reset(struct smu_context *smu)
  {
-	u32 smu_version;
+	u32 smu_version, fatal_err, param;
  	int ret = 0;
+	struct amdgpu_device *adev = smu->adev;
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+
+	fatal_err = 0;
+	param = SMU_RESET_MODE_1;
+
  	/*
  	* PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
  	*/
  	smu_cmn_get_smc_version(smu, NULL, &smu_version);
  	if (smu_version < 0x00440700)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu) · line 1449

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +7 -2
  		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
-	else
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_1, NULL);
+	else {
+		/* fatal error triggered by ras, PMFW supports the flag
+		   from 68.44.0 */
+		if ((smu_version >= 0x00442c00) && ras &&
+		    atomic_read(&ras->in_recovery))
+			fatal_err = 1;
+

From PMFW version, this looks specific to aldebaran. Since there is version check as well, the implementation needs to be moved to aldebaran_ppt.c

Thanks,
Lijo

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
+		param |= (fatal_err << 16);
+		ret = smu_cmn_send_smc_msg_with_param(smu,
+					SMU_MSG_GfxDeviceDriverReset, param, NULL);
+	}
 
  	if (!ret)
  		msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);
author
#3 lore raw

[AMD Official Use Only]

Hi Lijo,

Your concern is reasonable, but in fact smu_v13_0_mode1_reset is used only by ALDEBARAN currently. I assume the PMFW of new smu v13 ASIC in the future will follow this design, otherwise we could move the implementation into xxx_ppt.c.

Regards,
Tao

Quoted 73 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, November 16, 2021 3:44 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Yang, Stanley <[email protected]>; Quan, Evan <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: support new mode-1 reset interface

Quoted 6 lines · Tao Zhou

If gpu reset is triggered by ras fatal error, tell it to smu in mode-1 reset message.

---
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 21

++++++++++++++++---

Quoted 17 lines
  1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +3 -1
index 35145db6eedf..6f3d064a8232 100644
@@ -1426,16 +1426,31 @@ int smu_v13_0_set_azalia_d3_pme(struct
 smu_context *smu)
 
  int smu_v13_0_mode1_reset(struct smu_context *smu)
  {
-   u32 smu_version;
+   u32 smu_version, fatal_err, param;
    int ret = 0;
+   struct amdgpu_device *adev = smu->adev;
+   struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct · line 1443

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
+
+   fatal_err = 0;
+   param = SMU_RESET_MODE_1;
+
    /*
    * PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
    */
    smu_cmn_get_smc_version(smu, NULL, &smu_version);
    if (smu_version < 0x00440700)
            ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset,

NULL);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct · line 1439

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -2
-   else
-           ret = smu_cmn_send_smc_msg_with_param(smu,

SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_1, NULL);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu) · line 1449

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +7 -0
+   else {
+           /* fatal error triggered by ras, PMFW supports the flag
+              from 68.44.0 */
+           if ((smu_version >= 0x00442c00) && ras &&
+               atomic_read(&ras->in_recovery))
+                   fatal_err = 1;
+

From PMFW version, this looks specific to aldebaran. Since there is version
check as well, the implementation needs to be moved to aldebaran_ppt.c

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +3 -0
+           param |= (fatal_err << 16);
+           ret = smu_cmn_send_smc_msg_with_param(smu,
+                                   SMU_MSG_GfxDeviceDriverReset,

param, NULL);

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -0
+   }
 
    if (!ret)
            msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);
#4 lore raw
Quoted 6 lines · Tao

[AMD Official Use Only]

Hi Lijo,

Your concern is reasonable, but in fact smu_v13_0_mode1_reset is used only by ALDEBARAN currently. I assume the PMFW of new smu v13 ASIC in the future will follow this design, otherwise we could move the implementation into xxx_ppt.c.

Actually, this is meant to be a common logic for SMU13 based ASICs. The version check in a common file is not maintainable. I see there is a version check before also, even that is not proper :)

It is better to do it properly when support is added rather than thinking of refactoring with future ASICs.

Thanks,
Lijo

Quoted 76 lines

Regards,
Tao

Quoted 73 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, November 16, 2021 3:44 PM
To: Zhou1, Tao <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Yang, Stanley <[email protected]>; Quan, Evan <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: support new mode-1 reset interface

Quoted 6 lines · Tao Zhou

If gpu reset is triggered by ras fatal error, tell it to smu in mode-1 reset message.

---
   .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 21

++++++++++++++++---

Quoted 17 lines
   1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +3 -1
index 35145db6eedf..6f3d064a8232 100644
@@ -1426,16 +1426,31 @@ int smu_v13_0_set_azalia_d3_pme(struct
 smu_context *smu)
 
   int smu_v13_0_mode1_reset(struct smu_context *smu)
   {
-   u32 smu_version;
+   u32 smu_version, fatal_err, param;
     int ret = 0;
+   struct amdgpu_device *adev = smu->adev;
+   struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct · line 1443

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -0
+
+   fatal_err = 0;
+   param = SMU_RESET_MODE_1;
+
     /*
     * PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
     */
     smu_cmn_get_smc_version(smu, NULL, &smu_version);
     if (smu_version < 0x00440700)
             ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset,

NULL);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct · line 1439

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -2
-   else
-           ret = smu_cmn_send_smc_msg_with_param(smu,

SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_1, NULL);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu) · line 1449

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +7 -0
+   else {
+           /* fatal error triggered by ras, PMFW supports the flag
+              from 68.44.0 */
+           if ((smu_version >= 0x00442c00) && ras &&
+               atomic_read(&ras->in_recovery))
+                   fatal_err = 1;
+

From PMFW version, this looks specific to aldebaran. Since there is version
check as well, the implementation needs to be moved to aldebaran_ppt.c

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +3 -0
+           param |= (fatal_err << 16);
+           ret = smu_cmn_send_smc_msg_with_param(smu,
+                                   SMU_MSG_GfxDeviceDriverReset,

param, NULL);

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -0
+   }
 
     if (!ret)
             msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);