|
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,3 +926,131 @@ const struct smu_temp_funcs smu_v13_0_12_temp_funcs = { |
925 | 926 | .temp_metrics_is_supported = smu_v13_0_12_is_temp_metrics_supported, |
926 | 927 | .get_temp_metrics = smu_v13_0_12_get_temp_metrics, |
927 | 928 | }; |
| 929 | + |
| 930 | +static int smu_v13_0_12_get_ras_table_version(struct amdgpu_device *adev, |
| 931 | + uint32_t *table_version) |
| 932 | +{ |
| 933 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 934 | + |
| 935 | + return smu_cmn_send_smc_msg_with_param(smu, |
| 936 | + SMU_MSG_GetRASTableVersion, 0, table_version); |
| 937 | +} |
| 938 | + |
| 939 | +static int smu_v13_0_12_get_badpage_count(struct amdgpu_device *adev, uint32_t *count, |
| 940 | + uint32_t timeout) |
| 941 | +{ |
| 942 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 943 | + uint64_t end, now; |
| 944 | + int ret = 0; |
| 945 | + |
| 946 | + now = (uint64_t)ktime_to_ms(ktime_get()); |
| 947 | + end = now + timeout; |
| 948 | + do { |
| 949 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 950 | + SMU_MSG_GetBadPageCount, 0, count); |
| 951 | + /* eeprom is not ready */ |
| 952 | + if (ret != -EBUSY) |
| 953 | + return ret; |
| 954 | + mdelay(10); |
| 955 | + now = (uint64_t)ktime_to_ms(ktime_get()); |
| 956 | + } while (now < end); |
| 957 | + |
| 958 | + return ret; |
| 959 | +} |
| 960 | + |
| 961 | +static int smu_v13_0_12_set_timestamp(struct amdgpu_device *adev, uint64_t timestamp) |
| 962 | +{ |
| 963 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 964 | + |
| 965 | + return smu_cmn_send_smc_msg_with_param(smu, |
| 966 | + SMU_MSG_SetTimestamp, (uint32_t)timestamp, 0); |
| 967 | +} |
| 968 | + |
| 969 | +static int smu_v13_0_12_get_timestamp(struct amdgpu_device *adev, |
| 970 | + uint16_t index, uint64_t *timestamp) |
| 971 | +{ |
| 972 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 973 | + uint32_t temp; |
| 974 | + int ret; |
| 975 | + |
| 976 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 977 | + SMU_MSG_GetTimestamp, index, &temp); |
| 978 | + if (!ret) |
| 979 | + *timestamp = temp; |
| 980 | + |
| 981 | + return ret; |
| 982 | +} |
| 983 | + |
| 984 | +static int smu_v13_0_12_get_badpage_ipid(struct amdgpu_device *adev, |
| 985 | + uint16_t index, uint64_t *ipid) |
| 986 | +{ |
| 987 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 988 | + uint32_t temp_arg, temp_ipid_lo, temp_ipid_high; |
| 989 | + int ret; |
| 990 | + |
| 991 | + temp_arg = index | (1 << 16); |
| 992 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 993 | + SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_lo); |
| 994 | + if (ret) |
| 995 | + return ret; |
| 996 | + |
| 997 | + temp_arg = index | (2 << 16); |
| 998 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 999 | + SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_high); |
| 1000 | + if (!ret) |
| 1001 | + *ipid = (uint64_t)temp_ipid_high << 32 | temp_ipid_lo; |
| 1002 | + return ret; |
| 1003 | +} |
| 1004 | + |
| 1005 | +static int smu_v13_0_12_erase_ras_table(struct amdgpu_device *adev, |
| 1006 | + uint32_t *result) |
| 1007 | +{ |
| 1008 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 1009 | + |
| 1010 | + return smu_cmn_send_smc_msg_with_param(smu, |
| 1011 | + SMU_MSG_EraseRasTable, 0, result); |
| 1012 | +} |
| 1013 | + |
| 1014 | +static int smu_v13_0_12_get_badpage_mca_addr(struct amdgpu_device *adev, |
| 1015 | + uint16_t index, uint64_t *mca_addr) |
| 1016 | +{ |
| 1017 | + struct smu_context *smu = adev->powerplay.pp_handle; |
| 1018 | + uint32_t temp_arg, temp_addr_lo, temp_addr_high; |
| 1019 | + int ret; |
| 1020 | + |
| 1021 | + temp_arg = index | (1 << 16); |
| 1022 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 1023 | + SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_lo); |
| 1024 | + if (ret) |
| 1025 | + return ret; |
| 1026 | + |
| 1027 | + temp_arg = index | (2 << 16); |
| 1028 | + ret = smu_cmn_send_smc_msg_with_param(smu, |
| 1029 | + SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_high); |
| 1030 | + if (!ret) |
| 1031 | + *mca_addr = (uint64_t)temp_addr_high << 32 | temp_addr_lo; |
| 1032 | + return ret; |
| 1033 | +} |
| 1034 | + |
| 1035 | +static const struct ras_eeprom_smu_funcs smu_v13_0_12_eeprom_smu_funcs = { |
| 1036 | + .get_ras_table_version = smu_v13_0_12_get_ras_table_version, |
| 1037 | + .get_badpage_count = smu_v13_0_12_get_badpage_count, |
| 1038 | + .get_badpage_mca_addr = smu_v13_0_12_get_badpage_mca_addr, |
| 1039 | + .set_timestamp = smu_v13_0_12_set_timestamp, |
| 1040 | + .get_timestamp = smu_v13_0_12_get_timestamp, |
| 1041 | + .get_badpage_ipid = smu_v13_0_12_get_badpage_ipid, |
| 1042 | + .erase_ras_table = smu_v13_0_12_erase_ras_table, |
| 1043 | +}; |
| 1044 | + |
| 1045 | +static void smu_v13_0_12_ras_smu_feature_flags(struct amdgpu_device *adev, uint64_t *flags) |
| 1046 | +{ |
| 1047 | + if (!flags) |
| 1048 | + return; |
| 1049 | + |
| 1050 | + *flags = 0ULL; |
| 1051 | +} |
| 1052 | + |
| 1053 | +const struct ras_smu_drv smu_v13_0_12_ras_smu_drv = { |
| 1054 | + .smu_eeprom_funcs = &smu_v13_0_12_eeprom_smu_funcs, |
| 1055 | + .ras_smu_feature_flags = smu_v13_0_12_ras_smu_feature_flags, |
| 1056 | +}; |
0 commit comments