Replace nouveau driver with nvidia driver on first run

According to https://nouveau.freedesktop.org/wiki/KernelModeSetting/
it ist possible to unload the noveau and kms drivers an replace them
with the nvidia driver.

Warning: This causes the console output to freeze until
the next reboot (which shouldn't matter much because we want to output
via Xorg).

The yavdr-xorg role performs the equivalent of those command if
the module nouveau is loaded:

echo 0 > /sys/class/vtconsole/vtcon1/bind
rmmod nouveau
rmmod ttm
rmmod drm_kms_helper
rmmod drm
modprobe nvidia
systemctl start nvidia-persistenced

TODO: is the variable first_run still needed?
This commit is contained in:
Alexander Grothe 2019-05-06 15:27:01 +02:00
parent 9acae05e63
commit ce24cedf53
3 changed files with 804 additions and 648 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2688,42 +2688,86 @@ preferred_refreshrates:
name: x@vt7.service
state: stopped
- name: Workaround for wrong connector names on first run
block:
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 10
- name: check if a nvidia driver has been installed
set_fact:
nvidia_driver_installed: '{{ "nvidia" in lookup("file", "/etc/yavdr/autoinstalled") }}'
- name: "start x-verbose@.service"
- name: unload nouveau driver, replace with nvidia
block:
- name: unbind vconsole
shell: echo 0 > /sys/class/vtconsole/vtcon1/bind
- name: "wait a little, so noveau isn't used anymore"
wait_for:
timeout: 1
# unloading the drivers using the modprobe module does not work for some strange reason...
- name: unload kms drivers
command: rmmod '{{ item }}'
loop:
- nouveau
- ttm
- drm_kms_helper
- drm
ignore_errors: yes
- name: load nvidia driver
modprobe:
name: "nvidia"
state: present
- name: "wait a little before starting nvidia-persistenced"
wait_for:
timeout: 1
- name: start nvidia-persistenced
systemd:
name: "x-verbose@vt7.service"
name: "nvidia-persistenced"
state: started
enabled: false
enabled: true
masked: false
daemon_reload: true
when:
- nvidia_detected
- nvidia_driver_installed
- '"nouveau" in modules'
- name: "wait a little bit, so X has some time to start up (needed?)"
wait_for:
timeout: 3
#- name: Workaround for wrong connector names on first run
# block:
# - name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
# wait_for:
# timeout: 10
#
# - name: "start x-verbose@.service"
# systemd:
# name: "x-verbose@vt7.service"
# state: started
# enabled: false
# masked: false
# daemon_reload: true
#
# - name: "wait a little bit, so X has some time to start up (needed?)"
# wait_for:
# timeout: 3
#
# - name: "stop x-verbose@vt7.service"
# systemd:
# name: "x-verbose@vt7.service"
# state: stopped
# enabled: false
# masked: true
# when: first_run
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
when: first_run
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
- name: "trigger udevadm reload"
command: 'udevadm trigger '
- name: "wait a little bit, so udev has some time to reapply rules (needed?)"
wait_for:
timeout: 3
#- name: "wait a little bit, so X has some time to shut down (needed?)"
# wait_for:
# timeout: 3
#
#- name: "trigger udevadm reload"
# command: 'udevadm trigger '
#
#- name: "wait a little bit, so udev has some time to reapply rules (needed?)"
# wait_for:
# timeout: 3
- name: "start x-verbose@.service"
systemd:
@ -2733,7 +2777,7 @@ preferred_refreshrates:
masked: false
daemon_reload: true
- name: "wait a little bit, so X has some time to start up (needed?)"
- name: "wait a little, so X has some time to start up"
wait_for:
timeout: 3
@ -2761,9 +2805,9 @@ preferred_refreshrates:
enabled: false
masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
#- name: "wait a little bit, so X has some time to shut down (needed?)"
# wait_for:
# timeout: 3
- name: save results
block:

View File

@ -41,42 +41,86 @@
name: x@vt7.service
state: stopped
- name: Workaround for wrong connector names on first run
block:
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 10
- name: check if a nvidia driver has been installed
set_fact:
nvidia_driver_installed: '{{ "nvidia" in lookup("file", "/etc/yavdr/autoinstalled") }}'
- name: "start x-verbose@.service"
- name: unload nouveau driver, replace with nvidia
block:
- name: unbind vconsole
shell: echo 0 > /sys/class/vtconsole/vtcon1/bind
- name: "wait a little, so noveau isn't used anymore"
wait_for:
timeout: 1
# unloading the drivers using the modprobe module does not work for some strange reason...
- name: unload kms drivers
command: rmmod '{{ item }}'
loop:
- nouveau
- ttm
- drm_kms_helper
- drm
ignore_errors: yes
- name: load nvidia driver
modprobe:
name: "nvidia"
state: present
- name: "wait a little before starting nvidia-persistenced"
wait_for:
timeout: 1
- name: start nvidia-persistenced
systemd:
name: "x-verbose@vt7.service"
name: "nvidia-persistenced"
state: started
enabled: false
enabled: true
masked: false
daemon_reload: true
when:
- nvidia_detected
- nvidia_driver_installed
- '"nouveau" in modules'
- name: "wait a little bit, so X has some time to start up (needed?)"
wait_for:
timeout: 3
#- name: Workaround for wrong connector names on first run
# block:
# - name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
# wait_for:
# timeout: 10
#
# - name: "start x-verbose@.service"
# systemd:
# name: "x-verbose@vt7.service"
# state: started
# enabled: false
# masked: false
# daemon_reload: true
#
# - name: "wait a little bit, so X has some time to start up (needed?)"
# wait_for:
# timeout: 3
#
# - name: "stop x-verbose@vt7.service"
# systemd:
# name: "x-verbose@vt7.service"
# state: stopped
# enabled: false
# masked: true
# when: first_run
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
when: first_run
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
- name: "trigger udevadm reload"
command: 'udevadm trigger '
- name: "wait a little bit, so udev has some time to reapply rules (needed?)"
wait_for:
timeout: 3
#- name: "wait a little bit, so X has some time to shut down (needed?)"
# wait_for:
# timeout: 3
#
#- name: "trigger udevadm reload"
# command: 'udevadm trigger '
#
#- name: "wait a little bit, so udev has some time to reapply rules (needed?)"
# wait_for:
# timeout: 3
- name: "start x-verbose@.service"
systemd:
@ -86,7 +130,7 @@
masked: false
daemon_reload: true
- name: "wait a little bit, so X has some time to start up (needed?)"
- name: "wait a little, so X has some time to start up"
wait_for:
timeout: 3
@ -114,9 +158,9 @@
enabled: false
masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
#- name: "wait a little bit, so X has some time to shut down (needed?)"
# wait_for:
# timeout: 3
- name: save results
block: