Skip to content

Commit 2e8ea02

Browse files
committed
docs: add gpu OC tech docs
add a short technical describtion of the OC-process
1 parent e19d73e commit 2e8ea02

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Exynos9820 GPU OC patch notes
2+
3+
This document captures how the Exynos9820 GPU was patched to run faster, based
4+
on the same DVFS override path used for CPU overclocking.
5+
6+
## CPU OC pattern (reference)
7+
8+
The CPU overclocking logic lives in the CAL DVFS override flow:
9+
10+
- `drivers/soc/samsung/cal-if/cpucl1_dvfs_table.h` and
11+
`drivers/soc/samsung/cal-if/cpucl2_dvfs_table.h` define the full CPUCL1/2
12+
DVFS tables, including the highest (overclocked) bins.
13+
- `drivers/soc/samsung/cal-if/cpucl1_dvfs_overrides.h` and
14+
`drivers/soc/samsung/cal-if/cpucl2_dvfs_overrides.h` expose those bins as
15+
override entries for CAL/FVMap/vclk.
16+
- `drivers/soc/samsung/cal-if/vclk.c` inserts override bins into the vclk LUT
17+
at runtime and bumps the max/boot/resume rate if needed.
18+
- `drivers/soc/samsung/cal-if/cal-if.c` ensures `cal_dfs_get_max_freq()` and
19+
`cal_dfs_get_rate_table()` return the override levels when present.
20+
21+
GPU OC follows the same mechanism and entry points.
22+
23+
## GPU OC implementation
24+
25+
### DVFS table + override exposure (CAL/FVMap/vclk)
26+
27+
The GPU overclock levels are defined in `drivers/soc/samsung/cal-if/g3d_dvfs_table.h`.
28+
Each entry lists `(rate_khz, volt_uv, pll_freq_hz, pll_p, pll_m, pll_s, pll_k, override)`.
29+
Only the top four bins (910/858/806/754 MHz) set `override = 1`, so
30+
`drivers/soc/samsung/cal-if/gpu_dvfs_overrides.h` will materialize them as
31+
`gpu_dvfs_override_entry` structures that carry the `(rate_khz, volt_uv)` pair.
32+
33+
`drivers/soc/samsung/cal-if/vclk.c::vclk_get_dfs_info` is the runtime hook that
34+
builds each `vclk->lut` from the ECT `DVFS` block. After copying the standard
35+
levels, it checks `is_gpu` and the override list. For each override entry it:
36+
37+
1. Finds an insertion point that keeps the LUT sorted (descending rates in the
38+
normal GPU DVFS ordering). A duplicate entry is skipped.
39+
2. Allocates a params array cloned from the template level and patches the
40+
PLL indices via `vclk_pll_idx_for_rate()` so the override uses correct PLL
41+
settings.
42+
3. Inserts the override level by shifting the LUT and hooks the new params.
43+
4. Tracks `highest_override` and, once all overrides are injected, updates
44+
`vclk->max_freq`, `boot_freq`, and `resume_freq` so they point at the new top
45+
bin if they previously matched the original limit.
46+
47+
`drivers/soc/samsung/cal-if/cal-if.c::cal_dfs_get_max_freq()` mirrors this by
48+
querying `gpu_dvfs_override_highest_rate()` (the highest override entry) and
49+
forcing the CAL max rate to that value. `cal_dfs_get_rate_table()` will also
50+
prepend the override rates to the published table so userspace sees them.
51+
52+
This is 1:1 with how CPUCL1/CPUCL2 OC works because `cal-if` treats GPUs, CPUCL1,
53+
and CPUCL2 the same: each has a `_dvfs_overrides` file, the override count is
54+
added to `alloc_num_rates`, and only the forced components (GPU/CPUCL1/CPUCL2)
55+
apply the extra levels. This keeps FVMap, CAL, and vclk in sync without
56+
special-casing GPU logic elsewhere.
57+
58+
### Device tree DVFS/limits (Mali node)
59+
60+
The Mali device tree tables must match the override table so that
61+
governor/pm_qos consumers can request the new rates.
62+
63+
- `arch/arm64/boot/dts/exynos/exynos9820-mali_tables.dtsi` contains the
64+
`gpu_dvfs_table` (each row is `freq down up stay mif little middle big`), and
65+
the `gpu_cl_pmqos_table`. The top rows reach 910 MHz, and both
66+
`gpu_max_clock` and `gpu_max_clock_limit` are set to `910000`, ensuring the
67+
Mali driver enforces the same cap as CAL.
68+
- `arch/arm64/boot/dts/samsung/exynos9820-mali_rev2.dtsi` pulls in the table and
69+
explicitly sets `gpu_dvfs_start_clock` / `gpu_dvfs_bl_config_clock` so the
70+
interactive governor can start at the lower boundary (and the boot rate
71+
stays within the table) while still allowing dynamic jumps to the override
72+
bins.
73+
74+
Together this guarantees that the DT-based Mali DVFS controller, the CAL
75+
override path, and the GPU governor see a consistent set of frequencies.
76+
77+
## Changing the GPU OC bins (technical checklist)
78+
79+
1. **Define the new levels.** Extend `drivers/soc/samsung/cal-if/g3d_dvfs_table.h`
80+
with every new `(rate_khz, volt_uv, pll_freq_hz, pll_p, pll_m, pll_s, pll_k, override)`
81+
tuple. Set `override = 1` for all levels that should bypass the stock DVFS LUT.
82+
Confirm the PLL values match the `vclk_pll_idx_for_rate()` table inside
83+
`drivers/soc/samsung/cal-if/vclk.c` so the new rate can resolve to a valid
84+
PLL index when `dvfs_override_insert()` patches `override_params`.
85+
86+
2. **Keep overrides in sync.** No further source changes are needed: once the
87+
table exposes an override entry, `gpu_dvfs_overrides.h` automatically builds
88+
the `gpu_dvfs_override_entry[]`, and `vclk_get_dfs_info()` handles:
89+
- increasing `alloc_num_rates`, allocating `override_params`, and looking up the
90+
PLL index per clock via `vclk_pll_idx_for_rate()`.
91+
- inserting the level into `vclk->lut`, re-sorting (descending rates), and
92+
bumping `vclk->max_freq/boot_freq/resume_freq` if needed. Inspect the loop
93+
starting at `drivers/soc/samsung/cal-if/vclk.c:660` to understand the insertion flow.
94+
95+
3. **Update the Mali DT tables.**
96+
- `arch/arm64/boot/dts/exynos/exynos9820-mali_tables.dtsi` must list the same
97+
frequencies inside `gpu_dvfs_table`. Keep `gpu_max_clock`/`gpu_max_clock_limit`
98+
aligned to the highest override rate.
99+
- If you need a different startup or boot hint, change `gpu_dvfs_start_clock`
100+
/ `gpu_dvfs_bl_config_clock` (and optionally `interactive_info` or
101+
`gpu_vk_boost_*`) inside `arch/arm64/boot/dts/samsung/exynos9820-mali_rev2.dtsi`.
102+
- Double-check that `gpu_sustainable_info` still matches the new bin range.
103+
104+
4. **Rebuild and verify the override path.**
105+
- After building, `cal_dfs_get_rate_table()` (called by sysfs/debugfs and CAL users)
106+
should list the new rate; it reuses `vclk->lut` including overrides (see the
107+
bottom of `drivers/soc/samsung/cal-if/cal-if.c`).
108+
- `cal_dfs_get_max_freq()` should now report `gpu_dvfs_override_highest_rate()`
109+
rather than the legacy max from the base DVFS table.
110+
- You can inspect `/sys/kernel/debug/clk/*/rates` or `cal_dfs_get_rate_table()`
111+
via `sysfs` to confirm the override is active.

0 commit comments

Comments
 (0)