240703-boot2waylandFailed

201 阅读6分钟

240703-boot2waylandFailed

eton@240703-boot2waylandFailed

  1. failed to boot in wayland
  2. check syslog
$ sudo cat /var/log/syslog|grep -i wayland
2024-07-03T16:50:11.347823+08:00 acr10d systemd[5100]: Starting org.gnome.Shell@wayland.service - GNOME Shell on Wayland...
2024-07-03T16:50:11.349290+08:00 acr10d systemd[5100]: org.gnome.Shell@wayland.service: Skipped due to 'exec-condition'.
2024-07-03T16:50:11.349354+08:00 acr10d systemd[5100]: Condition check resulted in org.gnome.Shell@wayland.service - GNOME Shell on Wayland being skipped.

journalctl can see same info, but '--system' option cannot see it.

journalctl --user|grep -i wayland

org.gnome.Shell@wayland.service: Skipped due to 'exec-condition'.

  1. advice from bbs:

Wayland is disabled on nvidia by a gdm udev rule. You have to: rm /etc/udev/rules.d/61-gdm.rules and then ln -s /dev/null /etc/udev/rules.d/61-gdm.rules

但是我根本没有找到这个rules文件,所以这个是无效的; 但是/usr/lib/udev/rules.d/61-gdm.rules我看到了;

  1. 有人建议“downgrade egl-wayland to 1.1.7” 但是我不打算尝试;
  2. systemctl status发现State: degraded. That means some of your services failed to start.
systemctl --failed

可以看到失败的信息;

journalctl -xe 
//-x: Augment log lines with explanation texts from the message catalog. 
//-e 跳到分页End. Immediately jump to the end of the journal inside the implied pager tool. This implies -n1000 to guarantee that the pager will not buffer logs of unbounded size.

可以看到更多的相关日志; 意外发现很多gnome-shell的日志错误;

Jul 03 17:06:38 acr10d gnome-shell[5609]: Can't update stage views actor [:0x5633af98ab30] is on because it needs an allocation.

bbs.archlinux.org/viewtopic.p… 解决了为什么wayland的禁用,其实还是udev规则;

基于此,对方给的建议是将下面的内容注释掉;

RUN+="/usr/lib/gdm-runtime-config set daemon WaylandEnable false"

但是我希望找到这个规则在udev执行时候的运行日志,这样我就能知道是具体哪一条规则导致disable了. 下面两个也是对方建议的操作,基于bbs的rules文件自己判断是否这两个条件导致wayland-disabled;

stat /usr/bin/nvidia-sleep.sh
systemctl status nvidia-hibernate nvidia-resume nvidia-suspend

打印信息“Access: (0755/-rwxr-xr-x) ” 显示sleep.sh脚本权限确实不太匹配;默认的都是0755, 但是要求0711.

自己查看这个规则生成的文件, 有硬件GPU + 混合GPU + vendor驱动;

$ ls /run/udev/
gdm-machine-has-hardware-gpu  gdm-machine-has-hybrid-graphics  gdm-machine-has-vendor-nvidia-driver 
  1. rules文件添加信息后发现NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS=0 但是要求为1; 发现有个文件 /etc/modprobe.d/可以修改modprobe的选项
$ cat /etc/modprobe.d/nvidia-options.conf 
#options nvidia-current NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=44 NVreg_DeviceFileMode=0660

# To grant performance counter access to unprivileged users, uncomment the following line:
#options nvidia-current NVreg_RestrictProfilingToAdminUsers=0

# Uncomment to enable this power management feature:
options nvidia-current NVreg_PreserveVideoMemoryAllocations=1

# Uncomment to enable this power management feature:
#options nvidia-current NVreg_EnableS0ixPowerManagement=1
  1. reboot后发现还是不可以,但是已经进入前面三个功能nvidia-hibernate nvidia-resume nvidia-suspend是否enable的判断了; Chapter 21. Configuring Power Management Support 应该提供了官方有价值的信息;
$ sudo systemctl enable nvidia-hibernate.service
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-hibernate.service → /lib/systemd/system/nvidia-hibernate.service.

