Repository navigation
soc: apple: enable the T8140 system level cache - #215
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
dt-bindings: soc: apple: Add the T8140 memory cache controllerapple,boot-dma-devices: the devices that take over DMA the bootloader left running.soc: apple: Enable T8140 system level cache allocation(drivers/soc/apple/mcc.c,CONFIG_APPLE_MCC, defaultARCH_APPLE).apple,boot-dma-devicesdevice is bound.each plane's allocation-disable word, and it reads the word back.
arm64: dts: apple: t8140: Describe the memory cache controller0x2_2000_0000 + n * 0x40000, with the display as the hand-off device.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.
fault and a DCP RTKit timeout.
single boot is not attributed to the cache; it is an existing intermittent hand-off race that is being fixed
separately.
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:
Benchmarks.
without its DT nodes.
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):
Checks:
checkpatch.pl --strictis clean except theAssisted-byformat warning.dt_binding_checkpasses forsoc/apple/apple,t8140-mcc.yaml.Other Apple machines (M1/M2)
T8140/J700 DT only.
apple,t8140-mcc, which appears only int8140.dtsi.ARCH_APPLE=y(the Fedora Asahi config used for our M1/M2 kernels),APPLE_MCCdefaults toy. 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.
APPLE_MCC=y.drivers/soc/apple/mcc.ocompiles with 0warnings, 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