lkml.org 
[lkml]   [2010]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [linux-pm] [PATCH] PM: Make it possible to avoid wakeup events from being lost
On Mon, 28 Jun 2010, David Brownell wrote:

> Did someone post the canonical driver changes
> to make use of this?

No, not really. The patch itself contains an example (PCI) but it
doesn't demonstrate the full range of possible usages.

> Something like
>
> suspend() { /* if wake-enabled, up count */ }
> resume() { /* if upcounted, downcount */ }
>
> is what first comes to mind.. expecting that
> the suspend/resume methods in the driver are
> already doing the right things for enabling
> and later disabling the "system wake" behavior
> on the various relevant hardware events...

The PCI example looks like this:

resume()
{
...
if (device_may_wakeup(dev))
pm_wakeup_event(dev, TIMEOUT_GUESS);
...
}

where TIMEOUT_GUESS is an estimate of how long to wait before allowing
the system to sleep.

For things like keyboards, an example would go more like this:

irq_handler()
{
...
if (key-press event occurred) {
...
if (input queue is empty)
pm_stay_awake(dev);
add event to input queue;
...
}
...
}

read_queue()
{
...
send queued data to userspace
if (input queue is empty)
pm_relax();
...
}

I left out the device_may_wakeup tests; things become rather
complicated if you can have more than one keyboard feeding the same
input queue and some of them are wakeup-enabled while others aren't.

Clearly the appropriate changes will depend on the subsystem and the
kind of event. They may also end up depending on the platform; perhaps
this will be used only on relatively small systems like an Android
phone.

Alan Stern



\
 
 \ /
  Last update: 2010-06-29 21:59    [W:0.333 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site