forked from pub-solar/os
dumpyourvms: linux 6.4 amdgpu switcheroo fixes
This commit is contained in:
parent
c06c2c7fe9
commit
c06e6d4cd1
|
@ -36,9 +36,7 @@ in {
|
||||||
# Explicitly set amdgpu support in place of radeon
|
# Explicitly set amdgpu support in place of radeon
|
||||||
# Source: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/southern-islands/default.nix
|
# Source: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/southern-islands/default.nix
|
||||||
# Try again after https://lists.freedesktop.org/archives/amd-gfx/2023-March/090096.html lands
|
# Try again after https://lists.freedesktop.org/archives/amd-gfx/2023-March/090096.html lands
|
||||||
# Maybe linux kernel 6.3?
|
boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive" "radeon.si_support=0" "amdgpu.si_support=1"];
|
||||||
#boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive" "radeon.si_support=0" "amdgpu.si_support=1"];
|
|
||||||
boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive"];
|
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
# Fix for Error switching console mode to 1: unsupported on startup
|
# Fix for Error switching console mode to 1: unsupported on startup
|
||||||
|
@ -80,29 +78,22 @@ in {
|
||||||
# https://ubuntuforums.org/showthread.php?t=2409856
|
# https://ubuntuforums.org/showthread.php?t=2409856
|
||||||
services.cron.systemCronJobs = [
|
services.cron.systemCronJobs = [
|
||||||
"@reboot root ${pkgs.util-linux}/bin/rfkill block bluetooth"
|
"@reboot root ${pkgs.util-linux}/bin/rfkill block bluetooth"
|
||||||
"@reboot root ${pkgs.coreutils}/bin/sleep 11; ${pkgs.coreutils}/bin/echo 510 > /sys/class/backlight/gmux_backlight/brightness"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# Disable dedicated GPU, use integrated Intel GPU to save battery
|
# Disable dedicated GPU, use integrated Intel GPU to save battery
|
||||||
# https://github.com/NixOS/nixpkgs/pull/33915
|
# https://github.com/NixOS/nixpkgs/pull/33915
|
||||||
systemd.services."amd-hybrid-graphics" = {
|
systemd.services."amd-hybrid-graphics-power-save" = {
|
||||||
path = [pkgs.bash];
|
path = [pkgs.bash pkgs.coreutils];
|
||||||
description = "Disable AMD Card";
|
description = "Power Off dedicated AMD Card to reduce power usage";
|
||||||
after = ["sys-kernel-debug.mount"];
|
after = ["sys-kernel-debug.mount"];
|
||||||
before = ["systemd-vconsole-setup.service" "display-manager.service"];
|
before = ["systemd-vconsole-setup.service" "display-manager.service"];
|
||||||
requires = ["sys-kernel-debug.mount" "vgaswitcheroo.path"];
|
requires = ["sys-kernel-debug.mount"];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'";
|
ExecStart = "${pkgs.bash}/bin/sh -c 'sleep 8 && echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'";
|
||||||
ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
|
ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
systemd.paths."vgaswitcheroo" = {
|
|
||||||
pathConfig = {
|
|
||||||
PathExists = "/sys/kernel/debug/vgaswitcheroo/switch";
|
|
||||||
Unit = "amd-hybrid-graphics.service";
|
|
||||||
};
|
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,12 +116,20 @@ in {
|
||||||
# brcmfmac being loaded during hibernation would inhibit a successful resume
|
# brcmfmac being loaded during hibernation would inhibit a successful resume
|
||||||
# https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116.
|
# https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116.
|
||||||
# Also brcmfmac could randomly crash on resume from sleep.
|
# Also brcmfmac could randomly crash on resume from sleep.
|
||||||
|
# For hibernate successfully using the amdgpu driver, the dedicated GPU needs
|
||||||
|
# to be powered on.
|
||||||
powerUpCommands = lib.mkBefore ("${pkgs.kmod}/bin/modprobe brcmfmac"
|
powerUpCommands = lib.mkBefore ("${pkgs.kmod}/bin/modprobe brcmfmac"
|
||||||
+ lib.optionalString
|
+ lib.optionalString
|
||||||
(lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc");
|
(lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc");
|
||||||
powerDownCommands = lib.mkBefore ("${pkgs.kmod}/bin/rmmod brcmfmac"
|
powerDownCommands = lib.mkBefore (
|
||||||
+ lib.optionalString
|
lib.optionalString
|
||||||
(lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc");
|
(lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2")
|
||||||
|
"${pkgs.kmod}/bin/rmmod brcmfmac_wcc\n"
|
||||||
|
+ ''
|
||||||
|
${pkgs.kmod}/bin/rmmod brcmfmac
|
||||||
|
${pkgs.systemd}/bin/systemctl stop amd-hybrid-graphics-power-save.service
|
||||||
|
''
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Change lid switch behaviour
|
# Change lid switch behaviour
|
||||||
|
@ -175,6 +174,9 @@ in {
|
||||||
hardware.firmware = with pkgs; [wireless-regdb];
|
hardware.firmware = with pkgs; [wireless-regdb];
|
||||||
boot.extraModprobeConfig = ''
|
boot.extraModprobeConfig = ''
|
||||||
options cfg80211 ieee80211_regdom="DE"
|
options cfg80211 ieee80211_regdom="DE"
|
||||||
|
|
||||||
|
# Enable the integrated GPU (iGPU) Intel i915 by default if present
|
||||||
|
options apple-gmux force_igd=y
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# This value determines the NixOS release from which the default
|
# This value determines the NixOS release from which the default
|
||||||
|
|
Loading…
Reference in a new issue