Skip to content

soc: apple: enable the T8140 system level cache - #215

Merged
RyanTheTide merged 3 commits into
aurora-wipfrom
j700/t8140-slc-allocation
Oct 9, 2026
Merged

RyanTheTide merged 3 commits into
aurora-wipfrom
j700/t8140-slc-allocation

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

soc: apple: enable the T8140 system level cache

On the MacBook Neo (J700, T8140), the boot firmware enables and powers the system level cache (SLC) but leaves
allocation disabled. Each of the 4 cache planes reports 12 ways enabled and 12 ways powered, while its
allocation-disable word still reads 1. As a result the SLC holds no data, and every GPU and CPU access that misses the
core caches goes to DRAM. This is the main cause of a ~2x GL/Vulkan throughput gap (see the benchmarks below). That gap
was not in the GPU driver.

This series adds a small driver that turns allocation on from Linux:

  1. dt-bindings: soc: apple: Add the T8140 memory cache controller
    • Describes one register block per cache plane.
    • Adds apple,boot-dma-devices: the devices that take over DMA the bootloader left running.
  2. soc: apple: Enable T8140 system level cache allocation (drivers/soc/apple/mcc.c, CONFIG_APPLE_MCC, default
    ARCH_APPLE).
    • The driver defers until every apple,boot-dma-devices device is bound.
    • It checks that every plane has ways enabled equal to ways powered and no flush in progress. Only then does it clear
      each plane's allocation-disable word, and it reads the word back.
    • A plane that is not ready is reported and left alone, because allocation is only a performance setting.
    • On shutdown and unbind it stops allocating and flushes the cache, so the next boot stage starts from a clean SLC.
    • No maintenance is needed before enabling: with allocation disabled the SLC holds no data.
  3. arm64: dts: apple: t8140: Describe the memory cache controller
    • Adds the four planes at 0x2_2000_0000 + n * 0x40000, with the display as the hand-off device.
    • Enables the node on J700.

Why wait for the display

The display controller (DCP) is handed over live by the bootloader. Enabling allocation after the display has bound
keeps the cache state from changing during that hand-off.

  • We first tried enabling allocation in m1n1. One test boot then failed the display takeover: a disp0 DART translation
    fault and a DCP RTKit timeout.
  • The same failure was later also seen on 1 of 3 boots of an unrelated kernel with the unmodified boot chain. So that
    single boot is not attributed to the cache; it is an existing intermittent hand-off race that is being fixed
    separately.
  • Enabling from the kernel after the display is up avoids the question entirely.

Testing (MacBook Neo J700, Mesa 26.1.4 git-10aafd3ab4 Honeykrisp, GL via Zink, GNOME session with the panel on)

Hand-off gate. Six boots of a kernel carrying this series (4 on the plain tip DT, 2 with additional local DT
changes), all clean:

Check Result
DCP bound at 3.33–3.36 s
SLC allocation enabled 0.16–0.19 s later, at 3.49–3.54 s
Allocation-disable words read back 0 on all planes
DART faults / DCP RTKit failures / SError, Oops, WARN 0 / 0 / 0
Display and backlight, PMP, Wi-Fi up

Benchmarks.

  • Method:
    • glmark2-wayland build+texture, 5 s each.
    • vkcube in mailbox mode, 10000 frames.
    • glmark2 terrain and refract at 1920x1200, 8 s each.
    • Before each run, wait until the hottest P-core zone is at or below 72 °C (60 s at most).
    • Results are mean ± sd, with min–max where shown.
  • Configurations:
    • Before: a public-tip kernel without this series. Its tree also carried a local PMC series, which stays inactive
      without its DT nodes.
    • After: this series.
    • Where both are labelled "same boot", the SLC allocation word was the only change.
Configuration build+texture vkcube fps terrain refract
before, performance governor (5 runs) 902.4 ± 6.5 (895–911) 2141 ± 31 41.4 ± 0.5 44.0 ± 0
before → after, same boot, only the allocation word toggled, performance (5 runs) 1886.4 ± 20.3 (1858–1913) 5584 ± 182 65.6 ± 1.3 61.0 ± 0
after (this series), performance (3 runs) 1903 ± 7 (1897–1911) 5885 ± 147 65.0 ± 2.0 61.3 ± 0.6
after (this series), balanced / schedutil, the Neo's default (5 runs) 1442 ± 15 (1420–1461) 4857 ± 49 60.0 ± 0 60.0 ± 0.7
earlier kernel with allocation enabled (reference), performance (5 runs) 1895 ± 20 6008 ± 176 65.4 ± 0.5 61.4 ± 0.5

Latency. For a clear-only pass submitted and awaited serially, the submit-to-completion latency drops from about
560 µs to about 210 µs. GPU timestamps show the pass itself executing about 2x faster (22 → 14 µs).

Governor note. The difference between the balanced and performance rows is the CPU frequency governor. These small
benchmarks are bound by the host submit path, so they track the CPU clock.

10-minute stability (balanced):

  • Workload: glmark2 at 1920x1200 (build, texture, terrain, refract, shadow, jellyfish), then vkcube, in a loop.
  • 10 iterations; the composite score held flat at 417–419.
  • 0 client failures, 0 GPU faults, 0 Oops/SError/WARN.
  • Peak thermal zone 67 °C.

Checks:

  • checkpatch.pl --strict is clean except the Assisted-by format warning.
  • dt_binding_check passes for soc/apple/apple,t8140-mcc.yaml.
  • J700 build: 0 warnings.

Other Apple machines (M1/M2)

  • No shared code changes. The series adds a new driver file, a binding, Kconfig/Makefile/MAINTAINERS entries and
    T8140/J700 DT only.
  • Binding scope. The driver binds only apple,t8140-mcc, which appears only in t8140.dtsi.
  • Effect on M1/M2. On a distro config with ARCH_APPLE=y (the Fedora Asahi config used for our M1/M2 kernels),
    APPLE_MCC defaults to y. The driver is built and registered but never probes, because no M1/M2 DT has the node.
    It has no other initcalls or side effects.
  • Build proof. Under the M2 config, olddefconfig gives APPLE_MCC=y. drivers/soc/apple/mcc.o compiles with 0
    warnings, and its only initcall registers the platform driver.

Provenance

Written for this tree; tested on the MacBook Neo (J700).

Draft until reviewed. Hardware results above are from the MacBook Neo only.

🤖 Generated with Claude Code

The memory cache controller of the Apple T8140 holds the system level
cache in front of DRAM, split into planes. The boot firmware enables and
powers the cache ways of every plane but leaves allocation disabled, so
the operating system has to allow it.

Describe one register block per plane, and the devices that take over
DMA the bootloader left running: allocation must wait until they are
bound.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
On T8140 the boot firmware enables and powers the 12 ways of each of
the 4 system level cache planes, but leaves the allocation-disable word
of every plane set. The cache therefore holds no data, and every GPU
and CPU access that misses the core caches goes to DRAM.

Clear the allocation-disable word of each plane once every plane
reports as many ways powered as enabled and no flush in progress, and
read it back. Do it only after the devices named in the device tree as
having taken over DMA from the bootloader are bound, so the cache
starts allocating after their hand-off rather than during it. On
shutdown, stop allocating and flush the cache before the next boot
stage runs. With allocation disabled the cache holds no data, so no
maintenance is needed before enabling it.

Measured on J700 (MacBook Neo), toggling only this word on a running
system: glmark2 build+texture 902 -> 1886, vkcube 2141 -> 5584 fps,
glmark2 terrain at 1920x1200 41 -> 66 fps, and the submit-to-completion
latency of an isolated GPU job 560 -> 210 us.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Add the four system level cache planes of the T8140 memory cache
controller, with the display as the device that must take over its
bootloader DMA before cache allocation is enabled, and enable it on
J700.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant