drivers/gpu/drm/amd/ras/rascore/ras_cmd.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/ras/rascore/ras_cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/ras/rascore/ras_cmd.c- Extension
.c- Size
- 16774 bytes
- Lines
- 544
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ras.hras_cmd.h
Detected Declarations
function filesfunction ras_cmd_update_bad_page_infofunction ras_cmd_get_group_bad_pagesfunction ras_cmd_get_bad_pagesfunction ras_cmd_clear_bad_page_infofunction ras_cmd_reset_all_error_countsfunction ras_cmd_get_cper_snapshotfunction ras_cmd_get_cper_recordsfunction ras_cmd_get_batch_trace_snapshotfunction ras_cmd_get_batch_trace_recordsfunction __get_ras_ta_blockfunction __get_ras_ta_err_typefunction ras_cmd_inject_errorfunction rascore_handle_cmdfunction ras_cmd_initfunction ras_cmd_finifunction ras_cmd_query_interface_infofunction ras_cmd_translate_soc_pa_to_bankfunction ras_cmd_translate_bank_to_soc_pa
Annotated Snippet
if (group_index >= group_cnt) {
ret = RAS_CMD__ERROR_INVALID_INPUT_DATA;
goto out;
}
i = group_index * RAS_CMD_MAX_BAD_PAGES_PER_GROUP;
for (;
i < bp_cnt && output_data->bp_in_group < RAS_CMD_MAX_BAD_PAGES_PER_GROUP;
i++) {
if (ras_umc_get_badpage_record(ras_core, i, &record)) {
ret = RAS_CMD__ERROR_GENERIC;
goto out;
}
ras_cmd_record = &output_data->records[i % RAS_CMD_MAX_BAD_PAGES_PER_GROUP];
memset(ras_cmd_record, 0, sizeof(*ras_cmd_record));
ras_cmd_update_bad_page_info(ras_cmd_record, &record);
output_data->bp_in_group++;
}
}
output_data->bp_total_cnt = bp_cnt;
out:
mutex_unlock(&ras_core->ras_umc.umc_lock);
return ret;
}
static int ras_cmd_get_bad_pages(struct ras_core_context *ras_core,
struct ras_cmd_ctx *cmd, void *data)
{
struct ras_cmd_bad_pages_info_req *input_data =
(struct ras_cmd_bad_pages_info_req *)cmd->input_buff_raw;
struct ras_cmd_bad_pages_info_rsp *output_data =
(struct ras_cmd_bad_pages_info_rsp *)cmd->output_buff_raw;
int ret;
if ((cmd->input_size != sizeof(struct ras_cmd_bad_pages_info_req)) ||
(cmd->output_buf_size < sizeof(*output_data)))
return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
ret = ras_cmd_get_group_bad_pages(ras_core, input_data->group_index, output_data);
if (ret)
return RAS_CMD__ERROR_GENERIC;
output_data->version = 0;
cmd->output_size = sizeof(struct ras_cmd_bad_pages_info_rsp);
return RAS_CMD__SUCCESS;
}
static int ras_cmd_clear_bad_page_info(struct ras_core_context *ras_core,
struct ras_cmd_ctx *cmd, void *data)
{
if (cmd->input_size != sizeof(struct ras_cmd_dev_handle))
return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
if (ras_fw_eeprom_supported(ras_core)) {
if (ras_fw_eeprom_reset_table(ras_core))
return RAS_CMD__ERROR_GENERIC;
} else {
if (ras_eeprom_reset_table(ras_core))
return RAS_CMD__ERROR_GENERIC;
}
if (ras_umc_clean_badpage_data(ras_core))
return RAS_CMD__ERROR_GENERIC;
return RAS_CMD__SUCCESS;
}
static int ras_cmd_reset_all_error_counts(struct ras_core_context *ras_core,
struct ras_cmd_ctx *cmd, void *data)
{
if (cmd->input_size != sizeof(struct ras_cmd_dev_handle))
return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
if (ras_aca_clear_all_blocks_ecc_count(ras_core))
return RAS_CMD__ERROR_GENERIC;
if (ras_umc_clear_logged_ecc(ras_core))
return RAS_CMD__ERROR_GENERIC;
return RAS_CMD__SUCCESS;
}
static int ras_cmd_get_cper_snapshot(struct ras_core_context *ras_core,
struct ras_cmd_ctx *cmd, void *data)
{
struct ras_cmd_cper_snapshot_rsp *output_data =
Annotation
- Immediate include surface: `ras.h`, `ras_cmd.h`.
- Detected declarations: `function files`, `function ras_cmd_update_bad_page_info`, `function ras_cmd_get_group_bad_pages`, `function ras_cmd_get_bad_pages`, `function ras_cmd_clear_bad_page_info`, `function ras_cmd_reset_all_error_counts`, `function ras_cmd_get_cper_snapshot`, `function ras_cmd_get_cper_records`, `function ras_cmd_get_batch_trace_snapshot`, `function ras_cmd_get_batch_trace_records`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.