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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/ras: add wrapper funcs for pmfw eeprom

add wrapper funcs for pmfw eeprom interface to make them
easier to be called

Signed-off-by: Gangliang Xie <ganglxie@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
0d21084c 12f4d448

+141
+125
drivers/gpu/drm/amd/ras/rascore/ras_eeprom_fw.c
··· 36 36 if (!sys_func->mp1_get_ras_enabled_mask(ras_core, &flags)) 37 37 ras_core->ras_fw_features = flags; 38 38 } 39 + 40 + bool ras_fw_eeprom_supported(struct ras_core_context *ras_core) 41 + { 42 + return !!(ras_core->ras_fw_features & RAS_CORE_FW_FEATURE_BIT__RAS_EEPROM); 43 + } 44 + 45 + int ras_fw_get_table_version(struct ras_core_context *ras_core, 46 + uint32_t *table_version) 47 + { 48 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 49 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 50 + 51 + return sys_func->mp1_send_eeprom_msg(ras_core, 52 + RAS_SMU_GetRASTableVersion, 0, table_version); 53 + } 54 + 55 + int ras_fw_get_badpage_count(struct ras_core_context *ras_core, 56 + uint32_t *count, uint32_t timeout) 57 + { 58 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 59 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 60 + uint64_t end, now; 61 + int ret = 0; 62 + 63 + now = (uint64_t)ktime_to_ms(ktime_get()); 64 + end = now + timeout; 65 + 66 + do { 67 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 68 + RAS_SMU_GetBadPageCount, 0, count); 69 + /* eeprom is not ready */ 70 + if (ret != -EBUSY) 71 + return ret; 72 + 73 + mdelay(10); 74 + now = (uint64_t)ktime_to_ms(ktime_get()); 75 + } while (now < end); 76 + 77 + RAS_DEV_ERR(ras_core->dev, 78 + "smu get bad page count timeout!\n"); 79 + return ret; 80 + } 81 + 82 + int ras_fw_get_badpage_mca_addr(struct ras_core_context *ras_core, 83 + uint16_t index, uint64_t *mca_addr) 84 + { 85 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 86 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 87 + uint32_t temp_arg, temp_addr_lo, temp_addr_high; 88 + int ret; 89 + 90 + temp_arg = index | (1 << 16); 91 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 92 + RAS_SMU_GetBadPageMcaAddr, temp_arg, &temp_addr_lo); 93 + if (ret) 94 + return ret; 95 + 96 + temp_arg = index | (2 << 16); 97 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 98 + RAS_SMU_GetBadPageMcaAddr, temp_arg, &temp_addr_high); 99 + 100 + if (!ret) 101 + *mca_addr = (uint64_t)temp_addr_high << 32 | temp_addr_lo; 102 + 103 + return ret; 104 + } 105 + 106 + int ras_fw_set_timestamp(struct ras_core_context *ras_core, 107 + uint64_t timestamp) 108 + { 109 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 110 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 111 + 112 + return sys_func->mp1_send_eeprom_msg(ras_core, 113 + RAS_SMU_SetTimestamp, (uint32_t)timestamp, 0); 114 + } 115 + 116 + int ras_fw_get_timestamp(struct ras_core_context *ras_core, 117 + uint16_t index, uint64_t *timestamp) 118 + { 119 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 120 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 121 + uint32_t temp = 0; 122 + int ret; 123 + 124 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 125 + RAS_SMU_GetTimestamp, index, &temp); 126 + if (!ret) 127 + *timestamp = temp; 128 + 129 + return ret; 130 + } 131 + 132 + int ras_fw_get_badpage_ipid(struct ras_core_context *ras_core, 133 + uint16_t index, uint64_t *ipid) 134 + { 135 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 136 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 137 + uint32_t temp_arg, temp_ipid_lo, temp_ipid_high; 138 + int ret; 139 + 140 + temp_arg = index | (1 << 16); 141 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 142 + RAS_SMU_GetBadPageIpid, temp_arg, &temp_ipid_lo); 143 + if (ret) 144 + return ret; 145 + 146 + temp_arg = index | (2 << 16); 147 + ret = sys_func->mp1_send_eeprom_msg(ras_core, 148 + RAS_SMU_GetBadPageIpid, temp_arg, &temp_ipid_high); 149 + if (!ret) 150 + *ipid = (uint64_t)temp_ipid_high << 32 | temp_ipid_lo; 151 + 152 + return ret; 153 + } 154 + 155 + int ras_fw_erase_ras_table(struct ras_core_context *ras_core, 156 + uint32_t *result) 157 + { 158 + struct ras_mp1 *mp1 = &ras_core->ras_mp1; 159 + const struct ras_mp1_sys_func *sys_func = mp1->sys_func; 160 + 161 + return sys_func->mp1_send_eeprom_msg(ras_core, 162 + RAS_SMU_EraseRasTable, 0, result); 163 + }
+16
drivers/gpu/drm/amd/ras/rascore/ras_eeprom_fw.h
··· 24 24 #ifndef __RAS_EEPROM_FW_H__ 25 25 #define __RAS_EEPROM_FW_H__ 26 26 27 + 27 28 void ras_fw_init_feature_flags(struct ras_core_context *ras_core); 29 + bool ras_fw_eeprom_supported(struct ras_core_context *ras_core); 30 + int ras_fw_get_table_version(struct ras_core_context *ras_core, 31 + uint32_t *table_version); 32 + int ras_fw_get_badpage_count(struct ras_core_context *ras_core, 33 + uint32_t *count, uint32_t timeout); 34 + int ras_fw_get_badpage_mca_addr(struct ras_core_context *ras_core, 35 + uint16_t index, uint64_t *mca_addr); 36 + int ras_fw_set_timestamp(struct ras_core_context *ras_core, 37 + uint64_t timestamp); 38 + int ras_fw_get_timestamp(struct ras_core_context *ras_core, 39 + uint16_t index, uint64_t *timestamp); 40 + int ras_fw_get_badpage_ipid(struct ras_core_context *ras_core, 41 + uint16_t index, uint64_t *ipid); 42 + int ras_fw_erase_ras_table(struct ras_core_context *ras_core, 43 + uint32_t *result); 28 44 29 45 #endif