Re: [PATCH] PM: Make it possible to avoid wakeup events from being lost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm


[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux