Skip to contentSkip to conversation

*** Add PSP ECC support for Vega10 ***

PATCH In review Junwei Zhang 2 participants 9 messages Jul 28, 2017 – Jul 31, 2017 4 messages not in the archive

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

cover *** Add PSP ECC support for Vega10 ***

Junwei Zhang (3):
drm/amdgpu: add psp bootloader command list
drm/amdgpu: add psp ecc support
drm/amdgpu: add psp ecc support for vega10

 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 20 +++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 32 +++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 64 +++++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.h   |  2 ++
 4 files changed, 113 insertions(+), 5 deletions(-)
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1501233079-24235-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/3 drm/amdgpu: add psp bootloader command list

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +10 -0
index 538fa9d..3776186 100644
@@ -53,6 +53,16 @@ struct psp_ring
 	uint32_t			ring_size;
 };
 
+enum psp_bootloader_command_list
+{
+	PSP_BL__LOAD_SYSDRV = 0x10000,
+	PSP_BL__LOAD_SOSDRV = 0x20000,
+	PSP_BL__NO_ECC      = 0x30000,
+	PSP_BL__PARTIAL_ECC = 0x30001,
+	PSP_BL__FULL_ECC    = 0x30002,
+	PSP_BL__DEFAULT_ECC = 0x30003,
+};
+
 struct psp_context
 {
 	struct amdgpu_device            *adev;
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +2 -2
index 2718e86..f93a66e 100644
@@ -190,7 +190,7 @@ int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
 	/* Provide the sys driver to bootrom */
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
 	       (uint32_t)(psp->fw_pri_mc_addr >> 20));
-	psp_gfxdrv_command_reg = 1 << 16;
+	psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
 	       psp_gfxdrv_command_reg);
 
@@ -231,7 +231,7 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
 	/* Provide the PSP secure OS to bootrom */
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
 	       (uint32_t)(psp->fw_pri_mc_addr >> 20));
-	psp_gfxdrv_command_reg = 2 << 16;
+	psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
 	       psp_gfxdrv_command_reg);
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1501233079-24235-2-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH 1/3] drm/amdgpu: add psp bootloader command list

Quoted 2 lines · Junwei Zhang

---

Quoted 54 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 10 ++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +10 -0
index 538fa9d..3776186 100644
@@ -53,6 +53,16 @@ struct psp_ring
 	uint32_t			ring_size;
 };
 
+enum psp_bootloader_command_list
+{
+	PSP_BL__LOAD_SYSDRV = 0x10000,
+	PSP_BL__LOAD_SOSDRV = 0x20000,
+	PSP_BL__NO_ECC      = 0x30000,
+	PSP_BL__PARTIAL_ECC = 0x30001,
+	PSP_BL__FULL_ECC    = 0x30002,
+	PSP_BL__DEFAULT_ECC = 0x30003,
+};
+
 struct psp_context
 {
 	struct amdgpu_device            *adev;
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +2 -2
index 2718e86..f93a66e 100644
@@ -190,7 +190,7 @@ int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
 	/* Provide the sys driver to bootrom */
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
 	       (uint32_t)(psp->fw_pri_mc_addr >> 20));
-	psp_gfxdrv_command_reg = 1 << 16;
+	psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
 	       psp_gfxdrv_command_reg);
 
@@ -231,7 +231,7 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
 	/* Provide the PSP secure OS to bootrom */
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
 	       (uint32_t)(psp->fw_pri_mc_addr >> 20));
-	psp_gfxdrv_command_reg = 2 << 16;
+	psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
 	WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
 	       psp_gfxdrv_command_reg);
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

PATCH 2/3 drm/amdgpu: add psp ecc support

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 22 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +14 -3
index 1aa41af..b04cc80 100644
@@ -256,6 +256,10 @@ static int psp_hw_start(struct psp_context *psp)
 {
 	int ret;
 
+	ret = psp_bootloader_set_ecc_mode(psp);
+	if (ret)
+		return ret;
+
 	ret = psp_bootloader_load_sysdrv(psp);
 	if (ret)
 		return ret;
@@ -365,9 +369,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	if (ret)
 		goto failed_mem;
 
-	ret = psp_hw_start(psp);
-	if (ret)
-		goto failed_mem;
+	if (psp_bootloader_is_sos_running(psp) &&
+			psp->config.ecc_mode != PSP_ECC_MODE__NONE) {
+		if (psp_ring_create(psp, PSP_RING_TYPE__KM))
+			goto failed_mem;
+		if (psp_tmr_load(psp))
+			goto failed_mem;
+	} else {
+		if (psp_hw_start(psp))
+			goto failed_mem;
+	}
 
 	ret = psp_np_fw_load(psp);
 	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +22 -0
index 3776186..8ec9194 100644
@@ -63,6 +63,19 @@ enum psp_bootloader_command_list
 	PSP_BL__DEFAULT_ECC = 0x30003,
 };
 
