You are not logged in.

#1 2017-09-20 12:54:52

shein
Member
Registered: 2017-04-20
Posts: 7

[SOLVED] Udev power_supply rule doesn't work

Hi All,

I noticed that 85-tlp.rules rule doesn't work when I connect/disconnect the AC adapter.

The events are visible but for some reason udev doesn't trigger the rule.

> sudo udevadm monitor -u -p
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [1035.258064] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
POWER_SUPPLY_CAPACITY=77
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_ENERGY_FULL=69320000
POWER_SUPPLY_ENERGY_FULL_DESIGN=62160000
POWER_SUPPLY_ENERGY_NOW=53710000
POWER_SUPPLY_MANUFACTURER=SANYO
POWER_SUPPLY_MODEL_NAME=45N1023
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_SERIAL_NUMBER= 2097
POWER_SUPPLY_STATUS=Unknown
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=11946000
SEQNUM=2546
SUBSYSTEM=power_supply
USEC_INITIALIZED=1035248026

UDEV  [1035.757264] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/ACPI0003:00/power_supply/AC
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_ONLINE=0
SEQNUM=2547
SUBSYSTEM=power_supply
USEC_INITIALIZED=1035736359

UDEV  [1037.958324] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
POWER_SUPPLY_CAPACITY=77
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_ENERGY_FULL=69320000
POWER_SUPPLY_ENERGY_FULL_DESIGN=62160000
POWER_SUPPLY_ENERGY_NOW=53710000
POWER_SUPPLY_MANUFACTURER=SANYO
POWER_SUPPLY_MODEL_NAME=45N1023
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_SERIAL_NUMBER= 2097
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=11955000
SEQNUM=2548
SUBSYSTEM=power_supply
USEC_INITIALIZED=1037944107

UDEV  [1038.477604] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/ACPI0003:00/power_supply/AC
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_ONLINE=1
SEQNUM=2549
SUBSYSTEM=power_supply
USEC_INITIALIZED=1038456358

Udev rule:

ACTION=="change", SUBSYSTEM=="power_supply", RUN+="/usr/bin/tlp auto"

I created a test rule for usb subsystem to verify that udev works at all. And usb rule worked. So, there's something wrong with power_supply subsystem.

Is there a way to see why udev doesn't trigger a rule? How can I debug this problem?

Update:
I checked add and remove actions work but change action doesn't work. I verified it with different subsystems (rfkill, platform).
Is change action broken in udev?

Update2:
Tried downgrading systemd with the same result. So, either I'm doing something wrong or action 'change' has been broken for a long time (which is unlikely...)

Last edited by shein (2017-09-20 14:51:11)

Offline

#2 2017-09-20 14:50:37

shein
Member
Registered: 2017-04-20
Posts: 7

Re: [SOLVED] Udev power_supply rule doesn't work

The problem was in 99-intelpwm.rules. This rule blocked execution of other rules.

After setting

udev_log="debug"

in '/etc/udev/udev.confg' it became clear what is going on:

Sep 20 17:48:37 arch-vostro systemd-udevd[23463]: seq 2471 forked new worker [10916]
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: seq 2471 running
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: RUN '/usr/local/bin/test.sh' /etc/udev/rules.d/49-test-2.rules:7
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: RUN '/usr/bin/tlp auto' /usr/lib/udev/rules.d/85-tlp.rules:7
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: RUN '/usr/bin/touch /home/yura/udev_works' /etc/udev/rules.d/86-test.rules:7
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: RUN '/usr/bin/intelpwm' /usr/lib/udev/rules.d/99-intelpwm.rules:3
Sep 20 17:48:37 arch-vostro systemd-udevd[10917]: starting '/usr/bin/intelpwm'
Sep 20 17:48:37 arch-vostro systemd-udevd[10916]: Process '/usr/bin/intelpwm' succeeded.
Sep 20 17:48:37 arch-vostro systemd-udevd[23463]: cleanup idle workers
Sep 20 17:48:37 arch-vostro systemd-udevd[23463]: worker [10916] exited
Sep 20 17:48:38 arch-vostro systemd-udevd[23463]: seq 2472 queued, 'change' 'power_supply'
Sep 20 17:48:38 arch-vostro systemd-udevd[23463]: seq 2472 forked new worker [10920]
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: seq 2472 running
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: RUN '/usr/local/bin/test.sh' /etc/udev/rules.d/49-test-2.rules:7
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: RUN '/usr/bin/tlp auto' /usr/lib/udev/rules.d/85-tlp.rules:7
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: RUN '/usr/bin/touch /home/yura/udev_works' /etc/udev/rules.d/86-test.rules:7
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: RUN '/usr/bin/intelpwm' /usr/lib/udev/rules.d/99-intelpwm.rules:3
Sep 20 17:48:38 arch-vostro systemd-udevd[10921]: starting '/usr/bin/intelpwm'
Sep 20 17:48:38 arch-vostro systemd-udevd[10920]: Process '/usr/bin/intelpwm' succeeded.
Sep 20 17:48:38 arch-vostro systemd-udevd[23463]: cleanup idle workers
Sep 20 17:48:38 arch-vostro systemd-udevd[23463]: worker [10920] exited

Offline

Board footer

Powered by FluxBB