lis3lv02d driver creates emulated joystick interface for events reported
by the sensor.
Because of HW, this has to be implemented as polled input device, with
20Hz frequency.
This is reported to create 20% CPU usage increase (and proportionaly higher
power consumption) just for the ipolldevd kernel thread (which is used
to read the sensor).
As most users probably only use the freefall functionality of the driver
and not the joystick interface, provide means for disabling the registration
of joystick device altogether via module parameter.
(I'd rather make it default to 0, but this will break backwards compatibility).
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
drivers/hwmon/lis3lv02d.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index b2f2277..bfbc02c 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -41,6 +41,9 @@
/* joystick device poll interval in milliseconds */
#define MDPS_POLL_INTERVAL 50
+static int enable_joystick = 1;
+module_param_named(joystick, enable_joystick, int, 0400);
+MODULE_PARM_DESC(joystick, "Enable joystick emulation (0 = disable, 1 = enable). Default: 1");
/*
* The sensor can also generate interrupts (DRDY) but it's pretty pointless
* because they are generated even if the data do not change. So it's better
@@ -434,14 +437,13 @@ EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable);
void lis3lv02d_joystick_disable(void)
{
- if (!lis3_dev.idev)
- return;
-
if (lis3_dev.irq)
misc_deregister(&lis3lv02d_misc_device);
- input_unregister_polled_device(lis3_dev.idev);
- input_free_polled_device(lis3_dev.idev);
- lis3_dev.idev = NULL;
+ if (lis3_dev.idev) {
+ input_unregister_polled_device(lis3_dev.idev);
+ input_free_polled_device(lis3_dev.idev);
+ lis3_dev.idev = NULL;
+ }
}
EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
@@ -559,7 +561,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
...Are you saying there is a 20% CPU usage even when the joystick interface is not open? This should not happen (and this is not happening on my laptop). The polling should happen only when a userspace app opens the joystick interface (like running neverball). So I'd tend to think it's more due to a misconfiguration of the system (like xserver using the joystick interface as a pointer device) or it's a bug in the way we set up the polling. Could you investigate and let me know? Cheers, Eric --
Marcin originally reported this to me. Marcin, could you please check 'lsof' output to see whether the joystick interface has been open by some application? Thanks, -- Jiri Kosina SUSE Labs, Novell Inc. --
I would randomly blame hal. It keeps my IR remote control device opened all the time and I have no idea why. -- Jean Delvare --
sorry for the delay, had a crunch time here is the link for this lsof: https://bugzilla.novell.com/attachment.cgi?id=354953 Best regards, Marcin. --
Could you check what is the polling period of the device. something like: cat /sys/devices/platform/lis3lv02d/input/input9/poll it is current polling period in milliseconds. 0 disables polling. -Samu
I think that on my system this is /sys/devices/platform/lis3lv02d/rate but i may be wrong. Anyway it contains 40 as a number. Marcin. --
This file is something else. Isn't there any file like /sys/devices/platform/lis3lv02d/input/input*/poll ? Maybe your kernel is too old to have this functionality (I don't know when it was introduced). Samu is right, here to disable the joystick, I can indeed do a: echo 0 > /sys/devices/platform/lis3lv02d/input/input*/poll Eric --
Dnia 16-04-2010 o 15:56:43 Éric Piel <eric.piel@tremplin-utc.net> nope, should i paste you list? my kernel is 2.6.31.12 --
It's not necessary. For your kernel, I'd recommend the trick with the mplayer configuration file. And as Samu explained, on newer kernels the ability to disable totally the polling is already there. Eric --
So apparently, it's opened by mplayer. Indeed, by default mplayer always opens the first joystick device, because some people like to control a movie with a joystick. I don't think much can be done from the kernel point of view. Maybe there are even people who enjoy controlling their movies by moving their laptop! Here, my ~/.mplayer/config looks like: [default] input=js-dev=/dev/input/js8 You could also put a udev rule to change the name of this joystick to something like js1. All I could think of in the kernel side to improve this situation would be to give more information about joystick devices, and define a subtype "accelerometer", which mplayer could avoid selecting by default. I don't know enough the input interface to know if this already exists... See you, Eric --
I've also never seen this problem on my HP 2510p. --
