RAS support for amdgpu
Subsystems (4)
cover RAS support for amdgpu
This patch set adds initial RAS (Reliability, Availability, Serviceability) support to amdgpu on supported boards. Features include SRAM and VRAM ECC, bad page tracking, and error containment.
Eric Huang (2):
drm/amdkfd: add RAS capabilities in topology for Vega20 (v2) drm/amdkfd: add RAS ECC event support (v2)
Feifei Xu (1):
drm/amdgpu: enable ras on gfx9 (v2)
xinhui pan (17):
drm/amdgpu: add ta ras fw info (v2)
drm/amdgpu: export ta fw info
drm/amdgpu: add module parameters for ras drm/amdgpu: add ta_ras_if.h
drm/amdgpu: add psp ras callback func and macro drm/amdgpu: add psp ras subsystem infrastructure (v2) drm/amdgpu: add psp v11 ras callback
drm/amdgpu: add psp cmd submit timeout drm/amdgpu: add amdgpu_ras.c to support ras (v2) drm/amdgpu: add debugfs ctrl node
drm/amdgpu: reserve bad pages during recovery drm/amdgpu: enable ras on sdma4
drm/amdgpu: enable ras on gmc9
drm/amdgpu: Add a new flag to AMDGPU_CTX_OP_QUERY_STATE2 drm/amdgpu: add ioctl query for enabled ras features (v2) drm/amdgpu: skip gpu reset when ras error occured drm/amdgpu: add human readable debugfs control support (v2)
drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 17 + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 31 + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 220 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 32 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 1438 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 229 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 4 + drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 174 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 277 ++++ drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 57 + drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 186 ++- drivers/gpu/drm/amd/amdgpu/ta_ras_if.h | 108 ++ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 11 + drivers/gpu/drm/amd/amdkfd/kfd_events.c | 18 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 + drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 16 + drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 4 + include/uapi/drm/amdgpu_drm.h | 35 + include/uapi/linux/kfd_ioctl.h | 12 +- 27 files changed, 2910 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h create mode 100644 drivers/gpu/drm/amd/amdgpu/ta_ras_if.h
Signature · 6 lines
2.20.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): 20190305204136.17587-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 1/20 drm/amdgpu: add ta ras fw info (v2)
From: xinhui pan <[email protected]>
Add ras fw part, xgmi and ras fw are combined together in ta binary. Reading the data from the info is not implemented yet.
v2: squash in "drm/amdgpu: fix NULL pointer when ta is missing"
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 4 ++++ drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 7 +++++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +4 -0
@@ -150,9 +150,13 @@ struct psp_context/* xgmi ta firmware and buffer */ const struct firmware *ta_fw; +uint32_t ta_fw_version;uint32_t ta_xgmi_ucode_version;uint32_t ta_xgmi_ucode_size;uint8_t *ta_xgmi_start_addr; +uint32_t ta_ras_ucode_version; +uint32_t ta_ras_ucode_size; +uint8_t *ta_ras_start_addr;struct psp_xgmi_context xgmi_context; };
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +7 -0
@@ -116,6 +116,13 @@ static int psp_v11_0_init_microcode(struct psp_context *psp) adev->psp.ta_xgmi_ucode_size =le32_to_cpu (ta_hdr->ta_xgmi_size_bytes); adev->psp.ta_xgmi_start_addr = (uint8_t *)ta_hdr +le32_to_cpu (ta_hdr->header.ucode_array_offset_bytes); + + adev->psp.ta_fw_version =le32_to_cpu (ta_hdr->header.ucode_version); + + adev->psp.ta_ras_ucode_version =le32_to_cpu (ta_hdr->ta_ras_ucode_version); + adev->psp.ta_ras_ucode_size =le32_to_cpu (ta_hdr->ta_ras_size_bytes); + adev->psp.ta_ras_start_addr = (uint8_t *)adev->psp.ta_xgmi_start_addr + +le32_to_cpu (ta_hdr->ta_ras_offset_bytes); }return 0 ;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/20 drm/amdgpu: export ta fw info
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Output the ta fw, aka xgmi/ras, via debugfs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 1 + 2 files changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +21 -0
@@ -295,6 +295,17 @@ static int amdgpu_firmware_info(struct drm_amdgpu_info_firmware *fw_info, fw_info->ver = adev->pm.fw_version; fw_info->feature =0 ;break ; +case AMDGPU_INFO_FW_TA : +if (query_fw->index >1 ) +return -EINVAL ; +if (query_fw->index ==0 ) { + fw_info->ver = adev->psp.ta_fw_version; + fw_info->feature = adev->psp.ta_xgmi_ucode_version; + }else { + fw_info->ver = adev->psp.ta_fw_version; + fw_info->feature = adev->psp.ta_ras_ucode_version; + } +break ;case AMDGPU_INFO_FW_SDMA :if (query_fw->index >= adev->sdma.num_instances)return -EINVAL ;
@@ -1327,6 +1338,16 @@ static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data)seq_printf (m,"ASD feature version: %u, firmware version: 0x%08x\n" , fw_info.feature, fw_info.ver); + query_fw.fw_type =AMDGPU_INFO_FW_TA ; +for (i =0 ; i <2 ; i++) { + query_fw.index = i; + ret =amdgpu_firmware_info (&fw_info, &query_fw, adev); +if (ret) +continue ; +seq_printf (m,"TA %s feature version: %u, firmware version: 0x%08x\n" , + i ?"RAS" :"XGMI" , fw_info.feature, fw_info.ver); + } +/* SMC */ query_fw.fw_type =AMDGPU_INFO_FW_SMC ; ret =amdgpu_firmware_info (&fw_info, &query_fw, adev);
include/uapi/drm/amdgpu_drm.h +1 -0
@@ -680,6 +680,7 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11/* Subquery id: Query DMCU firmware version */ #define AMDGPU_INFO_FW_DMCU 0x12 +#define AMDGPU_INFO_FW_TA 0x13/* number of bytes moved for TTM migration */ #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f/* the used VRAM size */
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/20 drm/amdgpu: add module parameters for ras
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Allow RAS feature enable/disable via boot parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -157,6 +157,8 @@ extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size;extern uint amdgpu_dc_feature_mask;extern struct amdgpu_mgpu_info mgpu_info; +extern int amdgpu_ras_enable; +extern uint amdgpu_ras_mask;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +17 -0
@@ -137,6 +137,8 @@ uint amdgpu_dc_feature_mask = 0;struct amdgpu_mgpu_info mgpu_info = { .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), }; +int amdgpu_ras_enable =-1 ; +uint amdgpu_ras_mask =0xffffffff ;/** * DOC: vramlimit (int)
@@ -495,6 +497,21 @@ module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444);MODULE_PARM_DESC (emu_mode,"Emulation mode, (1 = enable, 0 = disable)" );module_param_named (emu_mode, amdgpu_emu_mode, int,0444 ); +/** +* DOC: amdgpu_ras_enable (int) +* Enable RAS features on the GPU (0 = disable, 1 = enable, -1 = auto (default)) +*/ +MODULE_PARM_DESC (amdgpu_ras_enable,"Enable RAS features on the GPU (0 = disable, 1 = enable, -1 = auto (default))" ); +module_param_named (ras_enable, amdgpu_ras_enable, int,0444 ); + +/** +* DOC: amdgpu_ras_mask (uint) +* Mask of RAS features to enable (default 0xffffffff), only valid when ras_enable == 1 +* See the flags in drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +*/ +MODULE_PARM_DESC (amdgpu_ras_mask,"Mask of RAS features to enable (default 0xffffffff), only valid when ras_enable == 1" ); +module_param_named (ras_mask, amdgpu_ras_mask, uint,0444 ); +/** * DOC: si_support (int) * Set SI support driver. This parameter works after set config CONFIG_DRM_AMDGPU_SI. For SI asic, when radeon driver is enabled,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/20 drm/amdgpu: add ta_ras_if.h
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/ta_ras_if.h | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/ta_ras_if.h
drivers/gpu/drm/amd/amdgpu/ta_ras_if.h new file +108 -0
@@ -0,0 +1,108 @@ +/****************************************************************************\ +* +* File Name ta_ras_if.h +* Project AMD PSP SW IP Module +* +* Description Interface to the RAS Trusted Application +* +* Copyright 2019 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without restriction, +* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +* subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial +* portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef _TA_RAS_IF_H +#define _TA_RAS_IF_H + +/* Responses have bit 31 set */ +#define RSP_ID_MASK (1U << 31) +#define RSP_ID (cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK) + +#define TA_NUM_BLOCK_MAX 14 + +enum ras_command { +TA_RAS_COMMAND__ENABLE_FEATURES =0 , +TA_RAS_COMMAND__DISABLE_FEATURES , +TA_RAS_COMMAND__TRIGGER_ERROR , +}; + +enum ta_ras_status { +TA_RAS_STATUS__SUCCESS =0x00 , +TA_RAS_STATUS__RESET_NEEDED =0x01 , +TA_RAS_STATUS__ERROR_INVALID_PARAMETER =0x02 , +TA_RAS_STATUS__ERROR_RAS_NOT_AVAILABLE =0x03 , +TA_RAS_STATUS__ERROR_RAS_DUPLICATE_CMD =0x04 , +TA_RAS_STATUS__ERROR_INJECTION_FAILED =0x05 +}; + +enum ta_ras_block { +TA_RAS_BLOCK__UMC =0 , +TA_RAS_BLOCK__SDMA , +TA_RAS_BLOCK__GFX , +TA_RAS_BLOCK__MMHUB , +TA_RAS_BLOCK__ATHUB , +TA_RAS_BLOCK__PCIE_BIF , +TA_RAS_BLOCK__HDP , +TA_RAS_BLOCK__XGMI_WAFL , +TA_RAS_BLOCK__DF , +TA_RAS_BLOCK__SMN , +TA_RAS_BLOCK__SEM , +TA_RAS_BLOCK__MP0 , +TA_RAS_BLOCK__MP1 , +TA_RAS_BLOCK__FUSE = (TA_NUM_BLOCK_MAX -1 ), +}; + +enum ta_ras_error_type { +TA_RAS_ERROR__NONE =0 , +TA_RAS_ERROR__PARITY =1 , +TA_RAS_ERROR__SINGLE_CORRECTABLE =2 , +TA_RAS_ERROR__MULTI_UNCORRECTABLE =4 , +TA_RAS_ERROR__POISON =8 +}; + +struct ta_ras_enable_features_input { +enum ta_ras_block block_id; +enum ta_ras_error_type error_type; +}; + +struct ta_ras_disable_features_input { +enum ta_ras_block block_id; +enum ta_ras_error_type error_type; +}; + +struct ta_ras_trigger_error_input { +enum ta_ras_block block_id; +enum ta_ras_error_type inject_error_type; +uint32_t sub_block_index; +uint64_t address; +uint64_t value; +}; + +union ta_ras_cmd_input { +struct ta_ras_enable_features_input enable_features; +struct ta_ras_disable_features_input disable_features; +struct ta_ras_trigger_error_input trigger_error; +}; + +struct ta_ras_shared_memory { +uint32_t cmd_id; +uint32_t resp_id; +enum ta_ras_status ras_status; +uint32_t reserved; +union ta_ras_cmd_input ras_in_message; +}; + +#endif // TL_RAS_IF_H_
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/20 drm/amdgpu: add psp ras callback func and macro
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Define the driver side interface for ras ta.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +11 -0
@@ -28,6 +28,7 @@#include "amdgpu.h" #include "psp_gfx_if.h" #include "ta_xgmi_if.h" +#include "ta_ras_if.h" #define PSP_FENCE_BUFFER_SIZE 0x1000#define PSP_CMD_BUFFER_SIZE 0x1000
@@ -88,6 +89,9 @@ struct psp_funcsint (*xgmi_set_topology_info)(struct psp_context *psp,int number_devices,struct psp_xgmi_topology_info *topology);bool (*support_vmr_ring)(struct psp_context *psp); +int (*ras_trigger_error)(struct psp_context *psp, +struct ta_ras_trigger_error_input *info); +int (*ras_cure_posion)(struct psp_context *psp,uint64_t *mode_ptr); };struct psp_xgmi_context {
@@ -211,6 +215,13 @@ struct psp_xgmi_topology_info {#define amdgpu_psp_check_fw_loading_status (adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i)) +#define psp_ras_trigger_error (psp, info) \ + ((psp)->funcs->ras_trigger_error ? \ + (psp)->funcs->ras_trigger_error((psp), (info)) : -EINVAL) +#define psp_ras_cure_posion (psp, addr) \ + ((psp)->funcs->ras_cure_posion ? \ + (psp)->funcs->ras_cure_posion(psp, (addr)) : -EINVAL) +extern const struct amd_ip_funcs psp_ip_funcs;extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/20 drm/amdgpu: add psp ras subsystem infrastructure (v2)
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Add ras fw loading, init, terminate.
Add ras cmd submit helper.
Add ras feature enable/disable common function.
v2: squash in unused variable warning fix
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 214 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 16 ++ 2 files changed, 230 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +214 -0
@@ -466,6 +466,206 @@ static int psp_xgmi_initialize(struct psp_context *psp)return ret; } +// ras begin +static void psp_prep_ras_ta_load_cmd_buf (struct psp_gfx_cmd_resp *cmd, +uint64_t ras_ta_mc,uint64_t ras_mc_shared, +uint32_t ras_ta_size,uint32_t shared_size) +{ + cmd->cmd_id =GFX_CMD_ID_LOAD_TA ; + cmd->cmd.cmd_load_ta.app_phy_addr_lo =lower_32_bits (ras_ta_mc); + cmd->cmd.cmd_load_ta.app_phy_addr_hi =upper_32_bits (ras_ta_mc); + cmd->cmd.cmd_load_ta.app_len = ras_ta_size; + + cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo =lower_32_bits (ras_mc_shared); + cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi =upper_32_bits (ras_mc_shared); + cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size; +} + +static int psp_ras_init_shared_buf (struct psp_context *psp) +{ +int ret; + +/* +* Allocate 16k memory aligned to 4k from Frame Buffer (local +* physical) for ras ta <-> Driver +*/ + ret =amdgpu_bo_create_kernel (psp->adev,PSP_RAS_SHARED_MEM_SIZE , +PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM , + &psp->ras.ras_shared_bo, + &psp->ras.ras_shared_mc_addr, + &psp->ras.ras_shared_buf); + +return ret; +} + +static int psp_ras_load (struct psp_context *psp) +{ +int ret; +struct psp_gfx_cmd_resp *cmd; + +/* +* TODO: bypass the loading in sriov for now +*/ +if (amdgpu_sriov_vf (psp->adev)) +return 0 ; + + cmd =kzalloc (sizeof (struct psp_gfx_cmd_resp ),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + +memset (psp->fw_pri_buf,0 ,PSP_1_MEG ); +memcpy (psp->fw_pri_buf, psp->ta_ras_start_addr, psp->ta_ras_ucode_size); + +psp_prep_ras_ta_load_cmd_buf (cmd, psp->fw_pri_mc_addr, + psp->ras.ras_shared_mc_addr, + psp->ta_ras_ucode_size,PSP_RAS_SHARED_MEM_SIZE ); + + ret =psp_cmd_submit_buf (psp,NULL , cmd, + psp->fence_buf_mc_addr); + +if (!ret) { + psp->ras.ras_initialized =1 ; + psp->ras.session_id = cmd->resp.session_id; + } + +kfree (cmd); + +return ret; +} + +static void psp_prep_ras_ta_unload_cmd_buf (struct psp_gfx_cmd_resp *cmd, +uint32_t ras_session_id) +{ + cmd->cmd_id =GFX_CMD_ID_UNLOAD_TA ; + cmd->cmd.cmd_unload_ta.session_id = ras_session_id; +} + +static int psp_ras_unload (struct psp_context *psp) +{ +int ret; +struct psp_gfx_cmd_resp *cmd; + +/* +* TODO: bypass the unloading in sriov for now +*/ +if (amdgpu_sriov_vf (psp->adev)) +return 0 ; + + cmd =kzalloc (sizeof (struct psp_gfx_cmd_resp ),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + +psp_prep_ras_ta_unload_cmd_buf (cmd, psp->ras.session_id); + + ret =psp_cmd_submit_buf (psp,NULL , cmd, + psp->fence_buf_mc_addr); + +kfree (cmd); + +return ret; +} + +static void psp_prep_ras_ta_invoke_cmd_buf (struct psp_gfx_cmd_resp *cmd, +uint32_t ta_cmd_id, +uint32_t ras_session_id) +{ + cmd->cmd_id =GFX_CMD_ID_INVOKE_CMD ; + cmd->cmd.cmd_invoke_cmd.session_id = ras_session_id; + cmd->cmd.cmd_invoke_cmd.ta_cmd_id = ta_cmd_id; +/* Note: cmd_invoke_cmd.buf is not used for now */ +} + +int psp_ras_invoke (struct psp_context *psp,uint32_t ta_cmd_id) +{ +int ret; +struct psp_gfx_cmd_resp *cmd; + +/* +* TODO: bypass the loading in sriov for now +*/ +if (amdgpu_sriov_vf (psp->adev)) +return 0 ; + + cmd =kzalloc (sizeof (struct psp_gfx_cmd_resp ),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + +psp_prep_ras_ta_invoke_cmd_buf (cmd, ta_cmd_id, + psp->ras.session_id); + + ret =psp_cmd_submit_buf (psp,NULL , cmd, + psp->fence_buf_mc_addr); + +kfree (cmd); + +return ret; +} + +int psp_ras_enable_features (struct psp_context *psp, +union ta_ras_cmd_input *info,bool enable) +{ +struct ta_ras_shared_memory *ras_cmd; +int ret; + +if (!psp->ras.ras_initialized) +return -EINVAL ; + + ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; +memset (ras_cmd,0 ,sizeof (struct ta_ras_shared_memory )); + +if (enable) + ras_cmd->cmd_id =TA_RAS_COMMAND__ENABLE_FEATURES ; +else + ras_cmd->cmd_id =TA_RAS_COMMAND__DISABLE_FEATURES ; + + ras_cmd->ras_in_message = *info; + + ret =psp_ras_invoke (psp, ras_cmd->cmd_id); +if (ret) +return -EINVAL ; + +return ras_cmd->ras_status; +} + +static int psp_ras_terminate (struct psp_context *psp) +{ +int ret; + +if (!psp->ras.ras_initialized) +return 0 ; + + ret =psp_ras_unload (psp); +if (ret) +return ret; + + psp->ras.ras_initialized =0 ; + +/* free ras shared memory */ +amdgpu_bo_free_kernel (&psp->ras.ras_shared_bo, + &psp->ras.ras_shared_mc_addr, + &psp->ras.ras_shared_buf); + +return 0 ; +} + +static int psp_ras_initialize (struct psp_context *psp) +{ +int ret; + +if (!psp->ras.ras_initialized) { + ret =psp_ras_init_shared_buf (psp); +if (ret) +return ret; + } + + ret =psp_ras_load (psp); +if (ret) +return ret; + +return 0 ; +} +// ras end +static int psp_hw_start (struct psp_context *psp) {struct amdgpu_device *adev = psp->adev;
@@ -502,6 +702,12 @@ static int psp_hw_start(struct psp_context *psp)dev_err (psp->adev->dev,"XGMI: Failed to initialize XGMI session\n" ); } + + ret =psp_ras_initialize (psp); +if (ret) +dev_err (psp->adev->dev, +"RAS: Failed to initialize RAS\n" ); +return 0 ; }
@@ -753,6 +959,8 @@ static int psp_hw_fini(void *handle) psp->xgmi_context.initialized == 1)psp_xgmi_terminate (psp); +psp_ras_terminate (psp); +psp_ring_destroy (psp,PSP_RING_TYPE__KM );amdgpu_bo_free_kernel (&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
@@ -786,6 +994,12 @@ static int psp_suspend(void *handle) } } + ret =psp_ras_terminate (psp); +if (ret) { +DRM_ERROR ("Failed to terminate ras ta\n" ); +return ret; + } + ret =psp_ring_stop (psp,PSP_RING_TYPE__KM );if (ret) {DRM_ERROR ("PSP ring stop failed\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +16 -0
@@ -34,6 +34,7 @@#define PSP_CMD_BUFFER_SIZE 0x1000#define PSP_ASD_SHARED_MEM_SIZE 0x4000#define PSP_XGMI_SHARED_MEM_SIZE 0x4000 +#define PSP_RAS_SHARED_MEM_SIZE 0x4000#define PSP_1_MEG 0x100000#define PSP_TMR_SIZE 0x400000
@@ -102,6 +103,15 @@ struct psp_xgmi_context {void *xgmi_shared_buf; }; +struct psp_ras_context { +/*ras fw*/ +bool ras_initialized; +uint32_t session_id; +struct amdgpu_bo *ras_shared_bo; +uint64_t ras_shared_mc_addr; +void *ras_shared_buf; +}; +struct psp_context {struct amdgpu_device *adev;
@@ -162,6 +172,7 @@ struct psp_contextuint32_t ta_ras_ucode_size;uint8_t *ta_ras_start_addr;struct psp_xgmi_context xgmi_context; +struct psp_ras_context ras; };struct amdgpu_psp_funcs {
@@ -232,6 +243,11 @@ extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;int psp_gpu_reset (struct amdgpu_device *adev);int psp_xgmi_invoke (struct psp_context *psp,uint32_t ta_cmd_id); + +int psp_ras_invoke (struct psp_context *psp,uint32_t ta_cmd_id); +int psp_ras_enable_features (struct psp_context *psp, +union ta_ras_cmd_input *info,bool enable); +extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;#endif
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/20 drm/amdgpu: add psp v11 ras callback
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Add trigger_error and cure_posion.
--- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +50 -0
@@ -722,6 +722,54 @@ static int psp_v11_0_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_idreturn 0 ; } +static int psp_v11_0_ras_trigger_error (struct psp_context *psp, +struct ta_ras_trigger_error_input *info) +{ +struct ta_ras_shared_memory *ras_cmd; +int ret; + +if (!psp->ras.ras_initialized) +return -EINVAL ; + + ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; +memset (ras_cmd,0 ,sizeof (struct ta_ras_shared_memory )); + + ras_cmd->cmd_id =TA_RAS_COMMAND__TRIGGER_ERROR ; + ras_cmd->ras_in_message.trigger_error = *info; + + ret =psp_ras_invoke (psp, ras_cmd->cmd_id); +if (ret) +return -EINVAL ; + +return ras_cmd->ras_status; +} + +static int psp_v11_0_ras_cure_posion (struct psp_context *psp,uint64_t *mode_ptr) +{ +#if 0 +// not support yet. +struct ta_ras_shared_memory *ras_cmd; +int ret; + +if (!psp->ras.ras_initialized) +return -EINVAL ; + + ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; +memset (ras_cmd,0 ,sizeof (struct ta_ras_shared_memory )); + + ras_cmd->cmd_id =TA_RAS_COMMAND__CURE_POISON ; + ras_cmd->ras_in_message.cure_poison.mode_ptr = mode_ptr; + + ret =psp_ras_invoke (psp, ras_cmd->cmd_id); +if (ret) +return -EINVAL ; + +return ras_cmd->ras_status; +#else +return -EINVAL ; +#endif +} +static const struct psp_funcs psp_v11_0_funcs = { .init_microcode = psp_v11_0_init_microcode, .bootloader_load_sysdrv = psp_v11_0_bootloader_load_sysdrv,
@@ -738,6 +786,8 @@ static const struct psp_funcs psp_v11_0_funcs = { .xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id, .xgmi_get_node_id = psp_v11_0_xgmi_get_node_id, .support_vmr_ring = psp_v11_0_support_vmr_ring, + .ras_trigger_error = psp_v11_0_ras_trigger_error, + .ras_cure_posion = psp_v11_0_ras_cure_posion, };void psp_v11_0_set_psp_funcs (struct psp_context *psp)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/20 drm/amdgpu: add psp cmd submit timeout
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -1
@@ -120,6 +120,7 @@ psp_cmd_submit_buf(struct psp_context *psp, {int ret;int index; +int timeout =2000 ;memset (psp->cmd_buf_mem,0 ,PSP_CMD_BUFFER_SIZE );
@@ -133,8 +134,11 @@ psp_cmd_submit_buf(struct psp_context *psp,return ret; } -while (*((unsigned int *)psp->fence_buf) != index) +while (*((unsigned int *)psp->fence_buf) != index) { +if (--timeout ==0 ) +return -EINVAL ;msleep (1 ); + }/* In some cases, psp response status is not 0 even there is no * problem while the command is submitted. Some version of PSP FW
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/20 drm/amdgpu: add amdgpu_ras.c to support ras (v2)
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
add obj management.
add feature control.
add debugfs infrastructure.
add sysfs infrastructure.
add IH infrastructure.
add recovery infrastructure.
It is a framework. Other IPs need call amdgpu_ras_xxx function instead of psp_ras_xxx functions.
v2: squash in warning fixes
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 1247 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 217 ++++ 5 files changed, 1475 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -53,7 +53,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \ - amdgpu_gmc.o amdgpu_xgmi.o amdgpu_csa.o + amdgpu_gmc.o amdgpu_xgmi.o amdgpu_csa.o amdgpu_ras.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
@@ -60,6 +60,7 @@#include "amdgpu_pm.h" #include "amdgpu_xgmi.h" +#include "amdgpu_ras.h" MODULE_FIRMWARE ("amdgpu/vega10_gpu_info.bin" );MODULE_FIRMWARE ("amdgpu/vega12_gpu_info.bin" );
@@ -1638,6 +1639,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) {int i, r; + r =amdgpu_ras_init (adev); +if (r) +return r; +for (i =0 ; i < adev->num_ip_blocks; i++) {if (!adev->ip_blocks[i].status.valid)continue ;
@@ -1869,6 +1874,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) {int i, r; +amdgpu_ras_pre_fini (adev); +if (adev->gmc.xgmi.num_physical_nodes >1 )amdgpu_xgmi_remove_device (adev);
@@ -1937,6 +1944,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) adev->ip_blocks[i].status.late_initialized = false; } +amdgpu_ras_fini (adev); +if (amdgpu_sriov_vf (adev))if (amdgpu_virt_release_full_gpu (adev, false))DRM_ERROR ("failed to release exclusive mode on fini\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -110,6 +110,7 @@ struct psp_ras_context {struct amdgpu_bo *ras_shared_bo;uint64_t ras_shared_mc_addr;void *ras_shared_buf; +struct amdgpu_ras *ras; };struct psp_context
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c new file +1247 -0
1,247 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h new file +217 -0
217 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/20 drm/amdgpu: add debugfs ctrl node
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
allow userspace enable/disable ras
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 122 ++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 9 ++ 2 files changed, 121 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +112 -10
@@ -200,6 +200,90 @@ static const struct file_operations amdgpu_ras_debugfs_ops = { .llseek = default_llseek }; +/* +* DOC: ras debugfs control interface +* +* It accepts struct ras_debug_if who has two members. +* +* First member: ras_debug_if::head or ras_debug_if::inject. +* It is used to indicate which IP block will be under control. +* Its contents are not human readable, IOW, write it by your programs. +* +* head has four members, they are block, type, sub_block_index, name. +* block: which IP will be under control. +* type: what kind of error will be enabled/disabled/injected. +* sub_block_index: some IPs have subcomponets. say, GFX, sDMA. +* name: the name of IP. +* +* inject has two more members than head, they are address, value. +* As their names indicate, inject operation will write the +* value to the address. +* +* Second member: struct ras_debug_if::op. +* It has three kinds of operations. +* 0: disable RAS on the block. Take ::head as its data. +* 1: enable RAS on the block. Take ::head as its data. +* 2: inject errors on the block. Take ::inject as its data. +* +* How to check the result? +* +* For disable/enable, please check ras features at +* /sys/class/drm/card[0/1/2...]/device/ras/features +* +* For inject, please check corresponding err count at +* /sys/class/drm/card[0/1/2...]/device/ras/[gfx/sdma/...]_err_count +* +* NOTE: operation is only allowed on blocks which are supported. +* Please check ras mask at /sys/module/amdgpu/parameters/ras_mask +*/ +static ssize_t amdgpu_ras_debugfs_ctrl_write (struct file *f,const char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; +struct ras_debug_if data; +int ret =0 ; + +if (size <sizeof (data)) +return -EINVAL ; + +memset (&data,0 ,sizeof (data)); + +if (*pos) +return -EINVAL ; + +if (copy_from_user (&data, buf,sizeof (data))) +return -EINVAL ; + + *pos = size; + +if (!amdgpu_ras_is_supported (adev, data.head.block)) +return -EINVAL ; + +switch (data.op) { +case 0 : + ret =amdgpu_ras_feature_enable (adev, &data.head,0 ); +break ; +case 1 : + ret =amdgpu_ras_feature_enable (adev, &data.head,1 ); +break ; +case 2 : + ret =amdgpu_ras_error_inject (adev, &data.inject); +break ; + }; + +if (ret) +return -EINVAL ; + +return size; +} + +static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = { + .owner =THIS_MODULE , + .read =NULL , + .write = amdgpu_ras_debugfs_ctrl_write, + .llseek = default_llseek +}; +static ssize_t amdgpu_ras_sysfs_read (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -657,6 +741,31 @@ static int amdgpu_ras_sysfs_remove_all(struct amdgpu_device *adev)/* sysfs end */ /* debugfs begin */ +static int amdgpu_ras_debugfs_create_ctrl_node (struct amdgpu_device *adev) +{ +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); +struct drm_minor *minor = adev->ddev->primary; +struct dentry *root = minor->debugfs_root, *dir; +struct dentry *ent; + + dir =debugfs_create_dir ("ras" , root); +if (IS_ERR (dir)) +return -EINVAL ; + + con->dir = dir; + + ent =debugfs_create_file ("ras_ctrl" , +S_IWUGO |S_IRUGO , con->dir, + adev, &amdgpu_ras_debugfs_ctrl_ops); +if (IS_ERR (ent)) { +debugfs_remove (con->dir); +return -EINVAL ; + } + + con->ent = ent; +return 0 ; +} +int amdgpu_ras_debugfs_create (struct amdgpu_device *adev,struct ras_fs_if *head) {
@@ -709,8 +818,10 @@ static int amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)amdgpu_ras_debugfs_remove (adev, &obj->head); } +debugfs_remove (con->ent);debugfs_remove (con->dir); con->dir =NULL ; + con->ent =NULL ;return 0 ; }
@@ -720,17 +831,8 @@ static int amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)static int amdgpu_ras_fs_init (struct amdgpu_device *adev) { -struct amdgpu_ras *con =amdgpu_ras_get_context (adev); -struct drm_minor *minor = adev->ddev->primary; -struct dentry *root = minor->debugfs_root, *dir; - - dir =debugfs_create_dir ("ras" , root); -if (IS_ERR (dir)) -return -EINVAL ; - - con->dir = dir; -amdgpu_ras_sysfs_create_feature_node (adev); +amdgpu_ras_debugfs_create_ctrl_node (adev);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +9 -0
@@ -86,6 +86,8 @@ struct amdgpu_ras {struct list_head head;/* debugfs */ struct dentry *dir; +/* debugfs ctrl */ +struct dentry *ent;/* sysfs */ struct device_attribute features_attr;/* block array */
@@ -135,6 +137,13 @@ struct ras_dispatch_if {struct amdgpu_iv_entry *entry; }; +struct ras_debug_if { +union { +struct ras_common_if head; +struct ras_inject_if inject; + }; +int op; +};/* work flow * vbios * 1: ras feature enable (enabled by default)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/20 drm/amdgpu: reserve bad pages during recovery
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Mark vram pages with errors as bad and prevent the driver from using them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
@@ -3396,6 +3396,11 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,break ; } } + +list_for_each_entry (tmp_adev, device_list_handle, + gmc.xgmi.head) { +amdgpu_ras_reserve_bad_pages (tmp_adev); + } } }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/20 drm/amdgpu: enable ras on sdma4
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
register IH, enable ras features on sdma. create sysfs debugfs file for sdma.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 4 + drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 184 ++++++++++++++++++++++- 2 files changed, 187 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +4 -0
@@ -30,6 +30,8 @@enum amdgpu_sdma_irq {AMDGPU_SDMA_IRQ_TRAP0 =0 ,AMDGPU_SDMA_IRQ_TRAP1 , +AMDGPU_SDMA_IRQ_ECC0 , +AMDGPU_SDMA_IRQ_ECC1 ,AMDGPU_SDMA_IRQ_LAST };
@@ -49,9 +51,11 @@ struct amdgpu_sdma {struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES ];struct amdgpu_irq_src trap_irq;struct amdgpu_irq_src illegal_inst_irq; +struct amdgpu_irq_src ecc_irq;int num_instances;uint32_t srbm_soft_reset;bool has_page_queue; +struct ras_common_if *ras_if; };/*
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +183 -1
243 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/20 drm/amdgpu: enable ras on gfx9 (v2)
In reply to a message not in the archiveFrom: Feifei Xu <[email protected]>
Register ecc interrupts and ecc interrupt handler on gfx9. Add ras support on gfx9
v2: squash in warning fix
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 + drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 173 ++++++++++++++++++++++++ 2 files changed, 176 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3 -0
@@ -258,6 +258,9 @@ struct amdgpu_gfx {/* pipe reservation */ struct mutex pipe_reserve_mutex;DECLARE_BITMAP (pipe_reserve_bitmap,AMDGPU_MAX_COMPUTE_QUEUES ); + +/*ras */ +struct ras_common_if *ras_if; };#define amdgpu_gfx_get_gpu_clock_counter (adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev))
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +173 -0
233 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/20 drm/amdgpu: enable ras on gmc9
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 2 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 276 ++++++++++++++++++++++++ 2 files changed, 278 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +2 -0
@@ -144,6 +144,8 @@ struct amdgpu_gmc {const struct amdgpu_gmc_funcs *gmc_funcs;struct amdgpu_xgmi xgmi; +struct amdgpu_irq_src ecc_irq; +struct ras_common_if *ras_if; };#define amdgpu_gmc_flush_gpu_tlb (adev, vmid, type) (adev)->gmc.gmc_funcs->flush_gpu_tlb((adev), (vmid), (type))
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +276 -0
328 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/20 drm/amdgpu: Add a new flag to AMDGPU_CTX_OP_QUERY_STATE2
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Add AMDGPU_CTX_QUERY2_FLAGS_RAS_CE/UE which indicate if any error happened between previous query and this query.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 2 ++ include/uapi/drm/amdgpu_drm.h | 3 +++ 3 files changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +17 -0
@@ -26,6 +26,7 @@#include <drm/drm_auth.h> #include "amdgpu.h" #include "amdgpu_sched.h" +#include "amdgpu_ras.h" #define to_amdgpu_ctx_entity (e) \ container_of((e), struct amdgpu_ctx_entity, entity)
@@ -344,6 +345,7 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev, {struct amdgpu_ctx *ctx;struct amdgpu_ctx_mgr *mgr; +uint32_t ras_counter;if (!fpriv)return -EINVAL ;
@@ -368,6 +370,21 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev,if (atomic_read (&ctx->guilty)) out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_GUILTY ; +/*query ue count*/ + ras_counter =amdgpu_ras_query_error_count (adev, false); +/*ras counter is monotonic increasing*/ +if (ras_counter != ctx->ras_counter_ue) { + out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_UE ; + ctx->ras_counter_ue = ras_counter; + } + +/*query ce count*/ + ras_counter =amdgpu_ras_query_error_count (adev, true); +if (ras_counter != ctx->ras_counter_ce) { + out->state.flags |=AMDGPU_CTX_QUERY2_FLAGS_RAS_CE ; + ctx->ras_counter_ce = ras_counter; + } +mutex_unlock (&mgr->lock);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +2 -0
@@ -49,6 +49,8 @@ struct amdgpu_ctx {enum drm_sched_priority override_priority;struct mutex lock;atomic_t guilty; +uint32_t ras_counter_ce; +uint32_t ras_counter_ue; };struct amdgpu_ctx_mgr {
include/uapi/drm/amdgpu_drm.h +3 -0
@@ -210,6 +210,9 @@ union drm_amdgpu_bo_list {#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)/* indicate some job from this context once cause gpu hang */ #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2) +/* indicate some errors are detected by RAS */ +#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3) +#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)/* Context priority level */ #define AMDGPU_CTX_PRIORITY_UNSET -2048
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/20 drm/amdgpu: add ioctl query for enabled ras features (v2)
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Add a query for userspace to check which RAS features are enabled.
v2: squash in warning fix
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 ++++++++ include/uapi/drm/amdgpu_drm.h | 31 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10 -0
@@ -39,6 +39,7 @@#include "amdgpu_amdkfd.h" #include "amdgpu_gem.h" #include "amdgpu_display.h" +#include "amdgpu_ras.h" static void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) {
@@ -919,6 +920,15 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filecase AMDGPU_INFO_VRAM_LOST_COUNTER : ui32 =atomic_read (&adev->vram_lost_counter);return copy_to_user (out, &ui32,min (size,4u )) ? -EFAULT :0 ; +case AMDGPU_INFO_RAS_ENABLED_FEATURES : { +struct amdgpu_ras *ras =amdgpu_ras_get_context (adev); + +if (!ras) +return -EINVAL ; +return copy_to_user (out, &ras->features, +min_t (u32, size,sizeof (ras->features))) ? + -EFAULT :0 ; + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
include/uapi/drm/amdgpu_drm.h +31 -0
@@ -737,6 +737,37 @@ struct drm_amdgpu_cs_chunk_data {/* Number of VRAM page faults on CPU access. */ #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F +/* query ras mask of enabled features*/ +#define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20 + +/* RAS MASK: UMC (VRAM) */ +#define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0) +/* RAS MASK: SDMA */ +#define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1) +/* RAS MASK: GFX */ +#define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2) +/* RAS MASK: MMHUB */ +#define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3) +/* RAS MASK: ATHUB */ +#define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4) +/* RAS MASK: PCIE */ +#define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5) +/* RAS MASK: HDP */ +#define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6) +/* RAS MASK: XGMI */ +#define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7) +/* RAS MASK: DF */ +#define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8) +/* RAS MASK: SMN */ +#define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9) +/* RAS MASK: SEM */ +#define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10) +/* RAS MASK: MP0 */ +#define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11) +/* RAS MASK: MP1 */ +#define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12) +/* RAS MASK: FUSE */ +#define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/20 drm/amdgpu: skip gpu reset when ras error occured
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
gpu reset is not stable on vega20 A1.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +3 -0
@@ -182,10 +182,13 @@ int amdgpu_ras_reserve_bad_pages(struct amdgpu_device *adev);static inline int amdgpu_ras_reset_gpu (struct amdgpu_device *adev,bool is_baco) { +/* remove me when gpu reset works on vega20 A1. */ +#if 0 struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);if (atomic_cmpxchg (&ras->in_recovery,0 ,1 ) ==0 )schedule_work (&ras->recovery_work); +#endif return 0 ; }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/20 drm/amdgpu: add human readable debugfs control support (v2)
In reply to a message not in the archiveFrom: xinhui pan <[email protected]>
Currently, the debugfs control node can't parse bash-like commands. Now add such support for any tester that uses scripts.
v2: squash in fixes for input validation
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 115 +++++++++++++++++++++--- 1 file changed, 102 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +102 -13
@@ -200,14 +200,87 @@ static const struct file_operations amdgpu_ras_debugfs_ops = { .llseek = default_llseek }; +static int amdgpu_ras_find_block_id_by_name (const char *name,int *block_id) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (ras_block_string); i++) { + *block_id = i; +if (strcmp (name,ras_block_str (i)) ==0 ) +return 0 ; + } +return -EINVAL ; +} + +static int amdgpu_ras_debugfs_ctrl_parse_data (struct file *f, +const char __user *buf,size_t size, +loff_t *pos,struct ras_debug_if *data) +{ +ssize_t s =min_t (u64,64 , size); +char str[65 ]; +char block_name[33 ]; +char err[9 ] ="ue" ; +int op =-1 ; +int block_id; +u64 address, value; + +if (*pos) +return -EINVAL ; + *pos = size; + +memset (str,0 ,sizeof (str)); +memset (data,0 ,sizeof (*data)); + +if (copy_from_user (str, buf, s)) +return -EINVAL ; + +if (sscanf (str,"disable %32s" , block_name) ==1 ) + op =0 ; +else if (sscanf (str,"enable %32s %8s" , block_name, err) ==2 ) + op =1 ; +else if (sscanf (str,"inject %32s %8s" , block_name, err) ==2 ) + op =2 ; +else if (sscanf (str,"%32s" , block_name) ==1 ) +/* ascii string, but commands are not matched. */ +return -EINVAL ; + +if (op !=-1 ) { +if (amdgpu_ras_find_block_id_by_name (block_name, &block_id)) +return -EINVAL ; + + data->head.block = block_id; + data->head.type =memcmp ("ue" , err,2 ) ==0 ? +AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE : +AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE ; + data->op = op; + +if (op ==2 ) { +if (sscanf (str,"%*s %*s %*s %llu %llu" , + &address, &value) !=2 ) +if (sscanf (str,"%*s %*s %*s 0x%llx 0x%llx" , + &address, &value) !=2 ) +return -EINVAL ; + data->inject.address = address; + data->inject.value = value; + } + }else { +if (size <sizeof (data)) +return -EINVAL ; + +if (copy_from_user (data, buf,sizeof (*data))) +return -EINVAL ; + } + +return 0 ; +}/* * DOC: ras debugfs control interface * * It accepts struct ras_debug_if who has two members. * * First member: ras_debug_if::head or ras_debug_if::inject. -* It is used to indicate which IP block will be under control. -* Its contents are not human readable, IOW, write it by your programs. +* +* head is used to indicate which IP block will be under control. * * head has four members, they are block, type, sub_block_index, name. * block: which IP will be under control.
@@ -225,6 +298,28 @@ static const struct file_operations amdgpu_ras_debugfs_ops = {* 1: enable RAS on the block. Take ::head as its data. * 2: inject errors on the block. Take ::inject as its data. * +* How to use the interface? +* programs: +* copy the struct ras_debug_if in your codes and initialize it. +* write the struct to the control node. +* +* bash: +* echo op block [error [address value]] > .../ras/ras_ctrl +* op: disable, enable, inject +* disable: only block is needed +* enable: block and error are needed +* inject: error, address, value are needed +* block: umc, smda, gfx, ......... +* see ras_block_string[] for details +* error: ue, ce +* ue: multi_uncorrectable +* ce: single_correctable +* +* here are some examples for bash commands, +* echo inject umc ue 0x0 0x0 > /sys/kernel/debug/dri/0/ras/ras_ctrl +* echo inject umc ce 0 0 > /sys/kernel/debug/dri/0/ras/ras_ctrl +* echo disable umc > /sys/kernel/debug/dri/0/ras/ras_ctrl +* * How to check the result? * * For disable/enable, please check ras features at
@@ -243,19 +338,10 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *struct ras_debug_if data;int ret =0 ; -if (size <sizeof (data)) -return -EINVAL ; - -memset (&data,0 ,sizeof (data)); - -if (*pos) -return -EINVAL ; - -if (copy_from_user (&data, buf,sizeof (data))) + ret =amdgpu_ras_debugfs_ctrl_parse_data (f, buf, size, pos, &data); +if (ret)return -EINVAL ; - *pos = size; -if (!amdgpu_ras_is_supported (adev, data.head.block))return -EINVAL ;
@@ -269,6 +355,9 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *case 2 : ret =amdgpu_ras_error_inject (adev, &data.inject);break ; +default : + ret = -EINVAL ; +break ; };if (ret)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 19/20 drm/amdkfd: add RAS capabilities in topology for Vega20 (v2)
In reply to a message not in the archiveFrom: Eric Huang <[email protected]>
It is to collaborate with HSA_CAPABILITY in libhsakmt.
v2: squash in NULL pointer check
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 16 ++++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 4 ++++ 2 files changed, 20 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +16 -0
@@ -37,6 +37,7 @@#include "kfd_device_queue_manager.h" #include "kfd_iommu.h" #include "amdgpu_amdkfd.h" +#include "amdgpu_ras.h" /* topology_device_list - Master list of all topology devices */ static struct list_head topology_device_list;
@@ -1197,6 +1198,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)void *crat_image =NULL ;size_t image_size =0 ;int proximity_domain; +struct amdgpu_ras *ctx;INIT_LIST_HEAD (&temp_topology_device_list);
@@ -1328,6 +1330,20 @@ int kfd_topology_add_device(struct kfd_dev *gpu) dev->node_props.capability |=HSA_CAP_ATS_PRESENT ; } + ctx =amdgpu_ras_get_context ((struct amdgpu_device *)(dev->gpu->kgd)); +if (ctx) { +/* kfd only concerns sram ecc on GFX/SDMA and HBM ecc on UMC */ + dev->node_props.capability |= + (((ctx->features &BIT (AMDGPU_RAS_BLOCK__SDMA )) !=0 ) || + ((ctx->features &BIT (AMDGPU_RAS_BLOCK__GFX )) !=0 )) ? +HSA_CAP_SRAM_EDCSUPPORTED :0 ; + dev->node_props.capability |= ((ctx->features &BIT (AMDGPU_RAS_BLOCK__UMC )) !=0 ) ? +HSA_CAP_MEM_EDCSUPPORTED :0 ; + + dev->node_props.capability |= (ctx->features !=0 ) ? +HSA_CAP_RASEVENTNOTIFY :0 ; + } +kfd_debug_print_topology ();if (!res)
drivers/gpu/drm/amd/amdkfd/kfd_topology.h +4 -0
@@ -48,6 +48,10 @@#define HSA_CAP_DOORBELL_TYPE_2_0 0x2#define HSA_CAP_AQL_QUEUE_DOUBLE_MAP 0x00004000 +#define HSA_CAP_SRAM_EDCSUPPORTED 0x00080000 +#define HSA_CAP_MEM_EDCSUPPORTED 0x00100000 +#define HSA_CAP_RASEVENTNOTIFY 0x00200000 +struct kfd_node_properties {uint64_t hive_id;uint32_t cpu_cores_count;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 20/20 drm/amdkfd: add RAS ECC event support (v2)
In reply to a message not in the archiveFrom: Eric Huang <[email protected]>
RAS ECC event will combine with GPU reset event, due to ECC interrupts are caused by uncorrectable error that triggers GPU reset.
v2: Fix misleading-indentation warning
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 11 +++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_events.c | 18 +++++++++++++++++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 +++ include/uapi/linux/kfd_ioctl.h | 12 +++++++++++- 8 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -0
@@ -229,5 +229,6 @@ int kgd2kfd_quiesce_mm(struct mm_struct *mm);int kgd2kfd_resume_mm (struct mm_struct *mm);int kgd2kfd_schedule_evict_and_restore_process (struct mm_struct *mm,struct dma_fence *fence); +void kgd2kfd_set_sram_ecc_flag (struct kfd_dev *kfd);#endif /* AMDGPU_AMDKFD_H_INCLUDED */
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
@@ -4805,6 +4805,7 @@ static int gfx_v9_0_process_ras_data_cb(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry) {/* TODO ue will trigger an interrupt. */ +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev);amdgpu_ras_reset_gpu (adev,0 );return AMDGPU_RAS_UE ; }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
@@ -354,6 +354,7 @@ static int gmc_v9_0_ecc_interrupt_state(struct amdgpu_device *adev,static int gmc_v9_0_process_ras_data_cb (struct amdgpu_device *adev,struct amdgpu_iv_entry *entry) { +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev);amdgpu_ras_reset_gpu (adev,0 );return AMDGPU_RAS_UE ; }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -0
@@ -1851,6 +1851,8 @@ static int sdma_v4_0_process_ras_data_cb(struct amdgpu_device *adev,return 0 ; } +kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); +amdgpu_ras_reset_gpu (adev,0 );return AMDGPU_RAS_UE ;
drivers/gpu/drm/amd/amdkfd/kfd_device.c +11 -0
@@ -466,6 +466,8 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,memset (&kfd->doorbell_available_index,0 ,sizeof (kfd->doorbell_available_index)); +atomic_set (&kfd->sram_ecc_flag,0 ); +return kfd; }
@@ -661,6 +663,9 @@ int kgd2kfd_post_reset(struct kfd_dev *kfd)return ret; count =atomic_dec_return (&kfd_locked);WARN_ONCE (count !=0 ,"KFD reset ref. error" ); + +atomic_set (&kfd->sram_ecc_flag,0 ); +return 0 ; }
@@ -1024,6 +1029,12 @@ int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj)return 0 ; } +void kgd2kfd_set_sram_ecc_flag (struct kfd_dev *kfd) +{ +if (kfd) +atomic_inc (&kfd->sram_ecc_flag); +} +#if defined(CONFIG_DEBUG_FS )/* This function will send a package to HIQ to hang the HWS
drivers/gpu/drm/amd/amdkfd/kfd_events.c +17 -1
@@ -1011,25 +1011,41 @@ void kfd_signal_vm_fault_event(struct kfd_dev *dev, unsigned int pasid,void kfd_signal_reset_event (struct kfd_dev *dev) {struct kfd_hsa_hw_exception_data hw_exception_data; +struct kfd_hsa_memory_exception_data memory_exception_data;struct kfd_process *p;struct kfd_event *ev;unsigned int temp;uint32_t id, idx; +int reset_cause =atomic_read (&dev->sram_ecc_flag) ? +KFD_HW_EXCEPTION_ECC : +KFD_HW_EXCEPTION_GPU_HANG ;/* Whole gpu reset caused by GPU hang and memory is lost */ memset (&hw_exception_data,0 ,sizeof (hw_exception_data)); hw_exception_data.gpu_id = dev->id; hw_exception_data.memory_lost =1 ; + hw_exception_data.reset_cause = reset_cause; + +memset (&memory_exception_data,0 ,sizeof (memory_exception_data)); + memory_exception_data.ErrorType =KFD_MEM_ERR_SRAM_ECC ; + memory_exception_data.gpu_id = dev->id; + memory_exception_data.failure.imprecise = true; idx =srcu_read_lock (&kfd_processes_srcu);hash_for_each_rcu (kfd_processes_table, temp, p, kfd_processes) {mutex_lock (&p->event_mutex); id =KFD_FIRST_NONSIGNAL_EVENT_ID ; -idr_for_each_entry_continue (&p->event_idr, ev, id) +idr_for_each_entry_continue (&p->event_idr, ev, id) {if (ev->type ==KFD_EVENT_TYPE_HW_EXCEPTION ) { ev->hw_exception_data = hw_exception_data;set_event (ev); } +if (ev->type ==KFD_EVENT_TYPE_MEMORY && + reset_cause ==KFD_HW_EXCEPTION_ECC ) { + ev->memory_exception_data = memory_exception_data; +set_event (ev); + } + }mutex_unlock (&p->event_mutex); }srcu_read_unlock (&kfd_processes_srcu, idx);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3 -0
@@ -276,6 +276,9 @@ struct kfd_dev {uint64_t hive_id;bool pci_atomic_requested; + +/* SRAM ECC flag */ +atomic_t sram_ecc_flag; };enum kfd_mempool {
include/uapi/linux/kfd_ioctl.h +11 -1
@@ -211,6 +211,11 @@ struct kfd_ioctl_dbg_wave_control_args {#define KFD_HW_EXCEPTION_GPU_HANG 0#define KFD_HW_EXCEPTION_ECC 1 +/* For kfd_hsa_memory_exception_data.ErrorType */ +#define KFD_MEM_ERR_NO_RAS 0 +#define KFD_MEM_ERR_SRAM_ECC 1 +#define KFD_MEM_ERR_POISON_CONSUMED 2 +#define KFD_MEM_ERR_GPU_HANG 3struct kfd_ioctl_create_event_args {__u64 event_page_offset;/* from KFD */
@@ -250,7 +255,12 @@ struct kfd_hsa_memory_exception_data {struct kfd_memory_exception_failure failure;__u64 va;__u32 gpu_id; -__u32 pad; +__u32 ErrorType;/* 0 = no RAS error, +* 1 = ECC_SRAM, +* 2 = Link_SYNFLOOD (poison), +* 3 = GPU hang (not attributable to a specific cause), +* other values reserved +*/ };/* hw exception data */
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx