Restore power and average GFX meters, display clock telemetry and DPM ranges, and use rolling GRBM activity for GPU load. Add passive activity, cached SMU and GFX specification metrics contracts with matching monitor decoding and regression checks.
Fix SQ shared-buffer ownership across clients and synchronize the canonical LSE adapter with qualified default paths, inactive alternatives, cache identities and profiler fixes. Advance the driver build to 204 and record performance and perplexity evidence with actual target counts.
The driver-owned SQ busy counter (selector 70) reads 0 under load on
gfx1201: the SQ_PERFCOUNTER registers default to 0 and do not free-run
from a GRBM select-write, and the GRBM broadcast-read is select-to-one,
not a sum. The counter is armed only by the closed aqlprofile CP-perfmon
PM4 (workload-side), so a driver GRBM read cannot produce it. Verified
against the vendored Linux tree: amdgpu_pmu.c has no GC/SQ pmc_start
(only a Data-Fabric one), the event IDs 0x0e/0x0f are correct, and the
dext's own gfx_get_spec loops per-SE/SH rather than relying on
broadcast-sum.
Selector 70 now returns kIOReturnUnsupported with a real timestamp so
consumers see an honest no-source instead of a misleading 0; mtopg
labels the empty panel accordingly and points to the SMU GfxActivity /
dispatch-rate proxy as the usable GPU-busy signals. Bump driver to 201.
Also fix a pre-existing compile break in the dormant SQ-slot path
(selector 64): BOEntry no longer has a handle field, so store the caller's
opaque handle token instead of bo->handle.
Wires the real-hardware SQ busy counter (published by the LSE workload
process, see LemonSeed-Engine sq_profiler) to the observer tooling:
dext (driver build 200):
- kMacAMDGPUMethodRegisterSqSlot (64): the workload process registers the
16-byte GTT buffer its profiler writes ({seq, sq_busy, ref, clock},
4 x u32 LE). One slot per instance; a second workload's buffer is
refused, a restarted server re-claims its own.
- kMacAMDGPUMethodReadSqSlot (69): observer-only read of the slot
through the BAR4/ReBAR GART aperture (plain MMIO reads, no fence, no
writes — cannot perturb the workload). Returns
[status, seq, sq_busy, ref, clock]; status is kIOReturnUnsupported
while no slot is registered so consumers say "no source" instead of
0. seq-read-again guards against a mid-read window advance.
- BAR4 aperture captured at ensure_open; both selectors on the observer
allow-lists (shutdownBlocked / !pciOpen), like 61/68.
mtopg:
- GPUDriver: selSqSlot 69 (build 200+), SqSlotSample decode.
- MonitorModel: sqBusy series + current; a fresh seq becomes a busy %
(sq_busy / ref * 100, clamped), held across the ~500 ms window gap and
expired after 2.5 s of silence (the chart gap-blinks to n/a).
- Views: new "SQ Busy % (hardware counter)" panel with the honest
caption: real aqlprofile SQ_BUSY_CYCLES sums over all CUs — NOT CU
occupancy, NOT the dispatch-rate proxy (which stays as its own panel).
LSE adapter patch: sq_profiler.cpp added to lse_backend_hrx sources.
Nothing runs on the GPU until driver 200 is built/installed and the
server is restarted with the new LSE build; until then the panel shows
n/a and the existing dispatch-rate proxy is untouched.
The selector 68 UMC memory-busy counter read MM_PERFSTATUS at offset
0x04c18, but that register does not exist on gfx1201 (RDNA4): no MMHUB
PERFSTATUS/PERFCTR is defined in any upstream AMD register header, and the
read returned 0xFFFFFFFF at both idle and under an active 27B decode — an
unmapped MMIO address, not a slow-to-arrive counter. The offset was a
fabrication (the "NBIO UMC convention" the comment cited has no basis in the
vendored header), and the only firmware UMC field (SMU AverageUclkActivity,
offset 126) reads ~0-1% even under a verified copy sweep, so it is not a
useful memory-busy proxy either.
gfx1201 therefore has no working, verified UMC-busy counter. Instead of
publishing 0xFFFFFFFF as if it were a live value, selector 68 now returns a
distinct "unavailable" status (kIOReturnUnsupported) with zeroed data, so
consumers can tell "no counter" from "counter read 0". The read path is
retained behind a kMmhubPerfStatusSupported gate for a future ASIC that
exposes a real MMHUB UMC-busy register; the old offsets are kept as
labeled placeholders.
- amdgpu_ip.h: drop the fabricated offset narrative; add the support gate.
- MacAMDGPU.cpp: selector 68 returns unavailable when unsupported.
- amdgpu_mtop: the umc_activity_source label + umcValue comment state that
the SMU field is the only (low-sensitivity) source and there is no MMHUB
hardware counter on this ASIC.
- project.yml: 198 -> 199.
Built, resigned (minimal DriverKit entitlements), installed and activated;
verified driver=199 stage=0 and selector 68 now returns status
0xe00002c7 / raw 0x0 (was 0xFFFFFFFF) at idle and under a short decode load.
The selector-68 sensor body sits in MacAMDGPUUserClient::ExternalMethod,
not a MacAMDGPU_IVars member function, so the bare name did not resolve.
Qualify it; the constant stays a MacAMDGPU_IVars member.
Add an observer-only method that samples the MMHUB UMC busy-time
accumulator and exposes it to the TUI as a second UMC-activity source
independent of the SMU metrics table.
- amdgpu_ip.h (MMHUBRegs): MM_PERFSTATUS (0x04c18), MM_PERFCTR0
(0x04c1c), MM_PERFCTR1 (0x04c20), the PERFCTR0 UMC busy source-select
value 0x01000000, and the 20-bit count mask. The offsets sit in the
low MMHUB-cfg register hole documented in mmhub_4_1_0_offset.h.
- MacAMDGPU.cpp: kMacAMDGPUMethodReadMmhubPerfStatus = 68. Admitted
like selector 63 (observer only: no PCI open, no ownership, busy only
while a submission is pending), and kept allowed while shutdown is
blocked or PCI is closed (it simply reports the cache unavailable).
Implemented on the serialized lifecycle queue: when pciOpen and
bringup has reached SDMAInit with MMHUB resolved, write PERFCTR0 =
0x01000000, read back PERFSTATUS, and cache the result at ~1 Hz to
bound MMIO frequency. Returns 4 scalars: [status, raw register,
cumulative busy Q8 (raw>>24, 20-bit saturating), collectedAtNs
CLOCK_UPTIME_RAW]. The cache resets when the device is not ready, so
a previous session's value is never published.
- project.yml: driver build 197 -> 198, marketing 0.1.97 -> 0.1.98
(coordinated with the queued driver-198 cycle; no build performed
here, source commit only).
The dext reads the GC_INFO discovery geometry (shader engines, arrays,
backends, CUs/array, wavefront, waves/SIMD, scratch slots, LDS size) and
the live harvest / disable-mask / SH-block registers (CU bitmap, SA and
RB masks, SH_MEM_CONFIG / SH_MEM_BASES of VMID 0, shader-array config
words, GRBM_GFX_CNTL readback) into a fixed 32-dword GFXSpecSnapshot,
served as 32 scalar outputs on QueryInfo info tag 8. The reader is
observer-safe: it runs only once the GC IP is resolved, uses the GRBM
select/deselect sequence gfx_v12_0_get_cu_info already performs, and
finishes broadcast-deselected.
The HSA runtime passes the block through a new exported
mac_hsa_agent_get_device_spec: the buffer is zeroed before the call so a
decline never leaves stale words standing as an answer, and the call is
gated on driver build 197, the first build that serves the tag. A driver
that predates the tag declines with an invalid-argument, which the
runtime's own test asserts alongside the size and agent checks.
Reject power-state and SMU feature requests before acquiring a client lease when firmware is not ready. Cover lease-free monitor admission during initialization and pending work, and record concurrent Qwen inference validation.
Grow and reclaim BO metadata in64-entry pages, raise client capacity to4096 handles, and prevent VRAM free-range metadata exhaustion. Add GPU activity history, bounded sensor sampling and clock/counter reporting.
Select the qualified GPU-owned signal mailbox by default while gating native mixed atomics on original PCIe evidence. Include native HRX/LSE adapters, guarded compute tests, reproducible signing and local build/server guides linked to Lemon Seed Engine.
Hardware validation covers1024 live buffers with fragmented reuse, pooled HRX allocations and2GiB boundaries, shared signal lifecycle, Q6 projection and680 exact convolution outputs. Full-model token generation remains blocked on the missing Loom repeat template.
Read and validate AMD identity after opening the PCI provider, unwind failed reads, and report precise requester preflight errors. Preserve general AMD device admission while keeping the requester experiment restricted to the tested endpoint.
Driver 192 completed the unchanged OFF/ON experiment with verified bit readback and restoration. Both settings lost concurrent CPU/GPU increments despite exact single-agent controls; record the measured counts and limits. Lifecycle and HSA regressions, signed Xcode build and app verification pass.
Save, change and verify only the endpoint requester bit under an exclusive idle session. Restore on explicit end and shutdown with readback, transaction draining and failure retention.
Compare unchanged staggered native atomic workloads with the requester off and on. Record driver190 mapping and contention measurements, verified scratch growth, and real HRX vector and matrix results. Correct HRX access grants for unmapped device memory.
Implement coarse host pools, dynamic queue resources, discovery-based topology and ATOM clock queries. Correct R9700 two-array compute masks and NBIF ROM-bank access found during driver 188 validation.
Build pinned HRX, Loom and LSE through reproducible macOS adapters. Add guarded HRX compute, queue resource and native CPU/GPU add/CAS controls and contention tests. Driver 189 hardware validation remains pending; no inference or general fine-grained atomic support is claimed.
Map seven persistent queues across the two four-queue compute pipes and preserve monotonic 64-bit SDMA write pointers. Gate public queue capabilities on verified driver 187 support.
Validate all queue slots, multi-producer wraparound, two-process ownership and continued dispatch after peer exit, plus concurrent shader/CP/CPU-HSA signals. Record hardware results and remaining HRX integration requirements.
Reserve seven owned legacy compute queues, route HSA doorbells through the driver, and retain queue memory until verified removal or reset. Execute CPU updates to GPU-visible signals through a shared GPU atomic executor to avoid unsupported host/GPU atomic RMW interoperability.
Add queue ownership, lifecycle, failure propagation and transport regression coverage plus hardware tests for ring wraparound, barriers and concurrent signal updates. Record passed sequential signal hardware checks and the pending build 185 persistent-queue validation.
Add bounded owner-backed AQL launches with ROCr queue metadata and Linux compute MQDs. Reserve a compute slot and retain resources through acknowledged queue removal or verified reset.
VRAM and shared-memory hardware tests passed 128 and 256 outputs plus all allocation guards. Driver regressions and HSA sanitizer suites pass. Reorganize the README around working, unfinished and upcoming capabilities.
Provide the complete AMD loader 1.03 table with retained source storage, descriptor translations, loaded-object metadata and callback-safe enumeration. Verify loader behavior on the GPU after reader destruction.
Add a session-fixed GART host window, direct CPU DMA verification, GTT SDMA copies and equal-address IOKit mappings with collision rejection. Include a shared-memory hardware probe for build 182 and preserve faulted mappings until recovery. Shared HSA signals, hardware queues and inference remain incomplete pending the next hardware bringup steps.
Implement host virtual-memory aliases, page protections, overlapping locks, CPU cache queries and interprocess signals. Add GPU buffer export/import references that survive exporter process exit, with driver 181 hardware verification.
Resolve the remaining pinned HRX symbols while explicitly rejecting unsupported DMA-BUF, SVM and software-queue hardware controls. Record behavioral limits and fail the runtime-readiness audit independently of symbol coverage.
Validate eight sanitizer suites, 28 driver and tool regression scripts, two-process signal lifetime and full shared-GPU-buffer data checks.
Keep PCI ownership in the driver and retire per-client resources without resetting active peers. Validate normal and abrupt client departure on hardware, with reset after the final participant exits.
Add gfx1201 ISA queries and bounded ELF executable loading with metadata, descriptor and relocation validation. Test upload failures, symbol lifetime and shutdown under sanitizers, and verify executable loading on hardware.
Separate model storage above BAR0 from visible staging allocations. Add checked upload/readback and synchronous SDMA copy endpoints, retain buffers after published copy failures, and provide a 22 GiB sampled transfer test.
Record two successful build 176 shader dispatches and allocation reuse. Report firmware interface 0x33 as unsupported by the verified 0x2e telemetry layout without treating compatibility rejection as a firmware fault.
Bump host and driver to 177. All 25 regression suites, the Debug build and strict signatures pass; new buffer hardware acceptance remains pending.
Submit each compute checkpoint through an explicitly addressed VMID 0 IB after build 175 faulted on shader instruction fetch under VMID 3. Retain distinct verified IB storage until completion or reset.
Retain SMU table staging and add bounded owner sampling with a cached observer ABI for amdgpu_mtop. Invalidate samples during teardown, reject stale data, and keep periodic collection disabled pending hardware validation.
Bump host and driver to 176, record hardware evidence, and pin the HSA interface requirements to the HRX revision used by LSE. All 24 regression suites, the Debug build and strict signatures pass.
Separate cache, register and shader completion fences to locate the first stalled phase. Capture CP fault state and distinguish missing readback from successful verification. Record the version 174 timeout and successful software recovery; bump to 0.1.75.
Add a standalone observer-only terminal dashboard with stable GPU selection and JSON snapshots. Validate the SMU 14.0.3 metrics decoder against the Linux ABI. Dynamic telemetry remains unavailable pending firmware collection integration.
Dispatch a fixed wave32 load/add/store program and verify all output, input and guard words after cache flush and a unique completion fence. Retain failed-test storage until reset and preserve RPC diagnostics.
Validate shader assembly, PM4 fields, data checks and failure lifetimes. Bump host and driver to 0.1.74; hardware acceptance remains pending.
First version where the SDMA engine actually processes ring submissions
on this hardware. v0.1.0 through v0.1.46 had multiple cascading bugs;
this commit consolidates the chain of fixes uncovered by a line-by-line
re-audit against upstream amdgpu.
NBIO/NBIF
- Replaced the wrong nbio_v7_11 funcs with a full nbif_v6_3_1 port.
Our chip reports NBIF v6.3.1 in discovery (hw_id=108), not NBIO 7.11.
Different doorbell-routing model: S2A entries with explicit AWID/
AWADDR/RANGE_OFFSET/RANGE_SIZE per port, direct MMIO at BASE_IDX 2
(no PCIE_PORT indirect needed for the entry table). Ported:
nbif_v6_3_1_remap_hdp_registers (BX0 0x012d/0x012e @ BASE_IDX 2)
nbif_v6_3_1_init_registers (RCC_DEV0_EPF2_STRAP2)
nbif_v6_3_1_ih_control (BX0 INTERRUPT_CNTL)
nbif_v6_3_1_enable_doorbell_aperture
nbif_v6_3_1_enable_doorbell_selfring_aperture (BX_PF0)
nbif_v6_3_1_sdma_doorbell_range (S2A ENTRY_2, AWID=0xe AWADDR=0x3)
nbif_v6_3_1_ih_doorbell_range (S2A ENTRY_1)
nbif_v6_3_1_gc_doorbell_init (ENTRY_0=0x30000007, ENTRY_3=0x3000000d)
- PCIE_PORT_RREG32/WREG32 helpers via BIF_BX_PF1_RSMU_INDEX/DATA
(NBIO BASE_IDX 1), distinct from existing SMN path via PCIE_INDEX2.
- BAR2 PCIe phys addr captured in ensure_open, fed into SELFRING base.
- doorbell_init() was defined but never invoked — fix.
- Ordering: SELFRING enabled last (matches soc24_common_late_init).
- IP-version-aware base/_nbif_4_10 register dispatch.
SDMA register correctness
- All QUEUE0_* and UTCL1_* offsets were pulled from gc_12_1_0_offset.h
(a different chip, GFX 12.1) and were systematically 0x180 higher
than the correct gc_12_0_0_offset.h values for our R9700 (GFX 12.0.1).
Every ring-program write — RB_BASE, RB_CNTL, RB_WPTR, DOORBELL,
DOORBELL_OFFSET, WPTR_POLL_ADDR — has been hitting wrong GC registers
since v0.1.0. Corrected.
- sdma_reg_offset now uses GC BASE_IDX 1 for the hyp-dec range
[0x5880..0x589a] per upstream sdma_v7_0_get_reg_offset (line 125).
MCU_CNTL (0x588e) was being read/written at GC[0]+0x588e — a random
unrelated register — for the entire driver lifetime. HALT/RESET
writes had no effect; the symptomatic MCU_CNTL=0x92929292 was the
garbage at the wrong address. Corrected.
- RB_CNTL.MCU_WPTR_POLL_ENABLE = 1 (was 0). Without this the MCU
doesn't react to WPTR updates even with a valid doorbell signal.
- Removed the defensive HALT=1 at SDMA init step 1 — bare-metal
upstream path doesn't halt; halting tears down PSP-autoloaded MCU
firmware state.
- STATUS_REG bit positions corrected in both dext (sdma_log_status)
and Swift (testLiveStatus) decoders per gc_12_0_0_sh_mask.h:142-161.
Per-IP-version register tables
- IPBaseTable now stores IPVersion[block], populated by discovery.
- SDMARegs is no longer a namespace — it's a SDMARegOffsets struct with
per-chip tables: kSDMARegOffsets_gc_12_0_0 (R9700 / GFX 12.0.x) and
kSDMARegOffsets_gc_12_1_0 (gfx1250 / GFX 12.1.x). sdma_pick_reg_table
selects at runtime. All call sites converted to sdma_regs(dev).FIELD.
nbif_is_ip_7_11_4(dev) now reads the actual discovered NBIO version
for the _nbif_4_10 register-variant dispatch.
SDMA kick — MMIO WPTR mode (AS+TB5 deviation)
- BAR2 doorbell aperture writes via IOPCIDevice::MemoryWrite64 do not
reach the SDMA MCU on Apple Silicon + Thunderbolt 5. Verified across
v0.1.30-v0.1.46 with every NBIF routing variant, SELFRING base from
PCI config, WC-flush readback, and engine-side DOORBELL_OFFSET combo.
- sdma_kick_doorbell now does the full four-step kick:
1. sysmem WPTR shadow write (upstream atomic64_set)
2. HDP flush
3. BAR2 doorbell write (upstream WDOORBELL64 — inert on AS+TB5)
4. MMIO RB_WPTR write (upstream use_doorbell=false branch — the
functional path on this platform)
- v0.1.47 verified: SDMA Copy returns status=0 with RPTR=WPTR=0x40
(engine consumed 16 dwords and wrote the fence).
GART soft-gate (defensive)
- GARTContext.reads_supported flag (defaults false) — GART page table
is fully programmed but GPU-initiated reads through DART return zero
on AS+TB5. gart_init populates GARTContext from GMC's just-enabled
aperture and sets the flag with logged platform reasoning.
- BOAlloc(domain=kBODomainGTT) returns kIOReturnUnsupported when the
flag is false, so clients fail fast instead of allocating a BO that
silently misbehaves on every engine read. When Apple exposes a
working sysmem-mapping primitive, flipping the flag in gart_init
lights up the GTT path automatically with no other changes.
Version bumps 0.1.33 through 0.1.48 collapsed into this commit.
Three iterative fixes attempting to unblock the SDMA NOP/COPY smoke
test (all still failing — doorbell still not reaching engine):
v0.1.30: ring + WB sysmem -> VRAM (DART-mapped sysmem reads return
zero on AS+TB5; engine fetches all-zeros instead of packets).
Ring now lives in fwBuf-style VRAM bump allocation; CPU writes via
BAR0; engine fetches via FB aperture. MCU_WPTR_POLL_ENABLE also
flipped to 0 (wptr_poll_addr was sysmem).
v0.1.31: doorbell BAR/stride/width — back to BAR2 (matches upstream
pci_resource_start(pdev,2) in amdgpu_doorbell_mgr.c), 8-byte stride
(qword indexed), MemoryWrite64 (upstream WDOORBELL64; 32-bit writes
silently dropped on RDNA4).
v0.1.32: LiveStatus selector now returns 12 scalars including SDMA0
QUEUE0_RB_RPTR/WPTR/CNTL/MCU_CNTL — diagnostic for next iteration.
Diagnostic result: after Initialize GPU + SDMA Copy,
SDMA0 RPTR=0 WPTR=0 RB_CNTL=0x00801019 MCU_CNTL=0x92929292
STATUS_REG=0x6e1ee557 (idle=1 rb_empty=1)
WPTR stays at 0 -> doorbell write doesn't reach engine. RB_ENABLE=1
and MCU_HALT=0 are correctly programmed. RB_CNTL=0x801019 matches
what we set (RPTR_WRITEBACK_ENABLE + RB_SIZE).
Root cause now identified: NBIO regGDC0_BIF_CSDMA_DOORBELL_RANGE
(0x4f0afb, BASE_IDX 3) needs to be programmed via PCIE_PORT indirect
access for the chip to route doorbells to SDMA. Same applies to GFX
(CP NOP smoke also fails identically). Port deferred — needs the
WREG32_PCIE_PORT helper (different from our existing PCIE_INDEX2
SMN path). Tracked in [[mac-amdgpu-doorbell-range-nbio]].
Part 1 — pptable
- PPSMC UseDefaultPPTable (0x14) + NotifyPowerSource (0x42)
- smu_smc_hw_setup now sends UseDefaultPPTable between
SetDriverDramAddr and RunDcBtc. PMFW picks up the IFWI-baked
pptable, which (a) gives DPM a real fan curve and (b) populates
the chip-specific allowed-feature mask.
Part 2 — power state ABI
- new IOConnect selector kMacAMDGPUMethodSetPowerState = 40
- PPSMC SetSoftMinByFreq (0x19) + SetSoftMaxByFreq (0x1A)
- 5 power states: auto / low / nominal / high / peak — map to
GFXCLK soft-min/max clamps. peak pins to 2400 MHz for compute.
Part 3 — host UI
- 5 buttons: Power: Auto / Low / Nominal / High / Peak
End-user impact: fan no longer defaults to max; userspace can pick a
GFX clock policy without re-bringing-up the GPU. Pptable upload from
VBIOS (full parser) deferred to a follow-up.
(merge from worktree-agent-ac7e066679e922cd3)
- BOAlloc/BOFree/BOGetInfo extended with domain (VRAM=1, GTT=2)
- BOMap (selector 36) for client process mapping
- VRAMBumpAllocator upgraded to first-fit free-list
- Per-client BOEntry table tracks generation for handle validation
- GTT BO support via gart_bind_sysmem
- clientStopped now releases all BOs
Two new IOConnect selectors for runtime hardware health checks
without re-running bringup:
kMacAMDGPUMethodLiveStatus (30) — snapshot GRBM_STATUS, CP_STAT,
RLC_RLCS_BOOTLOAD_STATUS, SDMA0/1 STATUS_REG, and the SMU
running-features bitmap (high+low). The "Live Status" button in
the host app decodes the SDMA status bits (idle / rb_empty /
rb_full / ib_idle / srbm_idle) the same way the dext-side
sdma_log_status does, and flags ALIVE/dead based on whether any
of the reads returned non-zero.
kMacAMDGPUMethodDisableSmuFeatures (33) — fires PPSMC 0x7
(DisableAllSmuFeatures). PMFW parks DPM; without a chip-specific
fan curve from smu_set_default_dpm_table, this is what stops it
defaulting fan RPM to MAX. The "Quiet Fan" button calls it.
Reverse by re-running Initialize GPU (smc_hw_setup re-sends
EnableAllSmuFeatures).
Origin: user reported fan-at-full + "did it lock up?" after v0.1.23
brought everything online. EnableAllSmuFeatures (v0.1.21 fix) enabled
DPM but PMFW defaults fan to MAX without a curve. The proper fix is
to port smu_set_default_dpm_table + smu_get_thermal_temperature_range
(deferred — needs pptable parsing). DisableAllSmuFeatures is the
pragmatic interim toggle.
No upstream PMFW "EnableThermalAlert" message exists on this build
(upstream smu_v14_0_enable_thermal_alert is IRQ-driver-side; the
chip's PMFW only exposes AllowIHHostInterrupt=0x4D, which is
unrelated to fan curve).
Five-version diagnostic chain landing on a state where every IP block
initializes on hardware (IPDiscovery → SDMAInit). The decisive fixes:
v0.1.21 — port minimal smu_smc_hw_setup
PMFW must enable DPM before the IMU autoload state machine fires.
GetDriverIfVersion + SetDriverDramAddrHigh/Low (64KB VRAM slot via
fwBuf bump) + RunDcBtc + EnableAllSmuFeatures. PMFW returns
UnknownCmd for SetAllowedFeaturesMaskLow/High on this build, so the
mask-set is non-fatal — EnableAllSmuFeatures with the IFWI-baked
default mask is what trips the gate. running_features = 0x488f19e_
0x38fffcfb (DPM_GFXCLK + DPM_FCLK + DPM_UCLK + …) and BOOTLOAD_STATUS
transitions 0 → 0x8000003f within < 1 ms.
v0.1.22 — pin VRAM bump allocator to LOW BAR0-mapped region
BAR0 on R9700 + Apple Silicon + TB5 maps the BOTTOM 256 MB of VRAM
(FB_LOCATION_BASE = vram_start), not the top like most desktops. The
bump allocator was initialised with visible_base = vram_start +
(real_vram_size - visible_vram_size) which produced gpu_va near
vram_start + 32 GB — far outside BAR0. CSB write through
bar0_memcpy_to_vram page-faulted and killed the dext immediately
after autoload printed success. Fix: visible_base = vram_start, with
the first 24 MB reserved for PSP's hardcoded slots.
Also in this commit (work since v0.0.63):
- PSP TA bin parser + psp_asd_initialize (LOAD_ASD cmd_id 0x4) wired
between AUTOLOAD_RLC and psp_rl_load (v0.1.19)
- PSP ring KM=2, rb_frame 5-field-only, HDP flush+readback,
fw_pri-memset-before-memcpy (v0.1.14–0.1.18)
- Per-IP firmware extractors (RLC v2.x, MES uni_mes, GFX RS64,
SDMA v7), bump-allocated fwBuf slots per LOAD_IP_FW frame
- GMC + MMHUB + GFXHUB gart_enable port (mmhub_v4_1_0 / gfxhub_v12_0),
GART PT in VRAM at vram_start + 0x700000, CONTEXT0 enable
- RLC autoload wait + CSB content fill + SRM enable + CSIB program
- CP / MES / SDMA / GFX stage handlers (microcode signed off, no
live PM4 yet)
README updated to reflect v0.1.22 state. Deleted stale WORKLIST.md,
ROADMAP.md, and docs/PORTING_NOTES.md / docs/*PLAN*.md per session
cleanup; docs/ is gitignored going forward (audit-2026-05-22/ lives
there locally with the synthesis + per-agent reports + v0.1.19/0.1.20
plans).
Next frontier: first PM4 packet on a live ring (KIQ NOP smoke test) or
SDMA VRAM→VRAM copy. Bringup itself is solved.
Upstream allocates one firmware.fw_buf BO and gives every ucode its
own MC address inside it (fw_buf_mc + ALIGN(prev_size, PAGE_SIZE)),
which then lands in cmd_load_ip_fw.fw_phy_addr. We were reusing
psp.fwPriBusAddr for every LOAD_IP_FW.
PSPContext now carries fwBufBaseMC / fwBufSize / fwBufBumpOffset.
psp_init reserves an 8 MB region at VRAM offset 0x01000000 (16 MB
in, past GART PT at 8 MB). LoadFirmware bump-allocates a per-payload
slot with PAGE_SIZE alignment and submits LOAD_IP_FW with the unique
slot address. fw_pri stays for SOS / RL / TOC traffic only.
Verified on hardware: each frame now carries a distinct fw_phy_addr
(SMU @ 0x8001000000, SDMA @ 0x8001050000, CP_PFP @ 0x800105c000,
...). Bumped to 0.0.68.
Still open: SMU + IMU_I + IMU_D pass; SDMA / CP_RS64 (PFP/ME/MEC) /
CP_MES / RLC sub-bins still get rejected. The clean split between
accepted (MP1 / IMU, outside the GFX domain) and rejected (everything
landing in the GFX block) rules out the address scheme and points at
firmware/SOS compatibility — every blob that PSP routes into the GFX
slot fails signature validation against this psp_14_0_3 SOS revision.
extract_rlc now emits sub-bins first and RLC_G last, matching the
AMDGPU_UCODE_ID_* enum order at amdgpu_ucode.h:515-529. Host load
sequence reordered to SDMA → CP_RS64 → MES → IMU → RLC, mirroring
psp_load_non_psp_fw's iteration of firmware.ucode[].
Added psp_rlc_autoload_start (GFX_CMD_ID_AUTOLOAD_RLC = 0x21) and
called it right after RLC_G's LOAD_IP_FW returns success, same place
upstream amdgpu_psp.c:3113-3121 fires it.
psp_load_toc (GFX_CMD_ID_LOAD_TOC = 0x20) ported as well, but the
host doesn't call it: gc_<v>_toc.bin is only used by the
AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO path, not AMDGPU_FW_LOAD_PSP. The
implementation is kept for the backdoor-autoload mode we may want
later (and because it's needed regardless on psp_v14_0_5).
Bumped to 0.0.67.
Open: SDMA / CP_RS64 / MES still return TEE_BAD_PARAMETERS (0xFFFF0006)
on real hardware. SMU and IMU pass. Same firmware load path, same
fw_pri staging address, different acceptance — strongly suggests a
signature/version mismatch between the bundled gc_12_0_1_* / sdma_7_0_1
blobs and the psp_14_0_3 SOS we're using. RLC sub-bins return PSP
status 0x5, a distinct error.
v0.0.63 reaches 9 bringup stages green on a real R9700:
IPDiscovery → IHInit → GMCInit → PSPInit → PSPLoadSOS →
PSPRingCreate → TMRSetup → SMUInit → IMUInit
Two correctness fixes against upstream:
1. GART page table moved into VRAM (gmc_v12_0.cpp). Upstream's
gmc_v12_0_gart_init calls amdgpu_gart_table_vram_alloc — the PT
lives in VRAM, not sysmem. Our gmc_init was allocating it as
DART-mapped sysmem which PSP couldn't reach for the PT walk;
every LOAD_IP_FW hit TEE_BAD_PARAMETERS because GMC's walker
returned garbage. Now:
- gart_pt at fixed VRAM offset 0x800000 (128 KB for 256 MB GART)
- gart_pt_bus = vram_start_actual + offset (FB-aperture MC addr)
- PTE writes go through the BAR0 aperture
- hub_init_gart_aperture_regs writes PT_BASE | VALID only,
not the SYSTEM flag (PT is in VRAM, not sysmem)
2. LOAD_IP_FW firmware staging matches upstream psp_copy_fw.
Previously the dext was passing GART MC addresses backed by the
host's DMA buffer. Upstream copies firmware bytes into psp.fw_pri
(VRAM) via memcpy + flush_hdp and passes psp->fw_pri_mc_addr to
PSP. PSP fetches firmware through its internal VRAM path (FB
aperture, no GMC walk). Switched LoadFirmware to BAR0-copy
payload bytes into fw_pri at VRAM offset 0, HDP flush, then
submit with fwPriBusAddr.
Net effect: SMU PMFW + IMU_I + IMU_D all load successfully; SMU
TestMessage works; IMUInit stage clears. Stages 10+ (RLC/CP/MES/
SDMA) still hit TEE_BAD_PARAMETERS because the per-IP header
extractors in amdgpu_ucode_extract.cpp produce wrong offsets/sizes
for those file layouts — next chunk of work.
The headline fix: PSP_RING_TYPE__KM was 1 (= PSP_RING_TYPE__UM, the
SR-IOV / RBI ring), upstream is 2 (= GPCOM kernel ring). With KM=1
psp_v14_0_ring_create wrote `1<<16 = 0x10000 = INIT_RBI_RING` to
C2PMSG_64, PSP responded OK but never honored C2PMSG_67 wptr
doorbells — every ring submit silently dropped. KM=2 sends
`0x20000 = INIT_GPCOM_RING` and PSP starts processing frames.
Other audit-driven fixes that compounded the bring-up issues:
- MMHUB register offsets corrected to mmhub_4_1_0_offset.h:
FB_OFFSET 0x04c7, AGP_TOP/BOT/BASE 0x0556/0x0557/0x0558,
SYSTEM_APERTURE_DEFAULT_LSB/MSB 0x04c8/0x04c9, L2_CNTL4 0x04fd,
L2_CNTL5 0x0503, INVALIDATE_ENG0_ADDR_RANGE 0x05ab/0x05ac.
- PTE format: add AMDGPU_PTE_IS_PTE (bit 63) to PTEFlags::SYSMEM_RW
— mandatory on GFX12 with PAGE_TABLE_DEPTH=0 or every PTE faults.
- LoadIPKeyMgrDrv corrected to 0xF0000 (was 0x110000, a bogus value
PSP rejected mid-bootloader).
- NBIO `remap_hdp_registers` programmed during IPDiscovery
(BAR5 byte 0x44000 was a no-op without this).
- SOC15 multi-BASE_IDX support: IPBaseTable now stores up to 5 bases
per IP, discovery reads them all, SOC15_REG_OFFSET_BIDX(...) added.
SMU mailbox now uses MP1 BASE_IDX 1 (was hitting wrong reg).
- psp_query_fw_reservation: sends GFX_CMD_ID_FB_FW_RESERV_ADDR + EXT
after ring_create (matches upstream for SOS fw_version ≥ 0x3a0e14).
- psp_setup_tmr: skip on psp_v14_0_x (boot_time_tmr by SOS) per
upstream psp_skip_tmr.
- LoadFirmware (post-SOS): parse common_firmware_header and pass
(gart_mc_addr + ucode_array_offset_bytes, ucode_size_bytes) to
psp_load_ip_fw instead of the whole .bin file. fw_type table:
add SDMA_UCODE_TH0 (71), CP_MES (33), CP_MES_DATA (34), RS64
PFP/ME/MEC + P0..P3 stack variants (87-97).
- psp_load_ip_fw: drop spurious 4 KB alignment check (upstream
doesn't enforce it; ucode_array_offset_bytes is dword-aligned).
- rb_frame: leave cmd_buf_size at 0 after memset (was 0x400, which
PSP treated as a corrupt frame).
- HDP flush: write + readback (mirrors amdgpu_hdp_generic_flush +
nbio.get_memsize, the latter being the PCIe-write serialization
barrier we were missing).
- Host initializeGPU(): reorder to LoadFirmware(SMU) before SMUInit
stage so the smu_test_message has a live PMFW to talk to.
Untrack docs/ via .gitignore — internal porting notes / audit
reports are not for the public tree; keep them local-only.
Verified on a real R9700 over Thunderbolt 5: bringup now reaches
GMCInit (8 stages green). Next blocker is multi-component firmware
parsing for SDMA v3 / RLC sub-bins / uni_mes (PSP returns
TEE_ERROR_BAD_PARAMETERS because our simple "skip 32-byte common
header" doesn't fit those layouts).
The PSP ring DMA path needs GART-routable MC addresses, not raw VRAM —
that's what was silently dropping every ring submission since the
VRAM-fw_pri fix. This commit completes the GART port enough for the
PSP ring to use sysmem buffers bound through the new page table.
Changes:
- dext/amdgpu/amdgpu_gart.cpp gart_enable lands the
mmhub_v4_1_0_gart_enable register port:
setup_vm_pt_regs (pt base lo/hi), init_aperture_regs (start/end),
init_tlb_regs (ENABLE_L1_TLB, SYSTEM_ACCESS_MODE=3,
ENABLE_ADVANCED_DRIVER_MODEL, MTYPE_UC), init_cache_regs (L2_CNTL[1-5]),
enable_system_domain (MMVM_CONTEXT0_CNTL.ENABLE_CONTEXT=1).
Reads vram_start from MMMC_VM_FB_LOCATION_BASE to compute PT MC addr.
Skips setup_vmid_config + program_invalidation (only relevant for
VM contexts 1-14 / TLB invalidation engines — PSP uses context 0).
- dext/amdgpu/amdgpu_init.h adds GARTContext to BringupContext.
- dext/amdgpu/amdgpu_psp.h gains gart pointer + GARTBinding fields
(ringBinding, cmdBinding, fenceBinding). Legacy IOBufferMemoryDescriptor
slots kept as nullptr for ABI compat; the GARTBinding owns the lifetime.
- dext/MacAMDGPU.cpp wires psp.gart = &bringup.gart in ensure_open.
- dext/amdgpu/psp_v14_0.cpp psp_ring_create:
* On first entry, calls gart_init + gart_enable lazily.
* Allocates ring/cmd_buf/fence_buf as sysmem via gart_bind_sysmem and
passes the GART MC addresses to PSP via C2PMSG_69/70/71.
* Cleanup paths use gart_unbind.
- dext/amdgpu/psp_v14_0.cpp psp_ring_cmd_submit:
* Stages cmd_buf with native memcpy (sysmem CPU pointer) instead of
BAR0 MMIO — orders of magnitude faster.
* Polls fence via a volatile uint32_t* on the GART-mapped fence_buf
instead of BAR0 reads.
- xcodegen regenerated MacAMDGPU.xcodeproj to pick up amdgpu_gart.cpp
in the dext target.
Builds clean. TMR keeps VRAM-backed (PSP carves out a VRAM region for
itself + IP firmwares it loads — that's not the ring-DMA path).
This is the change that should unblock TMRSetup. If PSP now writes the
fence after each submit, every downstream stage (SMU/GMC/RLC/CP/MES/IH/
SDMA) gets to try its own next step instead of all timing out on the
same wedge.
Initialize GPU on a card that can't process ring submits went from 95 s
to 4 s. Two changes:
1. psp_ring_cmd_submit fence-poll timeout 10 s -> 1 s. PSP responds in
milliseconds when working; 10 s only mattered while we were chasing
a separate cold-boot timing issue. Now that's understood, 1 s is the
right budget — matches Linux's adev->usec_timeout.
2. initializeGPU bails out at the first stage failure instead of
grinding through 8 dependent stages all of which will time out
identically. Each subsequent stage depends on TMR being set up;
no point hammering them with the same broken state.
Also DMA-2 debug closure: with the C2PMSG_67 offset bug fixed
(s/0x67/0x83 — the "_67" in the register name is its logical index,
its actual register-file dword offset is 0x40 + N = 0x83), DumpPSP
now correctly shows the wptr after a submit:
C2PMSG_67 = 0x10 after one submit (= 16 dwords = one frame)
C2PMSG_67 = 0x80 after eight submits (= 128 dwords)
So our wptr writes ARE landing. PSP just doesn't process them —
fence stays 0, resp.status stays 0, cmd_buf isn't read.
Conclusion (now in docs/DMA_FIX_PLAN.md):
PSP's ring-DMA path can NOT read VRAM-backed cmd_buf on this chip
even though the fw_pri bootloader path can. Matches Linux's design
(GTT/GART for ring buffers, VRAM only for fw_pri optionally).
GART bootstrap (DMA-4..9) is therefore the blocker, not a quick win.
Adds docs/DMA_FIX_PLAN.md tracking the four research findings on
eliminating the ~10x BAR0 MMIO slowdown:
1. CreateMapping + GetAddress (BAR aperture CPU pointer) — research
status updated: qemu-vfio-apple uses this for sysmem DMA chunks,
NOT for BAR memory. Needs a prototype against _CopyDeviceMemoryWithIndex
to confirm BAR mapping is actually possible from a dext.
2. Bootstrap GART before PSP — long-term sysmem-via-GART architecture.
Aligns with user's "don't waste VRAM on control buffers" constraint.
Multi-step port (DMA-4..9).
3. SDMA-based copy — post-SOS only; deferred.
4. MemoryWrite64 instead of 32 — DONE this commit.
DMA-1 (done):
- bar0_memcpy_to_vram / bar0_memset_vram now use pci->MemoryWrite64
for the bulk-aligned region — half the MMIO calls.
- Falls back to MemoryWrite32 for the lead-in alignment + trailing
partial dwords. Should give ~30-50% staging speedup.
DMA-2 (debug, this commit):
- kMacAMDGPUMethodDumpCmdBuf (#26) + "Dump Cmd" host button.
- Reads VRAM cmd_buf header (16 dwords), payload area, resp.status
region near offset 864 (upstream PSP_GFX_CMD_RESP.resp), fence_buf,
and ring_mem head. Tells us whether PSP touched the cmd_buf at all
after our submission.
Saved memory feedback_mac_amdgpu_dma_strategy.md summarizing the
short-term + long-term DMA paths.
Add MMHUB to IPBlock enum (separate from GMC — they're distinct IPs
in upstream) and reconnect HWID::MMHUB to it in discovery's hwid_to_block.
Vendor MMHUBRegs::MMMC_VM_FB_LOCATION_BASE/TOP/OFFSET offsets from
upstream asic_reg/mmhub/mmhub_4_1_0_offset.h (RDNA4).
DumpPSP selector grows outputs[7..10]: MMHUB base, FB_LOCATION_BASE raw,
FB_LOCATION_TOP raw, computed vram_start = (FB_BASE & 0xFFFFFF) << 24.
Host UI prints them with the expected `C2PMSG_36 = vram_start >> 20`.
On the test R9700, this immediately revealed the problem:
psp/mmhub_base: 0x0001a000 FB_LOCATION_BASE=0x00008000
psp/vram_start (MC addr): 0x0000008000000000
→ expected C2PMSG_36 = 0x80000
We've been sending C2PMSG_36 = 0x820 (psp.fwPriBusAddr >> 20 where
fwPriBusAddr is the DART bus address of our sysmem IOBufferMemoryDescriptor).
PSP expects an MC address; vram_start alone is 0x80000 >> 20. The
PCIe bus address we send is not a valid GMC route on this chip — PSP
silently fails the firmware load.
Fix is to move fw_pri (and friends) into VRAM accessed via the visible
BAR0 aperture, then pass C2PMSG_36 = (vram_start + offset) >> 20.
Followup commit.
GetIdentity selector now returns 7 scalars instead of 6 — adds the
PCI revision byte as a separate field, previously masked off. The
host caches device id + revision (pciDeviceId, pciRevision) on first
Identity read so it can pick the kicker firmware variant where
upstream amdgpu does:
amdgpu_psp.c psp_init_sos_microcode line 3700:
if (amdgpu_is_kicker_fw(adev))
"amdgpu/%s_sos_kicker.bin"
else
"amdgpu/%s_sos.bin"
DriverController.kickerDeviceList[] vendors upstream
amdgpu_ucode.c kicker_device_list[] verbatim:
{0x744B, 0x00}, {0x7551, 0xC8}
The R9700 we're testing on reports rev 0xC0 (not 0xC8), so the
plain non-kicker firmware path is correct for it. Kicker rules out
as a cause of the SOS load failure.
initializeGPU now reads Identity early (right after openUserClient)
so pciDeviceId/pciRevision are populated before firmware filename
construction.
Audit of upstream firmware-load paths still NOT ported:
- psp_init_asd_microcode (ASD parser)
- psp_init_ta_microcode (TA parser)
- amdgpu_ucode_ip_version_decode (filename builder)
- amdgpu_ucode_print_* (header debug dumpers)
- gfx_v12_0_init_microcode / gfx_v12_1_init_microcode (gc_*.bin parser)
- sdma_v7_0/1_init_microcode (sdma_*.bin parser)
- mes_v12_0/1_init_microcode (uni_mes parser)
- imu_v12_0/1_init_microcode (imu parser)
Current state on hardware: BAR5 reads + IFWI + IP discovery all work.
First wait_for_bootloader passes (PSP receives C2PMSG_36 write). PSP
clears C2PMSG_35 after our LoadXXXDrv write but never sets bit 31
back — so it accepts the command and stops responding. Likely cause
under investigation: cache coherency between the CPU-side memcpy
into fw_pri and PSP's DMA read of that buffer on Apple Silicon DART.
Mirror upstream's full PSP firmware parser instead of memcpy'ing entire
.bin files as if they're raw payloads. Reason: AMD firmware files are
containers — a common_firmware_header followed by either v1.x legacy
descriptors or v2.x typed psp_fw_bin_desc array. PSP expects only the
specific sub-section (KDB, SYS_DRV, SOS, etc.) handed to it per
bootloader command.
New file dext/amdgpu/amdgpu_ucode_psp.h vendors upstream amdgpu_ucode.h
struct definitions verbatim:
- common_firmware_header
- psp_fw_legacy_bin_desc (v1.x)
- psp_firmware_header_v1_0 / v1_1 / v1_2 / v1_3
- psp_fw_bin_desc (v2.x)
- psp_firmware_header_v2_0 / v2_1
- psp_fw_type enum (PSP_FW_TYPE_PSP_*)
- psp_bootloader_cmd_e
dext/amdgpu/amdgpu_psp.h PSPContext now has a full set of PSPSubBin
descriptors mirroring upstream's psp_bin_desc fields:
sos, sys, kdb, toc, spl, rl, soc_drv, intf_drv, dbg_drv, ras_drv,
ipkeymgr_drv, spdm_drv, sys_drv_aux, sos_aux
dext/amdgpu/psp_v14_0.cpp gains two functions:
- psp_parse_sos_microcode: auto-detects header_version_major (v1 vs v2)
and populates every sub-bin descriptor with start_addr + size_bytes.
Direct port of upstream amdgpu_psp.c psp_init_sos_microcode.
- psp_load_sos_package: runs the full pre-SOS sequence
KDB -> SPL -> SYS_DRV -> SOC_DRV -> INTF_DRV -> DBG/HAD_DRV ->
RAS_DRV -> IPKEYMGR_DRV -> SOS via the bootloader. Mirrors
psp_v14_0_hw_init's load order, skipping sub-bins whose size is 0.
LoadFirmware(kFwSOS) now routes through psp_parse_sos_microcode +
psp_load_sos_package instead of the broken raw-memcpy path.
Saved memory feedback_mac_amdgpu_port_full_parsers.md: "vendor upstream
firmware structs as-is, port the WHOLE parser, never memcpy whole .bin
files as if they're raw payloads."
After this: discovery still succeeds, SOS load still times out — but
now for a different reason (PSP receives our individual sub-firmware
loads). The card revision-check / kicker-variant selection is the next
upstream piece to port (amdgpu_is_kicker_fw + kicker_device_list).
Add kMacAMDGPUMethodDumpPSP (#25) + "Dump PSP" UI button that reads the
SOC15-resolved MP0 C2PMSG_33/35/36/64/81 registers and prints them with
ready/alive indicators. This was missing — previously the only IFWI/SOS
status we could see was the legacy BAR alias which reads 0 on RDNA4.
Bump psp_wait_for_bootloader budget from 1 sec to 10 sec (matches
upstream worst-case of 10 retries × adev->usec_timeout for emulation/
passthrough mode; TB5 hotplug behaves similarly).
Findings from this iteration on hardware:
- MP0 IP base resolved correctly to 0x16000
- C2PMSG_33 bit 31 SET — IFWI is actually ready (our prior legacy-alias
reads to BAR5[0x61] were reading the wrong location)
- C2PMSG_35 was NOT bit-31 set at dump time — but C2PMSG_36 contained
0x820 (our fwPriBusAddr >> 20), proving wait_for_bootloader succeeded
earlier and the LoadSOSDrv command was actually written
- C2PMSG_81 stayed 0 — SOS firmware never came alive after the load