Background
About a year ago, I used powertop to optimise my laptop's power consuption (following this and this guide), ending up with this systemd service:
[Unit]
Description=Powertop tunings for X1 Carbon 5th
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';"
ExecStart=/bin/sh -c "echo '1' > '/sys/module/snd_hda_intel/parameters/power_save';"
ExecStart=/bin/sh -c "echo '0' > '/proc/sys/kernel/nmi_watchdog';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/i2c/devices/i2c-0/device/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/i2c/devices/i2c-2/device/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/usb/devices/1-9/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/i2c/devices/i2c-1/device/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control';"
ExecStart=/bin/sh -c "echo 'auto' > '/sys/bus/pci/devices/0000:00:08.0/power/control';"
# ... omitted some more PCI devices ...
[Install]
WantedBy=multi-user.target
Problem analysis
This worked fine and brought my laptop's idle power consumption down - until a few months ago when I got a Yubikey 5C nano.
Now however, my laptop's idle power consumption rose from previous 5-5.5W to now 5.8-6.2W (without Yubikey Nano plugged versus plugged in. Readings observed on a idle system with no open programs over 5ish minutes.)
It's not the Yubikey that's consuming this extra watt, otherwise it would likely be on fire. Instead it's probably caused by the USB controllers not going to sleep as they should.
When I run powertop
I get the following in the Tuning tab:
| Description | Script |
| ----------- | ------ |
| Autosuspend for USB device YubiKey OTP+FIDO+CCID [Yubico] | echo 'auto' > '/sys/bus/usb/devices/3-2/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 USB Controller (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:3c:00.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:07:04.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:07:01.0/power/control'; |
However, if I remove the Yubikey, insert it again, and run powertop --html=reportB.html
again I get the following in the Tuning tab:
| Description | Script |
| ----------- | ------ |
| Autosuspend for USB device YubiKey OTP+FIDO+CCID [Yubico] | echo 'auto' > '/sys/bus/usb/devices/3-2/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 USB Controller (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:3c:00.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:07:02.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:06:00.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:07:04.0/power/control'; |
| Runtime PM for PCI Device Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] | echo 'auto' > '/sys/bus/pci/devices/0000:07:01.0/power/control'; |
Question
This leads me to a series of question:
- Am I right in understanding that every time you plug in a USB device - even if it's been plugged in before - it will be assigned a new PCI identifier?
- Is it wise to add these tuning commands to my systemd service?
- What are the possible side effects?
- What about only the
Autosuspend for USB device YubiKey
?
- Would it be wise to add all commands given the constraint that I will never actually remove the Yubikey from its USB port? (*)
- What would then be the implications if in some odd circumstance I were to remove it anyway?
Thanks a lot!
(*) That is the whole point of having the Nano, being too lazy to always use the big Yubikey.