When running powertop
on Linux systems, you might encounter warnings like:
Bad: Runtime PM for PCI Device [8086:15d4] (Network controller: Intel Corporation Wireless-AC 9560)
Bad: Runtime PM for PCI Device [8086:9d21] (PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port)
These indicate that Runtime Power Management isn't properly enabled for certain PCI devices, leading to unnecessary power consumption.
As developers working on laptops or embedded systems:
- Reduced battery life affects productivity during coding sessions
- Thermal throttling can impact compilation performance
- Proper power management is crucial for IoT/embedded development
While powertop --auto-tune
can temporarily fix these issues, it doesn't persist across reboots. Here's what it actually does behind the scenes:
# Example of what powertop executes
echo 'auto' > /sys/bus/pci/devices/0000:00:1f.3/power/control
echo 'auto' > /sys/bus/pci/devices/0000:00:14.0/power/control
For a persistent fix, consider these approaches:
1. Using udev Rules
# Create a new udev rule file
sudo nano /etc/udev/rules.d/90-pci-pm.rules
# Add these lines (replace device IDs with yours)
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x15d4", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x9d21", ATTR{power/control}="auto"
2. Kernel Parameters
# Edit your grub configuration
sudo nano /etc/default/grub
# Add these parameters to GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pcie_aspm=force i915.enable_rc6=1 i915.enable_fbc=1"
After implementing changes, verify with:
# Check current power states
find /sys/devices -name power -type d | while read dir; do
echo "$dir: $(cat $dir/control)";
done | grep pci
# Alternative method using lspci
lspci -vv | grep -A5 LnkCtl
Some devices may resist power management:
- Check kernel messages with
dmesg | grep -i pci
- Some USB controllers (xhci_hcd) may block PCIe ASPM
- Try blacklisting problematic drivers temporarily
For developers needing fine control:
#!/bin/bash
# Script to toggle power management based on AC state
if [[ $(cat /sys/class/power_supply/AC/online) -eq 1 ]]; then
# On AC power - disable some power saving
echo "performance" > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
else
# On battery - enable aggressive power saving
echo "powersave" > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
for dev in /sys/bus/pci/devices/*; do
if [[ -f "$dev/power/control" ]]; then
echo "auto" > "$dev/power/control"
fi
done
fi
When working with Linux power optimization tools like powertop
, you might encounter warnings about "Bad Runtime PM for PCI Device." This indicates that the Runtime Power Management (RPM) feature isn't properly enabled for certain PCI devices in your system.
Properly configured Runtime PM can significantly reduce power consumption, especially important for:
- Laptop developers optimizing battery life
- Embedded systems engineers
- Cloud infrastructure maintainers
Here are several approaches to resolve this issue:
1. Manual Runtime PM Configuration
You can manually enable Runtime PM through sysfs:
# Identify your PCI device
lspci | grep -i "your_device_name"
# Enable Runtime PM (replace X:Y.Z with your device address)
echo auto > /sys/bus/pci/devices/0000:X:Y.Z/power/control
2. Persistent Configuration via udev
Create a udev rule to make the change persistent across reboots:
# /etc/udev/rules.d/85-pci-pm.rules
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x1234", ATTR{power/control}="auto"
3. Kernel Module Parameters
Some drivers support module parameters to control Runtime PM:
# Check available parameters for your driver
modinfo your_driver_module | grep pm
# Example for Intel WiFi
options iwlwifi power_save=1
If Runtime PM doesn't work as expected:
- Check kernel messages:
dmesg | grep -i pci
- Verify driver support:
lsmod | grep your_driver
- Test different power states:
cat /sys/bus/pci/devices/0000:X:Y.Z/power/state
Here's a complete example for an Intel WiFi card:
# Identify the device
lspci | grep -i wireless
# Output: 00:14.3 Network controller: Intel Corporation Wireless-AC 9560
# Check current power state
cat /sys/bus/pci/devices/0000:00:14.3/power/control
# If output is "on", proceed to enable
# Temporarily enable
echo auto > /sys/bus/pci/devices/0000:00:14.3/power/control
# Make permanent
echo 'ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0xa370", ATTR{power/control}="auto"' | sudo tee /etc/udev/rules.d/85-iwlwifi-pm.rules
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
After making changes, verify the impact with:
# Check current power state
cat /sys/bus/pci/devices/0000:X:Y.Z/power/runtime_status
# Monitor power usage
sudo powertop --html=power_report.html
For deeper troubleshooting, boot with these kernel parameters:
pcie_aspm=force pcie_aspm.policy=powersave
pci=noaer pcie_port_pm=on
Note: These may affect system stability - test thoroughly.