2008-03-19 21:56:18

by Alan Stern

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Tue, 18 Mar 2008 [email protected] wrote:

> Subject: pm-convert-wakeup-flag-accessors-to-inline-functions fix
> From: Andrew Morton <[email protected]>
>
> ia64 allmodconfig:
>
> In file included from include/linux/device.h:381,
> from include/linux/rtc.h:110,
> from include/linux/efi.h:19,
> from include/asm/sal.h:40,
> from include/asm-ia64/mca.h:20,
> from arch/ia64/kernel/asm-offsets.c:17:
> include/linux/pm_wakeup.h: In function `device_init_wakeup':
> include/linux/pm_wakeup.h:35: error: structure has no member named `should_wakeup'
> include/linux/pm_wakeup.h: In function `device_set_wakeup_enable':
> include/linux/pm_wakeup.h:45: error: structure has no member named `should_wakeup'
> include/linux/pm_wakeup.h: In function `device_may_wakeup':
> include/linux/pm_wakeup.h:50: error: structure has no member named `should_wakeup'
>
> Cc: Alan Stern <[email protected]>
> Cc: Greg KH <[email protected]>
> Cc: "Rafael J. Wysocki" <[email protected]>
> Cc: Len Brown <[email protected]>
> Signed-off-by: Andrew Morton <[email protected]>
> ---
>
> include/linux/pm_wakeup.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -puN include/linux/pm_wakeup.h~pm-convert-wakeup-flag-accessors-to-inline-functions-fix include/linux/pm_wakeup.h
> --- a/include/linux/pm_wakeup.h~pm-convert-wakeup-flag-accessors-to-inline-functions-fix
> +++ a/include/linux/pm_wakeup.h
> @@ -25,7 +25,7 @@
> # error "please don't include this file directly"
> #endif
>
> -#ifdef CONFIG_PM
> +#ifdef CONFIG_PM_SLEEP
>
> /* changes to device_may_wakeup take effect on the next pm state change.
> * by default, devices should wakeup if they can.

This is completely wrong.

Andrew, I don't know what happened. But if you go back and compare my
original patch to the
pm-make-wakeup-flags-available-whenever-config_pm-is-set patch you
actually applied, you'll see that you managed to leave out a hunk.
Possibly because of a conflict with one of Rafael's patches affecting
the same area of code.

Here's a URL for that patch as rebased by Rafael:

http://marc.info/?l=linux-kernel&m=120528034413861&w=2

The very first hunk in that patch makes the should_wakeup flag
available always, not just when CONFIG_PM_SLEEP is set. If you go back
and import it with that first hunk intact then there should be no need
for this "fix" patch.

(In order to do this, you'll first have to revert
pm-convert-wakeup-flag-accessors-to-inline-functions.patch and then
re-apply it afterward, because it depends on this one.)

Alan Stern


2008-03-19 19:51:42

by Andrew Morton

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Wed, 19 Mar 2008 10:55:35 -0400 (EDT) Alan Stern <[email protected]> wrote:

> On Tue, 18 Mar 2008 [email protected] wrote:
>
> > Subject: pm-convert-wakeup-flag-accessors-to-inline-functions fix
> > From: Andrew Morton <[email protected]>
> >
> > ia64 allmodconfig:
> >
> > In file included from include/linux/device.h:381,
> > from include/linux/rtc.h:110,
> > from include/linux/efi.h:19,
> > from include/asm/sal.h:40,
> > from include/asm-ia64/mca.h:20,
> > from arch/ia64/kernel/asm-offsets.c:17:
> > include/linux/pm_wakeup.h: In function `device_init_wakeup':
> > include/linux/pm_wakeup.h:35: error: structure has no member named `should_wakeup'
> > include/linux/pm_wakeup.h: In function `device_set_wakeup_enable':
> > include/linux/pm_wakeup.h:45: error: structure has no member named `should_wakeup'
> > include/linux/pm_wakeup.h: In function `device_may_wakeup':
> > include/linux/pm_wakeup.h:50: error: structure has no member named `should_wakeup'
> >
> > Cc: Alan Stern <[email protected]>
> > Cc: Greg KH <[email protected]>
> > Cc: "Rafael J. Wysocki" <[email protected]>
> > Cc: Len Brown <[email protected]>
> > Signed-off-by: Andrew Morton <[email protected]>
> > ---
> >
> > include/linux/pm_wakeup.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff -puN include/linux/pm_wakeup.h~pm-convert-wakeup-flag-accessors-to-inline-functions-fix include/linux/pm_wakeup.h
> > --- a/include/linux/pm_wakeup.h~pm-convert-wakeup-flag-accessors-to-inline-functions-fix
> > +++ a/include/linux/pm_wakeup.h
> > @@ -25,7 +25,7 @@
> > # error "please don't include this file directly"
> > #endif
> >
> > -#ifdef CONFIG_PM
> > +#ifdef CONFIG_PM_SLEEP
> >
> > /* changes to device_may_wakeup take effect on the next pm state change.
> > * by default, devices should wakeup if they can.
>
> This is completely wrong.
>
> Andrew, I don't know what happened. But if you go back and compare my
> original patch to the
> pm-make-wakeup-flags-available-whenever-config_pm-is-set patch you
> actually applied, you'll see that you managed to leave out a hunk.
> Possibly because of a conflict with one of Rafael's patches affecting
> the same area of code.
>
> Here's a URL for that patch as rebased by Rafael:
>
> http://marc.info/?l=linux-kernel&m=120528034413861&w=2

But there was a patch with the same title from yourself sent four days
later, which is what I merged.

Plus Greg has been merging and dropping older versions under our feet and
maybe Len has too.

> The very first hunk in that patch makes the should_wakeup flag
> available always, not just when CONFIG_PM_SLEEP is set. If you go back
> and import it with that first hunk intact then there should be no need
> for this "fix" patch.

> (In order to do this, you'll first have to revert
> pm-convert-wakeup-flag-accessors-to-inline-functions.patch and then
> re-apply it afterward, because it depends on this one.)

<shudder>

I'll drop everything, let's start again.

Only how? umm, please review Greg's driver tree, let us know which patches
shoudl be dropped from that then send new ones, I guess.

2008-03-19 23:12:52

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 1/3] Fix misuse of wakeup flag accessors in serial core

From: Alan Stern <[email protected]>

This patch (as1059) fixes a mistake in the way the serial core
initializes a device's wakeup settings. It should use the accessor
routine instead of relying on a macro producing an lvalue.

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
---

Index: usb-2.6/drivers/serial/serial_core.c
===================================================================
--- usb-2.6.orig/drivers/serial/serial_core.c
+++ usb-2.6/drivers/serial/serial_core.c
@@ -2356,7 +2356,7 @@ int uart_add_one_port(struct uart_driver
*/
tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev);
if (likely(!IS_ERR(tty_dev))) {
- device_can_wakeup(tty_dev) = 1;
+ device_init_wakeup(tty_dev, 1);
device_set_wakeup_enable(tty_dev, 0);
} else
printk(KERN_ERR "Cannot register tty device on line %d\n",


2008-03-19 23:13:28

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 0/3] PM wakeup flags revisited (was: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree)

On Wednesday, 19 of March 2008, Greg KH wrote:
> On Wed, Mar 19, 2008 at 11:48:29AM -0700, Andrew Morton wrote:
> > I'll drop everything, let's start again.
> >
> > Only how? umm, please review Greg's driver tree, let us know which patches
> > shoudl be dropped from that then send new ones, I guess.
>
> Yes, please do, I'm confused as well :)

Please drop pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch
and apply the following three patches instead.

Thanks,
Rafael

2008-03-19 23:14:38

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 2/3] PM: Make wakeup flags available whenever CONFIG_PM is set (ver 2)

From: Alan Stern <[email protected]>

The various wakeup flags and their accessor macros in struct
dev_pm_info should be available whenever CONFIG_PM is enabled, not
just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always
be configurable for runtime power management. This patch (as1056b)
fixes the oversight.

[rjw: rebased]

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/base/power/main.c | 2 --
drivers/base/power/sysfs.c | 2 ++
include/linux/pm.h | 36 +++++++++++++++++++++---------------
3 files changed, 23 insertions(+), 17 deletions(-)

Index: linux-2.6/include/linux/pm.h
===================================================================
--- linux-2.6.orig/include/linux/pm.h
+++ linux-2.6/include/linux/pm.h
@@ -183,9 +183,9 @@ typedef struct pm_message {
struct dev_pm_info {
pm_message_t power_state;
unsigned can_wakeup:1;
+ unsigned should_wakeup:1;
bool sleeping:1; /* Owned by the PM core */
#ifdef CONFIG_PM_SLEEP
- unsigned should_wakeup:1;
struct list_head entry;
#endif
};
@@ -198,11 +198,6 @@ extern void device_resume(void);
extern int device_suspend(pm_message_t state);
extern int device_prepare_suspend(pm_message_t state);

-#define device_set_wakeup_enable(dev,val) \
- ((dev)->power.should_wakeup = !!(val))
-#define device_may_wakeup(dev) \
- (device_can_wakeup(dev) && (dev)->power.should_wakeup)
-
extern void __suspend_report_result(const char *function, void *fn, int ret);

#define suspend_report_result(fn, ret) \
@@ -210,6 +205,24 @@ extern void __suspend_report_result(cons
__suspend_report_result(__FUNCTION__, fn, ret); \
} while (0)

+#else /* !CONFIG_PM_SLEEP */
+
+static inline int device_suspend(pm_message_t state)
+{
+ return 0;
+}
+
+#define suspend_report_result(fn, ret) do { } while (0)
+
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+
+#define device_set_wakeup_enable(dev,val) \
+ ((dev)->power.should_wakeup = !!(val))
+#define device_may_wakeup(dev) \
+ (device_can_wakeup(dev) && (dev)->power.should_wakeup)
+
/*
* Platform hook to activate device wakeup capability, if that's not already
* handled by enable_irq_wake() etc.
@@ -224,24 +237,17 @@ static inline int call_platform_enable_w
return 0;
}

-#else /* !CONFIG_PM_SLEEP */
-
-static inline int device_suspend(pm_message_t state)
-{
- return 0;
-}
+#else /* !CONFIG_PM */

#define device_set_wakeup_enable(dev,val) do{}while(0)
#define device_may_wakeup(dev) (0)

-#define suspend_report_result(fn, ret) do { } while (0)
-
static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
{
return 0;
}

-#endif /* !CONFIG_PM_SLEEP */
+#endif /* !CONFIG_PM */

/* changes to device_may_wakeup take effect on the next pm state change.
* by default, devices should wakeup if they can.
Index: linux-2.6/drivers/base/power/main.c
===================================================================
--- linux-2.6.orig/drivers/base/power/main.c
+++ linux-2.6/drivers/base/power/main.c
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);
/* 'true' if all devices have been suspended, protected by dpm_list_mtx */
static bool all_sleeping;

-int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
/**
* device_pm_add - add a device to the list of active devices
* @dev: Device to be added to the list
Index: linux-2.6/drivers/base/power/sysfs.c
===================================================================
--- linux-2.6.orig/drivers/base/power/sysfs.c
+++ linux-2.6/drivers/base/power/sysfs.c
@@ -6,6 +6,8 @@
#include <linux/string.h>
#include "power.h"

+int (*platform_enable_wakeup)(struct device *dev, int is_on);
+

/*
* wakeup - Report/change current wakeup option for device

2008-03-19 23:13:55

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 3/3] PM: Convert wakeup flag accessors to inline functions

From: Alan Stern <[email protected]>

This patch (as1058) improves the wakeup macros in include/linux/pm.h.
All but the trivial ones are converted to inline routines, which
requires moving them to a separate header file since they depend on
the definition of struct device.

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
---
include/linux/device.h | 3 +
include/linux/pm.h | 46 -----------------------
include/linux/pm_wakeup.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 45 deletions(-)

Index: linux-2.6/include/linux/pm.h
===================================================================
--- linux-2.6.orig/include/linux/pm.h
+++ linux-2.6/include/linux/pm.h
@@ -212,54 +212,10 @@ static inline int device_suspend(pm_mess
return 0;
}

-#define suspend_report_result(fn, ret) do { } while (0)
+#define suspend_report_result(fn, ret) do {} while (0)

#endif /* !CONFIG_PM_SLEEP */

-#ifdef CONFIG_PM
-
-#define device_set_wakeup_enable(dev,val) \
- ((dev)->power.should_wakeup = !!(val))
-#define device_may_wakeup(dev) \
- (device_can_wakeup(dev) && (dev)->power.should_wakeup)
-
-/*
- * Platform hook to activate device wakeup capability, if that's not already
- * handled by enable_irq_wake() etc.
- * Returns zero on success, else negative errno
- */
-extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
-static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
-{
- if (platform_enable_wakeup)
- return (*platform_enable_wakeup)(dev, is_on);
- return 0;
-}
-
-#else /* !CONFIG_PM */
-
-#define device_set_wakeup_enable(dev,val) do{}while(0)
-#define device_may_wakeup(dev) (0)
-
-static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
-{
- return 0;
-}
-
-#endif /* !CONFIG_PM */
-
-/* changes to device_may_wakeup take effect on the next pm state change.
- * by default, devices should wakeup if they can.
- */
-#define device_can_wakeup(dev) \
- ((dev)->power.can_wakeup)
-#define device_init_wakeup(dev,val) \
- do { \
- device_can_wakeup(dev) = !!(val); \
- device_set_wakeup_enable(dev,val); \
- } while(0)
-
/*
* Global Power Management flags
* Used to keep APM and ACPI from both being active
Index: linux-2.6/include/linux/device.h
===================================================================
--- linux-2.6.orig/include/linux/device.h
+++ linux-2.6/include/linux/device.h
@@ -475,6 +475,9 @@ struct device {
void (*release)(struct device *dev);
};

+/* Get the wakeup routines, which depend on struct device */
+#include <linux/pm_wakeup.h>
+
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
Index: linux-2.6/include/linux/pm_wakeup.h
===================================================================
--- /dev/null
+++ linux-2.6/include/linux/pm_wakeup.h
@@ -0,0 +1,90 @@
+/*
+ * pm_wakeup.h - Power management wakeup interface
+ *
+ * Copyright (C) 2008 Alan Stern
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _LINUX_PM_WAKEUP_H
+#define _LINUX_PM_WAKEUP_H
+
+#ifndef _DEVICE_H_
+# error "please don't include this file directly"
+#endif
+
+#ifdef CONFIG_PM
+
+/* changes to device_may_wakeup take effect on the next pm state change.
+ * by default, devices should wakeup if they can.
+ */
+static inline void device_init_wakeup(struct device *dev, int val)
+{
+ dev->power.can_wakeup = dev->power.should_wakeup = !!val;
+}
+
+static inline int device_can_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup;
+}
+
+static inline void device_set_wakeup_enable(struct device *dev, int val)
+{
+ dev->power.should_wakeup = !!val;
+}
+
+static inline int device_may_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup & dev->power.should_wakeup;
+}
+
+/*
+ * Platform hook to activate device wakeup capability, if that's not already
+ * handled by enable_irq_wake() etc.
+ * Returns zero on success, else negative errno
+ */
+extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
+
+static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
+{
+ if (platform_enable_wakeup)
+ return (*platform_enable_wakeup)(dev, is_on);
+ return 0;
+}
+
+#else /* !CONFIG_PM */
+
+/* For some reason the next two routines work even without CONFIG_PM */
+static inline void device_init_wakeup(struct device *dev, int val)
+{
+ dev->power.can_wakeup = !!val;
+}
+
+static inline int device_can_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup;
+}
+
+#define device_set_wakeup_enable(dev, val) do {} while (0)
+#define device_may_wakeup(dev) 0
+
+static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
+{
+ return 0;
+}
+
+#endif /* !CONFIG_PM */
+
+#endif /* _LINUX_PM_WAKEUP_H */

