Commit a2f74b1d authored by TotallyNotElite's avatar TotallyNotElite

Add nvidia power management

parent a788649e
......@@ -31,10 +31,32 @@ DEPENDS_64="lib32-nvidia-435xx-utils"
DEPKMOD="nvidia-435xx"
XORGFILE="/etc/X11/mhwd.d/nvidia.conf"
UDEVFILE="/lib/udev/rules.d/90-mhwd-prime-powermanagement.rules"
MHWDGPU_BLCKLSTNVIDIA="/etc/modprobe.d/mhwd-gpu.conf"
MHWDGPU_MODLDNVIDIA="/etc/modules-load.d/mhwd-gpu.conf"
_setup_nvidia_powermanagememnt()
{
cat <<EOF > "${UDEVFILE}"
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"
# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"
EOF
echo 'options nvidia "NVreg_DynamicPowerManagement=0x02"' > "${MHWDGPU_BLCKLSTNVIDIA}"
}
post_install()
{
......@@ -43,6 +65,8 @@ post_install()
mhwd-gpu --setmod nvidia --setxorg "${XORGFILE}"
_setup_nvidia_powermanagememnt
# Without this 'glxgears' doesn't work in live-session
MODULES_LOAD="/etc/modules-load.d"
echo "nvidia-drm" >> "${MODULES_LOAD}/mhwd-gpu.conf"
......@@ -55,15 +79,15 @@ post_install()
post_remove()
{
if [ -e "${XORGFILE}" ]; then
rm "${XORGFILE}"
fi
rm -f "${XORGFILE}"
rm -f "${UDEVFILE}"
if [ -f "${MHWDGPU_BLCKLSTNVIDIA}" ]; then
sed -i '/^blacklist nouveau/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist ttm/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist drm_kms_helper/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist drm/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^options nvidia "NVreg_DynamicPowerManagement=0x02"/d' "${MHWDGPU_BLCKLSTNVIDIA}"
fi
if [ -f "${MHWDGPU_MODLDNVIDIA}" ]; then
......@@ -72,4 +96,3 @@ post_remove()
mhwd-gpu --check
}
......@@ -31,10 +31,32 @@ DEPENDS_64="lib32-nvidia-440xx-utils"
DEPKMOD="nvidia-440xx"
XORGFILE="/etc/X11/mhwd.d/nvidia.conf"
UDEVFILE="/etc/udev/rules.d/90-mhwd-prime-powermanagement.rules"
MHWDGPU_BLCKLSTNVIDIA="/etc/modprobe.d/mhwd-gpu.conf"
MHWDGPU_MODLDNVIDIA="/etc/modules-load.d/mhwd-gpu.conf"
_setup_nvidia_powermanagememnt()
{
cat <<EOF > "${UDEVFILE}"
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"
# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"
EOF
echo 'options nvidia "NVreg_DynamicPowerManagement=0x02"' >> "${MHWDGPU_BLCKLSTNVIDIA}"
}
post_install()
{
......@@ -43,6 +65,8 @@ post_install()
mhwd-gpu --setmod nvidia --setxorg "${XORGFILE}"
_setup_nvidia_powermanagememnt
# Without this 'glxgears' doesn't work in live-session
MODULES_LOAD="/etc/modules-load.d"
echo "nvidia-drm" >> "${MODULES_LOAD}/mhwd-gpu.conf"
......@@ -55,15 +79,15 @@ post_install()
post_remove()
{
if [ -e "${XORGFILE}" ]; then
rm "${XORGFILE}"
fi
rm -f "${XORGFILE}"
rm -f "${UDEVFILE}"
if [ -f "${MHWDGPU_BLCKLSTNVIDIA}" ]; then
sed -i '/^blacklist nouveau/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist ttm/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist drm_kms_helper/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^blacklist drm/d' "${MHWDGPU_BLCKLSTNVIDIA}"
sed -i '/^options nvidia "NVreg_DynamicPowerManagement=0x02"/d' "${MHWDGPU_BLCKLSTNVIDIA}"
fi
if [ -f "${MHWDGPU_MODLDNVIDIA}" ]; then
......@@ -72,4 +96,3 @@ post_remove()
mhwd-gpu --check
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment