Skip to content

drm/asahi: allow firmware-managed GFX idle power-off - #3697

Merged
DjDeveloperr merged 8 commits into
mainfrom
fix/gfx-firmware-idle-power-off
Dec 3, 2026
Merged

DjDeveloperr merged 8 commits into
mainfrom
fix/gfx-firmware-idle-power-off

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What: Let the G15S/G16G firmware turn GFX off after idle. Keep the cores available through short gaps and service the startup cooling backstop while GFX is off.

Tested: J773g/G16G at 40178c02b870 and J516s/G15S at the earlier 98d103b8a5b4. Each board gated in 32/32 post-fence windows at about 42 ms. Controls stayed on in 32/32. Both compute and render CRCs matched throughout, with zero GPU faults, recoveries or hang kills. All 26 driver host tests passed at the head. J773g standalone at c53b7255 vs main dbfbced7 (one boot each): compute-wide CTS 119,249 cases and the render-turnaround sync list 39,375 cases identical to main with 0 Fail; GFX off in 16/16 idle windows at about 42 ms (main stays on); compute.light d4/d16/d64 within ±0.7 % of main; 10/10 pinned CRCs.

Risk: Two-way door · G15S/G16G. After a 200 ms idle gap, repowering GFX added 194 µs to the median M4 wake and 384 µs on M3 Pro. M4 first-workload d1 improved 2.9%. Its short depth-4/16/64 runs took 2.8%/1.5%/2.3% longer per submit. The longer unpinned comparison measured +0.18%/+0.08%/+0.52% at those depths.

Not yet

At the head ecd95b8ad8cf: J773g and J516s GFX off in 16/16 windows at 42 ms, 22/22 CRCs; J700 three deep sleeps with no regression. All three are in the comments below.

Driver change and physical measurements

Linux kept the bootstrap hold in place after channel setup. Its final device-control request held the GPU awake and its persistent Globals policy requested the same hold. Release both together on firmware layouts with guarded register access when GFX PMGR automatic mode is enabled. The running firmware can then gate the GPU and wake it on the next queue doorbell.

On J516s the loader also suppresses GFX automatic power management. Where Linux supplies the missing PMP link, release that hold in the same device-tree changeset. Keeping the loader hold in an isolation trial gave 0/16 off windows even with the firmware idle policy enabled.

The core and Fender timers run in sequence. A 40 ms core delay followed by 2 ms for Fender preserved short-gap wake latency and the overall gate time. On M4, gating also stopped the firmware events that used to service the cooling backstop after driver load. The new startup worker takes live PMP readings while the backstop needs them. It stops on a sensor error, a warm reading or completed qualification. Each transition still follows the existing temperature and elapsed-time rules.

A dedicated PMGR probe sampled ACTUAL after successful user timeline waits, for up to 250 ms. The intervals below are medians of the bracket around the first off sample. All 32 candidate windows on each board began with GFX on and ended with it off; subsequent submissions completed.

Board Tested revision Control off Candidate off Fence return to off
M4 mini, J773g 40178c0 0/32 32/32 42.116–42.387 ms
M3 Pro, J516s 98d103b 0/32 32/32 41.963–42.234 ms
Matched performance and correctness

Values are in microseconds. Each arm ran on two fresh boots with two uninstrumented passes per boot, 600 ms warmup and six 250 ms timed samples on throughput rows. The table gives the median of the four pass medians. The first-workload row uses only the first pass per boot. Timing runs and PMGR sampling were separate.

Row J773g control J773g head J516s control J516s earlier revision
First compute.light d1 after startup idle 103.63 100.64 — —
idle.wake, 2 ms gap 148.91 148.32 104.24 104.26
idle.wake, 20 ms gap 194.95 191.65 153.63 151.55
idle.wake, 200 ms gap 260.16 454.14 157.44 541.86
compute.light d1 103.63 101.91 90.07 89.10
compute.light d4 39.65 40.76 27.80 27.44
compute.light d16 23.47 23.82 13.96 13.73
compute.light d64 22.22 22.74 15.29 15.33
sync.signal, two queues, d2, per hop 25.40 25.86 15.81 15.86

On J773g, the order was head/control/control/head, using the same kernel Image (42169a041546), Mesa 285776c6af and GPUBench ae90a40. The signed head module had build ID 3bcab0e65213, the control 50b687b7c434. Each run waited eight seconds after driver load before the first workload. All 18 pre-work PMGR reads across the two head boots found GFX off. S10 became available at 53.74 and 53.96 seconds of boot time, within the controls' 53.59–54.25 seconds. First d1 took 99.86 and 101.42 µs on the head, versus 103.54 and 103.71 µs on control. In both visits the candidate took longer at d4/d16/d64. Uniform compute throughput changed from 367.33 to 367.13 Mthreads/s, and shadow throughput from 19.73 to 19.86 Gpixel/s.