~$ sudo systemctl enable nvidia-resume.service
Created symlink /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.

再次查看,已经不一样了, 设置前是disabled; preset: enabled)

$ systemctl status nvidia-hibernate nvidia-resume nvidia-suspend
○ nvidia-hibernate.service - NVIDIA system hibernate actions
     Loaded: loaded (/lib/systemd/system/nvidia-hibernate.service; enabled; preset: enabled)
     Active: inactive (dead)

○ nvidia-resume.service - NVIDIA system resume actions
     Loaded: loaded (/lib/systemd/system/nvidia-resume.service; enabled; preset: enabled)
     Active: inactive (dead)

○ nvidia-suspend.service - NVIDIA system suspend actions
     Loaded: loaded (/lib/systemd/system/nvidia-suspend.service; enabled; preset: enabled)
     Active: inactive (dead)
  1. 上面修改后还是没有效果;
$ sudo cat /sys/module/nvidia_drm/parameters/modeset
N

需要Y才可以; Chapter 36. Direct Rendering Manager Kernel Modesetting (DRM KMS)的方法不能将上面的信息进行更新; 按照nvidia frum添加下面文件

/etc/modprobe.d$ cat ./nvidia-modeset.conf 
options nvidia-drm modeset=1
  1. 完成modeset的配置后,终于成功了;
  2. Success;

Ref:

Appendix

cat /usr/lib/udev/rules.d/61-gdm.rules|xclip -i

# identify virtio graphics cards to find passthrough setups
SUBSYSTEM!="virtio", GOTO="gdm_virtio_device_end"
ACTION!="add", GOTO="gdm_virtio_device_end"
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"
LABEL="gdm_virtio_device_end"

SUBSYSTEM!="pci", GOTO="gdm_pci_device_end"
ACTION!="bind", GOTO="gdm_pci_device_end"

# identify virtio graphics cards to find passthrough setups
# cirrus
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"
# vga
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"
# qxl
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"

# disable Wayland on Hi1710 chipsets
ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", GOTO="gdm_disable_wayland"

# disable Wayland on Matrox chipsets
ATTR{vendor}=="0x102b", ATTR{device}=="0x0522", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0524", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0530", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0532", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0533", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0534", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0536", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x102b", ATTR{device}=="0x0538", GOTO="gdm_disable_wayland"

# disable Wayland on aspeed chipsets
ATTR{vendor}=="0x1a03", ATTR{device}=="0x2010", GOTO="gdm_disable_wayland"
ATTR{vendor}=="0x1a03", ATTR{device}=="0x2000", GOTO="gdm_disable_wayland"

LABEL="gdm_pci_device_end"

# disable Wayland if modesetting is disabled
KERNEL!="card[0-9]*", GOTO="gdm_nomodeset_end"
SUBSYSTEM!="drm", GOTO="gdm_nomodeset_end"
IMPORT{parent}="GDM_MACHINE_HAS_VIRTUAL_GPU"
ENV{GDM_MACHINE_HAS_VIRTUAL_GPU}!="1", RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hardware-gpu"
# but keep it enabled for simple framebuffer drivers
DRIVERS=="simple-framebuffer", GOTO="gdm_nomodeset_end"
IMPORT{cmdline}="nomodeset", GOTO="gdm_disable_wayland"
LABEL="gdm_nomodeset_end"

# The vendor nvidia driver has multiple modules that need to be loaded before GDM can make an
# informed choice on which way to proceed, so force GDM to wait until NVidia's modules are
# loaded before starting up.
KERNEL!="nvidia", GOTO="gdm_nvidia_end"
SUBSYSTEM!="module", GOTO="gdm_nvidia_end"
ACTION!="add", GOTO="gdm_nvidia_end"
RUN+="/usr/bin/touch /run/udev/gdm-machine-has-vendor-nvidia-driver"

# Check if suspend/resume services necessary for working wayland support is available
TEST{0711}!="/usr/bin/nvidia-sleep.sh", GOTO="gdm_disable_wayland"
TEST{0711}!="/usr/lib/systemd/system-sleep/nvidia", GOTO="gdm_disable_wayland"
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\""
ENV{NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS}!="1", GOTO="gdm_disable_wayland"
IMPORT{program}="/bin/sh -c 'echo NVIDIA_HIBERNATE=`systemctl is-enabled nvidia-hibernate`'"
ENV{NVIDIA_HIBERNATE}!="enabled", GOTO="gdm_disable_wayland"
IMPORT{program}="/bin/sh -c 'echo NVIDIA_RESUME=`systemctl is-enabled nvidia-resume`'"
ENV{NVIDIA_RESUME}!="enabled", GOTO="gdm_disable_wayland"
IMPORT{program}="/bin/sh -c 'echo NVIDIA_SUSPEND=`systemctl is-enabled nvidia-suspend`'"
ENV{NVIDIA_SUSPEND}!="enabled", GOTO="gdm_disable_wayland"
LABEL="gdm_nvidia_end"

# If this machine has an internal panel, take note, since it's probably a laptop
# FIXME: It could be "ghost connectors" make this pop positive for some workstations
# in the wild. If so, we may have to fallback to looking at the chassis type from
# dmi data or acpi
KERNEL!="card[0-9]-eDP-*", GOTO="gdm_laptop_check_end"
SUBSYSTEM!="drm", GOTO="gdm_laptop_check_end"
ACTION!="add", GOTO="gdm_laptop_check_end"
RUN+="/usr/bin/touch /run/udev/gdm-machine-is-laptop"
GOTO="gdm_hybrid_nvidia_laptop_check"
LABEL="gdm_laptop_check_end"

# If this is a hybrid graphics setup, take note
KERNEL!="card[1-9]*", GOTO="gdm_hybrid_graphics_check_end"
KERNEL=="card[1-9]-*", GOTO="gdm_hybrid_graphics_check_end"
SUBSYSTEM!="drm", GOTO="gdm_hybrid_graphics_check_end"
ACTION!="add", GOTO="gdm_hybrid_graphics_check_end"
RUN+="/usr/bin/touch /run/udev/gdm-machine-has-hybrid-graphics"
LABEL="gdm_hybrid_graphics_check_end"

# If this is a hybrid graphics laptop with vendor nvidia driver, disable wayland
LABEL="gdm_hybrid_nvidia_laptop_check"
TEST!="/run/udev/gdm-machine-is-laptop", GOTO="gdm_hybrid_nvidia_laptop_check_end"
TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_hybrid_nvidia_laptop_check_end"
TEST!="/run/udev/gdm-machine-has-vendor-nvidia-driver", GOTO="gdm_hybrid_nvidia_laptop_check_end"
GOTO="gdm_disable_wayland"
LABEL="gdm_hybrid_nvidia_laptop_check_end"

# Disable wayland in situation where we're in a guest with a virtual gpu and host passthrough gpu
LABEL="gdm_virt_passthrough_check"
TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_passthrough_check_end"
TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_passthrough_check_end"
TEST!="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_passthrough_check_end"
GOTO="gdm_disable_wayland"
LABEL="gdm_virt_passthrough_check_end"

# Disable wayland when there are multiple virtual gpus
LABEL="gdm_virt_multi_gpu_check"
TEST!="/run/udev/gdm-machine-has-hybrid-graphics", GOTO="gdm_virt_multi_gpu_check_end"
TEST!="/run/udev/gdm-machine-has-virtual-gpu", GOTO="gdm_virt_multi_gpu_check_end"
TEST=="/run/udev/gdm-machine-has-hardware-gpu", GOTO="gdm_virt_multi_gpu_check_end"
LABEL="gdm_virt_multi_gpu_check_end"

# Disable wayland when nvidia modeset is disabled or when drivers are a lower
# version than 470,
# For versions above 470 but lower than 510 prefer Xorg,
# Above 510, prefer Wayland.
KERNEL!="nvidia_drm", GOTO="gdm_nvidia_drm_end"
SUBSYSTEM!="module", GOTO="gdm_nvidia_drm_end"
ACTION!="add", GOTO="gdm_nvidia_drm_end"
# disable wayland if nvidia-drm modeset is not enabled
ATTR{parameters/modeset}!="Y", GOTO="gdm_disable_wayland"
# disable wayland for nvidia drivers versions lower than 470
ATTR{version}=="4[0-6][0-9].*|[0-3][0-9][0-9].*|[0-9][0-9].*|[0-9].*", GOTO="gdm_disable_wayland"
# For nvidia drivers versions Above 510, keep Wayland by default
ATTR{version}=="[5-9][1-9][0-9].*", GOTO="gdm_end"
# For nvidia drivers versions 470-495, prefer Xorg by default
GOTO="gdm_prefer_xorg"
LABEL="gdm_nvidia_drm_end"

GOTO="gdm_end"

LABEL="gdm_prefer_xorg"
RUN+="/usr/libexec/gdm-runtime-config set daemon PreferredDisplayServer xorg"
GOTO="gdm_end"

LABEL="gdm_disable_wayland"
RUN+="/usr/libexec/gdm-runtime-config set daemon WaylandEnable false"
GOTO="gdm_end"

LABEL="gdm_end"

Appendix-2

$ /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"
NVIDIA_RESMAN_DEBUG_LEVEL=4294967295
NVIDIA_RM_LOGON_RC=1
NVIDIA_MODIFY_DEVICE_FILES=1
NVIDIA_DEVICE_FILE_UID=0
NVIDIA_DEVICE_FILE_GID=0
NVIDIA_DEVICE_FILE_MODE=438
NVIDIA_INITIALIZE_SYSTEM_MEMORY_ALLOCATIONS=1
NVIDIA_USE_PAGE_ATTRIBUTE_TABLE=4294967295
NVIDIA_ENABLE_MSI=1
NVIDIA_ENABLE_PCIE_GEN3=0
NVIDIA_MEMORY_POOL_SIZE=0
NVIDIA_KMALLOC_HEAP_MAX_SIZE=0
NVIDIA_VMALLOC_HEAP_MAX_SIZE=0
NVIDIA_IGNORE_MMIOCHECK=0
NVIDIA_TCEBYPASS_MODE=0
NVIDIA_ENABLE_STREAM_MEM_OPS=0
NVIDIA_ENABLE_USER_NUMAMANAGEMENT=1
NVIDIA_NV_LINK_DISABLE=0
NVIDIA_RM_PROFILING_ADMIN_ONLY=1
NVIDIA_PRESERVE_VIDEO_MEMORY_ALLOCATIONS=0
NVIDIA_ENABLE_S0IX_POWER_MANAGEMENT=0
NVIDIA_S0IX_POWER_MANAGEMENT_VIDEO_MEMORY_THRESHOLD=256
NVIDIA_DYNAMIC_POWER_MANAGEMENT=3
NVIDIA_DYNAMIC_POWER_MANAGEMENT_VIDEO_MEMORY_THRESHOLD=200
NVIDIA_REGISTER_PCIDRIVER=1
NVIDIA_ENABLE_PCIERELAXED_ORDERING_MODE=0
NVIDIA_ENABLE_RESIZABLE_BAR=0
NVIDIA_ENABLE_GPU_FIRMWARE=18
NVIDIA_ENABLE_GPU_FIRMWARE_LOGS=2
NVIDIA_ENABLE_DBG_BREAKPOINT=0
NVIDIA_OPEN_RM_ENABLE_UNSUPPORTED_GPUS=0
NVIDIA_DMA_REMAP_PEER_MMIO=1
NVIDIA_REGISTRY_DWORDS=""
NVIDIA_REGISTRY_DWORDS_PER_DEVICE=""
NVIDIA_RM_MSG=""
NVIDIA_GPU_BLACKLIST=""
NVIDIA_TEMPORARY_FILE_PATH=""
NVIDIA_EXCLUDED_GPUS=""

240703-boot2waylandFailed.endoooo