Skip to content

Commit 2df479e

Browse files
author
Mirko Brombin
authored
feat: exp drivers
1 parent 9a0f4b1 commit 2df479e

File tree

3 files changed

+159
-9
lines changed

3 files changed

+159
-9
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[daemon]
2+
WaylandEnable=true
3+
4+
[security]
5+
6+
[xdmcp]
7+
8+
[chooser]
9+
10+
[debug]
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
SUBSYSTEM!="pci", GOTO="gdm_pci_device_end"
2+
ACTION!="bind", ACTION!="add", GOTO="gdm_pci_device_end"
3+
4+
# cirrus
5+
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"
6+
# virtio
7+
ATTR{vendor}=="0x1af4", ATTR{device}=="0x1050", 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"
8+
# qxl
9+
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"
10+
# vga
11+
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"
12+
13+
# disable Wayland on Hi1710 chipsets
14+
ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", GOTO="gdm_disable_wayland"
15+
16+
LABEL="gdm_pci_device_end"
17+
18+
# (vos) commented: IMPORT{cmdline}="nomodeset", GOTO="gdm_disable_wayland"
19+
# disable Wayland if modesetting is disabled
20+
KERNEL!="card[0-9]*", GOTO="gdm_nomodeset_end"
21+
KERNEL=="card[0-9]-*", GOTO="gdm_nomodeset_end"
22+
SUBSYSTEM!="drm", GOTO="gdm_nomodeset_end"
23+
# but keep it enabled for simple framebuffer drivers
24+
DRIVERS=="simple-framebuffer", GOTO="gdm_nomodeset_end"
25+
IMPORT{parent}="GDM_MACHINE_HAS_VIRTUAL_GPU"
26+
ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}!="1", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hardware-gpu"
27+
# IMPORT{cmdline}="nomodeset", GOTO="gdm_disable_wayland"
28+
LABEL="gdm_nomodeset_end"
29+
30+
# The vendor nvidia driver has multiple modules that need to be loaded before GDM can make an
31+
# informed choice on which way to proceed, so force GDM to wait until NVidia's modules are
32+
# loaded before starting up.
33+
KERNEL!="nvidia", GOTO="gdm_nvidia_end"
34+
SUBSYSTEM!="module", GOTO="gdm_nvidia_end"
35+
ACTION!="add", GOTO="gdm_nvidia_end"
36+
RUN+="/usr/bin/touch /run/udev/gdm-machine-has-vendor-nvidia-driver"
37+
38+
# Import nvidia kernel parameters
39+
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\""
40+
41+
# Check if S0ix-based power management is available
42+
# If it is, there's no need to check for the suspend/resume services
43+
ENV{NVIDIA_ENABLE_S0IX_POWER_MANAGEMENT}=="1", GOTO="gdm_nvidia_suspend_end"
44+
45+
# Check if suspend/resume services necessary for working wayland support is available
46+
TEST{0711}!="/usr/bin/nvidia-sleep.sh", GOTO="gdm_disable_wayland"
47+
TEST{0711}!="/usr/lib/systemd/system-sleep/nvidia", GOTO="gdm_disable_wayland"
48+
49+
ENV{NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS}!="1", GOTO="gdm_disable_wayland"
50+
IMPORT{program}="/bin/sh -c 'echo NVIDIA_HIBERNATE=`systemctl is-enabled nvidia-hibernate`'"
51+
ENV{NVIDIA_HIBERNATE}!="enabled", GOTO="gdm_disable_wayland"
52+
IMPORT{program}="/bin/sh -c 'echo NVIDIA_RESUME=`systemctl is-enabled nvidia-resume`'"
53+
ENV{NVIDIA_RESUME}!="enabled", GOTO="gdm_disable_wayland"
54+
IMPORT{program}="/bin/sh -c 'echo NVIDIA_SUSPEND=`systemctl is-enabled nvidia-suspend`'"
55+
ENV{NVIDIA_SUSPEND}!="enabled", GOTO="gdm_disable_wayland"
56+
LABEL="gdm_nvidia_suspend_end"
57+
LABEL="gdm_nvidia_end"
58+
59+
# If this machine has an internal panel, take note, since it's probably a laptop
60+
# FIXME: It could be "ghost connectors" make this pop positive for some workstations
61+
# in the wild. If so, we may have to fallback to looking at the chassis type from
62+
# dmi data or acpi
63+
KERNEL!="card[0-9]-eDP-*", GOTO="gdm_laptop_check_end"
64+
SUBSYSTEM!="drm", GOTO="gdm_laptop_check_end"
65+
ACTION!="add", GOTO="gdm_laptop_check_end"
66+
RUN+="/usr/bin/touch /run/udev/gdm-machine-is-laptop"
67+
GOTO="gdm_hybrid_nvidia_laptop_check"
68+
LABEL="gdm_laptop_check_end"
69+
70+
# (vos) commented the whole block
71+
# If this is a hybrid graphics setup, take note
72+
# KERNEL!="card[1-9]*", GOTO="gdm_hybrid_graphics_check_end"
73+
# KERNEL=="card[1-9]-*", GOTO="gdm_hybrid_graphics_check_end"
74+
# SUBSYSTEM!="drm", GOTO="gdm_hybrid_graphics_check_end"
75+
# ACTION!="add", GOTO="gdm_hybrid_graphics_check_end"
76+
# IMPORT{program}="/bin/sh -c \"echo GDM_NUMBER_OF_GRAPHICS_CARDS=`ls -1d /sys/class/drm/card[0-9] | wc -l`\""
77+
# ENV{GDM_NUMBER_OF_GRAPHICS_CARDS}=="1", RUN+="/usr/bin/rm -f /run/udev/gdm-machine-has-hybrid-graphics"
78+
# ENV{GDM_NUMBER_OF_GRAPHICS_CARDS}!="1", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hybrid-graphics"
79+
# LABEL="gdm_hybrid_graphics_check_end"
80+
81+
# Disable wayland in situation where we're in a guest with a virtual gpu and host passthrough gpu
82+
LABEL="gdm_virt_passthrough_check"
83+
TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_passthrough_check_end"
84+
TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_passthrough_check_end"
85+
TEST!="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_passthrough_check_end"
86+
GOTO="gdm_disable_wayland"
87+
LABEL="gdm_virt_passthrough_check_end"
88+
89+
# Disable wayland when there are multiple virtual gpus
90+
LABEL="gdm_virt_multi_gpu_check"
91+
TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_multi_gpu_check_end"
92+
TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_multi_gpu_check_end"
93+
TEST=="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_multi_gpu_check_end"
94+
LABEL="gdm_virt_multi_gpu_check_end"
95+
96+
# Disable wayland when nvidia modeset is disabled
97+
KERNEL!="nvidia_drm", GOTO="gdm_nvidia_drm_end"
98+
SUBSYSTEM!="module", GOTO="gdm_nvidia_drm_end"
99+
ACTION!="add", GOTO="gdm_nvidia_drm_end"
100+
# disable wayland if nvidia-drm modeset is not enabled
101+
ATTR{parameters/modeset}!="Y", GOTO="gdm_disable_wayland"
102+
LABEL="gdm_nvidia_drm_end"
103+
104+
GOTO="gdm_end"
105+
106+
LABEL="gdm_prefer_xorg"
107+
RUN+="/usr/libexec/gdm-runtime-config set daemon PreferredDisplayServer xorg"
108+
GOTO="gdm_end"
109+
110+
LABEL="gdm_disable_wayland"
111+
RUN+="/usr/libexec/gdm-runtime-config set daemon WaylandEnable false"
112+
GOTO="gdm_end"
113+
114+
LABEL="gdm_end"

recipe.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,34 @@ stages:
2020
- lpkg --unlock
2121
- apt-get update
2222

23-
- name: install-nvidia
24-
type: apt
25-
source:
26-
packages:
27-
- nvidia-driver
28-
- nvidia-vaapi-driver
29-
- nvidia-settings
30-
- nvidia-smi
31-
- firmware-misc-nonfree
23+
- name: nvidia-official-repo
24+
type: shell
25+
commands:
26+
- curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/nvidia-drivers.gpg
27+
- echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /' > /etc/apt/sources.list.d/nvidia-drivers.list
28+
- apt-get update
29+
30+
- name: nvidia-official-driver
31+
type: shell
32+
commands:
33+
- apt-mark hold nvidia-kernel-open nvidia-driver nvidia-vaapi-driver nvidia-settings nvidia-persistenced nvidia-smi libnvidia-cfg1 libnvidia-glcore libnvidia-glvkspirv libnvidia-gpucomp libnvidia-fbc1 nvidia-container-toolkit
34+
modules:
35+
- name: install-nvidia
36+
type: apt
37+
source:
38+
packages:
39+
- nvidia-kernel-open
40+
- nvidia-driver
41+
- nvidia-vaapi-driver
42+
- nvidia-settings
43+
- nvidia-persistenced
44+
- cuda-drivers
45+
- libnvidia-cfg1
46+
- libnvidia-glcore
47+
- libnvidia-glvkspirv
48+
- libnvidia-gpucomp
49+
- libnvidia-fbc1
50+
- nvidia-container-toolkit
3251

3352
- name: nvidia-sysd-units
3453
type: shell
@@ -62,6 +81,12 @@ stages:
6281
type: includes
6382
includes:
6483
- modules/80-set-image-abroot-config.yml
84+
85+
- name: enable-wayland
86+
type: shell
87+
commands:
88+
- mkdir -p /etc/udev/rules.d
89+
- ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
6590

6691
- name: cleanup
6792
type: shell
@@ -70,6 +95,7 @@ stages:
7095
- apt-get clean
7196
- SUDO_FORCE_REMOVE=yes apt purge -y sudo
7297
- lpkg --lock
98+
- rm /etc/apt/sources.list.d/nvidia-drivers.list
7399

74100
- name: fsguard
75101
type: fsguard

0 commit comments

Comments
 (0)