From df3f1c4375afcd9f788f6e9ac06708270167eda1 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Fri, 20 Oct 2023 15:50:54 -0700 Subject: [PATCH] chore: Cleanup bazzite-hardware-setup, make more use of initramfs chore: Use lower numbers for sysctl.d --- Containerfile | 6 +- .../usr/etc/modprobe.d/deck-blacklist.conf | 5 + .../{00-kernel.conf => 60-kernel.conf} | 0 .../{10-memory.conf => 65-memory.conf} | 0 .../shared/usr/bin/bazzite-flatpak-manager | 2 +- .../shared/usr/bin/bazzite-hardware-setup | 130 +++++++----------- .../desktop/shared/usr/bin/bazzite-user-setup | 2 +- .../shared/usr/etc/modprobe.d/amdgpu.conf | 5 + .../shared/usr/etc/modprobe.d/nvidia.conf | 6 + .../{100-kernel.conf => 60-kernel.conf} | 0 .../{110-memory.conf => 65-memory.conf} | 0 .../{120-gaming.conf => 70-gaming.conf} | 0 ...130-networking.conf => 75-networking.conf} | 0 .../{140-inotify.conf => 80-inotify.conf} | 0 14 files changed, 70 insertions(+), 86 deletions(-) create mode 100644 system_files/deck/shared/usr/etc/modprobe.d/deck-blacklist.conf rename system_files/deck/shared/usr/lib/sysctl.d/{00-kernel.conf => 60-kernel.conf} (100%) rename system_files/deck/shared/usr/lib/sysctl.d/{10-memory.conf => 65-memory.conf} (100%) create mode 100644 system_files/desktop/shared/usr/etc/modprobe.d/amdgpu.conf create mode 100644 system_files/desktop/shared/usr/etc/modprobe.d/nvidia.conf rename system_files/desktop/shared/usr/lib/sysctl.d/{100-kernel.conf => 60-kernel.conf} (100%) rename system_files/desktop/shared/usr/lib/sysctl.d/{110-memory.conf => 65-memory.conf} (100%) rename system_files/desktop/shared/usr/lib/sysctl.d/{120-gaming.conf => 70-gaming.conf} (100%) rename system_files/desktop/shared/usr/lib/sysctl.d/{130-networking.conf => 75-networking.conf} (100%) rename system_files/desktop/shared/usr/lib/sysctl.d/{140-inotify.conf => 80-inotify.conf} (100%) diff --git a/Containerfile b/Containerfile index 39d5538d..4a5e240d 100644 --- a/Containerfile +++ b/Containerfile @@ -202,13 +202,15 @@ RUN if grep -qv "nvidia" <<< "${IMAGE_NAME}"; then \ rocm-clinfo \ waydroid \ weston && \ - sed -i~ -E 's/=.\$\(command -v (nft|ip6?tables-legacy).*/=/g' /usr/lib/waydroid/data/scripts/waydroid-net.sh \ + sed -i~ -E 's/=.\$\(command -v (nft|ip6?tables-legacy).*/=/g' /usr/lib/waydroid/data/scripts/waydroid-net.sh && \ + rm -f /usr/etc/modprobe.d/nvidia.conf \ ; else \ + rm -f /usr/etc/modprobe.d/amdgpu.conf && \ if [[ "${FEDORA_MAJOR_VERSION}" -lt "39" ]]; then \ rpm-ostree install \ mesa-libGL.i686 \ mesa-libEGL.i686 \ - ;fi && \ + ; fi && \ rpm-ostree install \ vulkan-loader.i686 \ alsa-lib.i686 \ diff --git a/system_files/deck/shared/usr/etc/modprobe.d/deck-blacklist.conf b/system_files/deck/shared/usr/etc/modprobe.d/deck-blacklist.conf new file mode 100644 index 00000000..5579193b --- /dev/null +++ b/system_files/deck/shared/usr/etc/modprobe.d/deck-blacklist.conf @@ -0,0 +1,5 @@ +# Blacklist the Intel TCO Watchdog/Timer module +blacklist iTCO_wdt + +# Blacklist the AMD SP5100 TCO Watchdog/Timer module (Required for Ryzen CPUs) +blacklist sp5100_tco diff --git a/system_files/deck/shared/usr/lib/sysctl.d/00-kernel.conf b/system_files/deck/shared/usr/lib/sysctl.d/60-kernel.conf similarity index 100% rename from system_files/deck/shared/usr/lib/sysctl.d/00-kernel.conf rename to system_files/deck/shared/usr/lib/sysctl.d/60-kernel.conf diff --git a/system_files/deck/shared/usr/lib/sysctl.d/10-memory.conf b/system_files/deck/shared/usr/lib/sysctl.d/65-memory.conf similarity index 100% rename from system_files/deck/shared/usr/lib/sysctl.d/10-memory.conf rename to system_files/deck/shared/usr/lib/sysctl.d/65-memory.conf diff --git a/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager b/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager index 7a62c484..490c7daa 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager +++ b/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Script Version -VER=4 +VER=5 VER_FILE="/etc/bazzite/flatpak_manager_version" VER_RAN=$(cat $VER_FILE) diff --git a/system_files/desktop/shared/usr/bin/bazzite-hardware-setup b/system_files/desktop/shared/usr/bin/bazzite-hardware-setup index d7c4d30a..fd761e1b 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-hardware-setup +++ b/system_files/desktop/shared/usr/bin/bazzite-hardware-setup @@ -7,7 +7,7 @@ BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO) FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO) # SCRIPT VERSION -HWS_VER=9 +HWS_VER=11 HWS_VER_FILE="/etc/bazzite/hws_version" HWS_VER_RAN=$(cat $HWS_VER_FILE) @@ -19,14 +19,57 @@ KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE) KNOWN_FEDORA_VERSION_FILE="/etc/bazzite/fedora_version" KNOWN_FEDORA_VERSION=$(cat $KNOWN_FEDORA_VERSION_FILE) +# RUN REMAINDER OF SCRIPT ONLY IF UPDATED +if [[ -f $HWS_VER_FILE && $HWS_VER = $HWS_VER_RAN ]]; then + if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then + if [[ -f $KNOWN_FEDORA_VERSION_FILE && -f $KNOWN_FEDORA_VERSION_FILE ]]; then + # Run script if image has been rebased + if [[ $IMAGE_NAME = $KNOWN_IMAGE_NAME && $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR && $FEDORA_VERSION = $KNOWN_FEDORA_VERSION ]]; then + echo "Hardware setup has already run. Exiting..." + exit 0 + fi + fi + fi +fi + # GLOBAL SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" GPU_ID=$(lspci -k | grep -A 3 -E "(VGA|3D)") KARGS=$(rpm-ostree kargs) -INITRAMFS=$(rpm-ostree initramfs) NEEDED_KARGS="" echo "Current kargs: $KARGS" -mkdir -p /etc/bazzite +INITRAMFS=$(rpm-ostree initramfs) +NEEDED_INITRAMFS="" +echo "Current initramfs: $INITRAMFS" + +# INITRAMFS +if [[ ! $INITRAMFS =~ "/etc/crypttab" ]]; then + NEEDED_INITRAMFS="$NEEDED_INITRAMFS --arg=/etc/crypttab" +fi + +if [[ $IMAGE_FLAVOR =~ "nvidia" ]]; then + if [[ ! $INITRAMFS =~ "/etc/modprobe.d/nvidia.conf" ]]; then + NEEDED_INITRAMFS="$NEEDED_INITRAMFS --arg=/etc/modprobe.d/nvidia.conf" + fi +else + if [[ ! $INITRAMFS =~ "/etc/modprobe.d/amdgpu.conf" ]]; then + NEEDED_INITRAMFS="$NEEDED_INITRAMFS --arg=/etc/modprobe.d/amdgpu.conf" + fi +fi + +if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then + if [[ ! $INITRAMFS =~ "/etc/modprobe.d/deck-blacklist.conf" ]]; then + NEEDED_INITRAMFS="$NEEDED_INITRAMFS --arg=/etc/modprobe.d/deck-blacklist.conf" + fi +fi + +if [[ -n "$NEEDED_INITRAMFS" ]]; then + echo "Found needed initramfs changes, applying the following: $NEEDED_INITRAMFS" + plymouth display-message --text="Updating initramfs - Please wait, this may take a while" || true + rpm-ostree initramfs --enable --arg=-I ${NEEDED_INITRAMFS} +else + echo "No initramfs changes needed" +fi # KERNEL ARGUMENTS if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then @@ -44,73 +87,14 @@ if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then if [[ "$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo)" == "31664740" ]]; then echo "32GB RAM Steam Deck detected" NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.gttsize=16256" - sed -i 's/zram-size=1024/zram-size=2048/g' /etc/systemd/zram-generator.conf - else NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.gttsize=8128" fi fi - - if [[ ! $KARGS =~ "spi_amd.speed_dev" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=spi_amd.speed_dev=1" - fi - + if [[ ! $KARGS =~ "initcall_blacklist" ]]; then NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=initcall_blacklist=simpledrm_platform_driver_init" fi - - if [[ ! $KARGS =~ "modprobe.blacklist=sp5100_tco" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=modprobe.blacklist=sp5100_tco" - fi -fi - -if grep -qz "Kernel driver in use: radeon" <<< $GPU_ID; then - echo "Legacy AMD hardware detected, enabling CIK and SI support in AMDGPU" - if [[ ! $KARGS =~ "radeon.si_support" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=radeon.si_support=0" - fi - - if [[ ! $KARGS =~ "radeon.cik_support" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=radeon.cik_support=0" - fi - - if [[ ! $KARGS =~ "amdgpu.si_support" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.si_support=1" - fi - - if [[ ! $KARGS =~ "amdgpu.cik_support" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.cik_support=1" - fi -fi - -if [[ $IMAGE_FLAVOR =~ "nvidia" ]]; then - echo "Checking for needed karg changes (Nvidia)" - - if [[ ! $KARGS =~ "rd.driver.blacklist=nouveau" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=rd.driver.blacklist=nouveau" - fi - - if [[ ! $KARGS =~ "modprobe.blacklist=nouveau" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=modprobe.blacklist=nouveau" - fi - - if [[ ! $KARGS =~ "nvidia-drm.modeset" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=nvidia-drm.modeset=1" - fi -else - echo "Checking for needed karg changes" - - if [[ $KARGS =~ "rd.driver.blacklist=nouveau" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=rd.driver.blacklist=nouveau" - fi - - if [[ $KARGS =~ "modprobe.blacklist=nouveau" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=modprobe.blacklist=nouveau" - fi - - if [[ $KARGS =~ "nvidia-drm.modeset" ]]; then - NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=nvidia-drm.modeset=1" - fi fi if [[ $KARGS =~ "nomodeset" ]]; then @@ -118,12 +102,6 @@ if [[ $KARGS =~ "nomodeset" ]]; then NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=nomodeset" fi -if [[ $INITRAMFS =~ "disabled" ]]; then - echo "Found needed initramfs changes, applying." - plymouth display-message --text="Updating initramfs - Please wait, this may take a while" || true - rpm-ostree initramfs --enable --arg=-I --arg=/etc/crypttab -fi - if [[ -n "$NEEDED_KARGS" ]]; then echo "Found needed karg changes, applying the following: $NEEDED_KARGS" plymouth display-message --text="Updating kargs - Please wait, this may take a while" || true @@ -132,19 +110,6 @@ else echo "No karg changes needed" fi -# RUN REMAINDER OF SCRIPT ONLY IF UPDATED -if [[ -f $HWS_VER_FILE && $HWS_VER = $HWS_VER_RAN ]]; then - if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then - if [[ -f $KNOWN_FEDORA_VERSION_FILE && -f $KNOWN_FEDORA_VERSION_FILE ]]; then - # Run script if image has been rebased - if [[ $IMAGE_NAME = $KNOWN_IMAGE_NAME && $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR && $FEDORA_VERSION = $KNOWN_FEDORA_VERSION ]]; then - echo "Hardware setup has already run. Exiting..." - exit 0 - fi - fi - fi -fi - if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then # Future updates to Deck on Jupiter here @@ -187,6 +152,7 @@ if (( $(hostname | wc -m) > 16 )); then hostnamectl set-hostname bazzite fi +mkdir -p /etc/bazzite echo $HWS_VER > $HWS_VER_FILE echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE echo $IMAGE_FLAVOR > $KNOWN_IMAGE_FLAVOR_FILE diff --git a/system_files/desktop/shared/usr/bin/bazzite-user-setup b/system_files/desktop/shared/usr/bin/bazzite-user-setup index e04f53c7..7b041be7 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-user-setup +++ b/system_files/desktop/shared/usr/bin/bazzite-user-setup @@ -7,7 +7,7 @@ FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO) SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" # SCRIPT VERSION -USER_SETUP_VER=9 +USER_SETUP_VER=10 USER_SETUP_VER_FILE="$HOME/.bazzite-configured" USER_SETUP_VER_RAN=$(cat $USER_SETUP_VER_FILE) USER_SETUP_FEDORA_VER_FILE="$HOME/.bazzite-configured-fedora-version" diff --git a/system_files/desktop/shared/usr/etc/modprobe.d/amdgpu.conf b/system_files/desktop/shared/usr/etc/modprobe.d/amdgpu.conf new file mode 100644 index 00000000..1350ddca --- /dev/null +++ b/system_files/desktop/shared/usr/etc/modprobe.d/amdgpu.conf @@ -0,0 +1,5 @@ +# Use Vulkan driver for AMD GCN 1.0 & GCN 2.0 GPUs (HD 7000-8000 series) +options amdgpu si_support=1 +options amdgpu cik_support=1 +options radeon si_support=0 +options radeon cik_support=0 diff --git a/system_files/desktop/shared/usr/etc/modprobe.d/nvidia.conf b/system_files/desktop/shared/usr/etc/modprobe.d/nvidia.conf new file mode 100644 index 00000000..2335d81a --- /dev/null +++ b/system_files/desktop/shared/usr/etc/modprobe.d/nvidia.conf @@ -0,0 +1,6 @@ +# Blacklist Nouveau +blacklist nouveau +options nouveau modeset=0 + +# Enable Nvidia Modeset +options nvidia-drm modeset=1 diff --git a/system_files/desktop/shared/usr/lib/sysctl.d/100-kernel.conf b/system_files/desktop/shared/usr/lib/sysctl.d/60-kernel.conf similarity index 100% rename from system_files/desktop/shared/usr/lib/sysctl.d/100-kernel.conf rename to system_files/desktop/shared/usr/lib/sysctl.d/60-kernel.conf diff --git a/system_files/desktop/shared/usr/lib/sysctl.d/110-memory.conf b/system_files/desktop/shared/usr/lib/sysctl.d/65-memory.conf similarity index 100% rename from system_files/desktop/shared/usr/lib/sysctl.d/110-memory.conf rename to system_files/desktop/shared/usr/lib/sysctl.d/65-memory.conf diff --git a/system_files/desktop/shared/usr/lib/sysctl.d/120-gaming.conf b/system_files/desktop/shared/usr/lib/sysctl.d/70-gaming.conf similarity index 100% rename from system_files/desktop/shared/usr/lib/sysctl.d/120-gaming.conf rename to system_files/desktop/shared/usr/lib/sysctl.d/70-gaming.conf diff --git a/system_files/desktop/shared/usr/lib/sysctl.d/130-networking.conf b/system_files/desktop/shared/usr/lib/sysctl.d/75-networking.conf similarity index 100% rename from system_files/desktop/shared/usr/lib/sysctl.d/130-networking.conf rename to system_files/desktop/shared/usr/lib/sysctl.d/75-networking.conf diff --git a/system_files/desktop/shared/usr/lib/sysctl.d/140-inotify.conf b/system_files/desktop/shared/usr/lib/sysctl.d/80-inotify.conf similarity index 100% rename from system_files/desktop/shared/usr/lib/sysctl.d/140-inotify.conf rename to system_files/desktop/shared/usr/lib/sysctl.d/80-inotify.conf