Blame SOURCES/0004-data-Use-latest-upstream-udev-rules.patch

84adb8
From 0131864b339dc0cc5f23def75e6caa5872c9ed11 Mon Sep 17 00:00:00 2001
84adb8
From: Ray Strode <rstrode@redhat.com>
84adb8
Date: Mon, 7 Mar 2022 10:16:39 -0500
84adb8
Subject: [PATCH 4/4] data: Use latest upstream udev rules
84adb8
84adb8
This pulls in the latest udev rule from upstream that gives us
84adb8
wayland on nvidia when we can, and disables wayland on nvidia
84adb8
when we should.
84adb8
84adb8
It also pulls in the latest handling for passthrough gpus.
84adb8
---
84adb8
 data/61-gdm.rules.in | 139 +++++++++++++++++++++++++++++++++++++++++--
84adb8
 1 file changed, 135 insertions(+), 4 deletions(-)
84adb8
84adb8
diff --git a/data/61-gdm.rules.in b/data/61-gdm.rules.in
84adb8
index b1da191f..5dae00ea 100644
84adb8
--- a/data/61-gdm.rules.in
84adb8
+++ b/data/61-gdm.rules.in
31d517
@@ -1,6 +1,123 @@
84adb8
+# identify virtio graphics cards to find passthrough setups
84adb8
+SUBSYSTEM!="virtio", GOTO="gdm_virtio_device_end"
84adb8
+ACTION!="add", GOTO="gdm_virtio_device_end"
84adb8
+ATTR{vendor}=="0x1af4", ATTR{device}=="0x0010", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-virtual-gpu", ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}="1", GOTO="gdm_virtio_device_end"
84adb8
+LABEL="gdm_virtio_device_end"
84adb8
+
84adb8
+SUBSYSTEM!="pci", GOTO="gdm_pci_device_end"
31d517
+ACTION!="bind", ACTION!="add", GOTO="gdm_pci_device_end"
84adb8
+
84adb8
+# identify virtio graphics cards to find passthrough setups
84adb8
+# cirrus
84adb8
+ATTR{vendor}=="0x1013", ATTR{device}=="0x00b8", ATTR{subsystem_vendor}=="0x1af4", ATTR{subsystem_device}=="0x1100", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-virtual-gpu", ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}="1", GOTO="gdm_pci_device_end"
84adb8
+# vga
84adb8
+ATTR{vendor}=="0x1b36", ATTR{device}=="0x0100", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-virtual-gpu", ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}="1", GOTO="gdm_pci_device_end"
84adb8
+# qxl
84adb8
+ATTR{vendor}=="0x1234", ATTR{device}=="0x1111", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-virtual-gpu", ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}="1", GOTO="gdm_pci_device_end"
84adb8
+
84adb8
 # disable Wayland on Hi1710 chipsets
84adb8
-ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", RUN+="@libexecdir@/gdm-runtime-config set daemon WaylandEnable false"
84adb8
-# disable Wayland when using the proprietary nvidia driver
84adb8
-DRIVER=="nvidia", RUN+="@libexecdir@/gdm-runtime-config set daemon WaylandEnable false"
84adb8
+ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", GOTO="gdm_disable_wayland"
84adb8
+
84adb8
+LABEL="gdm_pci_device_end"
84adb8
+
84adb8
 # disable Wayland if modesetting is disabled
84adb8
-IMPORT{cmdline}="nomodeset", RUN+="@libexecdir@/gdm-runtime-config set daemon WaylandEnable false"
84adb8
+KERNEL!="card[0-9]*", GOTO="gdm_nomodeset_end"
84adb8
+SUBSYSTEM!="drm", GOTO="gdm_nomodeset_end"
84adb8
+IMPORT{parent}="GDM_MACHINE_HAS_VIRTUAL_GPU"
84adb8
+ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}!="1", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hardware-gpu"
84adb8
+# but keep it enabled for simple framebuffer drivers
84adb8
+DRIVERS=="simple-framebuffer", GOTO="gdm_nomodeset_end"
84adb8
+IMPORT{cmdline}="nomodeset", GOTO="gdm_disable_wayland"
84adb8
+LABEL="gdm_nomodeset_end"
84adb8
+
84adb8
+# The vendor nvidia driver has multiple modules that need to be loaded before GDM can make an
84adb8
+# informed choice on which way to proceed, so force GDM to wait until NVidia's modules are
84adb8
+# loaded before starting up.
84adb8
+KERNEL!="nvidia", GOTO="gdm_nvidia_end"
84adb8
+SUBSYSTEM!="module", GOTO="gdm_nvidia_end"
84adb8
+ACTION!="add", GOTO="gdm_nvidia_end"
84adb8
+RUN+="/usr/bin/touch /run/udev/gdm-machine-has-vendor-nvidia-driver"
84adb8
+
84adb8
+# Check if suspend/resume services necessary for working wayland support is available
84adb8
+TEST{0711}!="/usr/bin/nvidia-sleep.sh", GOTO="gdm_disable_wayland"
84adb8
+TEST{0711}!="/usr/lib/systemd/system-sleep/nvidia", GOTO="gdm_disable_wayland"
84adb8
+IMPORT{program}="/bin/sh -c \"sed -e 's/: /=/g' -e 's/\([^[:upper:]]\)\([[:upper:]]\)/\1_\2/g' -e 's/[[:lower:]]/\U&/g' -e 's/^/NVIDIA_/' /proc/driver/nvidia/params\""
84adb8
+ENV{NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS}!="1", GOTO="gdm_disable_wayland"
84adb8
+IMPORT{program}="/bin/sh -c 'echo NVIDIA_HIBERNATE=`systemctl is-enabled nvidia-hibernate`'"
84adb8
+ENV{NVIDIA_HIBERNATE}!="enabled", GOTO="gdm_disable_wayland"
84adb8
+IMPORT{program}="/bin/sh -c 'echo NVIDIA_RESUME=`systemctl is-enabled nvidia-resume`'"
84adb8
+ENV{NVIDIA_RESUME}!="enabled", GOTO="gdm_disable_wayland"
84adb8
+IMPORT{program}="/bin/sh -c 'echo NVIDIA_SUSPEND=`systemctl is-enabled nvidia-suspend`'"
84adb8
+ENV{NVIDIA_SUSPEND}!="enabled", GOTO="gdm_disable_wayland"
84adb8
+LABEL="gdm_nvidia_end"
84adb8
+
84adb8
+# If this machine has an internal panel, take note, since it's probably a laptop
84adb8
+# FIXME: It could be "ghost connectors" make this pop positive for some workstations
84adb8
+# in the wild. If so, we may have to fallback to looking at the chassis type from
84adb8
+# dmi data or acpi
84adb8
+KERNEL!="card[0-9]-eDP-*", GOTO="gdm_laptop_check_end"
84adb8
+SUBSYSTEM!="drm", GOTO="gdm_laptop_check_end"
84adb8
+ACTION!="add", GOTO="gdm_laptop_check_end"
84adb8
+RUN+="/usr/bin/touch /run/udev/gdm-machine-is-laptop"
84adb8
+GOTO="gdm_hybrid_nvidia_laptop_check"
84adb8
+LABEL="gdm_laptop_check_end"
84adb8
+
84adb8
+# If this is a hybrid graphics setup, take note
84adb8
+KERNEL!="card[1-9]*", GOTO="gdm_hybrid_graphics_check_end"
84adb8
+KERNEL=="card[1-9]-*", GOTO="gdm_hybrid_graphics_check_end"
84adb8
+SUBSYSTEM!="drm", GOTO="gdm_hybrid_graphics_check_end"
84adb8
+ACTION!="add", GOTO="gdm_hybrid_graphics_check_end"
84adb8
+RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hybrid-graphics"
84adb8
+LABEL="gdm_hybrid_graphics_check_end"
84adb8
+
84adb8
+# If this is a hybrid graphics laptop with vendor nvidia driver, disable wayland
84adb8
+LABEL="gdm_hybrid_nvidia_laptop_check"
84adb8
+TEST!="/run/udev/gdm-machine-is-laptop", GOTO="gdm_hybrid_nvidia_laptop_check_end"
84adb8
+TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_hybrid_nvidia_laptop_check_end"
84adb8
+TEST!="/run/udev/gdm-machine-has-vendor-nvidia-driver", GOTO="gdm_hybrid_nvidia_laptop_check_end"
84adb8
+GOTO="gdm_disable_wayland"
84adb8
+LABEL="gdm_hybrid_nvidia_laptop_check_end"
84adb8
+
84adb8
+# Disable wayland in situation where we're in a guest with a virtual gpu and host passthrough gpu
84adb8
+LABEL="gdm_virt_passthrough_check"
84adb8
+TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_passthrough_check_end"
84adb8
+TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_passthrough_check_end"
84adb8
+TEST!="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_passthrough_check_end"
84adb8
+GOTO="gdm_disable_wayland"
84adb8
+LABEL="gdm_virt_passthrough_check_end"
84adb8
+
84adb8
+# Disable wayland when there are multiple virtual gpus
84adb8
+LABEL="gdm_virt_multi_gpu_check"
84adb8
+TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_multi_gpu_check_end"
84adb8
+TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_multi_gpu_check_end"
84adb8
+TEST=="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_multi_gpu_check_end"
84adb8
+LABEL="gdm_virt_multi_gpu_check_end"
84adb8
+
84adb8
+# Disable wayland when nvidia modeset is disabled or when drivers are a lower
84adb8
+# version than 470,
84adb8
+# For versions above 470 but lower than 510 prefer Xorg,
84adb8
+# Above 510, prefer Wayland.
84adb8
+KERNEL!="nvidia_drm", GOTO="gdm_nvidia_drm_end"
84adb8
+SUBSYSTEM!="module", GOTO="gdm_nvidia_drm_end"
84adb8
+ACTION!="add", GOTO="gdm_nvidia_drm_end"
84adb8
+# disable wayland if nvidia-drm modeset is not enabled
84adb8
+ATTR{parameters/modeset}!="Y", GOTO="gdm_disable_wayland"
84adb8
+# disable wayland for nvidia drivers versions lower than 470
84adb8
+ATTR{version}=="4[0-6][0-9].*|[0-3][0-9][0-9].*|[0-9][0-9].*|[0-9].*", GOTO="gdm_disable_wayland"
84adb8
+# For nvidia drivers versions Above 510, keep Wayland by default
84adb8
+ATTR{version}=="[5-9][1-9][0-9].*", GOTO="gdm_end"
84adb8
+# For nvidia drivers versions 470-495, prefer Xorg by default
84adb8
+GOTO="gdm_prefer_xorg"
84adb8
+LABEL="gdm_nvidia_drm_end"
84adb8
+
84adb8
+GOTO="gdm_end"
84adb8
+
84adb8
+LABEL="gdm_prefer_xorg"
84adb8
+RUN+="@libexecdir@/gdm-runtime-config set daemon PreferredDisplayServer xorg"
84adb8
+GOTO="gdm_end"
84adb8
+
84adb8
+LABEL="gdm_disable_wayland"
84adb8
+RUN+="@libexecdir@/gdm-runtime-config set daemon WaylandEnable false"
84adb8
+GOTO="gdm_end"
84adb8
+
84adb8
+LABEL="gdm_end"
84adb8
-- 
84adb8
2.34.1
84adb8