Skip to contentSkip to conversation

Add ras cap query from psp

PATCH In review Hawking Zhang 3 participants 9 messages Jan 2, 2024

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

cover Add ras cap query from psp

Driver can query RAS capability through psp or bios.

Hawking Zhang (3):
drm/amdgpu: Align ras block enum with firmware drm/amdgpu: Query ras capablity from psp
drm/amdgpu: Centralize ras cap query to amdgpu_ras_check_supported

 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  13 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |   2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 170 +++++++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |   2 +
 drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  |  26 ++++
 5 files changed, 136 insertions(+), 77 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 drm/amdgpu: Align ras block enum with firmware

Driver and firmware share the same ras block enum.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index 5785b705c692..8b053602c5ca 100644
@@ -70,6 +70,8 @@ enum amdgpu_ras_block {
 	AMDGPU_RAS_BLOCK__MCA,
 	AMDGPU_RAS_BLOCK__VCN,
 	AMDGPU_RAS_BLOCK__JPEG,
+	AMDGPU_RAS_BLOCK__IH,
+	AMDGPU_RAS_BLOCK__MPIO,
 
 	AMDGPU_RAS_BLOCK__LAST
 };
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 drm/amdgpu: Query ras capablity from psp

In reply to Hawking Zhang

Instead of traditional atomfirmware interfaces for RAS capability, host driver can query ras capability from psp starting from psp v13_0_6.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  | 26 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +13 -0
index 94b536e3cada..8a3847d3041f 100644
@@ -2125,6 +2125,19 @@ int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev)
 	return ret;
 }
 
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp)
+{
+	bool ret;
+
+	if (psp->funcs &&
+	    psp->funcs->get_ras_capability) {
+		ret = psp->funcs->get_ras_capability(psp);
+		return ret;
+	} else {
+		return false;
+	}
+}
+
 static int psp_hw_start(struct psp_context *psp)
 {
 	struct amdgpu_device *adev = psp->adev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +2 -0
index 09d1f8f72a9c..652b0a01854a 100644
@@ -134,6 +134,7 @@ struct psp_funcs {
 	int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
 	int (*vbflash_stat)(struct psp_context *psp);
 	int (*fatal_error_recovery_quirk)(struct psp_context *psp);
+	bool (*get_ras_capability)(struct psp_context *psp);
 };
 
 struct ta_funcs {
@@ -537,4 +538,5 @@ int psp_spatial_partition(struct psp_context *psp, int mode);
 int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +26 -0
index 676bec2cc157..722b6066ce07 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_ucode.h"
 #include "soc15_common.h"
 #include "psp_v13_0.h"
+#include "amdgpu_ras.h"
 
 #include "mp/mp_13_0_2_offset.h"
 #include "mp/mp_13_0_2_sh_mask.h"
@@ -770,6 +771,30 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct psp_context *psp)
 	return 0;
 }
 
+static bool psp_v13_0_get_ras_capability(struct psp_context *psp)
+{
+	struct amdgpu_device *adev = psp->adev;
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+	u32 reg_data;
+
+	/* query ras cap should be done from host side */
+	if (amdgpu_sriov_vf(adev))
+		return false;
+
+	if (!con)
+		return false;
+
+	if ((amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) &&
+	    (!(adev->flags & AMD_IS_APU))) {
+		reg_data = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_127);
+		adev->ras_hw_enabled = (reg_data & GENMASK_ULL(23, 0));
+		con->poison_supported = ((reg_data & GENMASK_ULL(24, 24)) >> 24) ? true : false;
+		return true;
+	} else {
+		return false;
+	}
+}
+
 static const struct psp_funcs psp_v13_0_funcs = {
 	.init_microcode = psp_v13_0_init_microcode,
 	.wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -792,6 +817,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
 	.update_spirom = psp_v13_0_update_spirom,
 	.vbflash_stat = psp_v13_0_vbflash_status,
 	.fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk,
+	.get_ras_capability = psp_v13_0_get_ras_capability,
 };
 
 void psp_v13_0_set_psp_funcs(struct psp_context *psp)
Signature · 1 line
2.17.1
#3 lore raw

RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

-----Original Message-----
From: Hawking Zhang <[email protected]>
Sent: Tuesday, January 2, 2024 11:45 AM
To: [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

Instead of traditional atomfirmware interfaces for RAS capability, host driver can query ras capability from psp starting from psp v13_0_6.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++  drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  | 26 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
index 94b536e3cada..8a3847d3041f 100644
@@ -2125,6 +2125,19 @@ int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev)
        return ret;
 }
 
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp) {
+       bool ret;
+
+       if (psp->funcs &&
+           psp->funcs->get_ras_capability) {
+               ret = psp->funcs->get_ras_capability(psp);
+               return ret;

[kevin]:
This variable 'ret' seems to have no other purpose, can we remove it and return directly ?

Best Regards,
Kevin
+ } else {
+ return false;
+ }
+}
+

 static int psp_hw_start(struct psp_context *psp)  {
        struct amdgpu_device *adev = psp->adev; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h

index 09d1f8f72a9c..652b0a01854a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +2 -0
@@ -134,6 +134,7 @@ struct psp_funcs {
        int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
        int (*vbflash_stat)(struct psp_context *psp);
        int (*fatal_error_recovery_quirk)(struct psp_context *psp);
+       bool (*get_ras_capability)(struct psp_context *psp);
 };
 
 struct ta_funcs {
@@ -537,4 +538,5 @@ int psp_spatial_partition(struct psp_context *psp, int mode);  int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +25 -0
index 676bec2cc157..722b6066ce07 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_ucode.h"
 #include "soc15_common.h"
 #include "psp_v13_0.h"
+#include "amdgpu_ras.h"
 
 #include "mp/mp_13_0_2_offset.h"
 #include "mp/mp_13_0_2_sh_mask.h"
@@ -770,6 +771,30 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct psp_context *psp)
        return 0;
 }
 
+static bool psp_v13_0_get_ras_capability(struct psp_context *psp) {
+       struct amdgpu_device *adev = psp->adev;
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       u32 reg_data;
+
+       /* query ras cap should be done from host side */
+       if (amdgpu_sriov_vf(adev))
+               return false;
+
+       if (!con)
+               return false;
+
+       if ((amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) &&
+           (!(adev->flags & AMD_IS_APU))) {
+               reg_data = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_127);
+               adev->ras_hw_enabled = (reg_data & GENMASK_ULL(23, 0));
+               con->poison_supported = ((reg_data & GENMASK_ULL(24, 24)) >> 24) ? true : false;
+               return true;
+       } else {
+               return false;
+       }
+}
+
 static const struct psp_funcs psp_v13_0_funcs = {
        .init_microcode = psp_v13_0_init_microcode,
        .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -792,6 +817,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
        .update_spirom = psp_v13_0_update_spirom,
        .vbflash_stat = psp_v13_0_vbflash_status,
        .fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk,
+       .get_ras_capability = psp_v13_0_get_ras_capability,
 };
 
 void psp_v13_0_set_psp_funcs(struct psp_context *psp)

--
2.17.1

#4 lore raw

RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

The ret gives us a chance to fallback to legacy query approach (from vbios).

You might want to see patch #3 of the series for more details, go to the following lines in patch #3

+ /* query ras capability from psp */
+ if (amdgpu_psp_get_ras_capability(&adev->psp))
+ goto init_ras_enabled_flag;

Regards,
Hawking

-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, January 2, 2024 13:19
To: Zhang, Hawking <[email protected]>; [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

-----Original Message-----
From: Hawking Zhang <[email protected]>
Sent: Tuesday, January 2, 2024 11:45 AM
To: [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

Instead of traditional atomfirmware interfaces for RAS capability, host driver can query ras capability from psp starting from psp v13_0_6.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++  drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  | 26 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
index 94b536e3cada..8a3847d3041f 100644
@@ -2125,6 +2125,19 @@ int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev)
        return ret;
 }
 
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp) {
+       bool ret;
+
+       if (psp->funcs &&
+           psp->funcs->get_ras_capability) {
+               ret = psp->funcs->get_ras_capability(psp);
+               return ret;

[kevin]:
This variable 'ret' seems to have no other purpose, can we remove it and return directly ?

Best Regards,
Kevin
+ } else {
+ return false;
+ }
+}
+

 static int psp_hw_start(struct psp_context *psp)  {
        struct amdgpu_device *adev = psp->adev; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h

index 09d1f8f72a9c..652b0a01854a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +2 -0
@@ -134,6 +134,7 @@ struct psp_funcs {
        int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
        int (*vbflash_stat)(struct psp_context *psp);
        int (*fatal_error_recovery_quirk)(struct psp_context *psp);
+       bool (*get_ras_capability)(struct psp_context *psp);
 };
 
 struct ta_funcs {
@@ -537,4 +538,5 @@ int psp_spatial_partition(struct psp_context *psp, int mode);  int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +25 -0
index 676bec2cc157..722b6066ce07 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_ucode.h"
 #include "soc15_common.h"
 #include "psp_v13_0.h"
+#include "amdgpu_ras.h"
 
 #include "mp/mp_13_0_2_offset.h"
 #include "mp/mp_13_0_2_sh_mask.h"
@@ -770,6 +771,30 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct psp_context *psp)
        return 0;
 }
 
+static bool psp_v13_0_get_ras_capability(struct psp_context *psp) {
+       struct amdgpu_device *adev = psp->adev;
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       u32 reg_data;
+
+       /* query ras cap should be done from host side */
+       if (amdgpu_sriov_vf(adev))
+               return false;
+
+       if (!con)
+               return false;
+
+       if ((amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) &&
+           (!(adev->flags & AMD_IS_APU))) {
+               reg_data = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_127);
+               adev->ras_hw_enabled = (reg_data & GENMASK_ULL(23, 0));
+               con->poison_supported = ((reg_data & GENMASK_ULL(24, 24)) >> 24) ? true : false;
+               return true;
+       } else {
+               return false;
+       }
+}
+
 static const struct psp_funcs psp_v13_0_funcs = {
        .init_microcode = psp_v13_0_init_microcode,
        .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -792,6 +817,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
        .update_spirom = psp_v13_0_update_spirom,
        .vbflash_stat = psp_v13_0_vbflash_status,
        .fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk,
+       .get_ras_capability = psp_v13_0_get_ras_capability,
 };
 
 void psp_v13_0_set_psp_funcs(struct psp_context *psp)

--
2.17.1

#5 lore raw

RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

Quoted 69 lines

-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Tuesday, January 2, 2024 1:38 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

The ret gives us a chance to fallback to legacy query approach (from vbios).

You might want to see patch #3 of the series for more details, go to the following lines in patch #3

(quoted diff) +3 -0
+       /* query ras capability from psp */
+       if (amdgpu_psp_get_ras_capability(&adev->psp))
+               goto init_ras_enabled_flag;

Regards,
Hawking

-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, January 2, 2024 13:19
To: Zhang, Hawking <[email protected]>; [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

-----Original Message-----
From: Hawking Zhang <[email protected]>
Sent: Tuesday, January 2, 2024 11:45 AM
To: [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

Instead of traditional atomfirmware interfaces for RAS capability, host driver can query ras capability from psp starting from psp v13_0_6.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  | 26 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index 94b536e3cada..8a3847d3041f 100644
@@ -2125,6 +2125,19 @@ int amdgpu_psp_wait_for_bootloader(struct
 amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c int amdgpu_psp_wait_for_bootloader(struct · line 2135

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
        return ret;
 }
 
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp) {
+       bool ret;
+
+       if (psp->funcs &&
+           psp->funcs->get_ras_capability) {
+               ret = psp->funcs->get_ras_capability(psp);
+               return ret;

[Tao] I think the code can be simplified as:

return psp->funcs->get_ras_capability(psp);

and drop the ret variable.

Quoted 89 lines

[kevin]:
This variable 'ret' seems to have no other purpose, can we remove it and return directly ?

Best Regards,
Kevin

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -0
+       } else {
+               return false;
+       }
+}
+
 static int psp_hw_start(struct psp_context *psp)  {
        struct amdgpu_device *adev = psp->adev; diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 09d1f8f72a9c..652b0a01854a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +2 -0
@@ -134,6 +134,7 @@ struct psp_funcs {
        int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
        int (*vbflash_stat)(struct psp_context *psp);
        int (*fatal_error_recovery_quirk)(struct psp_context *psp);
+       bool (*get_ras_capability)(struct psp_context *psp);
 };
 
 struct ta_funcs {
@@ -537,4 +538,5 @@ int psp_spatial_partition(struct psp_context *psp, int
 mode);  int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +25 -1
index 676bec2cc157..722b6066ce07 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_ucode.h"
 #include "soc15_common.h"
 #include "psp_v13_0.h"
+#include "amdgpu_ras.h"
 
 #include "mp/mp_13_0_2_offset.h"
 #include "mp/mp_13_0_2_sh_mask.h"
@@ -770,6 +771,30 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct
 psp_context *psp)
        return 0;
 }
 
+static bool psp_v13_0_get_ras_capability(struct psp_context *psp) {
+       struct amdgpu_device *adev = psp->adev;
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       u32 reg_data;
+
+       /* query ras cap should be done from host side */
+       if (amdgpu_sriov_vf(adev))
+               return false;
+
+       if (!con)
+               return false;
+
+       if ((amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) &&
+           (!(adev->flags & AMD_IS_APU))) {
+               reg_data = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_127);
+               adev->ras_hw_enabled = (reg_data & GENMASK_ULL(23, 0));
+               con->poison_supported = ((reg_data & GENMASK_ULL(24, 24)) >> 24) ?
 true : false;
+               return true;
+       } else {
+               return false;
+       }
+}
+
 static const struct psp_funcs psp_v13_0_funcs = {
        .init_microcode = psp_v13_0_init_microcode,
        .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -792,6 +817,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
        .update_spirom = psp_v13_0_update_spirom,
        .vbflash_stat = psp_v13_0_vbflash_status,
        .fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk,
+       .get_ras_capability = psp_v13_0_get_ras_capability,
 };
 
 void psp_v13_0_set_psp_funcs(struct psp_context *psp)
--

2.17.1

#6 lore raw

RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

Oh, that's good point. I guess Kevin mentioned the same thing. Yes. Returning directly is reasonable to me.

Regards,
Hawking

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Tuesday, January 2, 2024 16:49
To: Zhang, Hawking <[email protected]>; Wang, Yang(Kevin) <[email protected]>; [email protected]; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

Quoted 70 lines

-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Tuesday, January 2, 2024 1:38 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

The ret gives us a chance to fallback to legacy query approach (from vbios).

You might want to see patch #3 of the series for more details, go to the following lines in patch #3

(quoted diff) +3 -0
+       /* query ras capability from psp */
+       if (amdgpu_psp_get_ras_capability(&adev->psp))
+               goto init_ras_enabled_flag;

Regards,
Hawking

-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, January 2, 2024 13:19
To: Zhang, Hawking <[email protected]>; [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

[AMD Official Use Only - General]

-----Original Message-----
From: Hawking Zhang <[email protected]>
Sent: Tuesday, January 2, 2024 11:45 AM
To: [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Query ras capablity from psp

Instead of traditional atomfirmware interfaces for RAS capability, host driver can query ras capability from psp starting from psp v13_0_6.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  2 ++
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c  | 26 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index 94b536e3cada..8a3847d3041f 100644
@@ -2125,6 +2125,19 @@ int amdgpu_psp_wait_for_bootloader(struct
 amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c int amdgpu_psp_wait_for_bootloader(struct · line 2135

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
        return ret;
 }
 
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp) {
+       bool ret;
+
+       if (psp->funcs &&
+           psp->funcs->get_ras_capability) {
+               ret = psp->funcs->get_ras_capability(psp);
+               return ret;

[Tao] I think the code can be simplified as:

return psp->funcs->get_ras_capability(psp);

and drop the ret variable.

Quoted 92 lines

[kevin]:
This variable 'ret' seems to have no other purpose, can we remove it and return directly ?

Best Regards,
Kevin

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -0
+       } else {
+               return false;
+       }
+}
+
 static int psp_hw_start(struct psp_context *psp)  {
        struct amdgpu_device *adev = psp->adev; diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 09d1f8f72a9c..652b0a01854a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +2 -0
@@ -134,6 +134,7 @@ struct psp_funcs {
        int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
        int (*vbflash_stat)(struct psp_context *psp);
        int (*fatal_error_recovery_quirk)(struct psp_context *psp);
+       bool (*get_ras_capability)(struct psp_context *psp);
 };
 
 struct ta_funcs {
@@ -537,4 +538,5 @@ int psp_spatial_partition(struct psp_context *psp,
 int mode);  int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
+bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +1 -0
index 676bec2cc157..722b6066ce07 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_ucode.h"
 #include "soc15_common.h"
 #include "psp_v13_0.h"
+#include "amdgpu_ras.h"
 
 #include "mp/mp_13_0_2_offset.h"
 #include "mp/mp_13_0_2_sh_mask.h"
@@ -770,6 +771,30 @@ static int

psp_v13_0_fatal_error_recovery_quirk(struct
psp_context *psp)

        return 0;

}

drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +17 -0
+static bool psp_v13_0_get_ras_capability(struct psp_context *psp) {
+       struct amdgpu_device *adev = psp->adev;
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       u32 reg_data;
+
+       /* query ras cap should be done from host side */
+       if (amdgpu_sriov_vf(adev))
+               return false;
+
+       if (!con)
+               return false;
+
+       if ((amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) &&
+           (!(adev->flags & AMD_IS_APU))) {
+               reg_data = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_127);
+               adev->ras_hw_enabled = (reg_data & GENMASK_ULL(23, 0));
+               con->poison_supported = ((reg_data & GENMASK_ULL(24, 24)) >> 24) ?

true : false;

drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +6 -0
+               return true;
+       } else {
+               return false;
+       }
+}
+
 static const struct psp_funcs psp_v13_0_funcs = {
        .init_microcode = psp_v13_0_init_microcode,
        .wait_for_bootloader =

psp_v13_0_wait_for_bootloader_steady_state,

drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +1 -0
@@ -792,6 +817,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
        .update_spirom = psp_v13_0_update_spirom,
        .vbflash_stat = psp_v13_0_vbflash_status,
        .fatal_error_recovery_quirk =
 psp_v13_0_fatal_error_recovery_quirk,
+       .get_ras_capability = psp_v13_0_get_ras_capability,
 };
 

void psp_v13_0_set_psp_funcs(struct psp_context *psp)
--
2.17.1

#7 lore raw

PATCH 3/3 drm/amdgpu: Centralize ras cap query to amdgpu_ras_check_supported

In reply to Hawking Zhang

Move ras capablity check to amdgpu_ras_check_supported. Driver will query ras capablity through psp interace, or vbios interface, or specific ip callbacks.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 170 +++++++++++++-----------
 1 file changed, 93 insertions(+), 77 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +93 -77
index 5f302b7693b3..72b6e41329b0 100644
@@ -39,6 +39,7 @@
 #include "nbio_v7_9.h"
 #include "atom.h"
 #include "amdgpu_reset.h"
+#include "amdgpu_psp.h"
 
 #ifdef CONFIG_X86_MCE_AMD
 #include <asm/mce.h>
@@ -2680,6 +2681,87 @@ static void amdgpu_ras_get_quirks(struct amdgpu_device *adev)
 		adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__GFX);
 }
 
+/* Query ras capablity via atomfirmware interface */
+static void amdgpu_ras_query_ras_capablity_from_vbios(struct amdgpu_device *adev)
+{
+	/* mem_ecc cap */
+	if (amdgpu_atomfirmware_mem_ecc_supported(adev)) {
+		dev_info(adev->dev, "MEM ECC is active.\n");
+		adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__UMC |
+					 1 << AMDGPU_RAS_BLOCK__DF);
+	} else {
+		dev_info(adev->dev, "MEM ECC is not presented.\n");
+	}
+
+	/* sram_ecc cap */
+	if (amdgpu_atomfirmware_sram_ecc_supported(adev)) {
+		dev_info(adev->dev, "SRAM ECC is active.\n");
+		if (!amdgpu_sriov_vf(adev))
+			adev->ras_hw_enabled |= ~(1 << AMDGPU_RAS_BLOCK__UMC |
+						  1 << AMDGPU_RAS_BLOCK__DF);
+		else
+			adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__PCIE_BIF |
+						 1 << AMDGPU_RAS_BLOCK__SDMA |
+						 1 << AMDGPU_RAS_BLOCK__GFX);
+
+		/*
+		 * VCN/JPEG RAS can be supported on both bare metal and
+		 * SRIOV environment
+		 */
+		if (amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(2, 6, 0) ||
+		    amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(4, 0, 0) ||
+		    amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(4, 0, 3))
+			adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__VCN |
+						 1 << AMDGPU_RAS_BLOCK__JPEG);
+		else
+			adev->ras_hw_enabled &= ~(1 << AMDGPU_RAS_BLOCK__VCN |
+						  1 << AMDGPU_RAS_BLOCK__JPEG);
+
+		/*
+		 * XGMI RAS is not supported if xgmi num physical nodes
+		 * is zero
+		 */
+		if (!adev->gmc.xgmi.num_physical_nodes)
+			adev->ras_hw_enabled &= ~(1 << AMDGPU_RAS_BLOCK__XGMI_WAFL);
+	} else {
+		dev_info(adev->dev, "SRAM ECC is not presented.\n");
+	}
+}
+
+/* Query poison mode from umc/df IP callbacks */
+static void amdgpu_ras_query_poison_mode(struct amdgpu_device *adev)
+{
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+	bool df_poison, umc_poison;
+
+	/* poison setting is useless on SRIOV guest */
+	if (amdgpu_sriov_vf(adev) || !con)
+		return;
+
+	/* Init poison supported flag, the default value is false */
+	if (adev->gmc.xgmi.connected_to_cpu ||
+	    adev->gmc.is_app_apu) {
+		/* enabled by default when GPU is connected to CPU */
+		con->poison_supported = true;
+	} else if (adev->df.funcs &&
+	    adev->df.funcs->query_ras_poison_mode &&
+	    adev->umc.ras &&
+	    adev->umc.ras->query_ras_poison_mode) {
+		df_poison =
+			adev->df.funcs->query_ras_poison_mode(adev);
+		umc_poison =
+			adev->umc.ras->query_ras_poison_mode(adev);
+
+		/* Only poison is set in both DF and UMC, we can support it */
+		if (df_poison && umc_poison)
+			con->poison_supported = true;
+		else if (df_poison != umc_poison)
+			dev_warn(adev->dev,
+				"Poison setting is inconsistent in DF/UMC(%d:%d)!\n",
+				df_poison, umc_poison);
+	}
+}
+
 /*
  * check hardware's ras ability which will be saved in hw_supported.
  * if hardware does not support ras, we can skip some ras initializtion and
@@ -2696,49 +2778,13 @@ static void amdgpu_ras_check_supported(struct amdgpu_device *adev)
 	if (!amdgpu_ras_asic_supported(adev))
 		return;
 
-	if (!adev->gmc.xgmi.connected_to_cpu &&	!adev->gmc.is_app_apu) {
-		if (amdgpu_atomfirmware_mem_ecc_supported(adev)) {
-			dev_info(adev->dev, "MEM ECC is active.\n");
-			adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__UMC |
-						   1 << AMDGPU_RAS_BLOCK__DF);
-		} else {
-			dev_info(adev->dev, "MEM ECC is not presented.\n");
-		}
-
-		if (amdgpu_atomfirmware_sram_ecc_supported(adev)) {
-			dev_info(adev->dev, "SRAM ECC is active.\n");
-			if (!amdgpu_sriov_vf(adev))
-				adev->ras_hw_enabled |= ~(1 << AMDGPU_RAS_BLOCK__UMC |
-							    1 << AMDGPU_RAS_BLOCK__DF);
-			else
-				adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__PCIE_BIF |
-								1 << AMDGPU_RAS_BLOCK__SDMA |
-								1 << AMDGPU_RAS_BLOCK__GFX);
-
-			/* VCN/JPEG RAS can be supported on both bare metal and
-			 * SRIOV environment
-			 */
-			if (amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-				    IP_VERSION(2, 6, 0) ||
-			    amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-				    IP_VERSION(4, 0, 0) ||
-			    amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-				    IP_VERSION(4, 0, 3))
-				adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__VCN |
-							1 << AMDGPU_RAS_BLOCK__JPEG);
-			else
-				adev->ras_hw_enabled &= ~(1 << AMDGPU_RAS_BLOCK__VCN |
-							1 << AMDGPU_RAS_BLOCK__JPEG);
+	/* query ras capability from psp */
+	if (amdgpu_psp_get_ras_capability(&adev->psp))
+		goto init_ras_enabled_flag;
 
-			/*
-			 * XGMI RAS is not supported if xgmi num physical nodes
-			 * is zero
-			 */
-			if (!adev->gmc.xgmi.num_physical_nodes)
-				adev->ras_hw_enabled &= ~(1 << AMDGPU_RAS_BLOCK__XGMI_WAFL);
-		} else {
-			dev_info(adev->dev, "SRAM ECC is not presented.\n");
-		}
+	/* query ras capablity from bios */
+	if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) {
+		amdgpu_ras_query_ras_capablity_from_vbios(adev);
 	} else {
 		/* driver only manages a few IP blocks RAS feature
 		 * when GPU is connected cpu through XGMI */
@@ -2747,8 +2793,13 @@ static void amdgpu_ras_check_supported(struct amdgpu_device *adev)
 					   1 << AMDGPU_RAS_BLOCK__MMHUB);
 	}
 
+	/* apply asic specific settings (vega20 only for now) */
 	amdgpu_ras_get_quirks(adev);
 
+	/* query poison mode from umc/df ip callback */
+	amdgpu_ras_query_poison_mode(adev);
+
+init_ras_enabled_flag:
 	/* hw_supported needs to be aligned with RAS block mask. */
 	adev->ras_hw_enabled &= AMDGPU_RAS_BLOCK_MASK;
 
@@ -2781,39 +2832,6 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
 	pm_runtime_put_autosuspend(dev->dev);
 }
 
-static void amdgpu_ras_query_poison_mode(struct amdgpu_device *adev)
-{
-	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
-	bool df_poison, umc_poison;
-
-	/* poison setting is useless on SRIOV guest */
-	if (amdgpu_sriov_vf(adev) || !con)
-		return;
-
-	/* Init poison supported flag, the default value is false */
-	if (adev->gmc.xgmi.connected_to_cpu ||
-	    adev->gmc.is_app_apu) {
-		/* enabled by default when GPU is connected to CPU */
-		con->poison_supported = true;
-	} else if (adev->df.funcs &&
-	    adev->df.funcs->query_ras_poison_mode &&
-	    adev->umc.ras &&
-	    adev->umc.ras->query_ras_poison_mode) {
-		df_poison =
-			adev->df.funcs->query_ras_poison_mode(adev);
-		umc_poison =
-			adev->umc.ras->query_ras_poison_mode(adev);
-
-		/* Only poison is set in both DF and UMC, we can support it */
-		if (df_poison && umc_poison)
-			con->poison_supported = true;
-		else if (df_poison != umc_poison)
-			dev_warn(adev->dev,
-				"Poison setting is inconsistent in DF/UMC(%d:%d)!\n",
-				df_poison, umc_poison);
-	}
-}
-
 static int amdgpu_get_ras_schema(struct amdgpu_device *adev)
 {
 	return  amdgpu_ras_is_poison_mode_supported(adev) ? AMDGPU_RAS_ERROR__POISON : 0 |
@@ -2918,8 +2936,6 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
 			goto release_con;
 	}
 
-	amdgpu_ras_query_poison_mode(adev);
-
 	/* Get RAS schema for particular SOC */
 	con->schema = amdgpu_get_ras_schema(adev);
 
Signature · 1 line
2.17.1
Reviewed-by on v1 3/3
#8 lore raw

RE: [PATCH 3/3] drm/amdgpu: Centralize ras cap query to amdgpu_ras_check_supported

[AMD Official Use Only - General]

The series is:

Quoted 275 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Hawking Zhang
Sent: Tuesday, January 2, 2024 11:45 AM
To: [email protected]; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Chai, Thomas <[email protected]>; Li, Candice <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Ma, Le <[email protected]>; Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu: Centralize ras cap query to amdgpu_ras_check_supported

Move ras capablity check to amdgpu_ras_check_supported.
Driver will query ras capablity through psp interace, or vbios interface, or specific ip callbacks.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 170 +++++++++++++-----------
 1 file changed, 93 insertions(+), 77 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +17 -0
index 5f302b7693b3..72b6e41329b0 100644
@@ -39,6 +39,7 @@
 #include "nbio_v7_9.h"
 #include "atom.h"
 #include "amdgpu_reset.h"
+#include "amdgpu_psp.h"
 
 #ifdef CONFIG_X86_MCE_AMD
 #include <asm/mce.h>
@@ -2680,6 +2681,87 @@ static void amdgpu_ras_get_quirks(struct
 amdgpu_device *adev)
              adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__GFX);  }
 
+/* Query ras capablity via atomfirmware interface */ static void
+amdgpu_ras_query_ras_capablity_from_vbios(struct amdgpu_device *adev) {
+     /* mem_ecc cap */
+     if (amdgpu_atomfirmware_mem_ecc_supported(adev)) {
+             dev_info(adev->dev, "MEM ECC is active.\n");
+             adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__UMC |
+                                      1 << AMDGPU_RAS_BLOCK__DF);
+     } else {
+             dev_info(adev->dev, "MEM ECC is not presented.\n");
+     }
+
+     /* sram_ecc cap */
+     if (amdgpu_atomfirmware_sram_ecc_supported(adev)) {
+             dev_info(adev->dev, "SRAM ECC is active.\n");
+             if (!amdgpu_sriov_vf(adev))
+                     adev->ras_hw_enabled |= ~(1 <<

AMDGPU_RAS_BLOCK__UMC |
+ 1 <<
AMDGPU_RAS_BLOCK__DF);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+             else
+                     adev->ras_hw_enabled |= (1 <<

AMDGPU_RAS_BLOCK__PCIE_BIF |
+ 1 <<
AMDGPU_RAS_BLOCK__SDMA |
+ 1 <<
AMDGPU_RAS_BLOCK__GFX);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -0
+
+             /*
+              * VCN/JPEG RAS can be supported on both bare metal and
+              * SRIOV environment
+              */
+             if (amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(2, 6,

0) ||
+ amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(4, 0,
0) ||
+ amdgpu_ip_version(adev, VCN_HWIP, 0) == IP_VERSION(4, 0,
3))
+ adev->ras_hw_enabled |= (1 <<
AMDGPU_RAS_BLOCK__VCN |
+ 1 <<
AMDGPU_RAS_BLOCK__JPEG);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
+             else
+                     adev->ras_hw_enabled &= ~(1 <<

AMDGPU_RAS_BLOCK__VCN |
+ 1 <<
AMDGPU_RAS_BLOCK__JPEG);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -0
+
+             /*
+              * XGMI RAS is not supported if xgmi num physical nodes
+              * is zero
+              */
+             if (!adev->gmc.xgmi.num_physical_nodes)
+                     adev->ras_hw_enabled &= ~(1 <<

AMDGPU_RAS_BLOCK__XGMI_WAFL);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +34 -0
+     } else {
+             dev_info(adev->dev, "SRAM ECC is not presented.\n");
+     }
+}
+
+/* Query poison mode from umc/df IP callbacks */ static void
+amdgpu_ras_query_poison_mode(struct amdgpu_device *adev) {
+     struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+     bool df_poison, umc_poison;
+
+     /* poison setting is useless on SRIOV guest */
+     if (amdgpu_sriov_vf(adev) || !con)
+             return;
+
+     /* Init poison supported flag, the default value is false */
+     if (adev->gmc.xgmi.connected_to_cpu ||
+         adev->gmc.is_app_apu) {
+             /* enabled by default when GPU is connected to CPU */
+             con->poison_supported = true;
+     } else if (adev->df.funcs &&
+         adev->df.funcs->query_ras_poison_mode &&
+         adev->umc.ras &&
+         adev->umc.ras->query_ras_poison_mode) {
+             df_poison =
+                     adev->df.funcs->query_ras_poison_mode(adev);
+             umc_poison =
+                     adev->umc.ras->query_ras_poison_mode(adev);
+
+             /* Only poison is set in both DF and UMC, we can support it */
+             if (df_poison && umc_poison)
+                     con->poison_supported = true;
+             else if (df_poison != umc_poison)
+                     dev_warn(adev->dev,
+                             "Poison setting is inconsistent in

DF/UMC(%d:%d)!\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+                             df_poison, umc_poison);
+     }
+}
+
 /*
  * check hardware's ras ability which will be saved in hw_supported.
  * if hardware does not support ras, we can skip some ras initializtion and @@ -

2696,49 +2778,13 @@ static void amdgpu_ras_check_supported(struct amdgpu_device *adev)

      if (!amdgpu_ras_asic_supported(adev))
              return;

- if (!adev->gmc.xgmi.connected_to_cpu && !adev-

Quoted 1 line

gmc.is_app_apu) {

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
-             if (amdgpu_atomfirmware_mem_ecc_supported(adev)) {
-                     dev_info(adev->dev, "MEM ECC is active.\n");
-                     adev->ras_hw_enabled |= (1 <<

AMDGPU_RAS_BLOCK__UMC |
- 1 <<
AMDGPU_RAS_BLOCK__DF);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -8
-             } else {
-                     dev_info(adev->dev, "MEM ECC is not presented.\n");
-             }
-
-             if (amdgpu_atomfirmware_sram_ecc_supported(adev)) {
-                     dev_info(adev->dev, "SRAM ECC is active.\n");
-                     if (!amdgpu_sriov_vf(adev))
-                             adev->ras_hw_enabled |= ~(1 <<

AMDGPU_RAS_BLOCK__UMC |
- 1 <<
AMDGPU_RAS_BLOCK__DF);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-                     else
-                             adev->ras_hw_enabled |= (1 <<

AMDGPU_RAS_BLOCK__PCIE_BIF |
- 1 <<
AMDGPU_RAS_BLOCK__SDMA |
- 1 <<
AMDGPU_RAS_BLOCK__GFX);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-
-                     /* VCN/JPEG RAS can be supported on both bare metal

and

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -9
-                      * SRIOV environment
-                      */
-                     if (amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-                                 IP_VERSION(2, 6, 0) ||
-                         amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-                                 IP_VERSION(4, 0, 0) ||
-                         amdgpu_ip_version(adev, VCN_HWIP, 0) ==
-                                 IP_VERSION(4, 0, 3))
-                             adev->ras_hw_enabled |= (1 <<

AMDGPU_RAS_BLOCK__VCN |
- 1 <<
AMDGPU_RAS_BLOCK__JPEG);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -2
-                     else
-                             adev->ras_hw_enabled &= ~(1 <<

AMDGPU_RAS_BLOCK__VCN |
- 1 <<
AMDGPU_RAS_BLOCK__JPEG);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -6
+     /* query ras capability from psp */
+     if (amdgpu_psp_get_ras_capability(&adev->psp))
+             goto init_ras_enabled_flag;
 
