You are not logged in.

#1 2026-06-21 14:46:43

ifazral
Member
Registered: 2026-06-21
Posts: 3

[SOLVED] KWin Wayland defaults to NVIDIA (card0) instead of Intel

Hello everyone,

I am running a fully up-to-date, vanilla Arch Linux system on an ASUS Optimus laptop (Intel i7-13650HX & NVIDIA RTX 4060). I am using KDE Plasma 6 (Wayland) inside a systemd-boot environment with Unified Kernel Images (UKI). (ASUS ROG Strix G16 G614JV (2023))

The issue: At boot, the NVIDIA dGPU always gets assigned to `card0`, while the Intel iGPU gets assigned to `card1`. Because of this hardware/driver initialization order, `kwin_wayland` automatically hooks into the NVIDIA card (occupying ~7MiB of VRAM and keeping the dGPU awake at 1W-4W during idle desktop usage).

What I have tried:
1. I checked my kernel command line; I do not have `nvidia_drm.fbdev=1` active anymore (it was removed from the UKI profile).
2. I tried rearranging the `MODULES=(...)` array inside `/etc/mkinitcpio.conf` to force load `i915` and `xe` before `nvidia`, but the dGPU still wins the race and becomes `card0`.
3. Trying to force KWin via `KWIN_DRM_DEVICES` to use `card1` causes the Plasma session to crash into a Core Dump during login.

It seems like the UEFI/BIOS initializes the PCIe lanes for the dGPU slightly faster than the iGPU, forcing the kernel to register NVIDIA first. Is there a reliable way to solve this layout issue under Wayland without breaking the session?

Here are my system logs:
- DRI by-path output: https://paste.rs/eBIJ9
- bootctl list output: https://paste.rs/TTTUf
- nvidia-smi output: https://paste.rs/GdngY
- Full journalctl -b 0: https://paste.rs/0xu9a

Thank you in advance for your time and help!

"Edit:
Answer: Use method member "seth" mentioned https://wiki.archlinux.org/title/KDE#Me … -specific) then after reboot see if gpu can suspend itself
cat /sys/bus/pci/devices/0000:01:00.0/power/control
cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status

or you can see the wiki it probably knows better than me https://wiki.archlinux.org/title/PRIME# … Management
or
https://download.nvidia.com/XFree86/Lin … ement.html

if it doesn't say auto and suspended then you should do:
sudo nano /etc/modprobe.d/nvidia-power.conf
options nvidia NVreg_DynamicPowerManagement=0x03

sudo nano /etc/udev/rules.d/80-nvidia-pm.rules
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"

# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"

# Enable runtime PM for NVIDIA VGA/3D controller devices on adding device
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"

then reboot it."

Last edited by ifazral (2026-06-22 05:35:46)

Offline

#2 2026-06-21 20:16:03

ifazral
Member
Registered: 2026-06-21
Posts: 3

Re: [SOLVED] KWin Wayland defaults to NVIDIA (card0) instead of Intel

System Context: ASUS ROG/TUF (or similar Intel + NVIDIA hybrid laptops), KDE Plasma, KWin Wayland, Linux-Zen Kernel (7.x+).

The Problem:

When running on battery, the discrete NVIDIA GPU (RTX 40xx/30xx) refuses to stay in its deep sleep state (`D3cold` / 0 Watts). Instead, background processes or `kwin_wayland` constantly poll the GPU every 5 seconds, causing a devastating active <-> suspended ping-pong loop. This results in high idle power draw (20W+), overheating, and poor battery life. Legacy tools like `supergfxctl` are now deprecated or highly unstable on modern kernels.


The Permanent Solution

This fix utilizes next-gen eBPF LSM hooks to intercept and block hardware access syscalls at the kernel level, combined with forced PCI runtime power management.

1. Install the eBPF-based GPU Manager (`cardwire`)

`cardwire` tricks misbehaving applications into thinking the NVIDIA card doesn't even exist by returning an immediate `-ENOENT` (File/Device not found) error. Install it from the AUR:

yay -S cardwire


2. Configure Cardwire for NVIDIA

Create the missing configuration directory and file:

sudo mkdir -p /etc/cardwire
sudo nano /etc/cardwire/cardwire.toml


Paste the following configuration (enabling the experimental NVIDIA block is mandatory):

auto_apply_gpu_state = true
experimental_nvidia_block = true
battery_auto_switch = false
battery_auto_switch_mode = "hybrid"


3. Enable NVIDIA Dynamic Power Management

Tell the NVIDIA driver that it is allowed to power down when idle:

sudo nano /etc/modprobe.d/nvidia-power.conf


Add this line:

options nvidia NVreg_DynamicPowerManagement=0x02


4. Force the PCI Power Switch to Auto (udev Rule)

By default, the Linux kernel keeps the NVIDIA PCIe slot's master power switch set to `on`. We need to force it to `auto` so it can actually cut the power:

sudo nano /etc/udev/rules.d/80-nvidia-pm.rules


Paste these 3 exact rules to cover the GPU and its sub-components (Audio/USB):

ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}="0x040300", ATTR{power/control}="auto"


5. Fire Up the Service and Reboot

Enable the backend daemon, set your initial mode, and restart your machine to apply the kernel parameters:


sudo systemctl enable --now cardwired.service
cardwire set integrated
sudo reboot


Upon reboot, running `cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status` should finally report `suspended`


CRITICAL LIMITATION / THE UNRESOLVED CAVEAT

While this setup provides a massive battery life extension, it is not 100% automated if you choose to boot into Hybrid mode, due to the architectural design of Wayland.

The KWin DRM Binding Issue: If you boot your system while Cardwire is set to Hybrid, `kwin_wayland` initializes at the login screen and immediately binds to the NVIDIA card (`card0`).
Once KWin grabs a hold of the NVIDIA DRM node, it refuses to let go. If you try to run `cardwire set integrated` later on, KWin will block the GPU from entering its deep sleep state, and the card will stay `active`.

To safely drop back down to `suspended` (0W) mode without dealing with a persistent wake-state, you must do one of the following:

1. Make sure to run `cardwire set integrated` before you reboot or shut down your system, ensuring the next boot forces KWin onto the Intel card exclusively.
2. Or you can use a script:

Automated Hybrid Mode for Cardwire on KWin Wayland (Fixing DRM Binding via KDE User-Space)

The Trick:

Shift the automation entirely into the KDE Plasma User-Space lifecycle:

1. On Shutdown: Use KDE Plasma's native logout hook to force Cardwire to `integrated` mode the exact millisecond you click the shutdown/reboot button. This guarantees that D-Bus and `cardwired` are still 100% alive.
2. On Boot: The system boots safely with the NVIDIA card hidden. Once you log in, a KDE Autostart script enforces a brute-force 30-second delay. This allows KWin and Xwayland to completely finish their hardware scanning and lock onto the iGPU before Cardwire safely flips the switch back to `hybrid` mode.

---

Implementation

1. Create the KDE Plasma Shutdown Hook

This script runs immediately when you trigger a shutdown, reboot, or logout sequence from the desktop UI.

mkdir -p ~/.config/plasma-workspace/shutdown/
nano ~/.config/plasma-workspace/shutdown/set-integrated-before-die.sh


Paste the following lines:


#!/bin/bash
/usr/bin/cardwire set integrated


Make it executable:

chmod +x ~/.config/plasma-workspace/shutdown/set-integrated-before-die.sh


2. Create the Delayed Hybrid Boot Script

This script acts as the background timer, waiting out KWin's initial hardware probe window.

sudo nano /usr/local/bin/cardwire-boot-hook.sh


Paste the following lines:

#!/bin/bash
sleep 30
/usr/bin/cardwire set hybrid


Make it executable:

sudo chmod +x /usr/local/bin/cardwire-boot-hook.sh


3. Create the Desktop Autostart Trigger

This desktop entry ensures the background timer starts right after your desktop panels load.

mkdir -p ~/.config/autostart/
nano ~/.config/autostart/cardwire-hybrid-trigger.desktop


Paste the following configuration:

[Desktop Entry]
Type=Application
Name=Cardwire Hybrid Trigger
Exec=/usr/local/bin/cardwire-boot-hook.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
X-KDE-Autostart-after=panel

---

Result

Your system gracefully logs off in `integrated` mode every single time. On the next boot, KWin is forced to map entirely to your iGPU. 30 seconds after you log in, `hybrid` mode arms itself seamlessly.

Running `nvidia-smi` will show No running processes found, allowing your dGPU to sit completely powered down at 0 Watts (`suspended`) until you explicitly invoke it with `prime-run`.

Offline

#3 2026-06-21 20:41:00

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,896

Re: [SOLVED] KWin Wayland defaults to NVIDIA (card0) instead of Intel

I'm not gonna read that WOT and just assume it's some AI nonsense but you were looking for https://wiki.archlinux.org/title/KDE#Me … -specific)

Offline

#4 2026-06-22 05:06:50

ifazral
Member
Registered: 2026-06-21
Posts: 3

Re: [SOLVED] KWin Wayland defaults to NVIDIA (card0) instead of Intel

I tried this method today, and it seems to really work. My previous method worked too, but it didn't use 7 MB of locked VRAM. The current method does use it, but since the driver isn't rendering, it can enter a suspended state using d3cold.
But I still needed to change nvidia-power.conf and 80-nvidia-pm.rules without them card couldn't suspend itself.
Also wiki page for power management in nvidia: https://wiki.archlinux.org/title/PRIME# … Management

Last edited by ifazral (2026-06-22 05:24:21)

Offline

#5 2026-07-19 00:34:22

richardm
Member
Registered: 2023-02-19
Posts: 8

Re: [SOLVED] KWin Wayland defaults to NVIDIA (card0) instead of Intel

On my kernel command line:

initcall_blacklist=simpledrm_platform_driver_init

...stabilized my /dev/dri/cardx and /dev/dri/renderD1xx relationships and made them congruent with PCI address ordering.  It's been very helpful when steering kwin and others to specific cards.  Unfortunately you lose early boot text.

Offline

Board footer

Powered by FluxBB