Skip to content

drm/radeon: use I/O accessors for the VCE firmware upload - #3464

Merged
RyanTheTide merged 2 commits into
mainfrom
fix/radeon-vce-iomem
Nov 28, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
fix/radeon-vce-iomem

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem. radeon_vce_resume() clears the VCE VCPU buffer object and copies the VCE firmware into it with plain memset()/memcpy(), and vce_v1_0_load_fw() writes the signature words through a plain pointer. That buffer object is in VRAM, so the CPU mapping is a write-combined mapping of the PCI BAR. On arm64, memset() with a zero value uses dc zva, and a dc zva into PCIe BAR space is not a valid PCIe write. On Apple Silicon the fabric answers it with an asynchronous SError and the kernel panics. This killed every attempt to bind radeon to an R9 390X (Hawaii) in a Thunderbolt 5 enclosure on a K114s (M5 Pro): on hot-plug, at boot, and on a manual modprobe.

Change. Use memset_io(), memcpy_toio() and writel(), as radeon's UVD path and amdgpu's VCE path already do. No behaviour change on hosts where the plain accessors happened to work.

Testing.

  • K114s M5 Pro (T6050), R9 390X 8 GB in a TB5 enclosure (JHL9480) on the right port, bridge kernel 7.3.0-k114sstack, radeon.ko built from this diff (make M=drivers/gpu/drm/radeon) and loaded with insmod on the same boot. Before: SError Interrupt ... pc : __pi_memset_generic+0x170 (the dc zva), lr : radeon_vce_resume+0x70, panic, 4 of 4 attempts. After: POST, MSI, ring tests 0-7 and IB tests 0-7 pass, UVD initialized, VCE initialized, fb1 radeondrmfb, card2/renderD129. Stock Fedora Mesa 26.2.7 radeonsi (AMD radeonsi, hawaii, ACO, DRM 2.51) renders GLES 3.2 over EGL: clear read-back exact, 3 x 5000 full-screen 1080p draws, no DART fault, no AER error, runtime-PM resume (IB tests re-ran) OK.
  • Store-shape matrix on the same BAR, no driver bound (static probe through sysfs resource0_wc): 8/4/2/1-byte stores, stp, 16/32-byte NEON stores, unaligned stores, libc memcpy and non-zero memset all pass; only dc zva and libc memset(0) panic.

Tested: K114s M5 Pro (T6050) + R9 390X (Hawaii) over Thunderbolt 5 at this diff (radeon.ko against 7.3.0-k114sstack): before 4/4 SError panics in radeon_vce_resume, after radeon binds with all 8 ring + 8 IB tests passing and radeonsi GLES 3.2 rendering
Risk: one-way · radeon only (VCE firmware upload path; SI vce_v1_0 path compiled, not run: no SI card)

Still to run. An SI card (Tahiti/Pitcairn/Verde) for the vce_v1_0_load_fw() half. No other Mac in the lab has an AMD GPU, so there is no second regression Mac for this file.

Evidence

traces/gpu/20261128-k114s-egpu/ on the lab store: radeon-serror-netconsole.log (the panic), storeshape/result.txt (the matrix), live/ (bind and GL logs). Patch kit kits/test/20261128-egpu/radeon-vce-iomem/. Not tainted.

radeon_vce_resume() clears the VCPU buffer object and copies the VCE
firmware into it with plain memset() and memcpy(), and vce_v1_0_load_fw()
writes the signature words through a plain pointer. The buffer object
lives in VRAM, so the CPU mapping is an ioremap_wc() of the PCI BAR, not
normal memory.

On arm64 memset() with a zero value uses DC ZVA. A DC ZVA into PCIe BAR
space is not a valid PCIe transaction; on Apple Silicon the fabric
answers it with an asynchronous SError and the kernel panics:

  SError Interrupt on CPU16, code 0x00000000be000000 -- SError
  pc : __pi_memset_generic+0x170/0x188
  lr : radeon_vce_resume+0x70/0x1b4 [radeon]
  Kernel panic - not syncing: Asynchronous SError Interrupt

Use memset_io(), memcpy_toio() and writel() as the UVD path in radeon and
the VCE path in amdgpu already do.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 28, 2026 02:50

@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.

Please retain the SI firmware signature alignment semantics. The old uint32_t pointer advanced by (len + 64) / 4 words; the new void __iomem pointer advances by len + 64 bytes and writes with writel. With an unaligned len, the new path makes unaligned MMIO writes where the old path used an aligned address. Preserve the old word offset or explicitly validate alignment before the writes if that is a firmware invariant. The I/O helpers themselves match the Radeon UVD and amdgpu VCE upload paths. Radeon ring, IB pool, and WB use GTT on the PCIe path, and fences use the WB allocation. The reported Hawaii bind, ring, IB, render and runtime-PM row supports that path. SI runtime and a second Apple family with the enclosure are still owed. Keep the user VRAM mmap issue tracked separately.

The previous change moved vce_v1_0_load_fw() from a uint32_t pointer to
a void __iomem pointer. The old code advanced the pointer by
(len + 64) / 4 dwords before writing the signature words, which rounds
an unaligned length down to a dword boundary. The new code advanced by
len + 64 bytes, so an unaligned len would give unaligned MMIO writes at
a different address than before.

Round the byte offset down to a multiple of 4 so the signature lands on
the same dword as before.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 98ceaee, item 1 (SI signature alignment): fixed in ccd862e. The pointer now advances by round_down(len + 64, 4) bytes, which is the same dword the old (len + 64) / 4 word step landed on, so the signature writel()s stay aligned and at the old address. Built W=1 for arm64 (vce_v1_0.o, radeon_vce.o), checkpatch clean. Hardware: the lab card is Hawaii (CIK), which does not run vce_v1_0_load_fw (SI/Aruba only), so the SI runtime row is still owed; the Hawaii row from the PR body is unchanged by this commit. User VRAM mmap issue stays tracked separately.

@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.

Verdict: MERGE at ccd862eb once the landing evidence is recorded. This clears the SI alignment change request.

Checked: Compared the revised SI signature address with the old unsigned dword index. The new round-down produces the same aligned byte address. Twelve sampled lengths, including unaligned lengths and the unsigned wrap boundary, agreed. The forward change touches only that offset. The earlier review covered the I/O accessors and checked the UVD and GTT ring/IB paths. No DT changes or board gating.

The K114s Hawaii bind and GLES report is useful feature evidence for the original patch. Attach the exact-commit build/receipt, hosted CI and second-family regression evidence before landing. SI runtime remains untested.

@github-actions github-actions Bot added door:one-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 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at ccd862eb: not ready yet

Check Detail
CI at head ok 2 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at ccd862eb
Conflicts ok none
PR text ok Risk: one-way · radeon only (VCE firmware upload path; SI vcev10 path compiled, not run: no SI card) Still to run. An SI card (Tahiti/Pitcairn/Verde) for the vce_v1_0_load_fw() half. No other Mac in the lab has an AMD GPU, so there is no second regression Mac for this file.

Areas: none matched in CODEOWNERS

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

@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.

Verdict: MERGE at ccd862eb5f28. Second, independent approval (REVIEW6 approved this head at 14:42); requested by ORCH5 for the eGPU demo/upstream path.

Checked:

  • Offsets, old word arithmetic vs new byte arithmetic: signature block at (256 − 64)/4 words = 192 bytes; nonce at +0/4/8/12; length word len + 64 at +16; 44 zero bytes at +20; firmware body at +64; then data += (len + 64)/4 words = round_down(len + 64, 4) bytes, and sigval at +0..12 from there. All match. ccd862eb is exactly the fix that keeps that last offset (a plain len + 64 would differ when it isn't a multiple of 4).
  • Byte order: writel(le32_to_cpu(x)) puts the original little-endian bytes on the bus on any CPU, the same bytes the old raw store wrote on little-endian.
  • Access type: the VCPU BO is created and pinned in VRAM, so the kernel map is I/O memory. memset_io/memcpy_toio/writel are right throughout radeon_vce_resume() and vce_v1_0_load_fw(), and on x86 they compile to the same work as before.
  • The prototype in radeon_asic.h matches the new void __iomem * parameter. CI green at this head. No attribution.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware row at ccd862eb: K114s M5 Pro (T6050) + R9 390X (Hawaii) over Thunderbolt 5, PASS for the CIK VCE path.

  • The radeon row (8/8 ring + 8/8 IB tests, UVD + VCE initialised, radeonsi GLES 3.2 renders) ran at 98ceaee. The only change from 98ceaee to ccd862e is in vce_v1_0_load_fw(), the SI/Aruba upload, which this Hawaii card never calls. The CIK path this row exercises is the same at both SHAs.
  • The SI hunk at ccd862e has a host proof: the extracted vce_v1_0_load_fw bodies were run under mocked I/O. Under both GCC and Clang, all 16 fixed cases write byte-identical aperture contents to the original dword writer (traces/kernel/20261128-kunit-new/vce-v1-offset.log). The unrounded revision acts as the negative control: it makes 4 unaligned writes.

Not yet: an SI (VCE 1.0) runtime row. The lab has no SI card.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 28, 2026
@RyanTheTide
RyanTheTide merged commit c6e7bdc into main Nov 28, 2026
3 of 5 checks passed
@RyanTheTide
RyanTheTide deleted the fix/radeon-vce-iomem branch November 28, 2026 09:37
DjDeveloperr pushed a commit to olivergreg/linux that referenced this pull request Dec 3, 2026
Complement the VCE firmware upload fix (aurora-silicon#3464) by auditing the remaining
kernel CPU accesses to VRAM-resident BOs in radeon and routing them
through I/O accessors so compiler-merged stores or DC ZVA cannot fault
on Device-nGnRnE non-posted BAR mappings:
- Add radeon_bo_memset/memcpy_to/memcpy_from helpers keyed on
  bus.is_nonposted.
- Use readl()/writel() for the UVD ring fence stored in vcpu_bo (VRAM),
  UVD_FW_START readback, RLC save/restore list, and CIK CP PG table.
- Bounce the RLC clear-state buffer through host memory when
  is_nonposted and copy via memcpy_toio().
- Copy the UVD CS message header through radeon_bo_memcpy_from() with a
  BO-size check instead of dereferencing the kmap pointer directly.
- Use radeon_bo_memcpy_from()/to() for VRAM reads/writes in
  radeon_do_test_moves().

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

door:one-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant