fix(amdgpu): ask the driver whether a GPU is integrated - #37
Open
6jrx wants to merge 1 commit into
Open
Conversation
The PCI class code does not tell us whether a GPU is integrated: an APU enumerates as 030000 when its iGPU is the boot VGA device and as 038000 when it is not. Any APU that is not the boot VGA device was therefore treated as discrete and never got a TDP interface, leaving the device with no TDP control at all. Query AMDGPU_INFO_DEV_INFO instead and look at AMDGPU_IDS_FLAGS_FUSION, which the driver sets for every APU, and use it to correct the class when the PCI class code suggests the GPU is discrete. Fixes ShadowBlip#28 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #28, at least the direction the title describes.
The problem
get_gpu()derives theintegrated/dedicatedclass from the PCI class code alone, but that code doesn't say where the GPU lives — it says whether the GPU is the boot VGA device. An APU enumerates as030000(VGA compatible controller) when its iGPU is the boot VGA device and as038000(display controller) when it isn't. In the second case it gets classifieddedicated,AmdGpu::get_tdp_interface()returnsNone, and the device is left with no TDP control at all.That's what's happening on Strix Point handhelds — GPD Win Mini / Win Max 2 / Win 4 HX370, reported downstream as ublue-os/bazzite#5382:
The fix
Ask the driver, as suggested in #28.
AMDGPU_INFO_DEV_INFOreportsAMDGPU_IDS_FLAGS_FUSION, which amdgpu sets for every APU — the same flag switcheroo-control looks at. It's queried through a smalllibc::ioctlwrapper so that libdrm doesn't have to be pulled in.The correction only runs when the PCI class code did not already say
integrated, and it can only ever promote a card tointegrated. Every device that works today keeps exactly the class it has today, and if the query can't be answered — no render node, not an amdgpu device, no access to/dev/dri— the existing behaviour is kept. Intel is untouched.Testing
All on a GPD WIN 4 (Ryzen AI 9 HX 370 / Radeon 890M), i.e. the affected hardware.
The query itself:
And the daemon. Before:
After:
That run was unprivileged, so RyzenAdj init fails with EIO and the bus name can't be owned afterwards; neither has anything to do with the classification.
The added test skips itself when there's no reachable AMD card, so it's a no-op on CI runners.
Not addressed
A discrete GPU that is the boot VGA device reports
030000and is still classifiedintegrated, which is the other half of #28. Happy to widen the check to always consult the driver — I kept it narrow so that no currently-working device changes classification, and so that a runtime-suspended discrete GPU isn't woken just to be asked.