linux-thinkpad / hdapsd

HDAPS daemon for IBM/Lenovo ThinkPads
http://hdaps.sf.net
GNU General Public License v2.0
43 stars 7 forks source link

toshiba_haps is now in /sys/devices/platform/TOS620A:00 #15

Open mercuriete opened 8 years ago

mercuriete commented 8 years ago

im not sure if i am doing something wrong but i dont have no one of this files

#define TOSHIBA_MOVEMENT_FILE   "/sys/devices/platform/toshiba_haps/movement"
#define TOSHIBA_LEVEL_FILE  "/sys/devices/platform/toshiba_haps/protection_level"
#define TOSHIBA_POSITION_FILE   "/sys/devices/platform/toshiba_acpi/position"

but i have this other ones:

mercuriete@localhost /sys/devices/platform/TOS620A:00/firmware_node $ ls -l
total 0
lrwxrwxrwx 1 root root    0 sep 20 11:27 driver -> ../../../../bus/acpi/drivers/Toshiba HAPS
-r--r--r-- 1 root root 4096 sep 20 12:00 hid
-r--r--r-- 1 root root 4096 sep 20 12:00 modalias
-r--r--r-- 1 root root 4096 sep 20 12:00 path
lrwxrwxrwx 1 root root    0 sep 20 12:00 physical_node -> ../../../platform/TOS620A:00
drwxr-xr-x 2 root root    0 sep 20 12:00 power
-rw-r--r-- 1 root root 4096 sep 20 12:00 protection_level
--w------- 1 root root 4096 sep 20 12:00 reset_protection
-r--r--r-- 1 root root 4096 sep 20 12:00 status
lrwxrwxrwx 1 root root    0 sep 20 11:27 subsystem -> ../../../../bus/acpi
-rw-r--r-- 1 root root 4096 sep 20 12:00 uevent

i need some help because the driver is working because it writes to dmesg an event every time that i move the computer. and hdapsd starts automatically with systemd but then exits with code 255 after tries to load a lot of modules.

by the way, i compile toshiba_haps inside the kernel not as a module. i dont know if this could be the problem.

thanks for your work

edit: version of linux: uname -a Linux localhost 4.0.5-gentoo SMP PREEMPT Tue Sep 8 21:37:19 WEST 2015 x86_64 Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz GenuineIntel GNU/Linux

mercuriete commented 8 years ago

sorry this driver is an ACPI driver and send an ACPI event.

the solution was this -> http://nathanielmnelson.com/node/24

using acpid instead hdapsd

then configure some files in /etc/acpi/events/

and that it.

this ticket can be closed :)

evgeni commented 8 years ago

Hi,

good that it works for ya with the pure-ACPI method. Still, I would have expected it to work with hdapsd too, reading the HW decision from TOSHIBA_MOVEMENT_FILE.

Are you using the driver mentioned in the link, or the one in the kernel? https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/toshiba_haps.c

evgeni commented 8 years ago

@mercuriete ping? :)

klondi commented 8 years ago

@evgeni I have this problem too, and I'm using the driver provided by the kernel.

klondi commented 8 years ago

Also documentation for this is available on https://www.kernel.org/doc/Documentation/laptops/toshiba_haps.txt

evgeni commented 8 years ago

@klondi thanks for the heads up. what I am currently missing in the described API is a file that tells me "damn, park the heads, now". I guessed this is the "movement" file but the output of @mercuriete does not show it?

klondi commented 8 years ago

@evgeni it should be an ACPI event usually when the event triggers you get these two events (from dmesg): [673657.468709] toshiba_haps: Received event: 0x80 [673658.578680] toshiba_haps: Received event: 0x81

First one is park the heads now IIRC second is you can unpark them now if you want. I'm unsure though which event interface generates this as it is ACPI based.

Internet archive gives a hint on how this is handled by acpid though https://web.archive.org/web/20150218214553/http://nathanielmnelson.com/node/24

klondi commented 8 years ago

@evgeni Some googling pointed me at the kacpimon tool and this tool returned this:

Kernel ACPI Event Monitor...
open for /proc/acpi/event: No such file or directory (2)
  (ACPI proc filesystem may not be present)
