You are not logged in.

#1 2016-01-16 11:47:05

louic
Member
Registered: 2013-06-13
Posts: 15

powertop vs udev

As a follow-up of this topic (https://bbs.archlinux.org/viewtopic.php?id=201486) where I asked how to use powertop --auto-tune on everything except the USB mouse, I tried the following:

#  /etc/systemd/system/powertop.service

[Unit]
Description = Powertop Auto-Tune

[Service]
Type = oneshot
ExecStart = \
/usr/bin/powertop --auto-tune && \
echo 'on' > /sys/bus/usb/devices/1-1.2/power/control && \
echo 'on' > /sys/bus/usb/devices/usb1/power/control && \
echo 'on' > /sys/bus/usb/devices/usb2/power/control && \
echo 'on' > /sys/bus/usb/devices/usb3/power/control && \
echo 'on' > /sys/bus/usb/devices/usb4/power/control

[Install]
WantedBy = multi-user.target

Then of course: # systemctl enable powertop.service
This sets all the automatic powertop settings, but the "echo" commands do not disable my USB autosuspend.

So I thought to use UDEV to disable the USB mouse and keyboard autosuspend, and did this:

# /etc/udev/rules.d/90-usb-autosuspend.rules

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c52b", ATTR{power/control}="on"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="2013", ATTR{power/control}="on"

This works nicely when I unplug/replug the mouse and keyboard, but I would like this to trigger at boot as well, after powertop of course.

So my questions are:

1. Does the udev script as it is now trigger at boot or not? If not, is there something I can do about it?
2. What is the run order of my systemd script and the udev rules? If udev runs first, can I change this?
3. Any other suggestions to achieve what I want?

Thanks in advance.

Offline

#2 2016-01-16 13:18:41

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: powertop vs udev

Rather than using `powertop --auto-tune` instead use module parameters, udev rules and sysctl to set the values you want explicitly.
https://wiki.archlinux.org/index.php/Po … and_tricks


Jin, Jîyan, Azadî

Offline

#3 2016-01-16 14:19:02

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: powertop vs udev

The reason your service doesn't work is simple - your execstart line is a shell command line, but systemd command lines are different. See http://www.freedesktop.org/software/sys … nd%20lines
The simplest short-term solution is to create a simple shell script with the power top and echo commands and have that script as the execstart command.

Offline

#4 2016-01-17 22:00:42

louic
Member
Registered: 2013-06-13
Posts: 15

Re: powertop vs udev

Thank you for your answers. I remain interested in the answer to my questions 1 and 2 about the run order of udev and systemd units, and how to control this.

Offline

#5 2016-01-18 14:52:12

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: powertop vs udev

The answer to 1 is "it depends". If the kernel knows how to handle the device (either by built in logic or from a loaded kernel module) at boot time, it will cause udev to run the rules. Otherwise the rules will fire when you load the kernel module.
With regard to 2, your service runs later because you have the default dependencies and I'm assuming you're not dealing with a slow device. I suggest you read all the systemd man pages to get a better understanding of this.

The point is moot, however. You've created an XY problem, and are now trying to do unnatural things in order to solve Y, when Y is the wrong solution to X.

Last edited by ukhippo (2016-01-18 14:53:00)

Offline

Board footer

Powered by FluxBB