Skip to content

drm/amd/pm: defer UCLK DPM enablement on Apple Navi 14 0218 - #60

Closed
edschofield wants to merge 2 commits into
t2linux:mainfrom
edschofield:fix/apple-0218-late-uclk
Closed

edschofield wants to merge 2 commits into
t2linux:mainfrom
edschofield:fix/apple-0218-late-uclk

Conversation

@edschofield

@edschofield edschofield commented Sep 8, 2026 •

Copy link
Copy Markdown

On an iMac20,1 (2020, 27") with GPU 1002:7340 / 106b:0218, revision 41, the normal EnableAllSmuFeatures request can time out with error -62, leaving no AMDGPU DRM device. This patch leaves UCLK DPM out of that request and enables it from Navi's post-init callback. It then verifies the firmware bit and refreshes the driver's supported-feature bit, memory DPM table and sustainable clock limits.

Both memory-voltage features stay enabled during normal initialization. The patch respects PP_MCLK_DPM_MASK, validates the PPT memory states consumed by DCN20, and matches only the tested 0218/41 board. It leaves patch 6001's 0219 workaround unchanged.

This follows Atharva Tiwari's delayed-UCLK proposal for 0219. I described results with my hardware in
the September 4 comment on kernel issue 19. Enabling UCLK separately immediately after enable-all failed in an earlier
experiment; the later callback is the tested point in initialization. The results do not establish the firmware's internal cause.

Here's the testing I've done on my iMac:

Implementation Evidence
Experimental test3 40 successful warm boots and 10 cold boots: eight with AC connected, two with the iMac unplugged after orderly shutdown
Same-kernel control Restoring the original policy reproduced the enable-all timeout; delayed-UCLK warm recovery passed
This production patch on T2 7.2.3 Normal warm boot, hardware rendering, VAAPI H.264 comparison, and sustained rendering with all four memory states observed
Production cold conditions Prescribed AC-connected and AC-unplugged starts passed, with operator-confirmed 60-second intervals and rendering/video checks; an additional AC-connected power-on also passed and is recorded separately
Production public-policy exclusion Separate warm boot with MCLK DPM disabled; expected fixed state, rendering and VAAPI pass
Production memory/update checks Ten-minute Vulkan memory test with 2 GiB budget and load/idle/load transition; normal boot/render/video pass after a full system update and initramfs regeneration
Build and host checks Full T2 build, module inventory/depmod checks, and 49,177 extracted-C cases with ASan/UBSan and mocked firmware

The build uses Arch v7.2.3-arch1 plus T2 patch collection 1ed4126844013f7e6fb3c8b0347cf0c5d6f99ffa. Historical counts belong to the experimental implementation. An intended unplugged start was corrected to AC-connected when the operator clarified the sequence; the actual unplugged check was then performed and confirmed. Other Apple boards, macOS-predecessor starts, suspend/resume and native 5K have not been validated. Boot-time MCE and Bluetooth observations remain outside this GPU initialization patch.

I would appreciate review of the callback ordering and clock-state updates, and testing on other affected hardware before considering a broader match. The intended destination is AMDGPU upstream; carrying it in T2 would also make the tested fix available to affected users.

This work was prompted by frequent, intermittent boot failures on my iMac due to the GPU not being initialized. I used Codex / GPT-6 to do the source investigation, patch implementation, test scripts, as well as then by requests to isolate the UCLK sequencing change, retain public policy behaviour and validate a production extraction. The checks above include compiled C, real hardware and an original-policy control; the host tests use mocked firmware.

Formatting checks: checkpatch --strict --no-signoff reports zero errors, two warnings and five checks. The warnings concern the accessible mail-archive link and the older assistance-trailer format expected by the checked-out checker; the five checks concern existing firmware-interface CamelCase names.

Add the board-specific initialization workaround for the tested 0218/41
iMac. Keep the existing 0219 patch unchanged.

Assisted-by: LLM
Defer UCLK DPM enablement to avoid timeouts on Apple iMac 1002:7340/106b:0218. Update firmware bit and memory DPM table accordingly.
@3v3nFloW

3v3nFloW commented Sep 9, 2026

Copy link
Copy Markdown

Thanks for this — it lines up with what I see on a MacBookPro16,1 (2019) with the Radeon Pro 5500M: 1002:7340, Apple subsystem 106b:020f, revision 0x40, VBIOS 113-D32206U1-019. Full write-up with a 27-boot log is in t2linux/wiki#753.

On that board the failure mode is slightly different from the iMac's: init usually succeeds, but the SMU stops responding on the first 3D load, i.e. on the first UCLK DPM transition (message timeouts, then a hard GPU hang; GFXCLK forced to 300 MHz does not help). Disabling DPM_UCLK at runtime via pp_features before the first load makes the GPU fully stable (glmark2 150 s at 1450 MHz, WebGL volume rendering at 48 W peak, 0 errors, uptime > 1 h) — at the cost of MCLK stuck at 95 MHz. Details in the follow-up comment on #753.

So the trigger is the same UCLK enablement / first transition your patch addresses, just on a third Apple Navi 14 subsystem next to 0218 and 0219.

Would you consider extending navi14_needs_late_uclk() to also match subsystem_device == 0x020f && revision == 0x40? I'm happy to test a build on this machine and report warm/cold boot counts plus pp_dpm_mclk output after a successful boot, if that helps decide whether the deferred enable also yields a working MCLK table here.

@edschofield

edschofield commented Sep 10, 2026 •

Copy link
Copy Markdown
Author

Thanks @3v3nFloW. I've included your 7340/020f, revision 40, in a new draft PR #61. (I'm keeping this narrower PR open separately so it doesn't have to wait for the additional boards if the maintainers want to merge it by itself.)

The AMD staging version passed ten warm boots on my 0218 iMac, with rendering and video checks each time. My memory clock stayed at 875 MHz throughout the recorded tests, so I don't know if this will fix the clock changes that appear to trigger your hang.

Are you still using Linux Mint 22.3 with 7.2.3-1-t2-noble? Please share your current uname -r and which workarounds are enabled, so we can think about a suitable build and a way back to your working kernel. For your board, I'd start with the first Radeon 3D load and memory-clock readings before and after it, then two warm boots if that works. There's a shared testing outline described in PR #61; we still need a real 020f result before calling it a fix.

Reference: your detailed report.

@3v3nFloW

Copy link
Copy Markdown

Thanks for adding 020f to #61.

Yes, still Linux Mint 22.3 (XFCE, T2-Mint ISO) with uname -r = 7.2.3-1-t2-noble from the t2 apt repo; in-tree amdgpu, no DKMS on the GPU side. Board: 1002:7340 / 106b:020f, rev 0x40, at 0000:03:00.0, VBIOS 113-D32206U1-019.

Workarounds currently enabled (all userspace/boot path, nothing patched in the kernel):

  • Cmdline: pm_async=off intel_iommu=on iommu=pt amdgpu.ppfeaturemask=0xfff73fff (GFXOFF off — no measurable effect, just left in place).
  • The greeter's X server starts with Option "Accel" "false". About 25 s after graphical.target a systemd service sets power_dpm_force_performance_level=manual, writes 0x00000442a3c9afb3 to pp_features (DPM_UCLK bit 3 off) and restarts X with acceleration. Autologin is off, so nothing touches the GPU with 3D before that write.
  • appletbdrm/tiny-dfr are loaded by a second, late service (loaded at boot they add a third DRM node and X hangs — unrelated to UCLK).
  • Suspend disabled.

One data point that may matter for the mclk question: with DPM_UCLK masked off, pp_dpm_mclk simply freezes at whatever level UCLK was in when the mask is written, and the GPU is stable at either level. On 04.09 (mask written from the boot service ~100 s after boot) it froze at the 736/750 MHz level for a 34-minute session with glmark2 and GPU volume rendering, 884 samples, 0 errors. Today, same boot sequence, it froze at 95 MHz; a fresh 30 s glmark2 run at 5 min uptime went to GFXCLK 1450 MHz / 23 W with MCLK at 95 MHz throughout and 0 amdgpu lines in dmesg. So it is the UCLK transition that wedges the SMU, not the level it sits at — which is why a deferred enable that ends in a working DPM table would be the real fix here.

Way back to a working kernel: 7.2.3 stays installed next to the test kernel, GRUB shows its menu for 5 s, macOS is on its own partition, and SSH is up ~9 s after boot while the hang has never come before ~20 s — so from another machine I can systemctl mask --now lightdm and reboot into the old kernel if the new one wedges on the first 3D load. I have done that several times during the 27-boot log.

Proposed 020f test, following the outline in #61:

  1. Boot the test kernel with my two services disabled (pp_features untouched, power_dpm_force_performance_level=auto, X directly with acceleration); log in; capture pp_features, pp_dpm_mclk, pp_dpm_sclk and dmesg | grep -i amdgpu.
  2. First 3D load: glmark2 for 60 s while sampling pp_dpm_mclk once per second; capture the same files plus dmesg afterwards.
  3. If that survives: two warm boots repeating 1–2, then a WebGL DICOM volume rendering as the heavier load (the one that killed the SMU within 30 s before).
  4. Report the full pp_dpm_mclk output, the mclk trace across the first load, and any amdgpu error lines.

Is there a ready noble build of the #61 kernel (CI artifact, or a T2-Ubuntu-Kernel branch I should build from)? Building locally is fine, I just want to test the same tree you tested. I can run this within the next few days.

@iurjscsi1101500

Copy link
Copy Markdown
Collaborator

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.

3 participants