In a separate single-boot diagnostic, the same module toggled between hold and allow across eight interleaved visits. Each visit validated the physical GFX state after a CRC-checked shadow render. Relative to hold, allow changed d1/d4/d16/d64 by −2.4%/−0.5%/−0.6%/−1.6%, and two-queue sync by +0.05%. This isolates the live policy toggle. The production/control binary comparison above still measured a difference.

Two further fresh J773g boots compared the unmodified control and head modules. The benchmark ran the same light compute sweep in six passes, with ordinary placement, high-capacity CPU, low-capacity CPU, low, high and ordinary. Each depth had 1.2 s of warmup and six 500 ms timed samples. Each cell gives the change in median µs per submit across the two passes in that placement.

Placement d4 d16 d64
Ordinary +0.18% +0.08% +0.52%
Fixed high-capacity CPU −0.07% +0.05% +0.35%
Fixed low-capacity CPU +0.18% +1.24% +0.95%

On ordinary placement the absolute times were 40.25 → 40.33 µs, 23.53 → 23.55 µs and 22.68 → 22.80 µs. The longer test used one boot per binary and did not repeat the two-queue sync row. Both boots reported zero GPU faults, recoveries or hang kills.

A separate M4 dEQP-VK compute-wide run on integration build 6f929cd5 matched main with 36,794 passes, zero failures and 82,455 unsupported cases. That build combined an earlier idle-gating revision with compute-manager changes.

On J516s the order was control/candidate/candidate/control, using the same 98d103b8a5b4 Image, Mesa 69179743d9ae, GPUBench cba9025d3fd9 and six active SLC planes. All eight passes on each board produced compute CRC b022fbaf and render CRC 7be9463a. All boots returned to stock.

A separate J516s sleep experiment observed both SpitfireE2 byte pairs at 01 01 after rendering with automatic GFX power. System sleep still stopped at stage 01 in that experiment.

Reproduce the second-generation row on J516s

Use a working T6030/J516s configuration and its usual 26B123 G15S boot handoff. Build the head and a baseline from e6c7b032633c with the same toolchain, config and board DT. Keep the normal module signing, boot and rollback procedure. The tested configuration used CONFIG_RUST=y, DRM_ASAHI=m, DRM_ASAHI_G15=y, DRM_ASAHI_G16=y, DRM_APPLE=m, DRM_APPLE_DCP_T8132=y, APPLE_DISPLAY_GATE=y, APPLE_PMP=m, THERMAL_OF=y and APPLE_PMGR_PWRSTATE=y. Verify CONFIG_APPLE_T6030_GPU_PMP_LINK=y in the resulting config; DRM_ASAHI_G15 selects it. The register sampler uses CONFIG_DEVMEM=y. Build the kernel Image, modules (including drivers/gpu/drm/asahi/aurora.ko) and DTBs. The built-in supplier change needs the head Image. Record the kernel and loaded module build IDs on each arm.

Use a separate output directory per boot. Boot headless, with modprobe.blacklist=aurora, and load the selected driver after its dependencies. Pin the same Borealis Vulkan ICD and GPUBench binary across arms. Run the first compute sweep after an eight-second idle. Save the output of every command, the kernel journal and before/after debugfs stats. The following shell fragment assumes G points at gpubench-vk and VK_DRIVER_FILES names the pinned ICD.

set -e
unset LD_PRELOAD
S=/sys/kernel/debug/aurora-g16/stats
cat "$S" > before.stats
sleep 8
for pass in 1 2; do
    opts=(--warmup-ms 600 --runs 6 --run-ms 250)
    "$G" --test compute.light --mode queue --depths 1,4,16,64 "${opts[@]}" > "light-$pass.jsonl"
    for gap in 2 20 200; do
        "$G" --test idle.wake --mode queue --depths 1 --param "gap_ms=$gap" "${opts[@]}" > "wake-$gap-$pass.jsonl"
    done
    "$G" --test sync.signal --mode queues --depths 2 --param kind=queue "${opts[@]}" > "sync-$pass.jsonl"
    "$G" --test compute.uber --mode queue --depths 4 --param kind=uniform "${opts[@]}" > "uniform-$pass.jsonl"
    "$G" --test render.shadow --mode queue --depths 4 --param mode=alpha_test --param res=2048 "${opts[@]}" > "shadow-$pass.jsonl"
done
cc -O2 -shared -fPIC gate.c -o gate.so -ldl
env LD_PRELOAD="$PWD/gate.so" "$G" --test idle.wake --mode queue --depths 1 --param gap_ms=200 --warmup-ms 600 --runs 6 --run-ms 250 > physical.jsonl 2> physical.stderr
cat "$S" > after.stats

Save the C block below as gate.c; it requires Vulkan headers and read access to the board's GFX PMGR register. A passing head should reach ACTUAL 0 from f in all 16 post-wait windows (about 42 ms), complete later submissions, match both CRCs, and have zero new GPU errors, recoveries, hang kills or quarantines. Report the paired timing rows, early or late gates, censored windows and any regressions.

// SPDX-License-Identifier: GPL-2.0-only
// Observe the first physical GFX-off sample after a successful Vulkan timeline wait.
// Used only for a dedicated electrical qualification run, outside timing rows.
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
#include <vulkan/vulkan_core.h>

static volatile const uint32_t *power_state;
static PFN_vkWaitSemaphores real_wait;
static unsigned observations;

static void die(const char *message)
{
    fprintf(stderr, "gate probe failed: %s\n", message);
    _exit(2);
}

static uint64_t now_ns(void)
{
    struct timespec ts;
    if (clock_gettime(CLOCK_MONOTONIC, &ts))
        die(strerror(errno));
    return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
}

__attribute__((constructor))
static void map_power_state(void)
{
    char board[256] = {0};
    int fd = open("/proc/device-tree/compatible", O_RDONLY | O_CLOEXEC);
    if (fd < 0)
        die(strerror(errno));
    ssize_t length = read(fd, board, sizeof(board));
    close(fd);
    if (length <= 0 || length == sizeof(board) || board[length - 1] != 0)
        die("unrecognized live compatible list");

    off_t address = 0;
    for (char *p = board; p < board + length; p += strlen(p) + 1) {
        if (!strcmp(p, "apple,j516s"))
            address = 0x290e80110;
        if (!strcmp(p, "apple,j773g"))
            address = 0x380700250;
    }
    if (!address)
        die("unknown board");
    long page = sysconf(_SC_PAGESIZE);
    if (page <= 0)
        die("unknown page size");
    fd = open("/dev/mem", O_RDONLY | O_SYNC | O_CLOEXEC);
    if (fd < 0)
        die(strerror(errno));
    void *mapping = mmap(NULL, page, PROT_READ, MAP_SHARED, fd, address - address % page);
    close(fd);
    if (mapping == MAP_FAILED)
        die(strerror(errno));
    power_state = (const volatile uint32_t *)((const char *)mapping + address % page);
    real_wait = (PFN_vkWaitSemaphores)dlsym(RTLD_NEXT, "vkWaitSemaphores");
    if (!real_wait)
        die("timeline wait symbol unavailable");
    fprintf(stderr, "gate address=%#" PRIx64 " initial=%#010x\n", (uint64_t)address, *power_state);
}

VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphores(VkDevice device,
        const VkSemaphoreWaitInfo *info, uint64_t timeout)
{
    VkResult result = real_wait(device, info, timeout);
    if (result != VK_SUCCESS || gettid() != getpid() || observations >= 16)
        return result;

    unsigned sample = ++observations;
    uint64_t start = now_ns(), last_nonzero_begin = start;
    uint32_t first = *power_state, word = first;
    uint64_t end = now_ns();
    while (((word >> 4) & 15) != 0 && end - start < 250000000) {
        struct timespec delay = { .tv_nsec = 200000 };
        nanosleep(&delay, NULL);
        uint64_t begin = now_ns();
        word = *power_state;
        end = now_ns();
        if ((word >> 4) & 15)
            last_nonzero_begin = begin;
    }
    fprintf(stderr, "gate wait=%u first=%#010x last=%#010x lower_ns=%" PRIu64
            " upper_ns=%" PRIu64 " off_observed=%u\n", sample, first, word,
            last_nonzero_begin - start, end - start, ((word >> 4) & 15) == 0);
    return result;
}

The shared G15/G16 runtime sends device-control opcode 0x0a with a
zero argument at startup. This requests a wake and keeps the GPU on.
On the G15S handoff the boot loader also forces the GFX power domain
active while the GPU lacks a PMP supplier.

When the kernel supplies that missing link, release the matching
power-domain hold in the same changeset. At GPU admission check that
PMGR permits automatic power and the runtime has a handoff guard for
powered-register accesses. Release the bootstrap hold in the final
policy command and persist the value for firmware re-import.

Give the cores the longer of the two successive idle intervals and
Fender the shorter interval. This keeps short gaps between submissions
warm while retaining the full-domain idle budget. On J773g the domain
gated at about 42 ms in 16/16 post-fence windows and the 2 ms and
20 ms wake latencies returned to their control levels.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Admission decides whether the domain can idle. Only InitData setup and
the final boot control consume that decision.

Pass it directly to both steps. Keeping a copy in the firmware graph
changed field offsets in the submission, polling and retirement paths
even though they never read that flag.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Autonomous GFX idle also stops the firmware notifications that drive
GPU housekeeping. On J773g the package stayed at 50-58 C, but the
driver took just one cooling sample over eight seconds and kept the
startup ceiling at S1. The first workload then spent 1.4-1.8 seconds
qualifying for the top state.

Arm the existing idle worker when the admitted GPU can idle and uses
PMP cooling. Collect real provider readings at the thermal polling
cadence while the startup backstop can still relax. Stop the extra
polls on a sensor error, a warm reading, or once the independent
backstop reaches the governor demand. Keep the normal protection and
time checks and require a live reading for these startup observations.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
The supplier harness compiles the production display-gate link helper.
Model the OF lookup and removal APIs used to drop the GFX hold when
adding the missing PMP link. Exercise the handoff path and check that
an existing supplier or a tree without the handoff retains the hold.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 30, 2026 20:46
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 30, 2026 20:46
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at ecd95b8a: ready to merge

Check Detail
CI at head ok 9 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at ecd95b8a
Conflicts ok none
PR text ok Risk: two-way · G15S/G16G. After a 200 ms idle gap, repowering GFX added 194 µs to the median M4 wake and 384 µs on M3 Pro. M4 first-workload d1 improved 2.9%. Its short depth-4/16/64 runs took 2.8%/1.5%/2.3% longer per submit. The longer unpinned comparison measured +0.18%/+0.08%/+0.52% at those depths.

Areas: area:gpu, area:platform
Merge: gh pr merge 3697 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded 12-01: not a hold under the merge bar (no shown failure). Only commit series checked, no code affirmation; follow-ups: queued CI, confirm exact-head or zero driver delta rows

Verdict: HOLD at c53b7255

Blockers:

  1. CI checks are still queued at c53b7255. Host tests, Apple build and KUnit, PMGR power state KUnit, and SEP source checks are still queued (pr-text and pr-readiness passed).
  2. Hardware rows predate the bff1fbd8 merge and c53b7255 head. The J773g/G16G (40178c02) and J516s/G15S (98d103b8) rows predate merging origin/main (bff1fbd8) and adding c53b7255; please confirm exact-head c53b7255 (or verify zero driver delta since 40178c02 once CI finishes green).

Checked:

  • Commit series (98d103b8..c53b7255, 15 files, +233/-35), MERGEABLE against main.
Evidence
  • Waiting for queued Host tests, Apple build and KUnit, PMGR power state KUnit, and SEP source checks at c53b7255, plus exact-head hardware row confirmation.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 30, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

PASS — J773g (M4 mini, T8132 G16G) standalone rows at c53b7255beeadec9a935c4e3662624cb01cfd577 vs main. CTS matches main exactly, GFX powers off in every idle window, and short-workload timing is within run-to-run noise.

  • Arms: main dbfbced7 with its own aurora module, and the same kernel with this head's driver (drivers/gpu/drm/asahi + pmp-cooling.h from c53b7255; tree checked equal to the head for those paths). The display-gate.c change isn't in the module, but it sits in the PMP-link path that T8132 never takes, so the module swap is the head's behaviour on this Mac. One boot per arm, same Borealis build.

  • CTS:

    List main head
    compute-wide (compute, SPIR-V compute, SSBO, memory model, atomics), 119,249 cases, 8 jobs 39,273 Pass / 0 Fail / 79,976 NotSupported 39,273 Pass / 0 Fail / 79,976 NotSupported
    render-turnaround sync list, 39,375 cases, 1 job 34,883 Pass / 0 Fail / 4,492 NotSupported 34,883 Pass / 0 Fail / 4,492 NotSupported

    0 GPU faults, recoveries or hang kills on either boot.

  • Idle/wake (200 ms gaps, PMGR GFX word sampled directly):

    • head: GFX went off in 16/16 windows, at 41.9–42.5 ms after the last fence.
    • main: GFX stayed on (0x1f0023ff) through the whole gap.
  • Short-workload timing, compute.light, µs/submit, two passes each:

    Depth main head
    1 98.3 / 106.3 106.9 / 97.3
    4 40.4 / 40.6 40.6 / 40.8
    16 23.7 / 23.7 23.6 / 23.4
    64 22.2 / 22.4 22.3 / 22.6

    Differences are within ±0.7 % at d4–d64; d1 swings ±8 % between passes on both arms.

  • Pinned CRCs, 10/10 on both arms: compute.uber d4 b022fbaf, render.postfx 1080p MSAA4 d1/d2 668d6f0a, render.bindless_ubo d2 1af53d5c, render.deferred tile MSAA4 d2 6dc74b48. Render timings match main within 0.3 %.

  • Afterwards: both boots returned to the saved stock kernel and passed the stock checks.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030, G15S B1, 27.2 stub) second-generation A/B row at exact head c53b7255beea vs exact merge-base dbfbced70b31 (same board, stock boot.bin, same gpubench-vk binary and Mesa): PASS.

  • Merge-base (dbfbced70b31, 7.3.0-m3-base3697+, boot_id=2674909d-f8ff-4152-b1b4-6e06a36bfc81):
    • PMGR GFX (290e80000 offset 0x110) over 16 × 200 ms idle gaps: OFF in 0/16 windows (stayed on=['0x0f0003ff']).
    • compute.light queue us_per_submit median (pass 1 / pass 2): d1 90.81 / 93.04, d4 31.46 / 30.73, d16 15.45 / 15.45, d64 16.82 / 16.82 µs.
    • aurora-g16 stats: jobs=752379, recoveries=0, hang_kills=0, failed=0, 0 GPU fault lines, 0 failed units.
  • Exact head (c53b7255beea, 7.3.0-m3-pr3697+, boot_id=63360419-9805-4f18-8199-bbefee17e627):
    • PMGR GFX (290e80000 offset 0x110) over 16 × 200 ms idle gaps: OFF in 16/16 windows (latency min=41.2 ms, median=43.3 ms, max=56.0 ms; on=['0x1400034f', '0x1f0003ff'], off=['0x1000030f']).
    • compute.light queue us_per_submit median (pass 1 / pass 2): d1 104.82 / 91.71, d4 30.93 / 34.65, d16 15.30 / 16.39, d64 16.80 / 16.63 µs (no short-workload regression).
    • aurora-g16 stats: jobs=741809, recoveries=0, hang_kills=0, failed=0, 0 GPU fault lines, 0 failed units.
  • CRCs (head vs merge-base, 100% match, all valid: true):
    • compute.uber d4: 9963f56c == 9963f56c
    • render.bindless_ubo d2: 57e7bedd == 57e7bedd
    • render.deferred (mode=tile,msaa=4) d2: 5e4130ce == 5e4130ce
    • render.postfx d1/d2 (default + msaa=4): 4707efa8 == 4707efa8
    • transfer.ops d1/d4: 55a4e6b1 == 55a4e6b1
  • Kernel errors: diff -u of journalctl -k -b -p err between base and head is empty (0 new kernel errors).

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merge-up check against current main (1262f9e1): three conflicts, and the g16/boot.rs one is not mechanical. Main's 34a6d434aeb9 ("stop G15S in prepare and preserve firmware SRAM") now sends the start devctl with policy.words[1] = 1 when the ADT layout has a powered block ("let the firmware manage idle at the normal boot policy boundary, Globals +0x30 = 1"). This PR replaces the same devctl_submit() call with DevCtl::idle_power_off(allow_idle). Both set the firmware idle policy at start, so whoever merges main has to pick one rule. Main's is unconditional for powered layouts, and this PR's follows allow_idle and the startup cooling backstop. The other two are adjacent edits: g16/mod.rs (main's register_pm_notify next to this PR's poll_now() at startup) and the stubs in t6030-pmp-supplier-tests.c. The J773g and J516s rows at c53b7255 stay valid for the merged head only if its G16 driver diff is unchanged from them, which the boot.rs choice decides. Left for the owner: merge main with that decision, then an independent review (the App's 11-30 pass checked only the commit series).

@RyanTheTide RyanTheTide reopened this Dec 3, 2026
@github-actions github-actions Bot removed the ready-to-merge Meets the merge policy: merge it (bot) label Dec 3, 2026
@erikwb

erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

We carry this PR in our unified daily kernel across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103).

Enabling firmware-managed GFX idle power-off lets the GPU power down cleanly when idle instead of sitting powered up between desktop frames, directly improving battery life on M1/M4/M5 laptops.

Booted and verified on our unified daily across J716c, J713, and J313 (desktop + Vulkan CTS smoke + Cyberpunk 2077 2.5 T2 on J716c) with zero GPU faults.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J615 (M3 Air, T8122, os-fw 27.2 / 26B123, aurora-g16) row at exact head d66b146 — PASS, no regression vs main.

Method: both arms booted as one aura-try trial with the same board DT, main's t8122-j615.dtb (byte-identical to this head's). On each arm, a GRUB one-shot into the kernel, the trial guard and a 30 min dead-man, then back to production. Order A, B, B, A. Each was measured about 240 s after boot. Kernel config: fleet94 + olddefconfig, the same for both arms.

  • A = main d1ae4f2 (7.3.0-m3p1), B = this head (7.3.0-m3p3697).
A main B #3697 B #3697 A main
glmark2-es2-gbm build/texture/shading FPS 5232/4962/4787 5784/5013/4807 build 5088 build 4865
terrain FPS (8 s runs) 639 361 637, 908, 913 910, 911, 443
g16 power under load / idle S8 / S2 S8 / S2 S8 S8
cooling backstop 8 -> 0 (limit S8) 18 s 20 s yes yes
health / GPU faults / recoveries 0 / 0 / 0 0 / 0 / 0 0 / 0 0 / 0

Terrain varies run to run on both arms by the same amount (one low run each: 443 on main, 361/637 on the head). The best runs match (913 vs 911). On T8122 the GFX genpd stays on throughout (allow_idle is false: no powered offset on this firmware), so this head changes no T8122 power behaviour, as intended. The only failed unit on both arms is the lab's older speakerguardd-v2-switchtest against the #3212 pairing. It is unrelated.

Note for other J615 rows: a 12-02+ kernel booted as a plain one-shot on our lab J615's older committed Stage 2 DT resets about 5 s into boot. Boot it with its own DTB (trial), as above.

Evidence (ours, untainted): traces/gpu/20261203-m3pro-gpu-dvfs/pr3697-j615/ (trial-A/B/B2/A2), trial logs traces/boot/20261127-dt-parity/rows/j615/run.log 12:59-13:38 AEDT. J615 restored: saved edge, Enforcing, 0 failed, no trial leftovers.

Conflict in g16/boot.rs: main (#3695) sends the last boot control from
Session::idle_power_off(), the same rule the compute UMA idle check
reads. Use that one rule for the control, the Globals word and the idle
delays, and drop this branch's separate Admitted::allow_idle copy of it.
test-publication.py checks the order of the merged code.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged main (62c60d13d4d8) as ecd95b8ad8cf. Merge commit only: no rebase, and no other commit on top of d66b146f6903.

Conflict: one, in g16/boot.rs. #3695 landed and sends the last boot control from Session::idle_power_off(). It is the same rule this branch had as Admitted::allow_idle (layout.powered), and the compute UMA idle check reads it too.

Changed against d66b146f6903:

  • boot.rs: the last boot control, the Globals word and the initdata idle delays all read session.idle_power_off(). Admitted::allow_idle and the run() parameter are gone. The bytes sent on each layout are the same as before.
  • mod.rs: startup cooling sampling tests layout.powered directly.
  • test-publication.py: drm/asahi: g16: keep compute UMA managers bound and ASC-cached #3695's check on the old policy.words[1] code now checks that one rule feeds the Globals word and the control, in that order.
  • All other files of this PR merged without a conflict. I did not edit them.

New on main, matters for the rows: #3695 and #3699 keep compute UMA managers bound and drop them when nothing is in flight on a layout that may power off. With this PR's delays the GPU does go off there, so the rows at this head test that too.

Checks: run-host-tests.py in the CI host-tests image: asahi-m4 1/1, m3- 19/19, pmp 24/24, pmgr 3/3, display 7/7. arm64 build of drivers/gpu/drm/asahi/, and W=1 of display-gate.o and g16/glue.o: no new warnings. That build used a trial tree that also has #3822; the GPU and display-gate sources in it are the same. The full host run was not repeated locally.

Rows owed at ecd95b8ad8cf: J516s (off windows, idle.wake, compute.light, CRCs, internal display up, a sleep cycle) and J773g (the same GPU points, time to S10). No hardware has run this head. The earlier approvals are for d66b146f6903, so this head needs a new one.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 3, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge uses the same layout-derived policy for the Globals word, final boot control and idle checks. The Globals update stays before the final control, and the existing host test now checks that ordering. Exact J516s and J773g rows remain pending.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (Apple M4 Mac mini, Mac16,10, T8132, G16G B0, os-fw 27.2 / 26B123) GPU idle power-gating and sustained CTS row at exact head ecd95b8ad8cf on 7.3.0-f3822 (Image 6adf47ba0a83…, t8132-j773g.dtb c793116212b0, boot_id=aeafd81f-7302-4f17-ac02-e92905aee7b0; composite kernel built on linux:main 62c60d13d4d8 + #3697 ecd95b8ad8cf + #3822 b3b1fc5c06af): PASS.

  • Physical GFX idle power-gating (payload-b, gate.so, PMGR 0x380700250):
    • Head 7.3.0-f3822: gate windows=16 on_first=16 off=16 off_ms min=42.2 med=42.4 max=81.9 (0x1f0023ff -> 0x1000230f on all 16/16 idle windows).
    • Base 7.3.0-j773g-ship1: gate windows=16 on_first=16 off=16 off_ms min=42.2 med=42.3 max=71.6.
  • gpubench-vk correctness + timing (payload-b, RESULT fails=0):
    • rows 23 invalid 0 (22/22 verified CRCs matched expected values, valid=True): compute.light d=4 39.23 / 38.91 us, compute.light d=64 20.13 / 20.17 us, compute.light procs d=2/8 60.10 / 34.57 us, compute.uber d=4 181.36 us (crc=b022fbaf), render.shadow d=4 1858.76 us, render.postfx d=1/2 1445.09 / 1033.06 us, render.deferred d=2 5618.69 us, sync.signal d=2 22.94 us, idle.wake gap=2/20/200ms 146.9 / 257.8 / 455.3 us.
  • Sustained 5+ min Vulkan CTS stress (mesa#1470 wide.txt, 4 parallel deqp-vk processes, default ICD):
    • 41 full passes (2,573 chunks, 188,509 Pass / 450,381 NotSupported / 0 Fail = 638,890 cases, 302.6s wall time, 1.22M GPU jobs, thermal ramp up to 79.25 C / S8).
    • 0 GPU recoveries (recoveries 0 -> 0, hang_kills 0 -> 0, health: failed 0 errno 0 degraded 0, 0 event 0x70 / ECANCELED / fault lines in dmesg).
  • Scope note: Single-generation (G16G B0) row; #3822's sleep check was not exercised on this boot because f3822's main DTB lacks #4164's apple,display-power.

DjDeveloperr added a commit to jgoyvaerts/linux that referenced this pull request Dec 3, 2026
…ng its pool

When a shared compute UMA manager's binding may be gone (it was
displaced, or the GPU may have powered off while idle), its next
command rebuilds its manager record. The rebuild also rewrote all 8192
freelist records (64 KiB of uncached writes) and the 16 pool-table
rows. When the firmware may power the GPU off on its own, every
publication with nothing in flight invalidates the held managers, so
nearly every job after an idle gap paid for that.

The freelist is a ring of 16384 records. The hardware takes pages at
the head cursor and returns them at the tail cursor, and both wrap at
the record count that bind loads with them. A rebuild restarts the
cursors at their seed: head 0, tail 8192. Taking a page only reads its
record; returning one writes the record at the tail. So after a
restart, returns fill the records from 8192 upwards, and none reaches
the first 8192 records before one has written the last record of the
ring. Until then the first 8192 records still hold the seed, every page
exactly once, and cursors at their seed describe the drained pool
exactly, wherever the hardware cursors were. Pages the hardware still
held when its cursors were lost do not matter: they are in the seed,
and with no command in flight no page is in use.

So the rebuild now reads two freelist records before it decides. The
last record reads zero until a return reaches it: the freelist is
zeroed when it is allocated, and a returned record holds a page
address. The first record still holds the first seed unless taking a
page wrote its record. If both hold, the rebuild writes only the
160-byte manager record and the 16 pool-row words. Otherwise it
reseeds the freelist as before and clears the last record, so that a
later rebuild can trust the seed again.

Some events do not show in the freelist. A system sleep, a recovery,
and a shared command that failed or was aborted advance a seed
generation in the slot ledger, and the next rebuild of every manager
then reseeds, whatever its freelist shows. Sleep and recovery call the
new restart_compute_uma(), which also invalidates the bindings; the
idle path still calls only invalidate_compute_uma().

On J773g, with aurora-silicon#3695 and aurora-silicon#3697 combined, skipping the reseed
unconditionally (idle invalidations unchanged, about 179k per boot)
measured:

  row                      as is         no reseed    no invalidation
  idle.wake 2/20/200 ms    175/272/539   145/193/458  142/192/458
  compute queue d1         121.5         99.1         101.2
  compute procs d2         67.9          59.0         58.3

That run passed the CRC smoke test 10/10 and the idle.wake stress with
checked compute, with the GPU physically off in 16 of 16 checks and no
faults. The reseed was the whole cost of the idle rebuild. This change
skips it only while the ring has not reached its end since the last
seed, which a run of short jobs between idle gaps never does.

The stats line gains the reseed count: "compute_uma: rebuilds N
invalidations M idle_invalidations K reseeds R".

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (Apple MacBook Pro 16-inch, M3 Pro, T6030, G15S B1, os-fw 27.2 / 26B123) update for ecd95b8ad8cf (7.3.0-f3822, Image 6adf47ba0a83…, identical stock DTB generation across base and head):

  • GPU idle power-gating (payload-b GPU arm — PASS):
    • Base (7.3.0-m3-s2r-g5f13cf7ab39a): gate address=0x290e80110 initial=0x0f0003ff, 16/16 waits off_observed=0.
    • Head (7.3.0-f3822, ecd95b8ad8cf): gate address=0x290e80110 initial=0x1f00030f, 16/16 waits on_first=16 (0x1f0003ff), off_observed=1 (0x1f00030f), off_ms min=42.2 med=42.3 max=75.4, rows 23 invalid 0, CONN card1-eDP-1 connected enabled On, RESULT fails=0, recoveries 0 hang_kills 0 sensor_errors 0.
  • GPU recovery control verdict (clears drm/asahi: allow firmware-managed GFX idle power-off #3697): The 11 G15S firmware recoveries (event=0x70/0x72/0x74, fault_scan: GPU powered down, PIO poll from agfGCPMSUpdateDashboard timeout after 250us [type:34 reg:0xd10080 expected:0x0 got:0x3]) seen during a subsequent Vulkan CTS run on 7.3.0-f3822 reproduced identically on the control kernel (7.3.0-pr3818v2+, without drm/asahi: allow firmware-managed GFX idle power-off #3697 or drm/apple: dcp: fix firmware-27 external and primary-HDMI s2r_ext deep sleep #3822): 11 recoveries on both kernels and both driver arms (drain_failed +98 on 7.3.0-f3822, +112 on 7.3.0-pr3818v2+), with chunks 0–61 (15,500 cases) clean and the first bad chunk at chunk 62 (dEQP-VK.ray_query.acceleration_structures.flags.traditional_structures.fragment_shader.gpu_built.triangles.identical_instances_aop.nopadding.fastbuild_update_0_0_bothgeneric).
  • Remaining payload-b step: The HEAD pm_test=1 sleep arm is not yet complete and is queued to run next once the machine is free for sleep cycles.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, A18 Pro, T8140, G17P) row, 12-03 12:55-13:03Z: PASS for no regression, as part of the dsrows merge tree 11a037b7481d, not the PR heads alone (this PR at ecd95b8ad8cf; tree and method in the #3822 comment). Kernel 7.3.0-f3822j-11a037b7.

  • GPUBench rows (compute_light, render_light, idle_wake_2, idle_wake_200) valid before and after three committed deep sleeps in one boot; 0 GPU fault/recovery lines, 0 WARN/BUG; the GPU renders with valid CRC after each wake.
  • Not covered: this PR's GFX-off windows. Its probe reads an M3/M4 power-manager register with no G17 equivalent, and its g16 driver doesn't run on the J700.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Local checks on this head merged with main 4789b55eb019 (the tree also carried #4039, which touches only g17/runtime.rs), in the CI host-tests image:

  • run-host-tests.py --only: t6030-pmp 5/5, asahi-m4 1/1, g16- 2/2, display-gate 1/1.
  • arm64 W=1 of drivers/gpu/drm/asahi/ and drivers/soc/apple/: builds, no C warnings. The Rust warnings are all on lines this PR does not touch.

Hosted KUnit asahi, apple-build and host-tests passed at this head (KUnit finished 11:21Z). Hardware rows at this head: J773g, J516s, J700 (above). Merging.

@DjDeveloperr
DjDeveloperr merged commit 53a83ab into main Dec 3, 2026
13 of 14 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/gfx-firmware-idle-power-off branch December 3, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants