13 Commits
Author SHA1 Message Date
geramyloveless 4f5531335c Fix architecture-selected scratch sizing and audit native atomics
Select scratch units and register limits from discovered GC capabilities. Correct gfx1201 wave stride and enforce the GFX12 DMA address limit.

Add owned mapping and endpoint PCIe diagnostics, serialized atomic handoff checks, returned-value validation, and asymmetric staggered contention tests. Complete HRX startup capability queries and document verified hardware results and remaining validation.
2026-09-23 15:37:53 -07:00
geramyloveless 1bbc1aa1f8 Implement AMD loader services and shared host memory transport
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.
2026-09-23 11:16:42 -07:00
geramyloveless 682ca7c553 Bring up RDNA4 command queues and verified host-memory transfers
Correct firmware acknowledgements, GPU address translation, MES queue setup, SDMA and CP submission, and driver session teardown. Add runtime identity checks, host diagnostics, checked GART mapping lifetime, and reusable aligned aperture reservations.

Record build 172 hardware acceptance and build 173 allocator validation. Add 19 regression suites covering packet layouts, firmware sequencing, command-ring reuse, mapping failure retention, and lifecycle behavior.
2026-09-22 22:28:00 -07:00
geramyloveless 553285475c latest changes. 2026-05-22 16:10:53 -07:00
geramyloveless 3bdeed2de9 v0.1.48: SDMA engine actually running — NBIF v6.3.1 + per-IP-version regs + MMIO WPTR mode
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.
2026-05-22 15:35:28 -07:00
geramyloveless b04bf9777a v0.1.22: full GPU bringup — all 15 stages pass on R9700
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.
2026-05-21 20:15:36 -07:00
geramyloveless c8d224e93f PSP ring: KM=2 fix, GART+NBIO HDP remap, BASE_IDX support → SMU+GMC online
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).
2026-05-15 15:22:24 -07:00
geramyloveless ac577a7341 GART + PSP: PT base translation, EXECUTABLE PTE bit, HDP flushes (audit fixes)
Five parallel agent audits (GART, PSP, discovery, regs, firmware parser)
flagged concrete divergences from upstream. This commit lands the top
three actionable fixes:

1. **PT base register translation** (amdgpu_gart.cpp gart_enable):
   Read MMMC_VM_FB_OFFSET to compute vram_base_offset; write
   pt_base = vram_base_offset + pageTableVRAMOffset | VALID instead
   of raw vram_start + offset. This is exactly what
   amdgpu_gmc_pd_addr → gmc_v12_0_get_vm_pde produces upstream.

2. **EXECUTABLE bit on PTE flags** (amdgpu_ip.h PTEFlags::SYSMEM_RW):
   Match upstream gart_pte_flags default. MTYPE bits 54-55 stay as
   MTYPE_NC (= 0, default) which matches gmc_v12_0_get_vm_pte's
   default for GTT sysmem PTEs.

3. **HDP flush** at three call sites (amdgpu_regs.h amdgpu_hdp_flush):
   - End of gart_enable (matches gmc_v12_0.c:1019)
   - End of gart_bind_sysmem after PTE writes (matches
     amdgpu_gart_invalidate_tlb's flush)
   - In psp_ring_cmd_submit before the wptr update (matches
     amdgpu_psp.c:3493)
   Implementation: write 0 to BAR5 byte 0x44000 — for NBIO 7_11 this
   is rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL.

Tasks #39 + #40 closed.

Audits also surfaced (not yet addressed; mostly low-risk or
optional):
- PSP setup_tmr.system_phy_addr = 0 vs upstream always populates
  (only matters once ring submit goes through TMR).
- psp_ring_cmd_submit fence-buf write coherency (HDP flush should
  help; if not, IODMACommand::Synchronize is the next step).
- v2.1 SOS aux-bin skip logic (chip-specific, doesn't apply to R9700).
- Multi-instance SOC15_REG_OFFSET (only matters for multi-die / dual-MMHUB
  chips — not R9700).

Tests-after: kill old dext, Initialize GPU, check Dump PSP for
C2PMSG_64 status and Dump Cmd for cmd_buf.resp.status + fence_buf[0].
2026-05-14 21:56:39 -07:00
geramyloveless fe21b6ef0d GART: OR AMDGPU_PTE_VALID into PT base addr; surface PSP error statuses
Two small fixes for the ring_create status=0x0a regression:

1. amdgpu_gmc_pd_addr() in upstream ORs AMDGPU_PTE_VALID into the
   page-table base address before writing PAGE_TABLE_BASE_ADDR_LO/HI.
   Without VALID, GMC treats the page table itself as invalid and
   every GART access faults. We were writing the bare MC address.

2. New poll_psp_response() in amdgpu_regs.h surfaces PSP-side error
   responses (bit 31 set + non-zero low 16 bits) as kIOReturnIOError
   instead of letting the poll spin until budget. Mirrors upstream
   psp_wait_for's "if status != 0 → -EIO" check. psp_ring_create
   now uses this so the log says ERROR vs TIMEOUT and prints the
   PSP status code immediately.
2026-05-14 21:42:23 -07:00
geramyloveless 3435797753 GART: full mmhub_v4_1_0_gart_enable port, per-step logging
Per user feedback "don't take workarounds — port everything except
genuine Mac platform specifics". v0.0.42 had a trimmed register
sequence (missing init_system_aperture_regs, disable_identity_aperture,
setup_vmid_config, program_invalidation). PSP rejected ring_create
with status 0x0a because some of those skipped writes are load-bearing
for L2 fault routing / VM context isolation.

This commit ports the missing parts:

- init_system_aperture_regs: disables AGP (BOT > TOP), programs
  system aperture LOW/HIGH to cover [vram_start, vram_end] (read from
  MMMC_VM_FB_LOCATION_BASE/TOP), sets system + L2-fault default
  addrs to 0 (we don't have mem_scratch / dummy_page yet — comment
  explains the deviation), sets
  MMVM_L2_PROTECTION_FAULT_CNTL2.ACTIVE_PAGE_MIGRATION_PTE_READ_RETRY.
- disable_identity_aperture: identity LOW = 0xF_FFFFFFFF, HIGH = 0
  (so context-1+ always takes the page-table route, never the
  identity bypass).
- setup_vmid_config: programs contexts 1..14's CONTEXT1_CNTL with
  all protection-fault enables + retry_permission, plus start/end
  addr stride registers. Stride constants ctx_distance=1,
  ctx_addr_distance=2.
- program_invalidation: 18 TLB invalidation engines, "match
  everything" range (0xFFFFFFFF / 0x1F).

Each sub-function GART_LOGs at entry so the os_log stream shows
the GART enable sequence section-by-section (matches Linux's
DRM_INFO style). The host UI doesn't see these directly — the
existing log-stream limitation applies — but `sudo log stream
--predicate 'process == "..."'` exposes them.

Added register offsets to dext/amdgpu/amdgpu_ip.h:
  MMMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB/MSB (at 0x4c8/0x4c9 —
    the ones init_system_aperture_regs writes, distinct from the
    similar-named regs at 0x559/0x55a/0x55f/0x560 used in a
    different context),
  MMVM_L2_PROTECTION_FAULT_CNTL2 + DEFAULT_ADDR_LO/HI,
  MMVM_L2_CONTEXT1_IDENTITY_APERTURE_{LOW,HIGH}_ADDR_{LO,HI}32,
  MMVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_{LO,HI}32,
  MMVM_CONTEXT1_CNTL, MMVM_CONTEXT1_PAGE_TABLE_{START,END}_ADDR_{LO,HI}32,
  MMVM_INVALIDATE_ENG0_ADDR_RANGE_{LO,HI}32.

Saved feedback_mac_amdgpu_no_workarounds.md: port the whole
upstream function, no "minimum-viable" trims. Only legitimate
deviations are Mac/Apple platform specifics.

Status: not yet tested on hardware (commit + push first; user will
re-run Initialize GPU on v0.0.43).
2026-05-14 21:36:47 -07:00
geramyloveless eb2274682e GART: enable BEFORE SOS load (match upstream order); full register sequence restored
Verifying against upstream: amdgpu's IP init order is GMC.hw_init
(which calls gart_enable) BEFORE PSP.hw_init (which loads SOS +
creates ring). Our v0.0.41 had it reversed — gart_enable was
triggered from psp_ring_create, AFTER SOS was already up.
Stomping on TLB/L2 state SOS had set up caused PSP to drop
ring_create entirely (regression vs v0.0.40 which at least got
through ring_create).

Two fixes this commit:

1. Move gart_init + gart_enable from psp_ring_create to the top of
   psp_load_sos. Now GART is configured BEFORE SOS comes up, just
   like upstream.

2. Restore the full mmhub_v4_1_0_gart_enable register sequence
   (was minimized to PT base + context0 enable as a workaround;
   not needed now that the order is correct):
     init_aperture_regs  (PT base lo/hi, start/end lo/hi)
     init_tlb_regs       (ENABLE_L1_TLB + SYSTEM_ACCESS_MODE=3 +
                          ENABLE_ADVANCED_DRIVER_MODEL + MTYPE_UC)
     init_cache_regs     (VM_L2_CNTL[1-5])
     enable_system_domain (CONTEXT0_CNTL.ENABLE=1)

3. Move gart_start from 0x0001_0000_0000_0000 (bit 48, may exceed
   the chip's MC bus width) to 0x0000_0001_0000_0000 (4 GB MC
   offset). Well below vram_start (= 512 GB) and within standard
   48-bit MC range.
2026-05-14 21:31:38 -07:00
geramyloveless a64131c051 GART: refactor PSP ring/cmd/fence to sysmem+GART; cmd_submit uses native memcpy
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.
2026-05-14 21:27:22 -07:00
geramyloveless 0b3d4e37ee GART port: skeleton + gart_init + gart_bind_sysmem + docs sync
Begin the GART bootstrap port to unblock PSP ring DMA. New module:

- dext/amdgpu/amdgpu_gart.h
    GARTContext (page-table location + bump allocator state),
    GARTBinding (per-BO mapping handle).
- dext/amdgpu/amdgpu_gart.cpp
    gart_init: idempotent — picks PT at VRAM offset 0x700000 (above
      PSP buffers + TMR), zeroes 4 KB (= 512 PTEs = 2 MB GART space),
      sets gart_start = 0x0001_0000_0000_0000 (far above vram_end).
    gart_bind_sysmem: alloc IOBufferMemoryDescriptor + IODMACommand,
      PrepareForDMA, write VALID|SYSTEM|SNOOPED|R|W PTEs into the VRAM
      page table via bar0_memcpy_to_vram, return GART MC address.
    gart_unbind: CompleteDMA + release + invalidate (bump-style).
    gart_enable: stubbed — register pokes land in task #36.

Vendored constants:
- dext/amdgpu/amdgpu_ip.h adds MMHUB GART registers
  (MMVM_CONTEXT0_*, MMMC_VM_AGP_*, MMMC_VM_SYSTEM_APERTURE_*,
  MMMC_VM_MX_L1_TLB_CNTL, MMVM_L2_CNTL[1-5]) and PTE flag bits
  (VALID/SYSTEM/SNOOPED/R/W) + AMDGPU_GPU_PAGE_SIZE / SHIFT.

Tracking docs synced (background agent):
- README.md STATUS reflects PSP SOS loads + ring created; GART is
  the next blocker.
- ROADMAP.md adds Phase 1B.0a (GART bootstrap), advances stage 0-4
  to confirmed.
- WORKLIST.md marks PSP items confirmed; new section 1B.0a tracks
  GART-1..GART-7 (mapped through the DMA_FIX_PLAN items DMA-1/1b/2
  already closed in earlier commits).
- docs/GART_PORT_PLAN.md authored at session start, drives this work.

Builds clean. gart_enable returns kIOReturnUnsupported until the
mmhub_v4_1_0_gart_enable port lands.
2026-05-14 21:15:58 -07:00