mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 22:52:19 +02:00
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>
This commit is contained in:
parent
12f4d4482a
commit
0d21084c02
|
|
@ -36,3 +36,128 @@ void ras_fw_init_feature_flags(struct ras_core_context *ras_core)
|
|||
if (!sys_func->mp1_get_ras_enabled_mask(ras_core, &flags))
|
||||
ras_core->ras_fw_features = flags;
|
||||
}
|
||||
|
||||
bool ras_fw_eeprom_supported(struct ras_core_context *ras_core)
|
||||
{
|
||||
return !!(ras_core->ras_fw_features & RAS_CORE_FW_FEATURE_BIT__RAS_EEPROM);
|
||||
}
|
||||
|
||||
int ras_fw_get_table_version(struct ras_core_context *ras_core,
|
||||
uint32_t *table_version)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
|
||||
return sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetRASTableVersion, 0, table_version);
|
||||
}
|
||||
|
||||
int ras_fw_get_badpage_count(struct ras_core_context *ras_core,
|
||||
uint32_t *count, uint32_t timeout)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
uint64_t end, now;
|
||||
int ret = 0;
|
||||
|
||||
now = (uint64_t)ktime_to_ms(ktime_get());
|
||||
end = now + timeout;
|
||||
|
||||
do {
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetBadPageCount, 0, count);
|
||||
/* eeprom is not ready */
|
||||
if (ret != -EBUSY)
|
||||
return ret;
|
||||
|
||||
mdelay(10);
|
||||
now = (uint64_t)ktime_to_ms(ktime_get());
|
||||
} while (now < end);
|
||||
|
||||
RAS_DEV_ERR(ras_core->dev,
|
||||
"smu get bad page count timeout!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ras_fw_get_badpage_mca_addr(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *mca_addr)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
uint32_t temp_arg, temp_addr_lo, temp_addr_high;
|
||||
int ret;
|
||||
|
||||
temp_arg = index | (1 << 16);
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetBadPageMcaAddr, temp_arg, &temp_addr_lo);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
temp_arg = index | (2 << 16);
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetBadPageMcaAddr, temp_arg, &temp_addr_high);
|
||||
|
||||
if (!ret)
|
||||
*mca_addr = (uint64_t)temp_addr_high << 32 | temp_addr_lo;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ras_fw_set_timestamp(struct ras_core_context *ras_core,
|
||||
uint64_t timestamp)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
|
||||
return sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_SetTimestamp, (uint32_t)timestamp, 0);
|
||||
}
|
||||
|
||||
int ras_fw_get_timestamp(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *timestamp)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
uint32_t temp = 0;
|
||||
int ret;
|
||||
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetTimestamp, index, &temp);
|
||||
if (!ret)
|
||||
*timestamp = temp;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ras_fw_get_badpage_ipid(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *ipid)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
uint32_t temp_arg, temp_ipid_lo, temp_ipid_high;
|
||||
int ret;
|
||||
|
||||
temp_arg = index | (1 << 16);
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetBadPageIpid, temp_arg, &temp_ipid_lo);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
temp_arg = index | (2 << 16);
|
||||
ret = sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_GetBadPageIpid, temp_arg, &temp_ipid_high);
|
||||
if (!ret)
|
||||
*ipid = (uint64_t)temp_ipid_high << 32 | temp_ipid_lo;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ras_fw_erase_ras_table(struct ras_core_context *ras_core,
|
||||
uint32_t *result)
|
||||
{
|
||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||
const struct ras_mp1_sys_func *sys_func = mp1->sys_func;
|
||||
|
||||
return sys_func->mp1_send_eeprom_msg(ras_core,
|
||||
RAS_SMU_EraseRasTable, 0, result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,22 @@
|
|||
#ifndef __RAS_EEPROM_FW_H__
|
||||
#define __RAS_EEPROM_FW_H__
|
||||
|
||||
|
||||
void ras_fw_init_feature_flags(struct ras_core_context *ras_core);
|
||||
bool ras_fw_eeprom_supported(struct ras_core_context *ras_core);
|
||||
int ras_fw_get_table_version(struct ras_core_context *ras_core,
|
||||
uint32_t *table_version);
|
||||
int ras_fw_get_badpage_count(struct ras_core_context *ras_core,
|
||||
uint32_t *count, uint32_t timeout);
|
||||
int ras_fw_get_badpage_mca_addr(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *mca_addr);
|
||||
int ras_fw_set_timestamp(struct ras_core_context *ras_core,
|
||||
uint64_t timestamp);
|
||||
int ras_fw_get_timestamp(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *timestamp);
|
||||
int ras_fw_get_badpage_ipid(struct ras_core_context *ras_core,
|
||||
uint16_t index, uint64_t *ipid);
|
||||
int ras_fw_erase_ras_table(struct ras_core_context *ras_core,
|
||||
uint32_t *result);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user