/dev/input/event0 (Lid Switch) opened successfully
/dev/input/event1 (Power Button) opened successfully
/dev/input/event10 (HDA Intel HDMI HDMI/DP,pcm=3) opened successfully
/dev/input/event11 (HDA Intel HDMI HDMI/DP,pcm=7) opened successfully
/dev/input/event12 (HDA Intel HDMI HDMI/DP,pcm=8) opened successfully
/dev/input/event13 (Toshiba WMI hotkeys) opened successfully
/dev/input/event2 (Power Button) opened successfully
/dev/input/event3 (Video Bus) opened successfully
/dev/input/event4 (Video Bus) opened successfully
/dev/input/event5 (AT Translated Set 2 keyboard) opened successfully
/dev/input/event6 (HDA Intel PCH Mic) opened successfully
/dev/input/event7 (HDA Intel PCH Headphone) opened successfully
/dev/input/event8 (TOSHIBA Web Camera - HD) opened successfully
/dev/input/event9 (SynPS/2 Synaptics TouchPad) opened successfully
Netlink ACPI Family ID: 20
Netlink ACPI Multicast Group ID: 7
netlink opened successfully
Press Escape to exit, or Ctrl-C if that doesn't work.
Input Layer:  Type: 4  Code: 4  Value: 28
Input Layer:  Type: 1  Code: 28  Value: 0
Input Layer:  Sync
netlink:  TOS620A:00 00000080 00000000
netlink:  TOS620A:00 00000081 00000000
netlink:  TOS620A:00 00000080 00000000
netlink:  TOS620A:00 00000081 00000000
netlink:  TOS620A:00 00000080 00000000
netlink:  TOS620A:00 00000081 00000000
netlink:  TOS620A:00 00000080 00000000
netlink:  TOS620A:00 00000081 00000000

So basically we need to listen on the netlink interface for event 80 and 81 for device TOS620A:00. The source code for how kacpimon does this is provided by acpid.

mercuriete commented 8 years ago

Sorry for not answer! :(

I have working my toshiba sensors with acpid. I dont recall exactly how i did it.

I created some files to tell acpid that on acpi event the hard disk should be stopped. when i reach my home i will share my files.

By the way @evgeni i think its the acpi kernel driver.

mercuriete commented 8 years ago

Tutorial for get acpid working with the toshiba acpi driver.

dmesg output:

[ 4353.935442] toshiba_haps: Received event: 0x80 [ 4356.469527] toshiba_haps: Received event: 0x81

this means you have the acpi kernel driver working

so you have to install acpid and write some files in /etc/acpi/

i created 2 files, 1 file per event

/etc/acpi/events/toshiba_hdaps_unload

mercuriete@localhost /etc/acpi/events $ cat toshiba_hdaps_unload event=TOS620A:00 00000080 00000000 action=echo 30000 > /sys/block/sda/device/unload_heads

/etc/acpi/events/toshiba_hdaps_load

mercuriete@localhost /etc/acpi/events $ cat toshiba_hdaps_load event=TOS620A:00 00000081 00000000 action=echo 0 > /sys/block/sda/device/unload_heads

With this 2 files you will trigger an action whenever an event is triggered.

For logging all event if you dont know which event is what you want.

1) stop the daemon (with systemd) sudo systemctl stop acpid

2) start the daemon in console.

sudo acpid --debug --logevents

some output:

acpid: received netlink event " TOS620A:00 00000080 00000000" acpid: received netlink event " TOS620A:00 00000081 00000000"

then you can copy this code and put it in your event file in /etc/acpi/events/

I dont know any practical way to know if you get all working. what i did was: 1) copy a big file that stress you hard drive 2) open ksysguard to know the transfer rate of your disk 3) shake your laptop 4) now you will see the tranfer rate goes down to 0 Kb/s 5) stop shaking your laptop 6) then you will see the tranfer rate come back to full speed.

I hope this kind of tutorial was useful for someone that visit this page.

evgeni commented 1 month ago

Yeah, I have no idea what I was reading when I wrote https://github.com/linux-thinkpad/hdapsd/commit/d24b7adea454fab59c2a288650e438d6b899ed33, but that movement file doesn't exist, so hdapsd can't work right now.

Does /sys/devices/platform/toshiba_acpi/position work for y'all?

evgeni commented 1 month ago

Hmm, no, reading https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-driver-toshiba_acpi, that path is wrong too :crying_cat_face: