Skip to content

drm/agx: current badapple driver; pick the backend from the loaded firmware - #105

Merged
henrikklee merged 3 commits into
mainfrom
a12-agx-badapple
Dec 2, 2026
Merged

henrikklee merged 3 commits into
mainfrom
a12-agx-badapple

Conversation

@henrikklee

Copy link
Copy Markdown

Part of the badapple import (https://forgejo.toe.quest/kiki/badapple @74ef26a). Nothing has run on hardware; with today's boot recipes nothing changes.

  • kieroid (author, [Orchard: from kiki/badapple@74ef26a patches/linux-0020-agx.patch], no sign-off: for orchard#388): his driver changes since the snapshot we merged: the 3D job waits on TA through a firmware-resolved barrier, render stamps step by 0x100, GPU capped at 740 MHz by default (agx.max_pstate; nothing throttles it yet), renders limited to 8192x4096 macrotiles (larger wedges the firmware), debugfs dump removed. dr1408's 21B91 path keeps its own behaviour.
  • Henrik: the backend follows the firmware actually loaded: agx.firmware if given, else the SHA-256 of the loaded firmware's __TEXT (20G81 8047723b…, 21B91 c63d55b5…, from the IPSWs), else the board's apple,firmware-build, else 20g81 (badapple's). XR/XS/XS Max -> 20G81 (byte-identical firmware on XR and XS Max), iPad 8 -> 21B91 (t8020-ipad8.dtsi sets the fallback). Binding updated.

Checked: full apple-16k kernel build (agx module, no warnings); all A12 DTBs compile; orchard test_source_* pass. Goes with OrchardLinux/mesa#45 (badapple Mesa refresh assumes this driver).

kieroid and others added 3 commits December 3, 2026 04:25
Since the snapshot this driver was imported from, badapple's driver has:

- queued a render's 3D job behind a barrier on its TA job's stamp,
  which the firmware resolves itself, instead of the driver kicking the
  3D job when it sees the TA stamp; render stamps now count up by 0x100
  per job, as Apple's do, and RegionC +0x8970 makes the scheduler poll a
  waiting barrier;
- capped the GPU at pstate 4 (740 MHz) by default, about half the power
  of the top 1098 MHz, since nothing throttles it for heat
  (agx.max_pstate=1..6);
- kept renders within 8192x4096 macrotiles, as twice that wedges the
  firmware;
- dropped its debugfs dump.

[Orchard: from kiki/badapple@74ef26a patches/linux-0020-agx.patch
 (badapple c6db02f, eead4b9, d64625b, 1c6d6e0); merged into the driver
 that carries dr1408's 21B91 backend: that path keeps its own stamps
 (agx21_render_rewrite()) and the fixed DONE_STAMP in the shared TA/3D
 builders, so only the 20G81 path changes.]
Assisted-by: LLM
The driver speaks two GPU firmware builds: badapple's 16.6.1 (20G81),
the XS Max's and, byte for byte, the XR's, and dr1408's 17.1.1 (21B91),
the iPad 8's and, byte for byte, the XR's. A module parameter defaulting
to 21b91 chose between them for every board, so a board handed the other
build would start the wrong backend.

Recognise the build from the firmware itself: the SHA-256 of its
0x44000-byte __TEXT segment, which iBoot loads at firmware address 0 and
m1n1 reserves (apple,segment-ranges), against the two known builds. The
Mach-O header with its UUID is not in a loaded segment, so the code
itself is the fingerprint. agx.firmware still overrides; without a match
the board's apple,firmware-build decides, else 20g81, the build badapple
runs.

Assisted-by: LLM
Signed-off-by: Henrik Klee <henrik@goat-code.com>
The iPad 8 is given 17.1.1's GPU firmware (21B91). The driver recognises
the build from the loaded firmware; apple,firmware-build is its fallback
when it cannot, so the iPad 8 never falls back to the XS Max's 20G81.

Assisted-by: LLM
Signed-off-by: Henrik Klee <henrik@goat-code.com>
@henrikklee
henrikklee merged commit 05ff517 into main Dec 2, 2026
4 checks passed
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.

2 participants