fix: retry detecting discrete GPU solving boot race - #194
Conversation
to resolve boot race where nvidia driver doesn't yet report being discrete to Vulkan/EGL probes which cardwired is already querying. Misclassifying nvidia discrete GPU as integrated and disabling Integrated/Smart modes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughGPU enumeration now uses ChangesDiscrete GPU Detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change retries GPU classification to handle startup timing; no actionable merge-blocking risk remains based on the supplied evidence. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
instead of having a retry loop, can't we wait for the device to be initialized before scanning it? drm_node_ids does it (with a retry loop that i wanted to get rid of), maybe we could just add it directly into the build_gpu() function cardwire/crates/cardwire-daemon/src/core/gpu/display.rs Lines 77 to 79 in 1d7222c |
|
I agree, preferring not to have retry loops. I'm not very familiar enough with linux device management but I hammered Claude and apparently a straight "wait for
Looking for better solutions but haven't found any yet. Possibly we could have one poll for everything to be ready 👀 |
|
maybe we should find a way to WAIT for the amdgpu/nvidia drivers before scanning GPUs? |
Problem
Misclassifying nvidia discrete GPU as integrated and disabling Integrated/Smart modes.
Context
Just updated my Asus G14 2025 Ubuntu 26.04 today and built latest cardwire from source.
Sidenote: Had to run the following to get it building because of c5e8dcd:
After installing and rebooting the option "Integrated" which I'm using most of the time was missing from my AMD/nvidia GPU setup. Also the nvidia GPU was not listed as discrete (and blocked) anymore.
Solution
I asked Claude for a solution and it quickly found that it's a boot race condition where cardwired is started before the nvidia driver is fully initialized. And the one Vulkan/EGL probe query for the nvidia GPU being dicrete returns an error and defaults to integrated instead.
Claude implemented a 10 times retry with 500ms in between for this discrete GPU probing.
Testing
On my setup it seems to always scceed on the second try for the nvidia GPU. The AMD GPU produces the same error instead of reporting being "non-descrete", so it fails 10 times (5 seconds) before defaulting to integrated which is correct delaying the service start which has no side effect in my testing.
I had to manually set "Integrated" mode again after reboot because once cardwire fell back to "Hybrid" mode even just once it would keep that as the user selected option until "Integrated" is available and manually selected again.
Possible alternatives
Not sure if these are feasible/better.
Checklist:
Corrects many other files.