Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add RAS query support for VCN 4.0

Initialize VCN RAS structure and add RAS status query function.

Signed-off-by: Tao Zhou <tao.zhou1@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Tao Zhou and committed by
Alex Deucher
377d0221 214c7642

+66
+60
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
··· 31 31 #include "soc15_hw_ip.h" 32 32 #include "vcn_v2_0.h" 33 33 #include "mmsch_v4_0.h" 34 + #include "vcn_v4_0.h" 34 35 35 36 #include "vcn/vcn_4_0_0_offset.h" 36 37 #include "vcn/vcn_4_0_0_sh_mask.h" ··· 65 64 static int vcn_v4_0_pause_dpg_mode(struct amdgpu_device *adev, 66 65 int inst_idx, struct dpg_pause_state *new_state); 67 66 static void vcn_v4_0_unified_ring_set_wptr(struct amdgpu_ring *ring); 67 + static void vcn_v4_0_set_ras_funcs(struct amdgpu_device *adev); 68 68 69 69 /** 70 70 * vcn_v4_0_early_init - set function pointers ··· 86 84 87 85 vcn_v4_0_set_unified_ring_funcs(adev); 88 86 vcn_v4_0_set_irq_funcs(adev); 87 + vcn_v4_0_set_ras_funcs(adev); 89 88 90 89 return 0; 91 90 } ··· 2004 2001 .rev = 0, 2005 2002 .funcs = &vcn_v4_0_ip_funcs, 2006 2003 }; 2004 + 2005 + static uint32_t vcn_v4_0_query_poison_by_instance(struct amdgpu_device *adev, 2006 + uint32_t instance, uint32_t sub_block) 2007 + { 2008 + uint32_t poison_stat = 0, reg_value = 0; 2009 + 2010 + switch (sub_block) { 2011 + case AMDGPU_VCN_V4_0_VCPU_VCODEC: 2012 + reg_value = RREG32_SOC15(VCN, instance, regUVD_RAS_VCPU_VCODEC_STATUS); 2013 + poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_VCPU_VCODEC_STATUS, POISONED_PF); 2014 + break; 2015 + default: 2016 + break; 2017 + } 2018 + 2019 + if (poison_stat) 2020 + dev_info(adev->dev, "Poison detected in VCN%d, sub_block%d\n", 2021 + instance, sub_block); 2022 + 2023 + return poison_stat; 2024 + } 2025 + 2026 + static bool vcn_v4_0_query_ras_poison_status(struct amdgpu_device *adev) 2027 + { 2028 + uint32_t inst, sub; 2029 + uint32_t poison_stat = 0; 2030 + 2031 + for (inst = 0; inst < adev->vcn.num_vcn_inst; inst++) 2032 + for (sub = 0; sub < AMDGPU_VCN_V4_0_MAX_SUB_BLOCK; sub++) 2033 + poison_stat += 2034 + vcn_v4_0_query_poison_by_instance(adev, inst, sub); 2035 + 2036 + return !!poison_stat; 2037 + } 2038 + 2039 + const struct amdgpu_ras_block_hw_ops vcn_v4_0_ras_hw_ops = { 2040 + .query_poison_status = vcn_v4_0_query_ras_poison_status, 2041 + }; 2042 + 2043 + static struct amdgpu_vcn_ras vcn_v4_0_ras = { 2044 + .ras_block = { 2045 + .hw_ops = &vcn_v4_0_ras_hw_ops, 2046 + }, 2047 + }; 2048 + 2049 + static void vcn_v4_0_set_ras_funcs(struct amdgpu_device *adev) 2050 + { 2051 + switch (adev->ip_versions[VCN_HWIP][0]) { 2052 + case IP_VERSION(4, 0, 0): 2053 + adev->vcn.ras = &vcn_v4_0_ras; 2054 + break; 2055 + default: 2056 + break; 2057 + } 2058 + 2059 + amdgpu_vcn_set_ras_funcs(adev); 2060 + }
+6
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.h
··· 24 24 #ifndef __VCN_V4_0_H__ 25 25 #define __VCN_V4_0_H__ 26 26 27 + enum amdgpu_vcn_v4_0_sub_block { 28 + AMDGPU_VCN_V4_0_VCPU_VCODEC = 0, 29 + 30 + AMDGPU_VCN_V4_0_MAX_SUB_BLOCK, 31 + }; 32 + 27 33 extern const struct amdgpu_ip_block_version vcn_v4_0_ip_block; 28 34 29 35 #endif /* __VCN_V4_0_H__ */