# qualcomm-linux/kgsl architecture

> Architecture diagram of the GitHub repository qualcomm-linux/kgsl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qualcomm-linux/kgsl
- Repository: https://github.com/qualcomm-linux/kgsl

## Overview

KGSL is the Linux kernel driver layer that enables userspace graphics and compute on Qualcomm Adreno GPUs. The main workflow is userspace issuing device operations and command submissions; KGSL manages device state and draw objects, while Adreno-specific code schedules and submits work to the GPU. Supporting branches manage GPU memory and power, communicate with the GMU, and expose debugging and profiling information. README statements support the broad capabilities; source excerpts are partial, so detailed runtime links not demonstrated there are omitted.

Main entry points: [`kgsl.c`](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl.c) (KGSL device core), [`adreno.c`](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno.c) (Adreno device), [`include/uapi/linux/msm_kgsl.h`](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/include/uapi/linux/msm_kgsl.h) (KGSL UAPI), [`adreno_hwsched.c`](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_hwsched.c) (Command scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Userspace interface"]
  node_uapi["KGSL UAPI<br/>[msm_kgsl.h]"]
end

subgraph group_core["KGSL core"]
  node_kgsl_ioctl["KGSL device core<br/>[kgsl.c]"]
  node_device_state["Device model<br/>[kgsl_device.h]"]
  node_drawobjs["Draw objects<br/>[kgsl_drawobj.c]"]
  node_kgsl_header["KGSL interfaces<br/>[kgsl.h]"]
end

subgraph group_gpu["Adreno execution"]
  node_adreno_core["Adreno device<br/>[adreno.c]"]
  node_adreno_types["Adreno interfaces<br/>[adreno.h]"]
  node_gpu_catalog["GPU models<br/>[adreno-gpulist.h]"]
  node_scheduler["Command scheduler<br/>[adreno_hwsched.c]"]
  node_gen8_hfi["Gen8 HFI"]
  node_command_packets["PM4 packets<br/>[adreno_pm4types.h]"]
  node_ib_parser["Command parser<br/>[adreno_cp_parser.c]"]
end

subgraph group_resources["Resources and power"]
  node_memory["GPU memory<br/>[kgsl_sharedmem.c]"]
  node_mmu["GPU address translation<br/>[kgsl_mmu.h]"]
  node_power["Power control<br/>[kgsl_pwrctrl.c]"]
  node_gmu["GMU core<br/>[kgsl_gmu_core.h]"]
end

subgraph group_observability["Diagnostics and profiling"]
  node_debug["Debug interfaces<br/>[kgsl_debugfs.h]"]
  node_snapshot["GPU snapshots<br/>[kgsl_snapshot.c]"]
  node_profiling["Profiling<br/>[adreno_profile.h]"]
  node_eventlog["Event log<br/>[kgsl_eventlog.h]"]
  node_tracing["Trace events<br/>[kgsl_trace.h]"]
end

node_userspace(("Graphics applications"))

node_userspace -->|"uses"| node_uapi
node_uapi -.->|"requests operations"| node_kgsl_ioctl
node_kgsl_ioctl -->|"creates submissions"| node_drawobjs
node_kgsl_ioctl -->|"uses device state"| node_device_state
node_kgsl_ioctl -->|"uses interfaces"| node_kgsl_header
node_kgsl_ioctl -->|"supports GPU operations"| node_adreno_core
node_adreno_core -->|"uses interfaces"| node_adreno_types
node_adreno_core -->|"selects GPU models"| node_gpu_catalog
node_adreno_core -->|"queues recovery work"| node_scheduler
node_scheduler -.->|"dispatches commands"| node_gen8_hfi
node_adreno_core -->|"uses packet definitions"| node_command_packets
node_ib_parser -->|"parses packets"| node_command_packets
node_kgsl_ioctl -->|"manages GPU memory"| node_memory
node_memory -.->|"uses address translation"| node_mmu
node_kgsl_ioctl -->|"manages GPU power"| node_power
node_adreno_core -->|"uses GMU services"| node_gmu
node_kgsl_ioctl -->|"provides debugging"| node_debug
node_adreno_core -.->|"captures GPU state"| node_snapshot
node_adreno_core -.->|"provides profiling"| node_profiling
node_kgsl_ioctl -->|"records events"| node_eventlog
node_adreno_core -->|"emits GPU traces"| node_tracing

click node_uapi "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/include/uapi/linux/msm_kgsl.h"
click node_kgsl_ioctl "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl.c"
click node_device_state "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_device.h"
click node_drawobjs "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_drawobj.c"
click node_kgsl_header "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl.h"
click node_adreno_core "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno.c"
click node_adreno_types "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno.h"
click node_gpu_catalog "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno-gpulist.h"
click node_scheduler "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_hwsched.c"
click node_gen8_hfi "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_gen8_hwsched_hfi.c"
click node_command_packets "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_pm4types.h"
click node_ib_parser "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_cp_parser.c"
click node_memory "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_sharedmem.c"
click node_mmu "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_mmu.h"
click node_power "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_pwrctrl.c"
click node_gmu "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_gmu_core.h"
click node_debug "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_debugfs.h"
click node_snapshot "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_snapshot.c"
click node_profiling "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_profile.h"
click node_eventlog "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_eventlog.h"
click node_tracing "https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_trace.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_uapi toneBlue
class node_kgsl_ioctl,node_device_state,node_drawobjs,node_kgsl_header toneAmber
class node_adreno_core,node_adreno_types,node_gpu_catalog,node_scheduler,node_gen8_hfi,node_command_packets,node_ib_parser toneMint
class node_memory,node_mmu,node_power,node_gmu toneRose
class node_debug,node_snapshot,node_profiling,node_eventlog,node_tracing,node_userspace toneIndigo
```

## Components

### Userspace interface

- [KGSL UAPI](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/include/uapi/linux/msm_kgsl.h): `include/uapi/linux/msm_kgsl.h`

### KGSL core

- [KGSL device core](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl.c): `kgsl.c`
- [Device model](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_device.h): `kgsl_device.h`
- [Draw objects](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_drawobj.c): `kgsl_drawobj.c`
- [KGSL interfaces](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl.h): `kgsl.h`

### Adreno execution

- [Adreno device](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno.c): `adreno.c`
- [Adreno interfaces](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno.h): `adreno.h`
- [GPU models](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno-gpulist.h): `adreno-gpulist.h`
- [Command scheduler](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_hwsched.c): `adreno_hwsched.c`
- [Gen8 HFI](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_gen8_hwsched_hfi.c): `adreno_gen8_hwsched_hfi.c`
- [PM4 packets](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_pm4types.h): `adreno_pm4types.h`
- [Command parser](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_cp_parser.c): `adreno_cp_parser.c`

### Resources and power

- [GPU memory](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_sharedmem.c): `kgsl_sharedmem.c`
- [GPU address translation](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_mmu.h): `kgsl_mmu.h`
- [Power control](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_pwrctrl.c): `kgsl_pwrctrl.c`
- [GMU core](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_gmu_core.h): `kgsl_gmu_core.h`

### Diagnostics and profiling

- [Debug interfaces](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_debugfs.h): `kgsl_debugfs.h`
- [GPU snapshots](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_snapshot.c): `kgsl_snapshot.c`
- [Profiling](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/adreno_profile.h): `adreno_profile.h`
- [Event log](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_eventlog.h): `kgsl_eventlog.h`
- [Trace events](https://github.com/qualcomm-linux/kgsl/blob/gfx-kernel.le.0.0/kgsl_trace.h): `kgsl_trace.h`

### Other components

- **Graphics applications**

## Connections

- Graphics applications → KGSL UAPI: uses
- KGSL UAPI → KGSL device core: requests operations
- KGSL device core → Draw objects: creates submissions (evidence: `kgsl.c`)
- KGSL device core → Device model: uses device state (evidence: `kgsl.c`)
- KGSL device core → KGSL interfaces: uses interfaces (evidence: `kgsl.c`)
- KGSL device core → Adreno device: supports GPU operations (evidence: `kgsl.c`)
- Adreno device → Adreno interfaces: uses interfaces (evidence: `adreno.c`)
- Adreno device → GPU models: selects GPU models (evidence: `adreno.c`)
- Adreno device → Command scheduler: queues recovery work (evidence: `adreno.c`)
- Command scheduler → Gen8 HFI: dispatches commands
- Adreno device → PM4 packets: uses packet definitions (evidence: `adreno.c`)
- Command parser → PM4 packets: parses packets (evidence: `adreno_cp_parser.c`)
- KGSL device core → GPU memory: manages GPU memory
- GPU memory → GPU address translation: uses address translation
- KGSL device core → Power control: manages GPU power
- Adreno device → GMU core: uses GMU services (evidence: `adreno.c`)
- KGSL device core → Debug interfaces: provides debugging (evidence: `kgsl.c`)
- Adreno device → GPU snapshots: captures GPU state
- Adreno device → Profiling: provides profiling
- KGSL device core → Event log: records events (evidence: `kgsl.c`)
- Adreno device → Trace events: emits GPU traces (evidence: `adreno.c`)
