drivers/gpu/drm/msm/adreno/a5xx_gpu.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/adreno/a5xx_gpu.c- Extension
.c- Size
- 56794 bytes
- Lines
- 1802
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/kernel.hlinux/types.hlinux/cpumask.hlinux/firmware/qcom/qcom_scm.hlinux/pm_opp.hlinux/nvmem-consumer.hlinux/slab.hmsm_gem.hmsm_mmu.ha5xx_gpu.h
Detected Declarations
struct a5xx_crashdumperstruct a5xx_gpu_statefunction update_shadow_rptrfunction a5xx_flushfunction a5xx_submit_in_rbfunction a5xx_submitfunction a5xx_set_hwcgfunction a5xx_me_initfunction adreno_is_a530function a5xx_preempt_startfunction a5xx_ucode_check_versionfunction a5xx_ucode_loadfunction a5xx_zap_shader_resumefunction a5xx_zap_shader_initfunction a5xx_hw_initfunction a5xx_recoverfunction a5xx_destroyfunction _a5xx_check_idlefunction a5xx_idlefunction a5xx_fault_handlerfunction a5xx_cp_err_irqfunction a5xx_rbbm_err_irqfunction a5xx_uche_err_irqfunction a5xx_gpmu_err_irqfunction a5xx_fault_detect_irqfunction a5xx_irqfunction a5xx_dumpfunction a5xx_pm_resumefunction a5xx_pm_suspendfunction A530function a5xx_get_timestampfunction a5xx_crashdumper_initfunction a5xx_crashdumper_runfunction a5xx_gpu_state_get_hlsq_regsfunction a5xx_gpu_state_destroyfunction a5xx_gpu_state_putfunction a5xx_showfunction a5xx_gpu_busyfunction a5xx_get_rptrfunction check_speed_bin
Annotated Snippet
struct a5xx_crashdumper {
void *ptr;
struct drm_gem_object *bo;
u64 iova;
};
struct a5xx_gpu_state {
struct msm_gpu_state base;
u32 *hlsqregs;
};
static int a5xx_crashdumper_init(struct msm_gpu *gpu,
struct a5xx_crashdumper *dumper)
{
dumper->ptr = msm_gem_kernel_new(gpu->dev,
SZ_1M, MSM_BO_WC, gpu->vm,
&dumper->bo, &dumper->iova);
if (!IS_ERR(dumper->ptr))
msm_gem_object_set_name(dumper->bo, "crashdump");
return PTR_ERR_OR_ZERO(dumper->ptr);
}
static int a5xx_crashdumper_run(struct msm_gpu *gpu,
struct a5xx_crashdumper *dumper)
{
u32 val;
if (IS_ERR_OR_NULL(dumper->ptr))
return -EINVAL;
gpu_write64(gpu, REG_A5XX_CP_CRASH_SCRIPT_BASE_LO, dumper->iova);
gpu_write(gpu, REG_A5XX_CP_CRASH_DUMP_CNTL, 1);
return gpu_poll_timeout(gpu, REG_A5XX_CP_CRASH_DUMP_CNTL, val,
val & 0x04, 100, 10000);
}
/*
* These are a list of the registers that need to be read through the HLSQ
* aperture through the crashdumper. These are not nominally accessible from
* the CPU on a secure platform.
*/
static const struct {
u32 type;
u32 regoffset;
u32 count;
} a5xx_hlsq_aperture_regs[] = {
{ 0x35, 0xe00, 0x32 }, /* HSLQ non-context */
{ 0x31, 0x2080, 0x1 }, /* HLSQ 2D context 0 */
{ 0x33, 0x2480, 0x1 }, /* HLSQ 2D context 1 */
{ 0x32, 0xe780, 0x62 }, /* HLSQ 3D context 0 */
{ 0x34, 0xef80, 0x62 }, /* HLSQ 3D context 1 */
{ 0x3f, 0x0ec0, 0x40 }, /* SP non-context */
{ 0x3d, 0x2040, 0x1 }, /* SP 2D context 0 */
{ 0x3b, 0x2440, 0x1 }, /* SP 2D context 1 */
{ 0x3e, 0xe580, 0x170 }, /* SP 3D context 0 */
{ 0x3c, 0xed80, 0x170 }, /* SP 3D context 1 */
{ 0x3a, 0x0f00, 0x1c }, /* TP non-context */
{ 0x38, 0x2000, 0xa }, /* TP 2D context 0 */
{ 0x36, 0x2400, 0xa }, /* TP 2D context 1 */
{ 0x39, 0xe700, 0x80 }, /* TP 3D context 0 */
{ 0x37, 0xef00, 0x80 }, /* TP 3D context 1 */
};
static void a5xx_gpu_state_get_hlsq_regs(struct msm_gpu *gpu,
struct a5xx_gpu_state *a5xx_state)
{
struct a5xx_crashdumper dumper = { 0 };
u32 offset, count = 0;
u64 *ptr;
int i;
if (a5xx_crashdumper_init(gpu, &dumper))
return;
/* The script will be written at offset 0 */
ptr = dumper.ptr;
/* Start writing the data at offset 256k */
offset = dumper.iova + (256 * SZ_1K);
/* Count how many additional registers to get from the HLSQ aperture */
for (i = 0; i < ARRAY_SIZE(a5xx_hlsq_aperture_regs); i++)
count += a5xx_hlsq_aperture_regs[i].count;
a5xx_state->hlsqregs = kcalloc(count, sizeof(u32), GFP_KERNEL);
if (!a5xx_state->hlsqregs)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/cpumask.h`, `linux/firmware/qcom/qcom_scm.h`, `linux/pm_opp.h`, `linux/nvmem-consumer.h`, `linux/slab.h`, `msm_gem.h`.
- Detected declarations: `struct a5xx_crashdumper`, `struct a5xx_gpu_state`, `function update_shadow_rptr`, `function a5xx_flush`, `function a5xx_submit_in_rb`, `function a5xx_submit`, `function a5xx_set_hwcg`, `function a5xx_me_init`, `function adreno_is_a530`, `function a5xx_preempt_start`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.