drivers/gpu/drm/amd/ras/rascore/ras_psp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/ras/rascore/ras_psp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/ras/rascore/ras_psp.c- Extension
.c- Size
- 21131 bytes
- Lines
- 753
- 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.hras_ta_if.hras_psp.hras_psp_v13_0.h
Detected Declarations
function filesfunction ras_psp_sync_system_ras_psp_statusfunction ras_psp_get_ras_ta_init_paramfunction ras_psp_put_gpu_memfunction __acquire_psp_cmd_lockfunction __release_psp_cmd_lockfunction __get_ring_frame_slotfunction __set_ring_frame_slotfunction write_frame_to_ras_psp_ringfunction send_psp_cmdfunction __check_ras_ta_cmd_respfunction send_ras_ta_runtime_cmdfunction trigger_ras_ta_errorfunction send_load_ta_fw_cmdfunction load_ras_ta_firmwarefunction unload_ras_ta_firmwarefunction ras_psp_load_firmwarefunction ras_psp_unload_firmwarefunction ras_psp_trigger_errorfunction ras_psp_query_addressfunction ras_psp_sw_initfunction ras_psp_sw_finifunction ras_psp_hw_initfunction ras_psp_hw_finifunction ras_psp_check_supported_cmd
Annotated Snippet
if (status.initialized) {
ta_ctx->preload_ras_ta_enabled = true;
ta_ctx->ras_ta_initialized = status.initialized;
ta_ctx->session_id = status.session_id;
}
psp_ctx->external_mutex = status.psp_cmd_mutex;
}
return 0;
}
static int ras_psp_get_ras_ta_init_param(struct ras_core_context *ras_core,
struct ras_ta_init_param *ras_ta_param)
{
struct ras_psp *psp = &ras_core->ras_psp;
if (psp->sys_func && psp->sys_func->get_ras_ta_init_param)
return psp->sys_func->get_ras_ta_init_param(ras_core, ras_ta_param);
RAS_DEV_ERR(ras_core->dev, "Not config get_ras_ta_init_param API!!\n");
return -EACCES;
}
static struct gpu_mem_block *ras_psp_get_gpu_mem(struct ras_core_context *ras_core,
enum gpu_mem_type mem_type)
{
struct ras_psp *psp = &ras_core->ras_psp;
struct gpu_mem_block *gpu_mem = NULL;
int ret;
switch (mem_type) {
case GPU_MEM_TYPE_RAS_PSP_RING:
gpu_mem = &psp->psp_ring.ras_ring_gpu_mem;
break;
case GPU_MEM_TYPE_RAS_PSP_CMD:
gpu_mem = &psp->psp_ctx.psp_cmd_gpu_mem;
break;
case GPU_MEM_TYPE_RAS_PSP_FENCE:
gpu_mem = &psp->psp_ctx.out_fence_gpu_mem;
break;
case GPU_MEM_TYPE_RAS_TA_FW:
gpu_mem = &psp->ta_ctx.fw_gpu_mem;
break;
case GPU_MEM_TYPE_RAS_TA_CMD:
gpu_mem = &psp->ta_ctx.cmd_gpu_mem;
break;
default:
return NULL;
}
if (!gpu_mem->ref_count) {
ret = ras_core_get_gpu_mem(ras_core, mem_type, gpu_mem);
if (ret)
return NULL;
gpu_mem->mem_type = mem_type;
}
gpu_mem->ref_count++;
return gpu_mem;
}
static int ras_psp_put_gpu_mem(struct ras_core_context *ras_core,
struct gpu_mem_block *gpu_mem)
{
if (!gpu_mem)
return 0;
gpu_mem->ref_count--;
if (gpu_mem->ref_count > 0) {
return 0;
} else if (gpu_mem->ref_count < 0) {
RAS_DEV_WARN(ras_core->dev,
"Duplicate free gpu memory %u\n", gpu_mem->mem_type);
} else {
ras_core_put_gpu_mem(ras_core, gpu_mem->mem_type, gpu_mem);
memset(gpu_mem, 0, sizeof(*gpu_mem));
}
return 0;
}
static void __acquire_psp_cmd_lock(struct ras_core_context *ras_core)
{
struct ras_psp_ctx *psp_ctx = &ras_core->ras_psp.psp_ctx;
if (psp_ctx->external_mutex)
mutex_lock(psp_ctx->external_mutex);
Annotation
- Immediate include surface: `ras.h`, `ras_ta_if.h`, `ras_psp.h`, `ras_psp_v13_0.h`.
- Detected declarations: `function files`, `function ras_psp_sync_system_ras_psp_status`, `function ras_psp_get_ras_ta_init_param`, `function ras_psp_put_gpu_mem`, `function __acquire_psp_cmd_lock`, `function __release_psp_cmd_lock`, `function __get_ring_frame_slot`, `function __set_ring_frame_slot`, `function write_frame_to_ras_psp_ring`, `function send_psp_cmd`.
- 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.