udev: Skip audio power_save override for AMD HDA controllers (#204)#206
udev: Skip audio power_save override for AMD HDA controllers (#204)#206
Conversation
On AMD Strix/Krackan laptops, the audio controller shares a PCI bus with the GPU. Forcing power_save=0 keeps the codec in D0 state, causing audible electrical interference/buzzing during GPU and NVMe activity. Restrict the power_save=0 override to Intel HDA controllers (vendor 0x8086), which are the hardware affected by the audio popping that this rule was designed to prevent. AMD HDA controllers now keep their default power_save behavior, allowing them to suspend when idle and eliminating the EMI noise. Also guard the AC/battery power_supply rules on the flag file existence so they only fire on systems where the boot rule actually applied. Closes #204 Signed-off-by: Peter Jung <admin@ptr1337.dev>
There was a problem hiding this comment.
Pull request overview
Updates the snd_hda_intel udev power-management behavior to avoid forcing power_save=0 on AMD HDA controllers (reported to cause EMI/buzzing on Strix/Krackan-class systems), while keeping the original “prevent popping” behavior targeted at Intel HDA hardware.
Changes:
- Restrict the
power_save=0override to Intel HDA controllers viaATTRS{vendor}=="0x8086". - Gate AC/battery
power_supplyhandlers on the presence of the/run/udev/snd-hda-intel-powersavestate file so they only run on systems where the boot-time rule matched.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| RUN+="/usr/bin/bash -c 'touch /run/udev/snd-hda-intel-powersave; \ | ||
| [[ $$(cat /sys/class/power_supply/BAT0/status 2>/dev/null) != \"Discharging\" ]] && \ | ||
| echo $$(cat /sys/module/snd_hda_intel/parameters/power_save) > /run/udev/snd-hda-intel-powersave && \ |
There was a problem hiding this comment.
The RUN script always touches /run/udev/snd-hda-intel-powersave before the battery check. If the system is already discharging at boot, this leaves the file empty (no saved value), which can later be treated as a valid value by the AC/battery handlers. Consider only creating the file when you also write the saved parameter value (or always write the current power_save into it regardless of charging state).
| RUN+="/usr/bin/bash -c 'touch /run/udev/snd-hda-intel-powersave; \ | |
| [[ $$(cat /sys/class/power_supply/BAT0/status 2>/dev/null) != \"Discharging\" ]] && \ | |
| echo $$(cat /sys/module/snd_hda_intel/parameters/power_save) > /run/udev/snd-hda-intel-powersave && \ | |
| RUN+="/usr/bin/bash -c 'echo $$(cat /sys/module/snd_hda_intel/parameters/power_save) > /run/udev/snd-hda-intel-powersave; \ | |
| [[ $$(cat /sys/class/power_supply/BAT0/status 2>/dev/null) != \"Discharging\" ]] && \ |
| RUN+="/usr/bin/bash -c 'echo $$(cat /run/udev/snd-hda-intel-powersave 2>/dev/null || \ | ||
| echo 10) > /sys/module/snd_hda_intel/parameters/power_save'" |
There was a problem hiding this comment.
cat /run/udev/snd-hda-intel-powersave 2>/dev/null || echo 10 does not fall back when the file exists but is empty (because cat still exits 0). With an empty saved-value file, this expands to an empty string and can attempt to write an invalid value to /sys/module/snd_hda_intel/parameters/power_save. Handle the empty-file case explicitly (e.g., validate the value is non-empty/numeric before writing, otherwise use a default).
| RUN+="/usr/bin/bash -c 'echo $$(cat /run/udev/snd-hda-intel-powersave 2>/dev/null || \ | |
| echo 10) > /sys/module/snd_hda_intel/parameters/power_save'" | |
| RUN+="/usr/bin/bash -c 'val=$$(cat /run/udev/snd-hda-intel-powersave 2>/dev/null); \ | |
| case $$val in (""|*[!0-9]*) val=10 ;; esac; \ | |
| echo $$val > /sys/module/snd_hda_intel/parameters/power_save'" |
On AMD Strix/Krackan laptops, the audio controller shares a PCI bus with the GPU. Forcing power_save=0 keeps the codec in D0 state, causing audible electrical interference/buzzing during GPU and NVMe activity.
Restrict the power_save=0 override to Intel HDA controllers (vendor 0x8086), which are the hardware affected by the audio popping that this rule was designed to prevent. AMD HDA controllers now keep their default power_save behavior, allowing them to suspend when idle and eliminating the EMI noise.
Also guard the AC/battery power_supply rules on the flag file existence so they only fire on systems where the boot rule actually applied.
Closes #204