https://bugs.kde.org/show_bug.cgi?id=528598

            Bug ID: 528598
           Summary: A GPU whose Vulkan driver isn't fully up when KWin
                    opens it never gets a Vulkan device: secondary-GPU
                    outputs stay on the CPU copy for the whole session
    Classification: Plasma
           Product: kwin
      Version First 6.7.6
       Reported In:
          Platform: Gentoo Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: platform-drm
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

Versions: KWin 6.7.6 (Wayland, Gentoo/OpenRC, also present in master a2a7855),
NVIDIA 595.104.02 open kernel modules (GSP firmware), Mesa 26.1.8, kernel
7.3.3. RTX 4080 (render GPU, first in `KWIN_DRM_DEVICES`) + Intel Arc A770 +
Intel UHD 770, 10 outputs across the three GPUs. SDDM autologin.

What happens: on a cold boot with autologin, the session starts about 5 s
before `nvidia-drm` has finished initializing (it loads the GSP firmware;
`[drm] Initialized nvidia-drm` at 19 s after power-on, KWin started at ~14 s).
When KWin opens the RTX 4080, NVIDIA's Vulkan driver lists the device but
without `VK_EXT_external_memory_dma_buf`:

kwin_vulkan: Device NVIDIA GeForce RTX 4080 misses required Vulkan extensions
kwin_vulkan: VK_EXT_external_memory_dma_buf
kwin_vulkan: Found Vulkan device Intel(R) UHD Graphics 770 (ADL-S GT1) for
/dev/dri/renderD128
kwin_vulkan: Found Vulkan device Intel(R) Arc(tm) A770 Graphics (DG2) for
/dev/dri/renderD130
kwin_wayland_drm: Using Atomic Mode Setting on gpu "/dev/dri/gpu-rtx4080"
kwin_vulkan: Device NVIDIA GeForce RTX 4080 misses required Vulkan extensions
kwin_vulkan: VK_EXT_external_memory_dma_buf
kwin_vulkan: No Vulkan device found for /dev/dri/renderD129
kwin_wayland_drm: adding GPU /dev/dri/gpu-rtx4080

A few seconds later the driver is complete (a standalone Vulkan program run
then lists the extension, and so does KWin after a session restart), but
`RenderDevice` never looks again: `RenderDevice::createVulkanDevice()` runs at
construction and otherwise only from `handleVulkanDeviceLoss()`. Without a
Vulkan device on the render GPU, every output on the other two GPUs uses the
CPU import (`glReadPixels` on KWin's main thread): with four 1080p outputs on
the Arc that is ~70–96% of a core on the main thread, and the readback/upload
traffic over the chipset link made USB audio crackle on that machine.
Restarting the session (GPU now fully initialized) gives the GPU copy paths and
~40% main thread.

Steps to reproduce: a GPU whose Vulkan driver completes initialization a few
seconds after its DRM node appears (NVIDIA with GSP firmware is a reliable
case), session started at boot (autologin), outputs on a second GPU. Check
`QT_LOGGING_RULES="kwin_vulkan.debug=true;kwin_wayland_drm.debug=true"`: "No
Vulkan device found" for the render GPU, "chose cpu import" for the secondary
outputs.

Expected: the render GPU gets its Vulkan device once the driver is ready, and
the outputs move to the GPU copy path.

Suggestion: if `openVulkanDevice()` finds the physical device but it misses
required extensions (or finds no device for the node), retry a few times with a
back-off (e.g. 1, 2, 4, 8 s) or on the next DRM change event for that device,
and re-evaluate the multi-GPU import mode of affected outputs when it succeeds.
A one-shot retry on the first `importBuffer` that would fall back to the CPU
would also do.

Workaround in use: a `plasma-workspace/env` script that waits (max 30 s) for
`/dev/dri/<nvidia card>` and `/dev/nvidia-modeset` before KWin starts.

Scope note: the machine also runs local KWin patches for multi-GPU copies (a
Vulkan copy into secondary GPUs' memory and a staged copy through system
memory, both close to what KWin 6.8 does upstream). The failure itself (no
retry after a failed Vulkan device lookup) is in unpatched code, and the CPU
fallback it causes is upstream behavior.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to