2008-03-19 23:19:51

by Alan Stern

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Wed, 19 Mar 2008, Greg KH wrote:

> On Wed, Mar 19, 2008 at 11:48:29AM -0700, Andrew Morton wrote:
> > I'll drop everything, let's start again.
> >
> > Only how? umm, please review Greg's driver tree, let us know which patches
> > shoudl be dropped from that then send new ones, I guess.
>
> Yes, please do, I'm confused as well :)

Okay. No doubt Rafael will correct me if I get something wrong.

Greg's tree still contains the original, wrong version of
pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch. It
should be reverted. In its place should be substituted this series of
patches (URLs for 0/3 ... 3/3):

http://marc.info/?l=linux-kernel&m=120561808422302&w=2
http://marc.info/?l=linux-kernel&m=120561808522316&w=2
http://marc.info/?l=linux-kernel&m=120561808522322&w=2
http://marc.info/?l=linux-kernel&m=120561808622328&w=2

There is likely to be a conflict in applying the 2/3 patch, because its
first hunk touches a region of code also affected by work Rafael has
been doing. The important aspect of that hunk is that it moves the
should_wakeup flag definition outside the region protected by "#ifdef
CONFIG_PM_SLEEP".

Alan Stern

2008-03-19 23:21:56

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Wednesday, 19 of March 2008, Alan Stern wrote:
> On Wed, 19 Mar 2008, Greg KH wrote:
>
> > On Wed, Mar 19, 2008 at 11:48:29AM -0700, Andrew Morton wrote:
> > > I'll drop everything, let's start again.
> > >
> > > Only how? umm, please review Greg's driver tree, let us know which patches
> > > shoudl be dropped from that then send new ones, I guess.
> >
> > Yes, please do, I'm confused as well :)
>
> Okay. No doubt Rafael will correct me if I get something wrong.
>
> Greg's tree still contains the original, wrong version of
> pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch. It
> should be reverted. In its place should be substituted this series of
> patches (URLs for 0/3 ... 3/3):
>
> http://marc.info/?l=linux-kernel&m=120561808422302&w=2
> http://marc.info/?l=linux-kernel&m=120561808522316&w=2
> http://marc.info/?l=linux-kernel&m=120561808522322&w=2
> http://marc.info/?l=linux-kernel&m=120561808622328&w=2
>
> There is likely to be a conflict in applying the 2/3 patch, because its
> first hunk touches a region of code also affected by work Rafael has
> been doing. The important aspect of that hunk is that it moves the
> should_wakeup flag definition outside the region protected by "#ifdef
> CONFIG_PM_SLEEP".

I've just resent the three patches, rebased on top of the current tree.

Please double check if everytning is right.

Thanks,
Rafael

2008-03-19 23:26:49

by Greg KH

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Wed, Mar 19, 2008 at 11:48:29AM -0700, Andrew Morton wrote:
> I'll drop everything, let's start again.
>
> Only how? umm, please review Greg's driver tree, let us know which patches
> shoudl be dropped from that then send new ones, I guess.

Yes, please do, I'm confused as well :)

thanks,

greg k-h

2008-03-19 23:32:55

by Alan Stern

[permalink] [raw]
Subject: Re: + pm-convert-wakeup-flag-accessors-to-inline-functions-fix.patch added to -mm tree

On Wed, 19 Mar 2008, Rafael J. Wysocki wrote:

> I've just resent the three patches, rebased on top of the current tree.

Yep, our messages crossed each other.

> Please double check if everytning is right.

It is.

Alan Stern

2008-03-19 23:52:33

by David Brownell

[permalink] [raw]
Subject: Re: [linux-pm] [PATCH 2/3] PM: Make wakeup flags available whenever CONFIG_PM is set (ver 2)

On Wednesday 19 March 2008, Rafael J. Wysocki wrote:
> From: Alan Stern <[email protected]>
>
> The various wakeup flags and their accessor macros in struct
> dev_pm_info should be available whenever CONFIG_PM is enabled, not
> just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always
> be configurable for runtime power management. This patch (as1056b)
> fixes the oversight.

More accurately, fixes the "regression" ... as noted sometime
last summer, after 296699de6bdc717189a331ab6bbe90e05c94db06
introduced CONFIG_SUSPEND. But that didn't make the regression
list for that kernel, ergo the delay in fixing it.

- Dave


> [rjw: rebased]
>
> Signed-off-by: Alan Stern <[email protected]>
> Signed-off-by: Rafael J. Wysocki <[email protected]>
> ---
> drivers/base/power/main.c | 2 --
> drivers/base/power/sysfs.c | 2 ++
> include/linux/pm.h | 36 +++++++++++++++++++++---------------
> 3 files changed, 23 insertions(+), 17 deletions(-)
>
> Index: linux-2.6/include/linux/pm.h
> ===================================================================
> --- linux-2.6.orig/include/linux/pm.h
> +++ linux-2.6/include/linux/pm.h
> @@ -183,9 +183,9 @@ typedef struct pm_message {
> struct dev_pm_info {
> pm_message_t power_state;
> unsigned can_wakeup:1;
> + unsigned should_wakeup:1;
> bool sleeping:1; /* Owned by the PM core */
> #ifdef CONFIG_PM_SLEEP
> - unsigned should_wakeup:1;
> struct list_head entry;
> #endif
> };
> @@ -198,11 +198,6 @@ extern void device_resume(void);
> extern int device_suspend(pm_message_t state);
> extern int device_prepare_suspend(pm_message_t state);
>
> -#define device_set_wakeup_enable(dev,val) \
> - ((dev)->power.should_wakeup = !!(val))
> -#define device_may_wakeup(dev) \
> - (device_can_wakeup(dev) && (dev)->power.should_wakeup)
> -
> extern void __suspend_report_result(const char *function, void *fn, int ret);
>
> #define suspend_report_result(fn, ret) \
> @@ -210,6 +205,24 @@ extern void __suspend_report_result(cons
> __suspend_report_result(__FUNCTION__, fn, ret); \
> } while (0)
>
> +#else /* !CONFIG_PM_SLEEP */
> +
> +static inline int device_suspend(pm_message_t state)
> +{
> + return 0;
> +}
> +
> +#define suspend_report_result(fn, ret) do { } while (0)
> +
> +#endif /* !CONFIG_PM_SLEEP */
> +
> +#ifdef CONFIG_PM
> +
> +#define device_set_wakeup_enable(dev,val) \
> + ((dev)->power.should_wakeup = !!(val))
> +#define device_may_wakeup(dev) \
> + (device_can_wakeup(dev) && (dev)->power.should_wakeup)
> +
> /*
> * Platform hook to activate device wakeup capability, if that's not already
> * handled by enable_irq_wake() etc.
> @@ -224,24 +237,17 @@ static inline int call_platform_enable_w
> return 0;
> }
>
> -#else /* !CONFIG_PM_SLEEP */
> -
> -static inline int device_suspend(pm_message_t state)
> -{
> - return 0;
> -}
> +#else /* !CONFIG_PM */
>
> #define device_set_wakeup_enable(dev,val) do{}while(0)
> #define device_may_wakeup(dev) (0)
>
> -#define suspend_report_result(fn, ret) do { } while (0)
> -
> static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
> {
> return 0;
> }
>
> -#endif /* !CONFIG_PM_SLEEP */
> +#endif /* !CONFIG_PM */
>
> /* changes to device_may_wakeup take effect on the next pm state change.
> * by default, devices should wakeup if they can.
> Index: linux-2.6/drivers/base/power/main.c
> ===================================================================
> --- linux-2.6.orig/drivers/base/power/main.c
> +++ linux-2.6/drivers/base/power/main.c
> @@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);
> /* 'true' if all devices have been suspended, protected by dpm_list_mtx */
> static bool all_sleeping;
>
> -int (*platform_enable_wakeup)(struct device *dev, int is_on);
> -
> /**
> * device_pm_add - add a device to the list of active devices
> * @dev: Device to be added to the list
> Index: linux-2.6/drivers/base/power/sysfs.c
> ===================================================================
> --- linux-2.6.orig/drivers/base/power/sysfs.c
> +++ linux-2.6/drivers/base/power/sysfs.c
> @@ -6,6 +6,8 @@
> #include <linux/string.h>
> #include "power.h"
>
> +int (*platform_enable_wakeup)(struct device *dev, int is_on);
> +
>
> /*
> * wakeup - Report/change current wakeup option for device
>
> _______________________________________________
> linux-pm mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/linux-pm
>

2008-03-20 23:24:19

by Greg KH

[permalink] [raw]
Subject: patch pm-convert-wakeup-flag-accessors-to-inline-functions.patch added to gregkh-2.6 tree


This is a note to let you know that I've just added the patch titled

Subject: PM: Convert wakeup flag accessors to inline functions

to my gregkh-2.6 tree. Its filename is

pm-convert-wakeup-flag-accessors-to-inline-functions.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From [email protected] Thu Mar 20 16:21:39 2008
From: Alan Stern <[email protected]>
Date: Wed, 19 Mar 2008 22:39:13 +0100
Subject: PM: Convert wakeup flag accessors to inline functions
To: Greg KH <[email protected]>
Cc: Andrew Morton <[email protected]>, Alan Stern <[email protected]>, Linux-pm mailing list <[email protected]>, Kernel development list <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Disposition: inline

From: Alan Stern <[email protected]>

This patch (as1058) improves the wakeup macros in include/linux/pm.h.
All but the trivial ones are converted to inline routines, which
requires moving them to a separate header file since they depend on
the definition of struct device.

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
include/linux/device.h | 3 +
include/linux/pm.h | 46 -----------------------
include/linux/pm_wakeup.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 45 deletions(-)

--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -475,6 +475,9 @@ struct device {
void (*release)(struct device *dev);
};

+/* Get the wakeup routines, which depend on struct device */
+#include <linux/pm_wakeup.h>
+
#ifdef CONFIG_NUMA
static inline int dev_to_node(struct device *dev)
{
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -212,54 +212,10 @@ static inline int device_suspend(pm_mess
return 0;
}

-#define suspend_report_result(fn, ret) do { } while (0)
+#define suspend_report_result(fn, ret) do {} while (0)

#endif /* !CONFIG_PM_SLEEP */

-#ifdef CONFIG_PM
-
-#define device_set_wakeup_enable(dev,val) \
- ((dev)->power.should_wakeup = !!(val))
-#define device_may_wakeup(dev) \
- (device_can_wakeup(dev) && (dev)->power.should_wakeup)
-
-/*
- * Platform hook to activate device wakeup capability, if that's not already
- * handled by enable_irq_wake() etc.
- * Returns zero on success, else negative errno
- */
-extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
-static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
-{
- if (platform_enable_wakeup)
- return (*platform_enable_wakeup)(dev, is_on);
- return 0;
-}
-
-#else /* !CONFIG_PM */
-
-#define device_set_wakeup_enable(dev,val) do{}while(0)
-#define device_may_wakeup(dev) (0)
-
-static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
-{
- return 0;
-}
-
-#endif /* !CONFIG_PM */
-
-/* changes to device_may_wakeup take effect on the next pm state change.
- * by default, devices should wakeup if they can.
- */
-#define device_can_wakeup(dev) \
- ((dev)->power.can_wakeup)
-#define device_init_wakeup(dev,val) \
- do { \
- device_can_wakeup(dev) = !!(val); \
- device_set_wakeup_enable(dev,val); \
- } while(0)
-
/*
* Global Power Management flags
* Used to keep APM and ACPI from both being active
--- /dev/null
+++ b/include/linux/pm_wakeup.h
@@ -0,0 +1,90 @@
+/*
+ * pm_wakeup.h - Power management wakeup interface
+ *
+ * Copyright (C) 2008 Alan Stern
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _LINUX_PM_WAKEUP_H
+#define _LINUX_PM_WAKEUP_H
+
+#ifndef _DEVICE_H_
+# error "please don't include this file directly"
+#endif
+
+#ifdef CONFIG_PM
+
+/* changes to device_may_wakeup take effect on the next pm state change.
+ * by default, devices should wakeup if they can.
+ */
+static inline void device_init_wakeup(struct device *dev, int val)
+{
+ dev->power.can_wakeup = dev->power.should_wakeup = !!val;
+}
+
+static inline int device_can_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup;
+}
+
+static inline void device_set_wakeup_enable(struct device *dev, int val)
+{
+ dev->power.should_wakeup = !!val;
+}
+
+static inline int device_may_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup & dev->power.should_wakeup;
+}
+
+/*
+ * Platform hook to activate device wakeup capability, if that's not already
+ * handled by enable_irq_wake() etc.
+ * Returns zero on success, else negative errno
+ */
+extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
+
+static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
+{
+ if (platform_enable_wakeup)
+ return (*platform_enable_wakeup)(dev, is_on);
+ return 0;
+}
+
+#else /* !CONFIG_PM */
+
+/* For some reason the next two routines work even without CONFIG_PM */
+static inline void device_init_wakeup(struct device *dev, int val)
+{
+ dev->power.can_wakeup = !!val;
+}
+
+static inline int device_can_wakeup(struct device *dev)
+{
+ return dev->power.can_wakeup;
+}
+
+#define device_set_wakeup_enable(dev, val) do {} while (0)
+#define device_may_wakeup(dev) 0
+
+static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
+{
+ return 0;
+}
+
+#endif /* !CONFIG_PM */
+
+#endif /* _LINUX_PM_WAKEUP_H */


Patches currently in gregkh-2.6 which might be from [email protected] are

usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch
usb/usb-make-usb_storage_onetouch-available-with-pm.patch
usb/usb-usb-ohci-sm501-driver-use-the-conventional-convention-for-suspend-and-resume.patch
usb/usb-reorganize-code-in-hub.c.patch
usb/usb-ehci-carry-out-port-handover-during-each-root-hub-resume.patch
usb/usb-new-quirk-flag-to-avoid-set-interface.patch
usb/drivers-usb-core-devio.c-suppress-warning-with-64k-page_size.patch
usb/usb-make-usb-persist-work-after-every-system-sleep.patch
usb/usb-remove-config_usb_persist-setting.patch
usb/usb-check-serial-number-string-after-device-reset.patch
usb/usb-enable-usb-persist-by-default.patch
usb/usb-remove-dev-power.power_state.patch
usb/usb-isd200-fix-memory-leak-in-isd200_get_inquiry_data.patch
usb/usb-remove-experimental-tags-from-some-usb-gadget-kconfig-entries.patch
driver-core/pm-handle-device-registrations-during-suspend-resume.patch
driver-core/pm-convert-wakeup-flag-accessors-to-inline-functions.patch
driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
driver-core/pm-fix-misuse-of-wakeup-flag-accessors-in-serial-core.patch
driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch

2008-03-20 23:24:34

by Greg KH

[permalink] [raw]
Subject: patch pm-fix-misuse-of-wakeup-flag-accessors-in-serial-core.patch added to gregkh-2.6 tree


This is a note to let you know that I've just added the patch titled

Subject: PM: Fix misuse of wakeup flag accessors in serial core

to my gregkh-2.6 tree. Its filename is

pm-fix-misuse-of-wakeup-flag-accessors-in-serial-core.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From [email protected] Thu Mar 20 16:20:16 2008
From: Alan Stern <[email protected]>
Date: Wed, 19 Mar 2008 22:35:13 +0100
Subject: PM: Fix misuse of wakeup flag accessors in serial core
To: Greg KH <[email protected]>
Cc: Andrew Morton <[email protected]>, Alan Stern <[email protected]>, Linux-pm mailing list <[email protected]>, Kernel development list <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Disposition: inline


From: Alan Stern <[email protected]>

This patch (as1059) fixes a mistake in the way the serial core
initializes a device's wakeup settings. It should use the accessor
routine instead of relying on a macro producing an lvalue.

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
drivers/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2356,7 +2356,7 @@ int uart_add_one_port(struct uart_driver
*/
tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev);
if (likely(!IS_ERR(tty_dev))) {
- device_can_wakeup(tty_dev) = 1;
+ device_init_wakeup(tty_dev, 1);
device_set_wakeup_enable(tty_dev, 0);
} else
printk(KERN_ERR "Cannot register tty device on line %d\n",


Patches currently in gregkh-2.6 which might be from [email protected] are

usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch
usb/usb-make-usb_storage_onetouch-available-with-pm.patch
usb/usb-usb-ohci-sm501-driver-use-the-conventional-convention-for-suspend-and-resume.patch
usb/usb-reorganize-code-in-hub.c.patch
usb/usb-ehci-carry-out-port-handover-during-each-root-hub-resume.patch
usb/usb-new-quirk-flag-to-avoid-set-interface.patch
usb/drivers-usb-core-devio.c-suppress-warning-with-64k-page_size.patch
usb/usb-make-usb-persist-work-after-every-system-sleep.patch
usb/usb-remove-config_usb_persist-setting.patch
usb/usb-check-serial-number-string-after-device-reset.patch
usb/usb-enable-usb-persist-by-default.patch
usb/usb-remove-dev-power.power_state.patch
usb/usb-isd200-fix-memory-leak-in-isd200_get_inquiry_data.patch
usb/usb-remove-experimental-tags-from-some-usb-gadget-kconfig-entries.patch
driver-core/pm-handle-device-registrations-during-suspend-resume.patch
driver-core/pm-convert-wakeup-flag-accessors-to-inline-functions.patch
driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
driver-core/pm-fix-misuse-of-wakeup-flag-accessors-in-serial-core.patch
driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch

2008-03-20 23:24:51

by Greg KH

[permalink] [raw]
Subject: patch pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch added to gregkh-2.6 tree


This is a note to let you know that I've just added the patch titled

Subject: PM: Make wakeup flags available whenever CONFIG_PM is set

to my gregkh-2.6 tree. Its filename is

pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From [email protected] Thu Mar 20 16:20:59 2008
From: Alan Stern <[email protected]>
Date: Wed, 19 Mar 2008 22:37:42 +0100
Subject: PM: Make wakeup flags available whenever CONFIG_PM is set
To: Greg KH <[email protected]>
Cc: Andrew Morton <[email protected]>, Alan Stern <[email protected]>, Linux-pm mailing list <[email protected]>, Kernel development list <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Disposition: inline


From: Alan Stern <[email protected]>

The various wakeup flags and their accessor macros in struct
dev_pm_info should be available whenever CONFIG_PM is enabled, not
just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always
be configurable for runtime power management. This patch (as1056b)
fixes the oversight.

David Brownell adds:
More accurately, fixes the "regression" ... as noted sometime
last summer, after 296699de6bdc717189a331ab6bbe90e05c94db06
introduced CONFIG_SUSPEND. But that didn't make the regression
list for that kernel, ergo the delay in fixing it.

[rjw: rebased]

Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
drivers/base/power/main.c | 2 --
drivers/base/power/sysfs.c | 2 ++
include/linux/pm.h | 36 +++++++++++++++++++++---------------
3 files changed, 23 insertions(+), 17 deletions(-)

--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);
/* 'true' if all devices have been suspended, protected by dpm_list_mtx */
static bool all_sleeping;

-int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
/**
* device_pm_add - add a device to the list of active devices
* @dev: Device to be added to the list
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -6,6 +6,8 @@
#include <linux/string.h>
#include "power.h"

+int (*platform_enable_wakeup)(struct device *dev, int is_on);
+

/*
* wakeup - Report/change current wakeup option for device
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -183,9 +183,9 @@ typedef struct pm_message {
struct dev_pm_info {
pm_message_t power_state;
unsigned can_wakeup:1;
+ unsigned should_wakeup:1;
bool sleeping:1; /* Owned by the PM core */
#ifdef CONFIG_PM_SLEEP
- unsigned should_wakeup:1;
struct list_head entry;
#endif
};
@@ -198,11 +198,6 @@ extern void device_resume(void);
extern int device_suspend(pm_message_t state);
extern int device_prepare_suspend(pm_message_t state);

-#define device_set_wakeup_enable(dev,val) \
- ((dev)->power.should_wakeup = !!(val))
-#define device_may_wakeup(dev) \
- (device_can_wakeup(dev) && (dev)->power.should_wakeup)
-
extern void __suspend_report_result(const char *function, void *fn, int ret);

#define suspend_report_result(fn, ret) \
@@ -210,6 +205,24 @@ extern void __suspend_report_result(cons
__suspend_report_result(__FUNCTION__, fn, ret); \
} while (0)

+#else /* !CONFIG_PM_SLEEP */
+
+static inline int device_suspend(pm_message_t state)
+{
+ return 0;
+}
+
+#define suspend_report_result(fn, ret) do { } while (0)
+
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+
+#define device_set_wakeup_enable(dev,val) \
+ ((dev)->power.should_wakeup = !!(val))
+#define device_may_wakeup(dev) \
+ (device_can_wakeup(dev) && (dev)->power.should_wakeup)
+
/*
* Platform hook to activate device wakeup capability, if that's not already
* handled by enable_irq_wake() etc.
@@ -224,24 +237,17 @@ static inline int call_platform_enable_w
return 0;
}

-#else /* !CONFIG_PM_SLEEP */
-
-static inline int device_suspend(pm_message_t state)
-{
- return 0;
-}
+#else /* !CONFIG_PM */

#define device_set_wakeup_enable(dev,val) do{}while(0)
#define device_may_wakeup(dev) (0)

-#define suspend_report_result(fn, ret) do { } while (0)
-
static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
{
return 0;
}

-#endif /* !CONFIG_PM_SLEEP */
+#endif /* !CONFIG_PM */

/* changes to device_may_wakeup take effect on the next pm state change.
* by default, devices should wakeup if they can.


Patches currently in gregkh-2.6 which might be from [email protected] are

usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch
usb/usb-make-usb_storage_onetouch-available-with-pm.patch
usb/usb-usb-ohci-sm501-driver-use-the-conventional-convention-for-suspend-and-resume.patch
usb/usb-reorganize-code-in-hub.c.patch
usb/usb-ehci-carry-out-port-handover-during-each-root-hub-resume.patch
usb/usb-new-quirk-flag-to-avoid-set-interface.patch
usb/drivers-usb-core-devio.c-suppress-warning-with-64k-page_size.patch
usb/usb-make-usb-persist-work-after-every-system-sleep.patch
usb/usb-remove-config_usb_persist-setting.patch
usb/usb-check-serial-number-string-after-device-reset.patch
usb/usb-enable-usb-persist-by-default.patch
usb/usb-remove-dev-power.power_state.patch
usb/usb-isd200-fix-memory-leak-in-isd200_get_inquiry_data.patch
usb/usb-remove-experimental-tags-from-some-usb-gadget-kconfig-entries.patch
driver-core/pm-handle-device-registrations-during-suspend-resume.patch
driver-core/pm-convert-wakeup-flag-accessors-to-inline-functions.patch
driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
driver-core/pm-fix-misuse-of-wakeup-flag-accessors-in-serial-core.patch
driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch