drivers/gpu/drm/amd/ras/rascore/ras_eeprom_fw.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/ras/rascore/ras_eeprom_fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/ras/rascore/ras_eeprom_fw.c- Extension
.c- Size
- 14685 bytes
- Lines
- 523
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ras.h
Detected Declarations
function filesfunction ras_fw_eeprom_supportedfunction ras_fw_get_table_versionfunction ras_fw_get_badpage_countfunction ras_fw_get_badpage_mca_addrfunction ras_fw_set_timestampfunction ras_fw_get_timestampfunction ras_fw_get_badpage_ipidfunction ras_fw_erase_ras_tablefunction ras_fw_eeprom_reset_tablefunction ras_fw_eeprom_check_safety_watermarkfunction ras_fw_eeprom_appendfunction ras_fw_eeprom_read_idxfunction ras_fw_eeprom_get_record_countfunction ras_fw_eeprom_update_recordfunction __check_ras_fw_table_statusfunction ras_fw_eeprom_hw_initfunction ras_fw_eeprom_hw_finifunction ras_fw_eeprom_check_storage_statusfunction ras_fw_eeprom_check_gpu_statusfunction ras_fw_eeprom_sync_info
Annotated Snippet
if (record_umc) {
record_umc[i - rec_idx].address = mca;
/* retired_page (pa) is unused now */
record_umc[i - rec_idx].retired_row_pfn = 0x1ULL;
record_umc[i - rec_idx].ts = ts;
record_umc[i - rec_idx].err_type = RAS_EEPROM_ERR_NON_RECOVERABLE;
ras_core->ras_umc.ip_func->mca_ipid_parse(ras_core, ipid,
&cu, &mem_channel, &mcumc_id, NULL);
record_umc[i - rec_idx].cu = (u8)cu;
record_umc[i - rec_idx].mem_channel = (u8)mem_channel;
record_umc[i - rec_idx].mcumc_id = (u8)mcumc_id;
/* update bad channel bitmap */
if ((record_umc[i - rec_idx].mem_channel < BITS_PER_TYPE(control->bad_channel_bitmap)) &&
!(control->bad_channel_bitmap & (1 << record_umc[i - rec_idx].mem_channel))) {
control->bad_channel_bitmap |= 1 << record_umc[i - rec_idx].mem_channel;
control->update_channel_flag = true;
}
}
if (ras_ecc) {
ras_ecc[i - rec_idx].addr = mca;
ras_ecc[i - rec_idx].ipid = ipid;
ras_ecc[i - rec_idx].ts = ts;
}
}
out:
mutex_unlock(&control->ras_tbl_mutex);
return ret;
}
uint32_t ras_fw_eeprom_get_record_count(struct ras_core_context *ras_core)
{
if (!ras_core)
return 0;
return ras_core->ras_fw_eeprom.ras_num_recs;
}
int ras_fw_eeprom_update_record(struct ras_core_context *ras_core,
struct ras_bank_ecc *ras_ecc)
{
struct ras_fw_eeprom_control *control = &ras_core->ras_fw_eeprom;
int ret, retry = 20;
u32 recs_num_new = control->ras_num_recs;
do {
/* 1000ms timeout is long enough, smu_get_badpage_count won't
* return -EBUSY before timeout.
*/
ret = ras_fw_get_badpage_count(ras_core,
&recs_num_new, RAS_SMU_MESSAGE_TIMEOUT_MS);
if (!ret &&
(recs_num_new == control->ras_num_recs)) {
/* record number update in PMFW needs some time,
* smu_get_badpage_count may return immediately without
* count update, sleep for a while and retry again.
*/
msleep(50);
retry--;
} else {
break;
}
} while (retry);
if (ret)
return ret;
if (recs_num_new > control->ras_num_recs)
ret = ras_fw_eeprom_read_idx(ras_core, 0,
ras_ecc, control->ras_num_recs, 1);
else
ret = -EINVAL;
return ret;
}
static int __check_ras_fw_table_status(struct ras_core_context *ras_core)
{
struct ras_fw_eeprom_control *control = &ras_core->ras_fw_eeprom;
uint64_t local_time;
int res;
mutex_init(&control->ras_tbl_mutex);
res = ras_fw_get_table_version(ras_core, &(control->version));
if (res)
Annotation
- Immediate include surface: `ras.h`.
- Detected declarations: `function files`, `function ras_fw_eeprom_supported`, `function ras_fw_get_table_version`, `function ras_fw_get_badpage_count`, `function ras_fw_get_badpage_mca_addr`, `function ras_fw_set_timestamp`, `function ras_fw_get_timestamp`, `function ras_fw_get_badpage_ipid`, `function ras_fw_erase_ras_table`, `function ras_fw_eeprom_reset_table`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.