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

drm/amd/pm: implement ras_smu_drv interface for smu v13.0.12

implement ras_smu_drv interface for smu v13.0.12

Signed-off-by: Gangliang Xie <ganglxie@amd.com>
Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Gangliang Xie and committed by
Alex Deucher
77dbd7c0 0c6f09e6

+156
+26
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
··· 503 503 uint64_t size; 504 504 }; 505 505 506 + struct ras_eeprom_table_version { 507 + uint32_t minor : 16; 508 + uint32_t major : 16; 509 + }; 510 + 511 + struct ras_eeprom_smu_funcs { 512 + int (*get_ras_table_version)(struct amdgpu_device *adev, 513 + uint32_t *table_version); 514 + int (*get_badpage_count)(struct amdgpu_device *adev, uint32_t *count, uint32_t timeout); 515 + int (*get_badpage_mca_addr)(struct amdgpu_device *adev, uint16_t index, uint64_t *mca_addr); 516 + int (*set_timestamp)(struct amdgpu_device *adev, uint64_t timestamp); 517 + int (*get_timestamp)(struct amdgpu_device *adev, 518 + uint16_t index, uint64_t *timestamp); 519 + int (*get_badpage_ipid)(struct amdgpu_device *adev, uint16_t index, uint64_t *ipid); 520 + int (*erase_ras_table)(struct amdgpu_device *adev, uint32_t *result); 521 + }; 522 + 523 + enum ras_smu_feature_flags { 524 + RAS_SMU_FEATURE_BIT__RAS_EEPROM = BIT_ULL(0), 525 + }; 526 + 527 + struct ras_smu_drv { 528 + const struct ras_eeprom_smu_funcs *smu_eeprom_funcs; 529 + void (*ras_smu_feature_flags)(struct amdgpu_device *adev, uint64_t *flags); 530 + }; 531 + 506 532 struct amdgpu_ras { 507 533 void *ras_mgr; 508 534 /* ras infrastructure */
+129
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
··· 34 34 #include "amdgpu_fru_eeprom.h" 35 35 #include <linux/pci.h> 36 36 #include "smu_cmn.h" 37 + #include "amdgpu_ras.h" 37 38 38 39 #undef MP1_Public 39 40 #undef smnMP1_FIRMWARE_FLAGS ··· 925 924 const struct smu_temp_funcs smu_v13_0_12_temp_funcs = { 926 925 .temp_metrics_is_supported = smu_v13_0_12_is_temp_metrics_supported, 927 926 .get_temp_metrics = smu_v13_0_12_get_temp_metrics, 927 + }; 928 + 929 + static int smu_v13_0_12_get_ras_table_version(struct amdgpu_device *adev, 930 + uint32_t *table_version) 931 + { 932 + struct smu_context *smu = adev->powerplay.pp_handle; 933 + 934 + return smu_cmn_send_smc_msg_with_param(smu, 935 + SMU_MSG_GetRASTableVersion, 0, table_version); 936 + } 937 + 938 + static int smu_v13_0_12_get_badpage_count(struct amdgpu_device *adev, uint32_t *count, 939 + uint32_t timeout) 940 + { 941 + struct smu_context *smu = adev->powerplay.pp_handle; 942 + uint64_t end, now; 943 + int ret = 0; 944 + 945 + now = (uint64_t)ktime_to_ms(ktime_get()); 946 + end = now + timeout; 947 + do { 948 + ret = smu_cmn_send_smc_msg_with_param(smu, 949 + SMU_MSG_GetBadPageCount, 0, count); 950 + /* eeprom is not ready */ 951 + if (ret != -EBUSY) 952 + return ret; 953 + mdelay(10); 954 + now = (uint64_t)ktime_to_ms(ktime_get()); 955 + } while (now < end); 956 + 957 + return ret; 958 + } 959 + 960 + static int smu_v13_0_12_set_timestamp(struct amdgpu_device *adev, uint64_t timestamp) 961 + { 962 + struct smu_context *smu = adev->powerplay.pp_handle; 963 + 964 + return smu_cmn_send_smc_msg_with_param(smu, 965 + SMU_MSG_SetTimestamp, (uint32_t)timestamp, 0); 966 + } 967 + 968 + static int smu_v13_0_12_get_timestamp(struct amdgpu_device *adev, 969 + uint16_t index, uint64_t *timestamp) 970 + { 971 + struct smu_context *smu = adev->powerplay.pp_handle; 972 + uint32_t temp; 973 + int ret; 974 + 975 + ret = smu_cmn_send_smc_msg_with_param(smu, 976 + SMU_MSG_GetTimestamp, index, &temp); 977 + if (!ret) 978 + *timestamp = temp; 979 + 980 + return ret; 981 + } 982 + 983 + static int smu_v13_0_12_get_badpage_ipid(struct amdgpu_device *adev, 984 + uint16_t index, uint64_t *ipid) 985 + { 986 + struct smu_context *smu = adev->powerplay.pp_handle; 987 + uint32_t temp_arg, temp_ipid_lo, temp_ipid_high; 988 + int ret; 989 + 990 + temp_arg = index | (1 << 16); 991 + ret = smu_cmn_send_smc_msg_with_param(smu, 992 + SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_lo); 993 + if (ret) 994 + return ret; 995 + 996 + temp_arg = index | (2 << 16); 997 + ret = smu_cmn_send_smc_msg_with_param(smu, 998 + SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_high); 999 + if (!ret) 1000 + *ipid = (uint64_t)temp_ipid_high << 32 | temp_ipid_lo; 1001 + return ret; 1002 + } 1003 + 1004 + static int smu_v13_0_12_erase_ras_table(struct amdgpu_device *adev, 1005 + uint32_t *result) 1006 + { 1007 + struct smu_context *smu = adev->powerplay.pp_handle; 1008 + 1009 + return smu_cmn_send_smc_msg_with_param(smu, 1010 + SMU_MSG_EraseRasTable, 0, result); 1011 + } 1012 + 1013 + static int smu_v13_0_12_get_badpage_mca_addr(struct amdgpu_device *adev, 1014 + uint16_t index, uint64_t *mca_addr) 1015 + { 1016 + struct smu_context *smu = adev->powerplay.pp_handle; 1017 + uint32_t temp_arg, temp_addr_lo, temp_addr_high; 1018 + int ret; 1019 + 1020 + temp_arg = index | (1 << 16); 1021 + ret = smu_cmn_send_smc_msg_with_param(smu, 1022 + SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_lo); 1023 + if (ret) 1024 + return ret; 1025 + 1026 + temp_arg = index | (2 << 16); 1027 + ret = smu_cmn_send_smc_msg_with_param(smu, 1028 + SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_high); 1029 + if (!ret) 1030 + *mca_addr = (uint64_t)temp_addr_high << 32 | temp_addr_lo; 1031 + return ret; 1032 + } 1033 + 1034 + static const struct ras_eeprom_smu_funcs smu_v13_0_12_eeprom_smu_funcs = { 1035 + .get_ras_table_version = smu_v13_0_12_get_ras_table_version, 1036 + .get_badpage_count = smu_v13_0_12_get_badpage_count, 1037 + .get_badpage_mca_addr = smu_v13_0_12_get_badpage_mca_addr, 1038 + .set_timestamp = smu_v13_0_12_set_timestamp, 1039 + .get_timestamp = smu_v13_0_12_get_timestamp, 1040 + .get_badpage_ipid = smu_v13_0_12_get_badpage_ipid, 1041 + .erase_ras_table = smu_v13_0_12_erase_ras_table, 1042 + }; 1043 + 1044 + static void smu_v13_0_12_ras_smu_feature_flags(struct amdgpu_device *adev, uint64_t *flags) 1045 + { 1046 + if (!flags) 1047 + return; 1048 + 1049 + *flags = 0ULL; 1050 + } 1051 + 1052 + const struct ras_smu_drv smu_v13_0_12_ras_smu_drv = { 1053 + .smu_eeprom_funcs = &smu_v13_0_12_eeprom_smu_funcs, 1054 + .ras_smu_feature_flags = smu_v13_0_12_ras_smu_feature_flags, 928 1055 };
+1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.h
··· 105 105 extern const struct cmn2asic_mapping smu_v13_0_12_feature_mask_map[]; 106 106 extern const struct cmn2asic_msg_mapping smu_v13_0_12_message_map[]; 107 107 extern const struct smu_temp_funcs smu_v13_0_12_temp_funcs; 108 + extern const struct ras_smu_drv smu_v13_0_12_ras_smu_drv; 108 109 109 110 #if defined(SWSMU_CODE_LAYER_L2) 110 111 #include "smu_cmn.h"