linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
86 stars 39 forks source link

modprobe -r ithc while ipts is active triggers log flooding and cpu spike #77

Closed Faexa closed 1 year ago

Faexa commented 1 year ago

Hello, I would like to report a bug when removing ithc module from kernel while ipts is active :

Surface Pro 7+ with Debian 11 kernel 5.19.4 ipts from action 85 : https://github.com/linux-surface/iptsd/actions/runs/2959281964 ithc compiled with dkms from quo/ithc

How to reproduce :

modprobe -r ithc

Exemple script which got me the problem :

#! /usr/bin/sh
case $1/$2 in

    "post/hibernate" | "post/suspend-then-hibernate" | "post/hybrid-sleep")
        # Fix the no touchscreen issue after wake-up from hibernation
        # Stop iptsd and reload ithc.
        # iptsd will be automaticly started by ithc.
        systemctl stop iptsd
        modprobe -r ithc
        modprobe ithc
        ;;

esac

In my old script the iptsd service was just iptsd and not iptsd@-dev-hidraw, so here, it fails on stoping iptsd but removes the ithc module

What happen :

syslog and daemon log got spammed with A LOT of logs entries (A LOT LOT LOT : disk if full in minutes) with that Sep 2 23:38:35 surface-debian iptsd[1113]: [23:38:35.580] [warning] Failed to read from HID device: Input/output error

Disk is quickly full and CPU is spiking 100% and surface becomes very hot with fan at full speed. systemd-journald and rsyslog process eats all cpu I can see two iptsd process

How to stop :

systemctl stop ipdst@... killall iptsd remove gigabits of logs

What should be happening :

I don't really know but at least limit the log entries or kill the iptsd process (or module ithc should not unload if ipts is active)

Thank you very much for your hard work !

NP-chaonay commented 1 year ago

1) you should not called "iptsd" as "ipts" these two thing is different, and sometime differ based on context (i think)

most context: ipts: Linux touch/stylus driver for <=SP7 gen or alike device iptsd: daemon handle data from supported driver (ithc/ipts/spi-hid), mostly made to support touch/stylus for Surface devices

NP-chaonay commented 1 year ago

systemctl stop ipdst@... killall iptsd remove gigabits of logs

What should be happening :

I don't really know but at least limit the log entries or kill the iptsd process (or module ithc should not unload if ipts is active)

Thank you very much for your hard work !

idk if you know this at this moment

"newer iptsd, it is change way how it execute, it is receive device file path as parameter, so the old script wont work, you have to do command that search for related systemd services and stop them."

But in this issue, is the program flood log. yeah good issue.

My implementation is to:

1) found error? fix and retry with log ( this fix instantly) 2) error again? wait for 5 seconds and then fix and retry , no (maybe) log (this attempt to adding delay before fixing) 3) error again? log and terminate (this give up and let user down)

NP-chaonay commented 1 year ago

Hello, I would like to report a bug when removing ithc module from kernel while ipts is active :

Surface Pro 7+ with Debian 11 kernel 5.19.4 ipts from action 85 : https://github.com/linux-surface/iptsd/actions/runs/2959281964 ithc compiled with dkms from quo/ithc

How to reproduce :

modprobe -r ithc

Exemple script which got me the problem :

#! /usr/bin/sh
case $1/$2 in

    "post/hibernate" | "post/suspend-then-hibernate" | "post/hybrid-sleep")
        # Fix the no touchscreen issue after wake-up from hibernation
        # Stop iptsd and reload ithc.
        # iptsd will be automaticly started by ithc.
        systemctl stop iptsd
        modprobe -r ithc
        modprobe ithc
        ;;

esac

In my old script the iptsd service was just iptsd and not iptsd@-dev-hidraw, so here, it fails on stoping iptsd but removes the ithc module

What happen :

syslog and daemon log got spammed with A LOT of logs entries (A LOT LOT LOT : disk if full in minutes) with that Sep 2 23:38:35 surface-debian iptsd[1113]: [23:38:35.580] [warning] Failed to read from HID device: Input/output error

Disk is quickly full and CPU is spiking 100% and surface becomes very hot with fan at full speed. systemd-journald and rsyslog process eats all cpu I can see two iptsd process

How to stop :

systemctl stop ipdst@... killall iptsd remove gigabits of logs

What should be happening :

I don't really know but at least limit the log entries or kill the iptsd process (or module ithc should not unload if ipts is active)

Thank you very much for your hard work !

oh maybe suggesting you to check log in /var/log if some file too large, and remove it

StollD commented 1 year ago

udev should automatically stop iptsd if the kernel module gets removed. Instead it keeps running and tries to read from a HID device that doesnt exist anymore.

Did you run any systemctl enable or systemctl start commands on iptsd?

Also, can you try to unload ithc after a fresh boot (without suspending), and check if the same happens?

I also dont think you need to reload ithc / iptsd after suspend. Why are you doing this?

StollD commented 1 year ago

Alright forget that. I managed to reproduce this. Seems that the systemd service is not actually stopped by udev.

I pushed a commit that fixes the issue for me, so please try that out. It will spam a little bit, but not nearly as excessive as right now, and it does shut down eventually.

Faexa commented 1 year ago

Hello again, sorry for the late answer

most context: ipts: Linux touch/stylus driver for <=SP7 gen or alike device iptsd: daemon handle data from supported driver (ithc/ipts/spi-hid), mostly made to support touch/stylus for Surface devices "newer iptsd, it is change way how it execute, it is receive device file path as parameter, so the old script wont work, you have to do command that search for related systemd services and stop them."

Thanks, I had a hard time understanding the different drivers used

Fresh reboot : why is there mutiple /dev/hidraw ? What exactly represent this device ?

ls /dev/hidraw*
crw------- 1 root root 234, 0 18 sept. 11:45 /dev/hidraw0
crw------- 1 root root 234, 1 18 sept. 11:45 /dev/hidraw1

Did you run any systemctl enable or systemctl start commands on iptsd? no, here is the systemctl status :

● iptsd@-dev-hidraw0.service - Intel Precise Touch & Stylus Daemon
Loaded: loaded (/lib/systemd/system/iptsd@.service; static)
Active: active (running) since Sun 2022-09-18 11:45:04 CEST; 51min ago
Docs: https://github.com/linux-surface/iptsd
Main PID: 1104 (iptsd)
Tasks: 1 (limit: 18914)
Memory: 2.6M
CPU: 31ms
CGroup: /system.slice/system-iptsd.slice/iptsd@-dev-hidraw0.service
└─1104 /usr/bin/iptsd /dev/hidraw0

Also, can you try to unload ithc after a fresh boot (without suspending), and check if the same happens?

yes, after clean reboot : modeprobe -r ithc

systemd-journald rsyslogd iptsd these three process eats all the cpu and pc burning until iptsd is killed

I also dont think you need to reload ithc / iptsd after suspend. Why are you doing this? Last time I checked after suspend the stilus and tactile won't work anymore. I'm gona check again New test :

Fresh reboot

ls /dev/hidraw*
crw------- 1 root root 234, 0 18 sept. 11:45 /dev/hidraw0
crw------- 1 root root 234, 1 18 sept. 11:45 /dev/hidraw1

One iptsd is running : iptsd@-dev-hidraw0.service

After hibernating and resuming : iptsd@-dev-hidraw0.service still active running. No logs ls /dev/hidraw* still same devices listed

No touchscreen anymore

After doing :

systemctl stop iptsd@-dev-hidraw0.service
modprobe -r ithc
modprobe ithc

Touchscreen is back and running

Testing new release

modeprobe -r ithc on fresh reboot

Works perfectly, iptsd is stopped :

systemctl status iptsd@-dev-hidraw0.service

oct. 09 23:55:46 surface-debian systemd[1]: Started Intel Precise Touch & Stylus Daemon.
oct. 09 23:55:46 surface-debian iptsd[1062]: [23:55:46.599] [info] Connected to device 045E:0C1A
oct. 09 23:57:30 surface-debian systemd[1]: Stopping Intel Precise Touch & Stylus Daemon...
oct. 09 23:57:30 surface-debian iptsd[1062]: [23:57:30.912] [warning] Failed to read from HID device: Input/output error
oct. 09 23:57:30 surface-debian iptsd[1062]: [23:57:30.912] [info] Stopping
oct. 09 23:57:31 surface-debian iptsd[1062]: [23:57:31.010] [error] Failed to set feature: No such device
oct. 09 23:57:31 surface-debian systemd[1]: iptsd@-dev-hidraw0.service: Main process exited, code=exited, status=1/FAILURE
oct. 09 23:57:31 surface-debian systemd[1]: iptsd@-dev-hidraw0.service: Failed with result 'exit-code'.
oct. 09 23:57:31 surface-debian systemd[1]: Stopped Intel Precise Touch & Stylus Daemon.

And modprobe ithc > everything comes back

In conclusion : your modifications works perfectly. Sill trouble when hibernating and resuming, loosing the touchscreen (but there is a workaround now fully functionnal without sides effects)

Thank you very much

NP-chaonay commented 1 year ago

@Faexa could you post the dmesg when you suspending without iptsd workaround

may be that info helpful for debugging