-                     /*
-                      * XGMI RAS is not supported if xgmi num physical nodes
-                      * is zero
-                      */
-                     if (!adev->gmc.xgmi.num_physical_nodes)
-                             adev->ras_hw_enabled &= ~(1 <<

AMDGPU_RAS_BLOCK__XGMI_WAFL);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -3
-             } else {
-                     dev_info(adev->dev, "SRAM ECC is not presented.\n");
-             }
+     /* query ras capablity from bios */
+     if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) {
+             amdgpu_ras_query_ras_capablity_from_vbios(adev);
      } else {
              /* driver only manages a few IP blocks RAS feature
               * when GPU is connected cpu through XGMI */ @@ -2747,8
+2793,13 @@ static void amdgpu_ras_check_supported(struct amdgpu_device

*adev)

                                         1 <<
AMDGPU_RAS_BLOCK__MMHUB);
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -32
+     /* apply asic specific settings (vega20 only for now) */
      amdgpu_ras_get_quirks(adev);
 
+     /* query poison mode from umc/df ip callback */
+     amdgpu_ras_query_poison_mode(adev);
+
+init_ras_enabled_flag:
      /* hw_supported needs to be aligned with RAS block mask. */
      adev->ras_hw_enabled &= AMDGPU_RAS_BLOCK_MASK;
@@ -2781,39 +2832,6 @@ static void amdgpu_ras_counte_dw(struct
 work_struct *work)
      pm_runtime_put_autosuspend(dev->dev);
 }
 
-static void amdgpu_ras_query_poison_mode(struct amdgpu_device *adev) -{
-     struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
-     bool df_poison, umc_poison;
-
-     /* poison setting is useless on SRIOV guest */
-     if (amdgpu_sriov_vf(adev) || !con)
-             return;
-
-     /* Init poison supported flag, the default value is false */
-     if (adev->gmc.xgmi.connected_to_cpu ||
-         adev->gmc.is_app_apu) {
-             /* enabled by default when GPU is connected to CPU */
-             con->poison_supported = true;
-     } else if (adev->df.funcs &&
-         adev->df.funcs->query_ras_poison_mode &&
-         adev->umc.ras &&
-         adev->umc.ras->query_ras_poison_mode) {
-             df_poison =
-                     adev->df.funcs->query_ras_poison_mode(adev);
-             umc_poison =
-                     adev->umc.ras->query_ras_poison_mode(adev);
-
-             /* Only poison is set in both DF and UMC, we can support it */
-             if (df_poison && umc_poison)
-                     con->poison_supported = true;
-             else if (df_poison != umc_poison)
-                     dev_warn(adev->dev,
-                             "Poison setting is inconsistent in
 DF/UMC(%d:%d)!\n",
-                             df_poison, umc_poison);
-     }
-}
-
 static int amdgpu_get_ras_schema(struct amdgpu_device *adev)  {
      return  amdgpu_ras_is_poison_mode_supported(adev) ?

AMDGPU_RAS_ERROR__POISON : 0 | @@ -2918,8 +2936,6 @@ int amdgpu_ras_init(struct amdgpu_device *adev)

                      goto release_con;
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
-     amdgpu_ras_query_poison_mode(adev);
-
      /* Get RAS schema for particular SOC */
      con->schema = amdgpu_get_ras_schema(adev);
 
--

2.17.1