+enum psp_ecc_mode
+{
+	PSP_ECC_MODE__NONE = 0,
+	PSP_ECC_MODE__OFF = 1,
+	PSP_ECC_MODE__ON = 2,
+	PSP_ECC_MODE__PARTIALON = 3,
+};
+
+struct psp_config
+{
+	enum psp_ecc_mode		ecc_mode;
+};
+
 struct psp_context
 {
 	struct amdgpu_device            *adev;
@@ -70,6 +83,8 @@ struct psp_context
 	struct psp_gfx_cmd_resp		*cmd;
 
 	int (*init_microcode)(struct psp_context *psp);
+	int (*bootloader_set_ecc_mode)(struct psp_context *psp);
+	bool (*bootloader_is_sos_running)(struct psp_context *psp);
 	int (*bootloader_load_sysdrv)(struct psp_context *psp);
 	int (*bootloader_load_sos)(struct psp_context *psp);
 	int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
@@ -123,6 +138,9 @@ struct psp_context
 	struct amdgpu_bo		*cmd_buf_bo;
 	uint64_t			cmd_buf_mc_addr;
 	struct psp_gfx_cmd_resp		*cmd_buf_mem;
+
+	/* psp config */
+	struct psp_config		config;
 };
 
 struct amdgpu_psp_funcs {
@@ -140,6 +158,10 @@ struct amdgpu_psp_funcs {
 		(psp)->compare_sram_data((psp), (ucode), (type))
 #define psp_init_microcode(psp) \
 		((psp)->init_microcode ? (psp)->init_microcode((psp)) : 0)
+#define psp_bootloader_set_ecc_mode(psp) \
+		((psp)->bootloader_set_ecc_mode ? (psp)->bootloader_set_ecc_mode((psp)) : 0)
+#define psp_bootloader_is_sos_running(psp) \
+		((psp)->bootloader_is_sos_running ? (psp)->bootloader_is_sos_running((psp)) : 0)
 #define psp_bootloader_load_sysdrv(psp) \
 		((psp)->bootloader_load_sysdrv ? (psp)->bootloader_load_sysdrv((psp)) : 0)
 #define psp_bootloader_load_sos(psp) \
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1501233079-24235-3-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

#7 lore raw

Re: [PATCH 2/3] drm/amdgpu: add psp ecc support

Quoted 22 lines · Junwei Zhang
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 22 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
index 1aa41af..b04cc80 100644
@@ -256,6 +256,10 @@ static int psp_hw_start(struct psp_context *psp)
 {
 	int ret;
 
+	ret = psp_bootloader_set_ecc_mode(psp);
+	if (ret)
+		return ret;
+
 	ret = psp_bootloader_load_sysdrv(psp);
 	if (ret)
 		return ret;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 373

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -3
@@ -365,9 +369,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	if (ret)
 		goto failed_mem;
 
-	ret = psp_hw_start(psp);
-	if (ret)
-		goto failed_mem;
+	if (psp_bootloader_is_sos_running(psp) &&
+			psp->config.ecc_mode != PSP_ECC_MODE__NONE) {

It need set a default value to config psp->ecc_mode, otherwise, it is always "0" in this implementation.

Quoted 45 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -0
+		if (psp_ring_create(psp, PSP_RING_TYPE__KM))
+			goto failed_mem;
+		if (psp_tmr_load(psp))
+			goto failed_mem;
+	} else {
+		if (psp_hw_start(psp))
+			goto failed_mem;
+	}
 
 	ret = psp_np_fw_load(psp);
 	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +15 -0
index 3776186..8ec9194 100644
@@ -63,6 +63,19 @@ enum psp_bootloader_command_list
 	PSP_BL__DEFAULT_ECC = 0x30003,
 };
 
+enum psp_ecc_mode
+{
+	PSP_ECC_MODE__NONE = 0,
+	PSP_ECC_MODE__OFF = 1,
+	PSP_ECC_MODE__ON = 2,
+	PSP_ECC_MODE__PARTIALON = 3,
+};
+
+struct psp_config
+{
+	enum psp_ecc_mode		ecc_mode;
+};
+
 struct psp_context
 {
 	struct amdgpu_device            *adev;
@@ -70,6 +83,8 @@ struct psp_context
 	struct psp_gfx_cmd_resp		*cmd;
 
 	int (*init_microcode)(struct psp_context *psp);
+	int (*bootloader_set_ecc_mode)(struct psp_context *psp);
+	bool (*bootloader_is_sos_running)(struct psp_context *psp);
 	int (*bootloader_load_sysdrv)(struct psp_context *psp);
 	int (*bootloader_load_sos)(struct psp_context *psp);
 	int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 143

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +3 -0
@@ -123,6 +138,9 @@ struct psp_context
 	struct amdgpu_bo		*cmd_buf_bo;
 	uint64_t			cmd_buf_mc_addr;
 	struct psp_gfx_cmd_resp		*cmd_buf_mem;
+
+	/* psp config */
+	struct psp_config		config;

At current, we don't need a psp_config wrapper here. Use "enum ecc_mode" directly to make code more simple.

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +4 -0
 };
 
 struct amdgpu_psp_funcs {
@@ -140,6 +158,10 @@ struct amdgpu_psp_funcs {
 		(psp)->compare_sram_data((psp), (ucode), (type))
 #define psp_init_microcode(psp) \
 		((psp)->init_microcode ? (psp)->init_microcode((psp)) : 0)
+#define psp_bootloader_set_ecc_mode(psp) \
+		((psp)->bootloader_set_ecc_mode ? (psp)->bootloader_set_ecc_mode((psp)) : 0)
+#define psp_bootloader_is_sos_running(psp) \
+		((psp)->bootloader_is_sos_running ? (psp)->bootloader_is_sos_running((psp)) : 0)
 #define psp_bootloader_load_sysdrv(psp) \
 		((psp)->bootloader_load_sysdrv ? (psp)->bootloader_load_sysdrv((psp)) : 0)
 #define psp_bootloader_load_sos(psp) \
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw

Re: [PATCH 2/3] drm/amdgpu: add psp ecc support

Quoted 26 lines · Huang Rui
Quoted 25 lines · Junwei Zhang
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 22 ++++++++++++++++++++++
  2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
index 1aa41af..b04cc80 100644
@@ -256,6 +256,10 @@ static int psp_hw_start(struct psp_context *psp)
  {
  	int ret;
 
+	ret = psp_bootloader_set_ecc_mode(psp);
+	if (ret)
+		return ret;
+
  	ret = psp_bootloader_load_sysdrv(psp);
  	if (ret)
  		return ret;
@@ -365,9 +369,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
  	if (ret)
  		goto failed_mem;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 373

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -3
-	ret = psp_hw_start(psp);
-	if (ret)
-		goto failed_mem;
+	if (psp_bootloader_is_sos_running(psp) &&
+			psp->config.ecc_mode != PSP_ECC_MODE__NONE) {

It need set a default value to config psp->ecc_mode, otherwise, it is always "0" in this implementation.

For ASIC support ECC, it's set in psp_sw_init(), like vega10 case. For ASIC not support ECC yet, it always "0", indicating PSP_ECC_MODE__NONE, aka not enabled by default.

It's expected result, I think.

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -0
+		if (psp_ring_create(psp, PSP_RING_TYPE__KM))
+			goto failed_mem;
+		if (psp_tmr_load(psp))
+			goto failed_mem;
+	} else {
+		if (psp_hw_start(psp))
+			goto failed_mem;
+	}
 
  	ret = psp_np_fw_load(psp);
  	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +13 -0
index 3776186..8ec9194 100644
@@ -63,6 +63,19 @@ enum psp_bootloader_command_list
  	PSP_BL__DEFAULT_ECC = 0x30003,
  };
 
+enum psp_ecc_mode
+{
+	PSP_ECC_MODE__NONE = 0,
+	PSP_ECC_MODE__OFF = 1,
+	PSP_ECC_MODE__ON = 2,
+	PSP_ECC_MODE__PARTIALON = 3,
+};
+
+struct psp_config
+{
+	enum psp_ecc_mode		ecc_mode;
+};
+
  struct psp_context
  {
  	struct amdgpu_device            *adev;
@@ -70,6 +83,8 @@ struct psp_context
  	struct psp_gfx_cmd_resp		*cmd;
 
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 143

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +5 -0
  	int (*init_microcode)(struct psp_context *psp);
+	int (*bootloader_set_ecc_mode)(struct psp_context *psp);
+	bool (*bootloader_is_sos_running)(struct psp_context *psp);
  	int (*bootloader_load_sysdrv)(struct psp_context *psp);
  	int (*bootloader_load_sos)(struct psp_context *psp);
  	int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
@@ -123,6 +138,9 @@ struct psp_context
  	struct amdgpu_bo		*cmd_buf_bo;
  	uint64_t			cmd_buf_mc_addr;
  	struct psp_gfx_cmd_resp		*cmd_buf_mem;
+
+	/* psp config */
+	struct psp_config		config;

At current, we don't need a psp_config wrapper here. Use "enum ecc_mode" directly to make code more simple.

I considered it twice when implemented the code.
IMO, it's good way to collect all config info in a structure like gfx config. It's not only used for ECC, but an initial step for psp_config.

How do you think about it?

Jerry

Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +4 -1
  };
 
  struct amdgpu_psp_funcs {
@@ -140,6 +158,10 @@ struct amdgpu_psp_funcs {
  		(psp)->compare_sram_data((psp), (ucode), (type))
  #define psp_init_microcode(psp) \
  		((psp)->init_microcode ? (psp)->init_microcode((psp)) : 0)
+#define psp_bootloader_set_ecc_mode(psp) \
+		((psp)->bootloader_set_ecc_mode ? (psp)->bootloader_set_ecc_mode((psp)) : 0)
+#define psp_bootloader_is_sos_running(psp) \
+		((psp)->bootloader_is_sos_running ? (psp)->bootloader_is_sos_running((psp)) : 0)
  #define psp_bootloader_load_sysdrv(psp) \
  		((psp)->bootloader_load_sysdrv ? (psp)->bootloader_load_sysdrv((psp)) : 0)
  #define psp_bootloader_load_sos(psp) \
--

1.9.1

Quoted 9 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH 2/3] drm/amdgpu: add psp ecc support

Quoted 36 lines · Jerry
Quoted 26 lines · Huang Rui
Quoted 25 lines · Junwei Zhang
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 22 ++++++++++++++++++++++
  2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
index 1aa41af..b04cc80 100644
@@ -256,6 +256,10 @@ static int psp_hw_start(struct psp_context *psp)
  {
  	int ret;
 
+	ret = psp_bootloader_set_ecc_mode(psp);
+	if (ret)
+		return ret;
+
  	ret = psp_bootloader_load_sysdrv(psp);
  	if (ret)
  		return ret;
@@ -365,9 +369,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
  	if (ret)
  		goto failed_mem;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 373

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -3
-	ret = psp_hw_start(psp);
-	if (ret)
-		goto failed_mem;
+	if (psp_bootloader_is_sos_running(psp) &&
+			psp->config.ecc_mode != PSP_ECC_MODE__NONE) {

It need set a default value to config psp->ecc_mode, otherwise, it is always "0" in this implementation.

Quoted 1 line

For ASIC support ECC, it's set in psp_sw_init(), like vega10 case.

Not only asic support, but also VBIOS enablement. Yes, we would better initialize it in sw init and use a boot param to configure it at least until we confirmed the method to get ecc_mode from VBIOS. At same time, it should add a comment to like below in sw_init:

/* FIXME: will find a way to get ecc mode via VBIOS */

Quoted 61 lines

For ASIC not support ECC yet, it always "0", indicating PSP_ECC_MODE__NONE, aka not enabled by default.

It's expected result, I think.

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -0
+		if (psp_ring_create(psp, PSP_RING_TYPE__KM))
+			goto failed_mem;
+		if (psp_tmr_load(psp))
+			goto failed_mem;
+	} else {
+		if (psp_hw_start(psp))
+			goto failed_mem;
+	}
 
  	ret = psp_np_fw_load(psp);
  	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +13 -0
index 3776186..8ec9194 100644
@@ -63,6 +63,19 @@ enum psp_bootloader_command_list
  	PSP_BL__DEFAULT_ECC = 0x30003,
  };
 
+enum psp_ecc_mode
+{
+	PSP_ECC_MODE__NONE = 0,
+	PSP_ECC_MODE__OFF = 1,
+	PSP_ECC_MODE__ON = 2,
+	PSP_ECC_MODE__PARTIALON = 3,
+};
+
+struct psp_config
+{
+	enum psp_ecc_mode		ecc_mode;
+};
+
  struct psp_context
  {
  	struct amdgpu_device            *adev;
@@ -70,6 +83,8 @@ struct psp_context
  	struct psp_gfx_cmd_resp		*cmd;
 
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 143

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +5 -0
  	int (*init_microcode)(struct psp_context *psp);
+	int (*bootloader_set_ecc_mode)(struct psp_context *psp);
+	bool (*bootloader_is_sos_running)(struct psp_context *psp);
  	int (*bootloader_load_sysdrv)(struct psp_context *psp);
  	int (*bootloader_load_sos)(struct psp_context *psp);
  	int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
@@ -123,6 +138,9 @@ struct psp_context
  	struct amdgpu_bo		*cmd_buf_bo;
  	uint64_t			cmd_buf_mc_addr;
  	struct psp_gfx_cmd_resp		*cmd_buf_mem;
+
+	/* psp config */
+	struct psp_config		config;

At current, we don't need a psp_config wrapper here. Use "enum ecc_mode" directly to make code more simple.

Quoted 6 lines

I considered it twice when implemented the code.
IMO, it's good way to collect all config info in a structure like gfx config. It's not only used for ECC, but an initial step for psp_config.

How do you think about it?

Yes, make sense. But we could introduce the config wrapper when we need add new configration in future. Currently, it looks a little superfluous. Anyway, I am also fine if you want to introduce it now, no matter.

Thanks,
Rui
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw

Re: [PATCH 2/3] drm/amdgpu: add psp ecc support

Quoted 37 lines · Huang Rui
Quoted 36 lines · Jerry
Quoted 34 lines · Huang Rui
Quoted 22 lines · Junwei Zhang
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++++---
   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 22 ++++++++++++++++++++++
   2 files changed, 36 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
index 1aa41af..b04cc80 100644
@@ -256,6 +256,10 @@ static int psp_hw_start(struct psp_context *psp)
   {
   	int ret;
 
+	ret = psp_bootloader_set_ecc_mode(psp);
+	if (ret)
+		return ret;
+
   	ret = psp_bootloader_load_sysdrv(psp);
   	if (ret)
   		return ret;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 373

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -3
@@ -365,9 +369,16 @@ static int psp_load_fw(struct amdgpu_device *adev)
   	if (ret)
   		goto failed_mem;
 
-	ret = psp_hw_start(psp);
-	if (ret)
-		goto failed_mem;
+	if (psp_bootloader_is_sos_running(psp) &&
+			psp->config.ecc_mode != PSP_ECC_MODE__NONE) {

It need set a default value to config psp->ecc_mode, otherwise, it is always "0" in this implementation.

Quoted 8 lines
Quoted 1 line

For ASIC support ECC, it's set in psp_sw_init(), like vega10 case.

Not only asic support, but also VBIOS enablement. Yes, we would better initialize it in sw init and use a boot param to configure it at least until we confirmed the method to get ecc_mode from VBIOS. At same time, it should add a comment to like below in sw_init:

/* FIXME: will find a way to get ecc mode via VBIOS */

Thanks for your advice.
I could add a comment for that.

Actually there is a patch 3 you may miss in mailbox, where already initialize the ecc mode for vega10.
* [PATCH 3/3] drm/amdgpu: add psp ecc support for vega10

Currently I'm not sure the requirements for ECC support, especially ECC mode initialization. So just hard code ECC mode for a specific ASIC(Vega10 for now).

Quoted 66 lines
Quoted 66 lines

For ASIC not support ECC yet, it always "0", indicating PSP_ECC_MODE__NONE, aka not enabled by default.

It's expected result, I think.

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -0
+		if (psp_ring_create(psp, PSP_RING_TYPE__KM))
+			goto failed_mem;
+		if (psp_tmr_load(psp))
+			goto failed_mem;
+	} else {
+		if (psp_hw_start(psp))
+			goto failed_mem;
+	}
 
   	ret = psp_np_fw_load(psp);
   	if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +13 -0
index 3776186..8ec9194 100644
@@ -63,6 +63,19 @@ enum psp_bootloader_command_list
   	PSP_BL__DEFAULT_ECC = 0x30003,
   };
 
+enum psp_ecc_mode
+{
+	PSP_ECC_MODE__NONE = 0,
+	PSP_ECC_MODE__OFF = 1,
+	PSP_ECC_MODE__ON = 2,
+	PSP_ECC_MODE__PARTIALON = 3,
+};
+
+struct psp_config
+{
+	enum psp_ecc_mode		ecc_mode;
+};
+
   struct psp_context
   {
   	struct amdgpu_device            *adev;
@@ -70,6 +83,8 @@ struct psp_context
   	struct psp_gfx_cmd_resp		*cmd;
 
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 143

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +5 -0
   	int (*init_microcode)(struct psp_context *psp);
+	int (*bootloader_set_ecc_mode)(struct psp_context *psp);
+	bool (*bootloader_is_sos_running)(struct psp_context *psp);
   	int (*bootloader_load_sysdrv)(struct psp_context *psp);
   	int (*bootloader_load_sos)(struct psp_context *psp);
   	int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
@@ -123,6 +138,9 @@ struct psp_context
   	struct amdgpu_bo		*cmd_buf_bo;
   	uint64_t			cmd_buf_mc_addr;
   	struct psp_gfx_cmd_resp		*cmd_buf_mem;
+
+	/* psp config */
+	struct psp_config		config;

At current, we don't need a psp_config wrapper here. Use "enum ecc_mode" directly to make code more simple.

I considered it twice when implemented the code.
IMO, it's good way to collect all config info in a structure like gfx config. It's not only used for ECC, but an initial step for psp_config.

Quoted 6 lines
Quoted 2 lines

How do you think about it?

Yes, make sense. But we could introduce the config wrapper when we need add new configration in future. Currently, it looks a little superfluous. Anyway, I am also fine if you want to introduce it now, no matter.

Got your concern.

Cause actually we always forget to add config structure until some day when somebody gets time to have a code clean-up.

Jerry

Quoted 4 lines

Thanks,
Rui

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#12 lore raw

PATCH 3/3 drm/amdgpu: add psp ecc support for vega10

In reply to a message not in the archive

Disable ecc by default

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  3 ++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 60 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.h   |  2 ++
 3 files changed, 65 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -0
index b04cc80..ec433b9 100644
@@ -52,6 +52,8 @@ static int psp_sw_init(void *handle)
 	switch (adev->asic_type) {
 	case CHIP_VEGA10:
 		psp->init_microcode = psp_v3_1_init_microcode;
+		psp->bootloader_is_sos_running = psp_v3_1_bootloader_is_sos_running;
+		psp->bootloader_set_ecc_mode = psp_v3_1_bootloader_set_ecc_mode;
 		psp->bootloader_load_sysdrv = psp_v3_1_bootloader_load_sysdrv;
 		psp->bootloader_load_sos = psp_v3_1_bootloader_load_sos;
 		psp->prep_cmd_buf = psp_v3_1_prep_cmd_buf;
@@ -61,6 +63,7 @@ static int psp_sw_init(void *handle)
 		psp->cmd_submit = psp_v3_1_cmd_submit;
 		psp->compare_sram_data = psp_v3_1_compare_sram_data;
 		psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk;
+		psp->config.ecc_mode = PSP_ECC_MODE__NONE;
 		break;
 	case CHIP_RAVEN:
 #if 0
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +60 -0

66 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v3_1.h +2 -0
index 9dcd0b2..3e52b5d 100644
@@ -34,6 +34,8 @@
 
 extern int psp_v3_1_init_microcode(struct psp_context *psp);
 extern int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp);
+extern bool psp_v3_1_bootloader_is_sos_running(struct psp_context *psp);
+extern int psp_v3_1_bootloader_set_ecc_mode(struct psp_context *psp);
 extern int psp_v3_1_bootloader_load_sos(struct psp_context *psp);
 extern int psp_v3_1_prep_cmd_buf(struct amdgpu_firmware_info *ucode,
 				 struct psp_gfx_cmd_resp *cmd);
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx