Skip to content

Conversation

pyhalov
Copy link
Contributor

@pyhalov pyhalov commented Jan 11, 2018

No description provided.

	- remove some openbsd-specific code in illumos backend
	- introduce minor_device_ioctl() to handle search & ioctl operations
	- add back up-native.c
	- implement up_backend_coldplug()
	- fix up_backend_update_lid_status()
…n_complete_get_critical_action(), not up_exported_daemon_complete_get_display_device()
	- minor_device_ioctl() should set device_path
	- canonify device_path, so that upower could handle it
up-daemon can't sum up UP_DEVICE_STATE_PENDING_CHARGE states,
and system can stuck in unknown, battery-missing global state.
@pyhalov
Copy link
Contributor Author

pyhalov commented Jan 11, 2018

It seems, ioctl(battery_device_fd,ACPI_DRV_IOC_POWER_STATUS) can exit with ENXIO on real HW, need to find out if we can find a better way to find out if battery information is available and fix up_backend_get_ac_device_path().

@Mno-hime
Copy link
Contributor

Mno-hime commented Jan 14, 2018

upower crashes when the OS is started on AC without battery and the battery is then inserted. Not sure why the upower service went to maintenance mode, the deamon could be restarted. Was using the test USB image.

core 'core' of 3788:	/usr/lib/upowerd -v
0000000000400000        220K r-x--  /usr/lib/upowerd
0000000000447000         12K rw---  /usr/lib/upowerd
000000000044A000        448K rw---    [ heap ]
FFFFFD7FFE150000          4K rw---    [ stack tid=7 ]
FFFFFD7FFE34E000          8K rw---    [ stack tid=5 ]
FFFFFD7FFE54E000          4K rw---    [ stack tid=4 ]
FFFFFD7FFE550000         88K r-x--  /lib/amd64/libnvpair.so.1
FFFFFD7FFE576000          4K rw---  /lib/amd64/libnvpair.so.1
FFFFFD7FFE77E000          4K rw---    [ stack tid=3 ]
FFFFFD7FFE780000         64K rwx--    [ anon ]
FFFFFD7FFE98E000          4K rw---    [ stack tid=2 ]
FFFFFD7FFE990000         44K r-x--  /lib/amd64/libsysevent.so.1
FFFFFD7FFE9AB000          4K rw---  /lib/amd64/libsysevent.so.1
FFFFFD7FFE9B0000        532K r-x--  /lib/amd64/libnsl.so.1
FFFFFD7FFEA45000         12K rw---  /lib/amd64/libnsl.so.1
FFFFFD7FFEA48000         32K rw---  /lib/amd64/libnsl.so.1
FFFFFD7FFEA50000         72K r-x--  /lib/amd64/libsocket.so.1
FFFFFD7FFEA72000          4K rw---  /lib/amd64/libsocket.so.1
FFFFFD7FFEA80000       1756K r-x--  /usr/lib/amd64/libgio-2.0.so.0.4600.2
FFFFFD7FFEC47000         32K rw---  /usr/lib/amd64/libgio-2.0.so.0.4600.2
FFFFFD7FFEC4F000          8K rw---  /usr/lib/amd64/libgio-2.0.so.0.4600.2
FFFFFD7FFEC60000         36K r-x--  /usr/lib/amd64/libffi.so.6.0.1
FFFFFD7FFEC79000          4K rw---  /usr/lib/amd64/libffi.so.6.0.1
FFFFFD7FFEC7D000         12K r-x--  /lib/amd64/libpthread.so.1
FFFFFD7FFEC80000       1396K r-x--  /usr/lib/amd64/libglib-2.0.so.0.4600.2
FFFFFD7FFEDED000         12K rw---  /usr/lib/amd64/libglib-2.0.so.0.4600.2
FFFFFD7FFEDF0000          4K rw---  /usr/lib/amd64/libglib-2.0.so.0.4600.2
FFFFFD7FFEE00000        356K r-x--  /usr/lib/amd64/libgobject-2.0.so.0.4600.2
FFFFFD7FFEE69000          8K rw---  /usr/lib/amd64/libgobject-2.0.so.0.4600.2
FFFFFD7FFEF70000          4K rwx--    [ anon ]
FFFFFD7FFEF80000        188K r-x--  /usr/lib/amd64/libupower-glib.so.3.0.1
FFFFFD7FFEFBF000         12K rw---  /usr/lib/amd64/libupower-glib.so.3.0.1
FFFFFD7FFEFD0000          4K r----*   [ anon ]
FFFFFD7FFEFE0000         64K rwx--    [ anon ]
FFFFFD7FFF000000          4K rwx--    [ anon ]
FFFFFD7FFF010000         64K rw---    [ anon ]
FFFFFD7FFF02F000        128K rw---    [ anon ]
FFFFFD7FFF050000          4K rwx--    [ anon ]
FFFFFD7FFF060000          4K rwx--    [ anon ]
FFFFFD7FFF070000        148K r-x--  /lib/amd64/libdevinfo.so.1
FFFFFD7FFF0A5000          4K rw---  /lib/amd64/libdevinfo.so.1
FFFFFD7FFF0B0000          4K rwx--    [ anon ]
FFFFFD7FFF0C0000          4K rwx--    [ anon ]
FFFFFD7FFF0D0000          4K rwx--    [ anon ]
FFFFFD7FFF0E0000        128K rwx--    [ anon ]
FFFFFD7FFF10B000         80K r----    [ anon ]
FFFFFD7FFF120000         64K rwx--    [ anon ]
FFFFFD7FFF132000          4K rwx--    [ anon ]
FFFFFD7FFF140000          4K rwx--    [ anon ]
FFFFFD7FFF150000         24K rwx--    [ anon ]
FFFFFD7FFF160000          4K rwx--    [ anon ]
FFFFFD7FFF170000          4K rwx--    [ anon ]
FFFFFD7FFF180000          4K rwx--    [ anon ]
FFFFFD7FFF190000          4K rwx--    [ anon ]
FFFFFD7FFF1A0000       1544K r-x--  /lib/amd64/libc.so.1
FFFFFD7FFF332000         48K rw---  /lib/amd64/libc.so.1
FFFFFD7FFF33E000         16K rw---  /lib/amd64/libc.so.1
FFFFFD7FFF350000          4K rwx--    [ anon ]
FFFFFD7FFF360000          4K rw---    [ anon ]
FFFFFD7FFF370000          4K rw---    [ anon ]
FFFFFD7FFF380000          4K rwx--    [ anon ]
FFFFFD7FFF390000          4K r----*   [ anon ]
FFFFFD7FFF397000        332K r-x--  /lib/amd64/ld.so.1
FFFFFD7FFF3FA000         12K rwx--  /lib/amd64/ld.so.1
FFFFFD7FFF3FD000          8K rwx--  /lib/amd64/ld.so.1
FFFFFD7FFFDFD000         12K rw---    [ stack ]
         total         8136K
core 'core' of 3788:	/usr/lib/upowerd -v
-----------------  lwp# 1 / thread# 1  --------------------
 fffffd7fff2c478a ioctl () + a
 fffffd7fff0822b0 walk_one_node (fffffd7fffdff928, 0, fffffd7fffdff9a0, 431bcf) + 70
 fffffd7fff082358 di_walk_node (4a5458, 0, fffffd7fffdff9a0, 431bcf) + 88
 0000000000431341 up_backend_update_lid_status () + b3
 0000000000430b7e up_backend_update_ac_state () + 20
 0000000000431215 up_acpi_device_refresh () + 48
 00000000004313e9 sysevent_iochannel_data () + 54
 fffffd7ffecfe5ee g_main_context_dispatch () + 13e
 fffffd7ffecfe9d8 g_main_context_iterate.isra.29 () + 1d8
 fffffd7ffecfed12 g_main_loop_run () + d2
 0000000000420eda main () + 326
 0000000000417623 _start_crt () + 83
 0000000000417588 _start () + 18
-----------------  lwp# 2 / thread# 2  --------------------
 fffffd7fff248be5 _malloc_unlocked (138) + a5
 fffffd7fff248b0b malloc (138) + 3b
 fffffd7fff231cda calloc (1, 138) + 3a
 fffffd7ffe9965e9 event_deliver_service (46a440, fffffd7ffe98ecc0, 138, 0, 0) + b9
 fffffd7fff2c55a0 __door_return () + 50
-----------------  lwp# 3 / thread# 3  --------------------
 fffffd7fff2bdc77 __lwp_park () + 17
 fffffd7fff2b71eb cond_wait_queue (46a4a0, 46a4b0, 0) + 5b
 fffffd7fff2b78a3 __cond_wait (46a4a0, 46a4b0) + b3
 fffffd7fff2b78da cond_wait (46a4a0, 46a4b0) + 2a
 fffffd7ffe99650e subscriber_event_handler (46a440) + be
 fffffd7fff2bd91a _thrp_setup (fffffd7ffe780a40) + 8a
 fffffd7fff2bdc30 _lwp_start ()
-----------------  lwp# 4 / thread# 4  --------------------
 fffffd7fff2c4a2a __pollsys () + a
 fffffd7fff254bb6 poll (47ab30, 1, ffffffff) + 56
 fffffd7ffecfe965 g_main_context_iterate.isra.29 () + 165
 fffffd7ffecfea7f g_main_context_iteration () + 2f
 fffffd7ffecfeac9 glib_worker_main () + 19
 fffffd7ffed2d0dd g_thread_proxy () + 5d
 fffffd7fff2bd91a _thrp_setup (fffffd7ffe781a40) + 8a
 fffffd7fff2bdc30 _lwp_start ()
-----------------  lwp# 5 / thread# 5  --------------------
 fffffd7fff2c4a2a __pollsys () + a
 fffffd7fff254bb6 poll (47abd0, 2, ffffffff) + 56
 fffffd7ffecfe965 g_main_context_iterate.isra.29 () + 165
 fffffd7ffecfed12 g_main_loop_run () + d2
 fffffd7ffebdefce gdbus_shared_thread_func () + 1e
 fffffd7ffed2d0dd g_thread_proxy () + 5d
 fffffd7fff2bd91a _thrp_setup (fffffd7ffe782240) + 8a
 fffffd7fff2bdc30 _lwp_start ()
-----------------  lwp# 7 / thread# 7  --------------------
 fffffd7fff2c556d __door_return () + 1d
 fffffd7fff2a8d8d door_return (0, 0, 0, 0) + cd
 fffffd7fff2a944c door_create_func (0) + 2c
 fffffd7fff2bd91a _thrp_setup (fffffd7ffe782a40) + 8a
 fffffd7fff2bdc30 _lwp_start ()
Jan 14 09:02:32 openindiana svc.startd[8]: [ID 748625 daemon.error] system/upower:default failed repeatedly: transitioned to maintenance (see 'svcs -xv' for details)
jack@openindiana:/jack$ svcs -xv
svc:/system/upower:default (UPower Daemon)
 State: maintenance since January 14, 2018 at 09:02:32 AM GMT
Reason: Restarting too quickly.
   See: http://illumos.org/msg/SMF-8000-L5
   See: man -M /usr/share/man -s 8 upowerd
   See: /var/svc/log/system-upower:default.log
Impact: This service is not running.


[ Jan 14 09:00:31 Executing start method ("/usr/lib/upowerd &"). ]
[ Jan 14 09:00:31 Method "start" exited with status 0. ]

(upowerd:382): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:382): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:382): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:382): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:382): UPower-illumos-WARNING **: Couldn't get state of battery
[ Jan 14 09:00:52 Stopping because process dumped core. ]
[ Jan 14 09:00:52 Executing stop method (:kill). ]
[ Jan 14 09:00:52 Executing start method ("/usr/lib/upowerd &"). ]
[ Jan 14 09:00:52 Method "start" exited with status 0. ]

(upowerd:2689): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:2689): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:2689): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:2689): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:2689): UPower-illumos-WARNING **: Couldn't get state of battery
[ Jan 14 09:01:12 Stopping because process dumped core. ]
[ Jan 14 09:01:12 Executing stop method (:kill). ]
[ Jan 14 09:01:12 Executing start method ("/usr/lib/upowerd &"). ]
[ Jan 14 09:01:12 Method "start" exited with status 0. ]

(upowerd:3179): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3179): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3179): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:3179): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3179): UPower-illumos-WARNING **: Couldn't get state of battery
[ Jan 14 09:01:32 Stopping because process dumped core. ]
[ Jan 14 09:01:32 Executing stop method (:kill). ]
[ Jan 14 09:01:32 Executing start method ("/usr/lib/upowerd &"). ]
[ Jan 14 09:01:32 Method "start" exited with status 0. ]

(upowerd:3189): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3189): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3189): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:3189): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3189): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:3189): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3189): UPower-illumos-WARNING **: Couldn't get state of battery

(upowerd:3189): UPower-illumos-WARNING **: ioctl 1 to device /devices/pseudo/acpi_drv@0:battery0 failed

(upowerd:3189): UPower-illumos-WARNING **: Couldn't get state of battery
[ Jan 14 09:02:32 Stopping because process dumped core. ]
[ Jan 14 09:02:32 Executing stop method (:kill). ]
[ Jan 14 09:02:32 Restarting too quickly, changing state to maintenance. ]

EDIT: Here's the core, should you want it: core.gz.

   - minor_device_ioctl() should avoid testing other devices is first device has failed,
     otherwise its semantic (device_path, present) is strange;
   - when ioctl on battery fails, but battery device is present,
     consider this an absent battery;
   - tell about battery/ac devices to upower daemon even if probing
     ioctls failed (could be an empty battery slot).
@pyhalov
Copy link
Contributor Author

pyhalov commented Jan 17, 2018

Now it dies the same way when ac0 device is present, but battery0 is not...

	- convert energy from mWh to Wh (as upower expects)
	- consider data updated even when nothing changed to avoid user confusion
@pyhalov pyhalov merged commit 9bf8314 into OpenIndiana:oi/hipster Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants