#!/bin/bash
set -euo pipefail
KVER=$(uname -r)
MODPATH="/lib/modules/$KVER/kernel/drivers/gpu/drm/amd/amdgpu"
echo "Kernel: $KVER"
echo "Module path: $MODPATH"
echo "--- Backup existing module ---"
sudo cp "$MODPATH/amdgpu.ko.zst" "$MODPATH/amdgpu.ko.zst.bak_2230"
echo "--- Install patched module (2500 MHz max) ---"
sudo cp /tmp/amdgpu_patched.ko.zst "$MODPATH/amdgpu.ko.zst"
echo "--- Verify ---"
ls -lh "$MODPATH/amdgpu.ko.zst" "$MODPATH/amdgpu.ko.zst.bak_2230"
echo "--- Running depmod ---"
sudo depmod -a
echo "--- Rebuilding initramfs ---"
sudo mkinitcpio -P
echo "DONE. Reboot required to load new module."