diff --git a/machines/home/default.nix b/machines/home/default.nix index f89728b..c60253a 100644 --- a/machines/home/default.nix +++ b/machines/home/default.nix @@ -4,6 +4,7 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./patches.nix ../modules/common.nix ../modules/sound.nix ../modules/window_manager.nix diff --git a/machines/home/patches.nix b/machines/home/patches.nix new file mode 100644 index 0000000..b60eac2 --- /dev/null +++ b/machines/home/patches.nix @@ -0,0 +1,20 @@ +{ + # Fix black screen after resuming from suspend + # Source: https://discourse.nixos.org/t/black-screen-when-resuming-from-suspend/10299 + # + # Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2223 + # Fixed in 6.1-rc4 + specialisation."amdgpu-patch-2223" = { + inheritParentConfig = true; + configuration = { + boot.loader.grub.configurationName = "amdgpu-patch-2223"; + #boot.kernelPackages = pkgs.linuxPackages_6_0; + boot.kernelPatches = [ + { + name = "amdgpu-patch"; + patch = ./patches/fail_suspend.patch; + } + ]; + }; + }; +} diff --git a/machines/home/patches/fail_suspend.patch b/machines/home/patches/fail_suspend.patch new file mode 100644 index 0000000..68e7a99 --- /dev/null +++ b/machines/home/patches/fail_suspend.patch @@ -0,0 +1,37 @@ +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index fb9b9349215b8..12c69b7ee54df 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -4047,15 +4047,17 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) + * at suspend time. + * + */ +-static void amdgpu_device_evict_resources(struct amdgpu_device *adev) ++static int amdgpu_device_evict_resources(struct amdgpu_device *adev) + { ++ int ret; + /* No need to evict vram on APUs for suspend to ram or s2idle */ + if ((adev->in_s3 || adev->in_s0ix) && (adev->flags & AMD_IS_APU)) +- return; ++ return 0; + +- if (amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM)) ++ ret = amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM); ++ if (ret) + DRM_WARN("evicting device resources failed\n"); +- ++ return ret; + } + + /* +@@ -4105,7 +4107,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) + if (!adev->in_s0ix) + amdgpu_amdkfd_suspend(adev, adev->in_runpm); + +- amdgpu_device_evict_resources(adev); ++ r = amdgpu_device_evict_resources(adev); ++ if (r) ++ return r; + + amdgpu_fence_driver_hw_fini(adev); +