shaohua.li | 8 Sep 11:18
Favicon

[RFC 0/5] device wakeup event support

This series add device wakeup event detection support. This is the base to
implement runtime device suspend/resume, though we don't support it now.
But David said USB is approaching to this. See this bugzilla
http://bugzilla.kernel.org/show_bug.cgi?id=6892 for detail.

The current process to handle wakeup event is:
1. driver enable wakeup event line pme and suspend
2. NPME or ACPI receives wakeup event
3. NPME or ACPI call .wakeup_event() to clear and disable wakeup event. Driver can do extra things in
.wakeup_event() too.
4. NPME or ACPI call generic wakeup event handler (device_receive_wakeup_event())
5. device resumes, and goto 1 for next round of suspend

There are somethings we need discuss:
1. is this generic for other platforms?
2. what should the generic wakeup event handler do?

Comments and suggestions are welcome!

Signed-off-by: Shaohua Li <shaohua.li <at> intel.com>
--

-- 
shaohua.li | 8 Sep 11:19
Favicon

[RFC 2/5] devcore adds generic wakeup event handler

The default action to handle wakeup event. Currently just prints something,
maybe we should call .resume(). The routine will be called in task context.

---
 drivers/base/power/main.c |    6 ++++++
 include/linux/pm.h        |    2 ++
 2 files changed, 8 insertions(+)

Index: linux/drivers/base/power/main.c
===================================================================
--- linux.orig/drivers/base/power/main.c	2008-09-08 13:55:56.000000000 +0800
+++ linux/drivers/base/power/main.c	2008-09-08 14:22:12.000000000 +0800
@@ -785,3 +785,9 @@ void __suspend_report_result(const char 
 	}
 }
 EXPORT_SYMBOL_GPL(__suspend_report_result);
+
+void device_receive_wakeup_event(struct device *dev)
+{
+	printk("Device %s invokes wakeup event\n", dev->bus_id);
+}
+EXPORT_SYMBOL(device_receive_wakeup_event);
Index: linux/include/linux/pm.h
===================================================================
--- linux.orig/include/linux/pm.h	2008-09-08 13:56:51.000000000 +0800
+++ linux/include/linux/pm.h	2008-09-08 14:22:12.000000000 +0800
@@ -436,6 +436,8 @@ static inline int device_suspend(pm_mess

 #endif /* !CONFIG_PM_SLEEP */

(Continue reading)

shaohua.li | 8 Sep 11:19
Favicon

[RFC 5/5] ACPI GPE based wakeup event detection

In ACPI platform, if native PME isn't enabled, GPE is used to report wakeup event.
---
 drivers/acpi/Kconfig        |    9 ++++++
 drivers/acpi/bus.c          |   15 ++++++++++
 drivers/acpi/sleep/wakeup.c |   66 ++++++++++++++++++++++++++++++++++++++++++++
 include/acpi/acpi_bus.h     |    4 ++
 4 files changed, 94 insertions(+)

Index: linux/drivers/acpi/Kconfig
===================================================================
--- linux.orig/drivers/acpi/Kconfig	2008-09-08 14:28:50.000000000 +0800
+++ linux/drivers/acpi/Kconfig	2008-09-08 14:29:08.000000000 +0800
@@ -45,6 +45,15 @@ config ACPI_SLEEP
 	depends on PM_SLEEP
 	default y

+config ACPI_GPE_WAKEUP
+	bool "ACPI wakeup event support"
+	depends on PM_SLEEP && EXPERIMENTAL
+	help
+	  Enable ACPI to detect wakeup event. For example, PCI device can
+	  invoke PME, and in ACPI platform, the PME will invoke a GPE. With
+	  the option, we can detect which device invokes wakeup event.
+
+
 config ACPI_PROCFS
 	bool "Deprecated /proc/acpi files"
 	depends on PROC_FS
Index: linux/drivers/acpi/bus.c
===================================================================
(Continue reading)

Rafael J. Wysocki | 8 Sep 22:57

Re: [RFC 5/5] ACPI GPE based wakeup event detection

On Monday, 8 of September 2008, shaohua.li <at> intel.com wrote:
> In ACPI platform, if native PME isn't enabled, GPE is used to report wakeup event.
> ---
>  drivers/acpi/Kconfig        |    9 ++++++
>  drivers/acpi/bus.c          |   15 ++++++++++
>  drivers/acpi/sleep/wakeup.c |   66 ++++++++++++++++++++++++++++++++++++++++++++
>  include/acpi/acpi_bus.h     |    4 ++
>  4 files changed, 94 insertions(+)
> 
> Index: linux/drivers/acpi/Kconfig
> ===================================================================
> --- linux.orig/drivers/acpi/Kconfig	2008-09-08 14:28:50.000000000 +0800
> +++ linux/drivers/acpi/Kconfig	2008-09-08 14:29:08.000000000 +0800
> @@ -45,6 +45,15 @@ config ACPI_SLEEP
>  	depends on PM_SLEEP
>  	default y
>  
> +config ACPI_GPE_WAKEUP
> +	bool "ACPI wakeup event support"
> +	depends on PM_SLEEP && EXPERIMENTAL
> +	help
> +	  Enable ACPI to detect wakeup event. For example, PCI device can
> +	  invoke PME, and in ACPI platform, the PME will invoke a GPE. With
> +	  the option, we can detect which device invokes wakeup event.
> +
> +
>  config ACPI_PROCFS
>  	bool "Deprecated /proc/acpi files"
>  	depends on PROC_FS
> Index: linux/drivers/acpi/bus.c
(Continue reading)

Zhao Yakui | 9 Sep 03:13
Favicon

Re: [RFC 5/5] ACPI GPE based wakeup event detection

On Mon, 2008-09-08 at 22:57 +0200, Rafael J. Wysocki wrote:
> On Monday, 8 of September 2008, shaohua.li <at> intel.com wrote:
> > In ACPI platform, if native PME isn't enabled, GPE is used to report wakeup event.
> > ---
> >  drivers/acpi/Kconfig        |    9 ++++++
> >  drivers/acpi/bus.c          |   15 ++++++++++
> >  drivers/acpi/sleep/wakeup.c |   66 ++++++++++++++++++++++++++++++++++++++++++++
> >  include/acpi/acpi_bus.h     |    4 ++
> >  4 files changed, 94 insertions(+)
> > 
> > Index: linux/drivers/acpi/Kconfig
> > ===================================================================
> > --- linux.orig/drivers/acpi/Kconfig	2008-09-08 14:28:50.000000000 +0800
> > +++ linux/drivers/acpi/Kconfig	2008-09-08 14:29:08.000000000 +0800
> > @@ -45,6 +45,15 @@ config ACPI_SLEEP
> >  	depends on PM_SLEEP
> >  	default y
> >  
> > +config ACPI_GPE_WAKEUP
> > +	bool "ACPI wakeup event support"
> > +	depends on PM_SLEEP && EXPERIMENTAL
> > +	help
> > +	  Enable ACPI to detect wakeup event. For example, PCI device can
> > +	  invoke PME, and in ACPI platform, the PME will invoke a GPE. With
> > +	  the option, we can detect which device invokes wakeup event.
> > +
> > +
> >  config ACPI_PROCFS
> >  	bool "Deprecated /proc/acpi files"
> >  	depends on PROC_FS
(Continue reading)

Li, Shaohua | 9 Sep 03:08
Favicon

Re: [RFC 5/5] ACPI GPE based wakeup event detection

>> > +
>> >  /**
>> >   * acpi_bus_notify
>> >   * ---------------
>> > @@ -506,6 +519,8 @@ static void acpi_bus_notify(acpi_handle
>> >     int result = 0;
>> >     struct acpi_device *device = NULL;
>> >
>> > +   blocking_notifier_call_chain(&acpi_bus_notify_list,
>> > +                   type, (void *)handle);
>>
>> Hm, perhaps I'm too tired and I'm missing something obvious, but can you
>> tell me please why that has to be a notifier chain?  It looks like you
>add only
>> one notifier to it, so seemingly it could be replaced by a direct call to
>a
>> function like acpi_gpe_pme_handler() (with modified list of arguments).
>When the notifier chain is used, it can work regardless of whether the
>CONFIG_ACPI_GPE_WAKEUP is set.
>If the CONFIG_ACPI_GPE_WAKEUP is set, what you said is also OK.
I actually had another usage for this (I sent a patchset for docking station, which uses it)

>> >     if (acpi_bus_get_device(handle, &device))
>> >             return;
>> > Index: linux/drivers/acpi/sleep/wakeup.c
>> > ===================================================================
>> > --- linux.orig/drivers/acpi/sleep/wakeup.c  2008-09-08
>14:28:55.000000000 +0800
>> > +++ linux/drivers/acpi/sleep/wakeup.c       2008-09-08
>15:04:23.000000000 +0800
(Continue reading)

Rafael J. Wysocki | 9 Sep 13:17

Re: [RFC 5/5] ACPI GPE based wakeup event detection

On Tuesday, 9 of September 2008, Li, Shaohua wrote:
> >> > +
> >> >  /**
> >> >   * acpi_bus_notify
> >> >   * ---------------
> >> > @@ -506,6 +519,8 @@ static void acpi_bus_notify(acpi_handle
> >> >     int result = 0;
> >> >     struct acpi_device *device = NULL;
> >> >
> >> > +   blocking_notifier_call_chain(&acpi_bus_notify_list,
> >> > +                   type, (void *)handle);
> >>
> >> Hm, perhaps I'm too tired and I'm missing something obvious, but can you
> >> tell me please why that has to be a notifier chain?  It looks like you
> >add only
> >> one notifier to it, so seemingly it could be replaced by a direct call to
> >a
> >> function like acpi_gpe_pme_handler() (with modified list of arguments).
> >When the notifier chain is used, it can work regardless of whether the
> >CONFIG_ACPI_GPE_WAKEUP is set.
> >If the CONFIG_ACPI_GPE_WAKEUP is set, what you said is also OK.
> I actually had another usage for this (I sent a patchset for docking station, which uses it)
> 
> >> >     if (acpi_bus_get_device(handle, &device))
> >> >             return;
> >> > Index: linux/drivers/acpi/sleep/wakeup.c
> >> > ===================================================================
> >> > --- linux.orig/drivers/acpi/sleep/wakeup.c  2008-09-08
> >14:28:55.000000000 +0800
> >> > +++ linux/drivers/acpi/sleep/wakeup.c       2008-09-08
(Continue reading)

Alan Stern | 9 Sep 16:08

Re: [RFC 5/5] ACPI GPE based wakeup event detection

On Tue, 9 Sep 2008, Zhao Yakui wrote:

> > > --- linux.orig/drivers/acpi/bus.c	2008-09-08 14:28:32.000000000 +0800
> > > +++ linux/drivers/acpi/bus.c	2008-09-08 14:29:03.000000000 +0800
> > > @@ -496,6 +496,19 @@ static int acpi_bus_check_scope(struct a
> > >  	return 0;
> > >  }
> > >  
> > > +static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
> > > +int register_acpi_bus_notifier(struct notifier_block *nb)
> > > +{
> > > +	return blocking_notifier_chain_register(&acpi_bus_notify_list, nb);
> > > +}
> > > +EXPORT_SYMBOL_GPL(register_acpi_bus_notifier);
> > > +
> > > +void unregister_acpi_bus_notifier(struct notifier_block *nb)
> > > +{
> > > +	blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb);
> > > +}
> > > +EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
> > > +
> > >  /**
> > >   * acpi_bus_notify
> > >   * ---------------
> > > @@ -506,6 +519,8 @@ static void acpi_bus_notify(acpi_handle 
> > >  	int result = 0;
> > >  	struct acpi_device *device = NULL;
> > >  
> > > +	blocking_notifier_call_chain(&acpi_bus_notify_list,
> > > +			type, (void *)handle);
(Continue reading)

David Brownell | 9 Sep 04:41

Re: [RFC 0/5] device wakeup event support

On Monday 08 September 2008, shaohua.li <at> intel.com wrote:
> This series add device wakeup event detection support. This is the base to
> implement runtime device suspend/resume, though we don't support it now.
> But David said USB is approaching to this. See this bugzilla
> http://bugzilla.kernel.org/show_bug.cgi?id=6892 for detail.

Glad to see more attention here.  :)

Note that this issue is specific to systems using PCI (at core),
with additional nuances for PCI systems which use ACPI.

Device wakeup through USB works fine on various non-PCI and
non-ACPI embedded systems, without needing these patches.
It's done so for several years now...

> The current process to handle wakeup event is:
> 1. driver enable wakeup event line pme and suspend
> 2. NPME or ACPI receives wakeup event
> 3. NPME or ACPI call .wakeup_event() to clear and disable wakeup
>    event. Driver can do extra things in .wakeup_event() too. 
> 4. NPME or ACPI call generic wakeup event handler (device_receive_wakeup_event())
> 5. device resumes, and goto 1 for next round of suspend
> 
> There are somethings we need discuss:
> 1. is this generic for other platforms?
> 2. what should the generic wakeup event handler do?
> 
> Comments and suggestions are welcome!

My reaction re "generic" is that these mechanisms should
(Continue reading)

Li, Shaohua | 9 Sep 05:54
Favicon

Re: [RFC 0/5] device wakeup event support


>-----Original Message-----
>From: linux-acpi-owner <at> vger.kernel.org [mailto:linux-acpi-
>owner <at> vger.kernel.org] On Behalf Of David Brownell
>Sent: Tuesday, September 09, 2008 10:41 AM
>To: Li, Shaohua
>Cc: linux-pm <at> lists.linux-foundation.org; linux-acpi <at> vger.kernel.org;
>stern <at> rowland.harvard.edu
>Subject: Re: [RFC 0/5] device wakeup event support
>
>On Monday 08 September 2008, shaohua.li <at> intel.com wrote:
>> This series add device wakeup event detection support. This is the base
>to
>> implement runtime device suspend/resume, though we don't support it now.
>> But David said USB is approaching to this. See this bugzilla
>> http://bugzilla.kernel.org/show_bug.cgi?id=6892 for detail.
>
>Glad to see more attention here.  :)
>
>Note that this issue is specific to systems using PCI (at core),
>with additional nuances for PCI systems which use ACPI.
>
>Device wakeup through USB works fine on various non-PCI and
>non-ACPI embedded systems, without needing these patches.
>It's done so for several years now...
>
>
>> The current process to handle wakeup event is:
>> 1. driver enable wakeup event line pme and suspend
>> 2. NPME or ACPI receives wake
(Continue reading)


Gmane