[TRACKING] Linux battery life tuning

@Jason_Hottelet This is a very late reply to your question about unbinding USB drivers, but in case you are still interested, these steps may allow you to bind/unbind USB drivers. I have found that my computer will lock up when TLP is running if I run these commands, but I have found that the improvement in battery life that comes when the USB cards are unbound results in longer battery life than I can get by running TLP. By running auto-cpufreq and unbinding the driver for the usb expansion cards, I can get around 6 hours of battery life with maximum charge set at 85%. I have a number of silly Gnome eye candy extensions installed. But even with several open terminals running, multiple Firefox windows, the Teams app running, I’m getting 5-6 hours. I’m sure that someone using a lower resource demanding desktop than Gnome should get longer battery life. So here are the commands I use.

First of all, you will need to find the correct PCI device identifier of the bus. This page provides an excellent description of how to do this.

The following command run as root should return the PCI device identifier for USB devices on your Framework laptop.

find /sys/devices -name "*usb*" | cut -d\/ -f5 | sort | uniq | sort | grep 0000

Here is the output I get for my laptop.

0000:00:0d.0
0000:00:14.0

Now to unbind your USB cards, you just run this command for each identified device. For example.

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind

The above two commands add the device id to the unbind file in /sys/bus/pci/drivers/xhci_hcd. The module, xhci_hcd, is the driver for USB devices. Note that once a device id has been added to the unbind file, you will no longer see anything with that id in /sys/devices. With my laptop, once these devices have been added to unbind, bluetooth and fingerprint recognition are disabled. Hdmi and wifi still work, though. To rebind the USB cards, you would simply run these commands.

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

Your USB devices should work again, including bluetooth. Once you have identified the correct device id, it’s simple to turn the appropriate commands into a bash script. So for a script named disable_usb.sh, you would simply do this.

#!/bin/bash

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind

Then do “chmod +x”. If you place the script in /usr/local/bin, you should be able to run this script by doing disable_usb.sh as root or with sudo.

To rebind the usb cards you could create a similar script named enable_usb.sh.

#!/bin/bash

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

Since you need to know what the bus IDs are for your usb devices on your machine, I can’t think of a simple way to make a script that can simply be run on any Framework computer. However, once you have identified the correct bus ids, it should be easy to modify the above scripts. I have found it much easier to simply run these scripts than manually pulling out my USB cards.

5 Likes