public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Shem Multinymous <multinymous@gmail.com>
Cc: "Brown, Len" <len.brown@intel.com>, Pavel Machek <pavel@suse.cz>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	kernel list <linux-kernel@vger.kernel.org>,
	linux-thinkpad@linux-thinkpad.org, linux-acpi@vger.kernel.org
Subject: Re: Generic battery interface
Date: Fri, 28 Jul 2006 22:23:59 +0200	[thread overview]
Message-ID: <20060728202359.GB5313@suse.cz> (raw)
In-Reply-To: <41840b750607280814x50db03erb30d833802ae983e@mail.gmail.com>

On Fri, Jul 28, 2006 at 06:14:57PM +0300, Shem Multinymous wrote:

> >The load isn't the problem. The incurred latencies - both interrupt and
> >scheduling - are. Audio playback skips, mice losing sync, keyboards
> >losing keystrokes, these are the nasty effects I've seen so far.
> 
> ACK. But I still don't what difference it makes, in this respect, if
> apps poll the kernel which queries the hardware (maybe with caching)
> vs. kernel queries the kernel and informs apps.

Not that much. The difference then remains only on a tickless system.

> >The Analog Devices ADXL2xx sensors in the HDAPS are not implementing
> >I2C, only having analog and PWM outputs. I doubt they're connected over
> >I2C to the EC.
> 
> The ADXL320 accelerometer is sampled by the H8S/2161B embedded
> controller, and the host polls the controller over LPC.

No I2C. LPC is so much faster than I2C (8 MHz 8-bit vs 100 kHz serial).

> >The timer interrupt still has to happen every time their select() or
> >sleep() expires, with the system having to wake up, even when nothing
> >happened.
> 
> Yes, it becomes an issue with tickless. Tell them now to poll more
> often then they need, then...
> 
> Here's the thing. An event mechanism makes sense when discrete events
> happen at irregular interval determined by the data source. But here,
> you're trying to convert a (pontentially) continuous function like
> voltage to a sporadic stream of "the value changed a lot" events. So
> you need to "fuzz" the stream like in the input layer, but you have no
> idea what the applications need. One client may try to monitor power
> fluctuations with 10Hz updates, while another may log once per minute.


> The exception is "status goes critical"-type events. For sysfs, the
> attribute change uevent (mentioned by Greg KH) looks like a perfect
> solution for these.
> 
> 
> >NOTE: I'm arguing event-based vs poll-based here. This is orthogonal to
> >the /dev vs /sys - both can supply or not supply events.
> 
> >        fd = open("/dev/bat0", O_RDONLY);
> >        ioctl(fd, BATCGVOLTAGE, &voltage);
> 
> So you *are* proposing polling fo rthe /dev interface too? I thought
> the main argument for the /dev

I'm not proposing polling. I'm proposing that there be a way how to read
the immediate values, in addition to the event notifications. 

Yes, this means polling would be possible.

Reading immediate values is a must, if only to know the values at the
start of your monitoring applet.

> OK, I agree the issues are orthogonal (once sysfs attr change uevents
> are added, anyway). My take:
> 1. We need polling. We
> 
> >for the sysfs implementation (for comparison), you'll need (at minimum):
> >
> >        fd = open("/dev/bat0", O_RDONLY);
> >        read(fd, buf, MAX_LEN);
> >        voltage = strtol(buf, buf + MAX_LEN, 10);
> 
> No, you can use fscanf.

Correct.

> >If you want a shell script, you'd use a small utility supplied with the
> >reference implementation:
> >
> >        batstate -t voltage /dev/bat0
> >
> >And it'd of course give you the same output as the 'cat' line.
> 
> And then we have to maintain both a kernel side and a userspace side.
> And what do I, poor author of tp_smapi, do if I want to add a
> non-standard attribute? Tell people to patch and overwrite their
> disto's batstate binary too?

How often do you plan to do that? Anyway, the answer is yes, it's not a
big deal to do.

> >The current well known methods are:
> >
> >        1) udev/hotplug. It can create device nodes and symlinks based on 
> >        the
> >                capabilities and IDs of an input device.
> >        1a) HAL. It has all the info from hotplug as well.
> >        2) open them all and do the capability checks / IDs yourself.
> 
> Ooh, that's messy. I'll have to think about it.

As Dmitry pointed out, all the info (except for the events) is in sysfs,
too.

> Meanwhile, here's another issue with the accelerometer input device
> (and by analogy, with batteries): client-specific event rate and fuzz.
> Neverball only needs "a big change has happened" events, maybe 10-20
> times per second. The disk parking daemon needs a perfectly accurate
> readouts at 50Hz or better, plus it needs to know whenever a sample is
> taken (even if it didn't change since the previous sample). How can
> this be handled without multiple input devices?

You need at least 50 Hz for reasonable game control, too. I remember
that analog joysticks sampled at 10 Hz were unusable.

The input layer was designed for input devices that control applications
by actions of the user. The fuzz filtering was designed with that in
mind and is expected to be set once at boot either by an educated guess
of a kernel driver or by the system administrator. Because it's designed
for input devices, it has these properties:

	* It ignores minor noise
	* It slowly reacts to continuous drift of the values
	* It reacts immediately to large changes

This would be likely completely unsuitable for batteries and may be bad
for a drive parking daemon, too. If the daemon can't use it, it'll need
another interface. 

-- 
Vojtech Pavlik
Director SuSE Labs

  reply	other threads:[~2006-07-28 20:23 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-27 20:06 Generic battery interface Brown, Len
2006-07-27 20:32 ` Shem Multinymous
2006-07-27 23:24   ` Vojtech Pavlik
2006-07-28  0:27     ` Shem Multinymous
2006-07-28  0:36       ` Matthew Garrett
2006-07-28  7:42       ` Vojtech Pavlik
2006-07-28 12:25         ` Pavel Machek
2006-07-28 13:43           ` Vojtech Pavlik
2006-07-28 15:38             ` Shem Multinymous
2006-07-28 15:57               ` Valdis.Kletnieks
2006-07-28 22:10                 ` Shem Multinymous
2006-07-28 23:14                   ` Valdis.Kletnieks
2006-07-29  9:48                     ` Shem Multinymous
2006-07-29 10:17                       ` Vojtech Pavlik
2006-07-29 10:30                         ` Shem Multinymous
2006-07-29 10:37                       ` Mark Underwood
2006-07-29 11:35                         ` Shem Multinymous
2006-07-30  8:35                       ` Valdis.Kletnieks
2006-07-30 11:44                         ` Vojtech Pavlik
2006-07-30 11:48                         ` Shem Multinymous
2006-07-31  0:58                           ` Valdis.Kletnieks
2006-07-31  1:34                             ` Shem Multinymous
2006-07-30  9:18             ` Pavel Machek
2006-07-30 10:14               ` Shem Multinymous
2006-07-30 11:33                 ` Shem Multinymous
2006-07-28 12:25         ` Dmitry Torokhov
2006-07-28 13:44           ` Vojtech Pavlik
2006-07-28 15:19           ` Shem Multinymous
2006-07-28 16:10             ` Dmitry Torokhov
2006-07-30  8:55               ` Greg KH
2006-07-30  9:52                 ` Shem Multinymous
2006-07-30 11:47                   ` Vojtech Pavlik
2006-07-30 12:50                     ` Shem Multinymous
2006-07-30 11:46                 ` Vojtech Pavlik
2006-07-28 15:14         ` Shem Multinymous
2006-07-28 20:23           ` Vojtech Pavlik [this message]
2006-07-28 22:48             ` Shem Multinymous
2006-07-28 23:17               ` Pavel Machek
2006-07-29 10:36               ` Vojtech Pavlik
2006-07-29 11:32                 ` Shem Multinymous
2006-07-29 12:04                   ` Vojtech Pavlik
2006-07-29 12:51                     ` Shem Multinymous
2006-07-29 13:42                       ` Vojtech Pavlik
2006-07-30  9:00                         ` Greg KH
2006-07-29 21:06               ` Shem Multinymous
2006-07-30 10:05                 ` Pavel Machek
2006-07-30 10:34                   ` Shem Multinymous
2006-07-30 10:37                     ` Pavel Machek
2006-07-30 18:37                 ` Shem Multinymous
2006-07-31 21:35                   ` Jean Delvare
2006-07-31 22:34                     ` Shem Multinymous
2006-07-31 23:01                     ` Pavel Machek
2006-08-02  7:18                       ` Jean Delvare
2006-08-02  7:46                         ` Marek Wawrzyczny
2006-08-03 11:29                         ` Thomas Renninger
2006-08-03 16:33                           ` Pavel Machek
     [not found]                   ` <20060731113735.GA22081@creature.apm.etc.tu-bs.de>
     [not found]                     ` <41840b750607310818j7ab2dcddpcb7a14b9a8f10871@mail.gmail.com>
     [not found]                       ` <20060731183719.GB22081@creature.apm.etc.tu-bs.de>
2006-07-31 22:45                         ` [ltp] " Shem Multinymous
     [not found]                           ` <20060801114303.GA13000@creature.apm.etc.tu-bs.de>
2006-08-02 21:59                             ` Shem Multinymous
2006-07-27 22:16 ` Pavel Machek
2006-07-27 22:56   ` Shem Multinymous
2006-07-27 23:08     ` Greg KH
2006-07-27 23:24       ` Pavel Machek
2006-07-30 12:29         ` Jean Delvare
2006-08-02 19:51           ` Pavel Machek
2006-08-03  9:20             ` Jean Delvare
2006-07-27 22:56   ` Greg KH
2006-07-27 23:31   ` Vojtech Pavlik
2006-07-28  0:35     ` Shem Multinymous
2006-07-28 10:11       ` Vojtech Pavlik
  -- strict thread matches above, loose matches on Subject: below --
2006-07-28  4:05 Brown, Len
2006-07-28  8:22 ` Johan Vromans
2006-07-28  9:58 ` Matthew Garrett
2006-07-28 10:10   ` Vojtech Pavlik
2006-07-28 12:21 ` Pavel Machek
2006-07-28 14:13 ` Shem Multinymous
2006-07-27 23:20 Brown, Len
2006-07-28  0:10 ` Shem Multinymous
2006-07-27 15:40 Brown, Len
2006-07-27 16:23 ` Shem Multinymous
2006-07-27 16:50   ` Daniel Barkalow
2006-07-27 20:07     ` Shem Multinymous

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060728202359.GB5313@suse.cz \
    --to=vojtech@suse.cz \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-thinkpad@linux-thinkpad.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=multinymous@gmail.com \
    --cc=pavel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox