From ac55d0909c291cbcb9c1ceaf8b0407846d7c420c Mon Sep 17 00:00:00 2001
From: Benjamin Sherman <benjamin@holyarmy.org>
Date: Mon, 28 Oct 2024 18:59:21 -0500
Subject: [PATCH] fix: nvidia fixes (#292)

* fix: chromium browser use of hw accel on hybrid laptops

Fixes: #285

* fix path

* fix: use default nvidia driver power management

This fixes power management on optimus laptops, specifically for Ampere+
where the specified config was preventing D3cold state.

Upstream negativo17 should be notified of this change, too.

Fix: #290
---
 nvidia-install.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nvidia-install.sh b/nvidia-install.sh
index 0530836..3b1e6c2 100755
--- a/nvidia-install.sh
+++ b/nvidia-install.sh
@@ -60,7 +60,13 @@ semodule --verbose --install /usr/share/selinux/packages/nvidia-container.pp
 # Universal Blue specific Initramfs fixes
 echo "options nvidia NVreg_TemporaryFilePath=/var/tmp" >> /usr/lib/modprobe.d/nvidia-atomic.conf
 cp /etc/modprobe.d/nvidia-modeset.conf /usr/lib/modprobe.d/nvidia-modeset.conf
+# we must force driver load to fix black screen on boot for nvidia desktops
 sed -i 's@omit_drivers@force_drivers@g' /usr/lib/dracut/dracut.conf.d/99-nvidia.conf
+# as we need forced load, also mustpre-load intel/amd iGPU else chromium web browsers fail to use hardware acceleration
+sed -i 's@ nvidia @ i915 amdgpu nvidia @g' /usr/lib/dracut/dracut.conf.d/99-nvidia.conf
+
+# delete forced power managemant to instead allow driver default (fixes ampere+ optimus D3cold state)
+sed '/^.*NVreg_DynamicPowerManagement.*/d' /usr/lib/modprobe.d/nvidia.conf
 
 if [[ "${IMAGE_NAME}" == "sericea" ]]; then
     mv /etc/sway/environment{,.orig}