* [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework
@ 2007-07-17 20:36 Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:36 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
Hi,
This series of patches implements changes that are possible/necessary/desirable
(IMO) after the introduction of the .set_target() method in 'struct pm_ops' (commit
2391dae3e36c19fe668c71eac2eb8344dbaaf46d).
The patches in the series make the following changes:
* make ACPI use the new .set_target() method in 'struct pm_ops'
* add an ACPI helper function for the devices to determine the power state
to put the device into
* move the definition of 'struct pm_ops' to <include/suspend.h>
* change the name of 'struct pm_ops' to 'struct platform_suspend_ops' and
modify the names of some related functions and global variables accordingly
* modify 'struct platform_suspend_ops' so that .prepare() and .finish() don't
take arguments (.enter() still takes the state argument, because some
platforms don't need to implement the other callbacks)
* make some functions normally defined in kernel/power/main.c be also defined
when CONFIG_PM is unset
* make suspend_ops be a static variable
* rework 'struct hibernation_ops' to add the new method analogous to
.set_target()
* rename 'struct hibernation_ops' to 'struct platform_hibernation_ops' (in
analogy with 'struct platform_suspend_ops')
The series in on top of the current -git with the following patches, currently
in -mm or in the ACPI tree, applied:
swsusp-remove-incorrect-code-from-userc.patch
swsusp-remove-code-duplication-between-diskc-and-userc.patch
swsusp-introduce-restore-platform-operations.patch
swsusp-fix-hibernation-code-ordering.patch
hibernation-prepare-to-enter-the-low-power-state.patch
pm-introduce-hibernation-and-suspend-notifiers.patch
acpi-do-not-attempt-to-run-s1-standby-workarounds-while-hibernating.patch
pm-reduce-code-duplication-between-mainc-and-userc-updated.patch
Greetings,
Rafael
--
"Premature optimization is the root of all evil." - Donald Knuth
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
@ 2007-07-17 20:40 ` Rafael J. Wysocki
2007-07-18 0:02 ` Andrew Morton
2007-07-21 19:26 ` David Brownell
2007-07-17 20:40 ` [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine Rafael J. Wysocki
` (7 subsequent siblings)
8 siblings, 2 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:40 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
In the future some drivers may need to use ACPI to determine the low power
states in which to place their devices, but to provide the drivers with this
information the ACPI core needs to know what sleep state the system is going to
enter. Namely, the device's state should not be too high power for given system
sleep state and, if the device is supposed to be able to wake up the system, its
state should not be too low power for the wake up to be possible). For this
purpose, the ACPI core needs to implement the set_target() method in 'struct
pm_ops' and store the target system sleep state passed by the PM core in a
variable.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/acpi/sleep/main.c | 84 ++++++++++++++++++++++++++++------------------
1 file changed, 52 insertions(+), 32 deletions(-)
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
static int init_8259A_after_S1;
+extern int acpi_sleep_prepare(u32 acpi_state);
+extern void acpi_power_off(void);
+
+static u32 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ * acpi_pm_set_target - Set the target system sleep state to the state
+ * associated with given @pm_state, if supported.
+ */
+
+static int acpi_pm_set_target(suspend_state_t pm_state)
+{
+ u32 acpi_state = acpi_suspend_states[pm_state];
+ int error = 0;
+
+ if (sleep_states[acpi_state]) {
+ acpi_target_sleep_state = acpi_state;
+ } else {
+ printk(KERN_ERR "ACPI does not support this state: %d\n",
+ pm_state);
+ error = -ENOSYS;
+ }
+ return error;
+}
+
/**
* acpi_pm_prepare - Do preliminary suspend work.
- * @pm_state: suspend state we're entering.
+ * @pm_state: ignored
*
- * Make sure we support the state. If we do, and we need it, set the
- * firmware waking vector and do arch-specific nastiness to get the
- * wakeup code to the waking vector.
+ * If necessary, set the firmware waking vector and do arch-specific
+ * nastiness to get the wakeup code to the waking vector.
*/
-extern int acpi_sleep_prepare(u32 acpi_state);
-extern void acpi_power_off(void);
-
static int acpi_pm_prepare(suspend_state_t pm_state)
{
- u32 acpi_state = acpi_suspend_states[pm_state];
+ int error = acpi_sleep_prepare(acpi_target_sleep_state);
- if (!sleep_states[acpi_state]) {
- printk("acpi_pm_prepare does not support %d \n", pm_state);
- return -EPERM;
- }
- return acpi_sleep_prepare(acpi_state);
+ if (error)
+ acpi_target_sleep_state = ACPI_STATE_S0;
+
+ return error;
}
/**
* acpi_pm_enter - Actually enter a sleep state.
- * @pm_state: State we're entering.
+ * @pm_state: ignored
*
- * Flush caches and go to sleep. For STR or STD, we have to call
+ * Flush caches and go to sleep. For STR or S2, we have to call
* arch-specific assembly, which in turn call acpi_enter_sleep_state().
* It's unfortunate, but it works. Please fix if you're feeling frisky.
*/
@@ -70,31 +90,32 @@ static int acpi_pm_enter(suspend_state_t
{
acpi_status status = AE_OK;
unsigned long flags = 0;
- u32 acpi_state = acpi_suspend_states[pm_state];
+ u32 acpi_state = acpi_target_sleep_state;
ACPI_FLUSH_CPU_CACHE();
/* Do arch specific saving of state. */
- if (pm_state > PM_SUSPEND_STANDBY) {
+ if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3) {
int error = acpi_save_state_mem();
- if (error)
+
+ if (error) {
+ acpi_target_sleep_state = ACPI_STATE_S0;
return error;
+ }
}
local_irq_save(flags);
acpi_enable_wakeup_device(acpi_state);
- switch (pm_state) {
- case PM_SUSPEND_STANDBY:
+ switch (acpi_state) {
+ case ACPI_STATE_S1:
barrier();
status = acpi_enter_sleep_state(acpi_state);
break;
- case PM_SUSPEND_MEM:
+ case ACPI_STATE_S2:
+ case ACPI_STATE_S3:
do_suspend_lowlevel();
break;
-
- default:
- return -EINVAL;
}
/* ACPI 3.0 specs (P62) says that it's the responsabilty
@@ -107,12 +128,8 @@ static int acpi_pm_enter(suspend_state_t
local_irq_restore(flags);
printk(KERN_DEBUG "Back to C!\n");
- /* restore processor state
- * We should only be here if we're coming back from STR or STD.
- * And, in the case of the latter, the memory image should have already
- * been loaded from disk.
- */
- if (pm_state > PM_SUSPEND_STANDBY)
+ /* restore processor state */
+ if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3)
acpi_restore_state_mem();
return ACPI_SUCCESS(status) ? 0 : -EFAULT;
@@ -120,7 +137,7 @@ static int acpi_pm_enter(suspend_state_t
/**
* acpi_pm_finish - Finish up suspend sequence.
- * @pm_state: State we're coming out of.
+ * @pm_state: ignored
*
* This is called after we wake back up (or if entering the sleep state
* failed).
@@ -128,7 +145,7 @@ static int acpi_pm_enter(suspend_state_t
static int acpi_pm_finish(suspend_state_t pm_state)
{
- u32 acpi_state = acpi_suspend_states[pm_state];
+ u32 acpi_state = acpi_target_sleep_state;
acpi_leave_sleep_state(acpi_state);
acpi_disable_wakeup_device(acpi_state);
@@ -136,6 +153,8 @@ static int acpi_pm_finish(suspend_state_
/* reset firmware waking vector */
acpi_set_firmware_waking_vector((acpi_physical_address) 0);
+ acpi_target_sleep_state = ACPI_STATE_S0;
+
if (init_8259A_after_S1) {
printk("Broken toshiba laptop -> kicking interrupts\n");
init_8259A(0);
@@ -176,6 +195,7 @@ static int acpi_pm_state_valid(suspend_s
static struct pm_ops acpi_pm_ops = {
.valid = acpi_pm_state_valid,
+ .set_target = acpi_pm_set_target,
.prepare = acpi_pm_prepare,
.enter = acpi_pm_enter,
.finish = acpi_pm_finish,
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
@ 2007-07-17 20:40 ` Rafael J. Wysocki
2007-07-22 9:00 ` Len Brown
2007-07-17 20:42 ` [Resend][PATCH 3/9] PM: Move definition of struct pm_ops to suspend.h Rafael J. Wysocki
` (6 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:40 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Shaohua Li <shaohua.li@intel.com>, Rafael J. Wysocki <rjw@sisk.pl>
Based on the David Brownell's patch at
http://marc.info/?l=linux-acpi&m=117873972806360&w=2
Add a helper routine returning the lowest power (highest number) ACPI device
power state that given device can be in while the system is in the sleep state
indicated by acpi_target_sleep_state .
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/acpi/sleep/main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
include/acpi/acpi_bus.h | 2 +
2 files changed, 77 insertions(+)
Index: linux-2.6.22-git9/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git9.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git9/drivers/acpi/sleep/main.c
@@ -255,6 +255,81 @@ static struct hibernation_ops acpi_hiber
};
#endif /* CONFIG_SOFTWARE_SUSPEND */
+/**
+ * acpi_pm_device_sleep_state - return preferred power state of ACPI device
+ * in the system sleep state given by %acpi_target_sleep_state
+ * @dev: device to examine
+ * @wake: if set, the device should be able to wake up the system
+ * @d_min_p: used to store the upper limit of allowed states range
+ * Return value: preferred power state of the device on success, -ENODEV on
+ * failure (ie. if there's no 'struct acpi_device' for @dev)
+ *
+ * Find the lowest power (highest number) ACPI device power state that
+ * device @dev can be in while the system is in the sleep state represented
+ * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
+ * able to wake up the system from this sleep state. If @d_min_p is set,
+ * the highest power (lowest number) device power state of @dev allowed
+ * in this system sleep state is stored at the location pointed to by it.
+ *
+ * The caller must ensure that @dev is valid before using this function.
+ * The caller is also responsible for figuring out if the device is
+ * supposed to be able to wake up the system and passing this information
+ * via @wake.
+ */
+
+int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
+{
+ acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
+ struct acpi_device *adev;
+ char acpi_method[] = "_SxD";
+ unsigned long d_min, d_max;
+
+ if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
+ printk(KERN_ERR "ACPI handle has no context!\n");
+ return -ENODEV;
+ }
+
+ acpi_method[2] = '0' + acpi_target_sleep_state;
+ /*
+ * If the sleep state is S0, we will return D3, but if the device has
+ * _S0W, we will use the value from _S0W
+ */
+ d_min = ACPI_STATE_D0;
+ d_max = ACPI_STATE_D3;
+
+ /*
+ * If present, _SxD methods return the minimum D-state (highest power
+ * state) we can use for the corresponding S-states. Otherwise, the
+ * minimum D-state is D0 (ACPI 3.x).
+ *
+ * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
+ * provided -- that's our fault recovery, we ignore retval.
+ */
+ if (acpi_target_sleep_state > ACPI_STATE_S0)
+ acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
+
+ /*
+ * If _PRW says we can wake up the system from the target sleep state,
+ * the D-state returned by _SxD is sufficient for that (we assume a
+ * wakeup-aware driver if wake is set). Still, if _SxW exists
+ * (ACPI 3.x), it should return the maximum (lowest power) D-state that
+ * can wake the system. _S0W may be valid, too.
+ */
+ if (acpi_target_sleep_state == ACPI_STATE_S0 ||
+ (wake && adev->wakeup.state.enabled &&
+ adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
+ acpi_method[3] = 'W';
+ acpi_evaluate_integer(handle, acpi_method, NULL, &d_max);
+ /* Sanity check */
+ if (d_max < d_min)
+ d_min = d_max;
+ }
+
+ if (d_min_p)
+ *d_min_p = d_min;
+ return d_max;
+}
+
/*
* Toshiba fails to preserve interrupts over S1, reinitialization
* of 8259 is needed after S1 resume.
Index: linux-2.6.22-git9/include/acpi/acpi_bus.h
===================================================================
--- linux-2.6.22-git9.orig/include/acpi/acpi_bus.h
+++ linux-2.6.22-git9/include/acpi/acpi_bus.h
@@ -364,6 +364,8 @@ acpi_handle acpi_get_child(acpi_handle,
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
+int acpi_pm_device_sleep_state(struct device *, int, int *);
+
#endif /* CONFIG_ACPI */
#endif /*__ACPI_BUS_H__*/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 3/9] PM: Move definition of struct pm_ops to suspend.h
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine Rafael J. Wysocki
@ 2007-07-17 20:42 ` Rafael J. Wysocki
2007-07-17 20:43 ` [Resend][PATCH 4/9] PM: Rename struct pm_ops and related things Rafael J. Wysocki
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:42 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
Move the definition of 'struct pm_ops' and related functions from <linux/pm.h>
to <linux/suspend.h> .
There are, at least, the following reasons to do that:
* 'struct pm_ops' is specifically related to suspend and not to the power
management in general.
* As long as 'struct pm_ops' is defined in <linux/pm.h>, any modification of it
causes the entire kernel to be recompiled, which is unnecessary and annoying.
* Some suspend-related features are already defined in <linux/suspend.h>, so it
is logical to move the definition of 'struct pm_ops' into there.
* 'struct hibernation_ops', being the hibernation-related counterpart of
'struct pm_ops', is defined in <linux/suspend.h> .
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
arch/arm/common/sharpsl_pm.c | 1
arch/arm/mach-at91/pm.c | 3
arch/arm/mach-omap1/pm.c | 3
arch/arm/mach-omap2/pm.c | 9 --
arch/arm/mach-pnx4008/pm.c | 2
arch/arm/mach-pxa/pxa25x.c | 2
arch/arm/mach-pxa/pxa27x.c | 2
arch/blackfin/mach-common/pm.c | 2
arch/powerpc/platforms/52xx/mpc52xx_pm.c | 2
drivers/char/apm-emulation.c | 2
include/asm-arm/arch-pxa/pm.h | 2
include/linux/pm.h | 91 ------------------------
include/linux/suspend.h | 113 +++++++++++++++++++++++++++----
13 files changed, 114 insertions(+), 120 deletions(-)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -1,5 +1,5 @@
-#ifndef _LINUX_SWSUSP_H
-#define _LINUX_SWSUSP_H
+#ifndef _LINUX_SUSPEND_H
+#define _LINUX_SUSPEND_H
#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
#include <asm/suspend.h>
@@ -10,6 +10,105 @@
#include <linux/pm.h>
#include <linux/mm.h>
+#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+extern int pm_prepare_console(void);
+extern void pm_restore_console(void);
+#else
+static inline int pm_prepare_console(void) { return 0; }
+static inline void pm_restore_console(void) {}
+#endif
+
+typedef int __bitwise suspend_state_t;
+
+#define PM_SUSPEND_ON ((__force suspend_state_t) 0)
+#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1)
+#define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
+#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
+
+/**
+ * struct pm_ops - Callbacks for managing platform dependent system sleep
+ * states.
+ *
+ * @valid: Callback to determine if given system sleep state is supported by
+ * the platform.
+ * Valid (ie. supported) states are advertised in /sys/power/state. Note
+ * that it still may be impossible to enter given system sleep state if the
+ * conditions aren't right.
+ * There is the %pm_valid_only_mem function available that can be assigned
+ * to this if the platform only supports mem sleep.
+ *
+ * @set_target: Tell the platform which system sleep state is going to be
+ * entered.
+ * @set_target() is executed right prior to suspending devices. The
+ * information conveyed to the platform code by @set_target() should be
+ * disregarded by the platform as soon as @finish() is executed and if
+ * @prepare() fails. If @set_target() fails (ie. returns nonzero),
+ * @prepare(), @enter() and @finish() will not be called by the PM core.
+ * This callback is optional. However, if it is implemented, the argument
+ * passed to @prepare(), @enter() and @finish() is meaningless and should
+ * be ignored.
+ *
+ * @prepare: Prepare the platform for entering the system sleep state indicated
+ * by @set_target() or represented by the argument if @set_target() is not
+ * implemented.
+ * @prepare() is called right after devices have been suspended (ie. the
+ * appropriate .suspend() method has been executed for each device) and
+ * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
+ * This callback is optional. It returns 0 on success or a negative
+ * error code otherwise, in which case the system cannot enter the desired
+ * sleep state (@enter() and @finish() will not be called in that case).
+ *
+ * @enter: Enter the system sleep state indicated by @set_target() or
+ * represented by the argument if @set_target() is not implemented.
+ * This callback is mandatory. It returns 0 on success or a negative
+ * error code otherwise, in which case the system cannot enter the desired
+ * sleep state.
+ *
+ * @finish: Called when the system has just left a sleep state, right after
+ * the nonboot CPUs have been enabled and before devices are resumed (it is
+ * executed with IRQs enabled). If @set_target() is not implemented, the
+ * argument represents the sleep state being left.
+ * This callback is optional, but should be implemented by the platforms
+ * that implement @prepare(). If implemented, it is always called after
+ * @enter() (even if @enter() fails).
+ */
+struct pm_ops {
+ int (*valid)(suspend_state_t state);
+ int (*set_target)(suspend_state_t state);
+ int (*prepare)(suspend_state_t state);
+ int (*enter)(suspend_state_t state);
+ int (*finish)(suspend_state_t state);
+};
+
+extern struct pm_ops *pm_ops;
+
+/**
+ * pm_set_ops - set platform dependent power management ops
+ * @pm_ops: The new power management operations to set.
+ */
+extern void pm_set_ops(struct pm_ops *pm_ops);
+extern int pm_valid_only_mem(suspend_state_t state);
+
+/**
+ * arch_suspend_disable_irqs - disable IRQs for suspend
+ *
+ * Disables IRQs (in the default case). This is a weak symbol in the common
+ * code and thus allows architectures to override it if more needs to be
+ * done. Not called for suspend to disk.
+ */
+extern void arch_suspend_disable_irqs(void);
+
+/**
+ * arch_suspend_enable_irqs - enable IRQs after suspend
+ *
+ * Enables IRQs (in the default case). This is a weak symbol in the common
+ * code and thus allows architectures to override it if more needs to be
+ * done. Not called for suspend to disk.
+ */
+extern void arch_suspend_enable_irqs(void);
+
+extern int pm_suspend(suspend_state_t state);
+
/* struct pbe is used for creating lists of pages that should be restored
* atomically during the resume from disk, because the page frames they have
* occupied before the suspend are in use.
@@ -24,14 +123,6 @@ struct pbe {
extern void drain_local_pages(void);
extern void mark_free_pages(struct zone *zone);
-#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
-extern int pm_prepare_console(void);
-extern void pm_restore_console(void);
-#else
-static inline int pm_prepare_console(void) { return 0; }
-static inline void pm_restore_console(void) {}
-#endif
-
/**
* struct hibernation_ops - hibernation platform support
*
@@ -127,4 +218,4 @@ static inline void register_nosave_regio
}
#endif
-#endif /* _LINUX_SWSUSP_H */
+#endif /* _LINUX_SUSPEND_H */
Index: linux-2.6.22-git5/arch/arm/common/sharpsl_pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/common/sharpsl_pm.c
+++ linux-2.6.22-git5/arch/arm/common/sharpsl_pm.c
@@ -24,6 +24,7 @@
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/apm-emulation.h>
+#include <linux/suspend.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
Index: linux-2.6.22-git5/arch/arm/mach-pnx4008/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pnx4008/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-pnx4008/pm.c
@@ -15,7 +15,7 @@
#include <linux/rtc.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/delay.h>
#include <linux/clk.h>
Index: linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap1/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
@@ -35,10 +35,9 @@
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
-#include <linux/pm.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
Index: linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap2/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
@@ -16,10 +16,9 @@
* published by the Free Software Foundation.
*/
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
-#include <linux/pm.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
@@ -85,9 +84,6 @@ static int omap2_pm_prepare(suspend_stat
case PM_SUSPEND_MEM:
break;
- case PM_SUSPEND_DISK:
- return -ENOTSUPP;
-
default:
return -EINVAL;
}
@@ -353,9 +349,6 @@ static int omap2_pm_enter(suspend_state_
case PM_SUSPEND_MEM:
ret = omap2_pm_suspend();
break;
- case PM_SUSPEND_DISK:
- ret = -ENOTSUPP;
- break;
default:
ret = -EINVAL;
}
Index: linux-2.6.22-git5/arch/arm/mach-at91/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-at91/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-at91/pm.c
@@ -10,10 +10,9 @@
* (at your option) any later version.
*/
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
-#include <linux/pm.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
Index: linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/blackfin/mach-common/pm.c
+++ linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
@@ -32,7 +32,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
#include <linux/io.h>
Index: linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/powerpc/platforms/52xx/mpc52xx_pm.c
+++ linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
@@ -1,5 +1,5 @@
#include <linux/init.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/io.h>
#include <asm/time.h>
#include <asm/cacheflush.h>
Index: linux-2.6.22-git5/include/linux/pm.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/pm.h
+++ linux-2.6.22-git5/include/linux/pm.h
@@ -102,97 +102,6 @@ struct pm_dev
extern void (*pm_idle)(void);
extern void (*pm_power_off)(void);
-typedef int __bitwise suspend_state_t;
-
-#define PM_SUSPEND_ON ((__force suspend_state_t) 0)
-#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1)
-#define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
-#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
-
-/**
- * struct pm_ops - Callbacks for managing platform dependent system sleep
- * states.
- *
- * @valid: Callback to determine if given system sleep state is supported by
- * the platform.
- * Valid (ie. supported) states are advertised in /sys/power/state. Note
- * that it still may be impossible to enter given system sleep state if the
- * conditions aren't right.
- * There is the %pm_valid_only_mem function available that can be assigned
- * to this if the platform only supports mem sleep.
- *
- * @set_target: Tell the platform which system sleep state is going to be
- * entered.
- * @set_target() is executed right prior to suspending devices. The
- * information conveyed to the platform code by @set_target() should be
- * disregarded by the platform as soon as @finish() is executed and if
- * @prepare() fails. If @set_target() fails (ie. returns nonzero),
- * @prepare(), @enter() and @finish() will not be called by the PM core.
- * This callback is optional. However, if it is implemented, the argument
- * passed to @prepare(), @enter() and @finish() is meaningless and should
- * be ignored.
- *
- * @prepare: Prepare the platform for entering the system sleep state indicated
- * by @set_target() or represented by the argument if @set_target() is not
- * implemented.
- * @prepare() is called right after devices have been suspended (ie. the
- * appropriate .suspend() method has been executed for each device) and
- * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
- * This callback is optional. It returns 0 on success or a negative
- * error code otherwise, in which case the system cannot enter the desired
- * sleep state (@enter() and @finish() will not be called in that case).
- *
- * @enter: Enter the system sleep state indicated by @set_target() or
- * represented by the argument if @set_target() is not implemented.
- * This callback is mandatory. It returns 0 on success or a negative
- * error code otherwise, in which case the system cannot enter the desired
- * sleep state.
- *
- * @finish: Called when the system has just left a sleep state, right after
- * the nonboot CPUs have been enabled and before devices are resumed (it is
- * executed with IRQs enabled). If @set_target() is not implemented, the
- * argument represents the sleep state being left.
- * This callback is optional, but should be implemented by the platforms
- * that implement @prepare(). If implemented, it is always called after
- * @enter() (even if @enter() fails).
- */
-struct pm_ops {
- int (*valid)(suspend_state_t state);
- int (*set_target)(suspend_state_t state);
- int (*prepare)(suspend_state_t state);
- int (*enter)(suspend_state_t state);
- int (*finish)(suspend_state_t state);
-};
-
-extern struct pm_ops *pm_ops;
-
-/**
- * pm_set_ops - set platform dependent power management ops
- * @pm_ops: The new power management operations to set.
- */
-extern void pm_set_ops(struct pm_ops *pm_ops);
-extern int pm_valid_only_mem(suspend_state_t state);
-
-/**
- * arch_suspend_disable_irqs - disable IRQs for suspend
- *
- * Disables IRQs (in the default case). This is a weak symbol in the common
- * code and thus allows architectures to override it if more needs to be
- * done. Not called for suspend to disk.
- */
-extern void arch_suspend_disable_irqs(void);
-
-/**
- * arch_suspend_enable_irqs - enable IRQs after suspend
- *
- * Enables IRQs (in the default case). This is a weak symbol in the common
- * code and thus allows architectures to override it if more needs to be
- * done. Not called for suspend to disk.
- */
-extern void arch_suspend_enable_irqs(void);
-
-extern int pm_suspend(suspend_state_t state);
-
/*
* Device power management
*/
Index: linux-2.6.22-git5/arch/arm/mach-pxa/pxa25x.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pxa/pxa25x.c
+++ linux-2.6.22-git5/arch/arm/mach-pxa/pxa25x.c
@@ -20,7 +20,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <asm/hardware.h>
#include <asm/arch/irqs.h>
Index: linux-2.6.22-git5/arch/arm/mach-pxa/pxa27x.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pxa/pxa27x.c
+++ linux-2.6.22-git5/arch/arm/mach-pxa/pxa27x.c
@@ -14,7 +14,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/platform_device.h>
#include <asm/hardware.h>
Index: linux-2.6.22-git5/include/asm-arm/arch-pxa/pm.h
===================================================================
--- linux-2.6.22-git5.orig/include/asm-arm/arch-pxa/pm.h
+++ linux-2.6.22-git5/include/asm-arm/arch-pxa/pm.h
@@ -7,5 +7,7 @@
*
*/
+#include <linux/suspend.h>
+
extern int pxa_pm_prepare(suspend_state_t state);
extern int pxa_pm_enter(suspend_state_t state);
Index: linux-2.6.22-git5/drivers/char/apm-emulation.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/char/apm-emulation.c
+++ linux-2.6.22-git5/drivers/char/apm-emulation.c
@@ -18,7 +18,7 @@
#include <linux/apm_bios.h>
#include <linux/capability.h>
#include <linux/sched.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
#include <linux/apm-emulation.h>
#include <linux/freezer.h>
#include <linux/device.h>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 4/9] PM: Rename struct pm_ops and related things
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (2 preceding siblings ...)
2007-07-17 20:42 ` [Resend][PATCH 3/9] PM: Move definition of struct pm_ops to suspend.h Rafael J. Wysocki
@ 2007-07-17 20:43 ` Rafael J. Wysocki
2007-07-17 20:44 ` [Resend][PATCH 5/9] PM: Rework struct platform_suspend_ops Rafael J. Wysocki
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:43 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
The name of 'struct pm_ops' suggests that it is related to the power management
in general, but in fact it is only related to suspend. Moreover, its name
should indicate what this structure is used for, so it seems reasonable to
change it to 'struct platform_suspend_ops'. In that case, the name of
the global variable of this type used by the PM core and the names of related
functions should be changed accordingly.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Documentation/power/interface.txt | 2 -
arch/arm/common/sharpsl_pm.c | 8 +++----
arch/arm/mach-at91/pm.c | 4 +--
arch/arm/mach-omap1/pm.c | 6 ++---
arch/arm/mach-omap2/pm.c | 6 ++---
arch/arm/mach-pnx4008/pm.c | 4 +--
arch/arm/mach-pxa/pxa25x.c | 6 ++---
arch/arm/mach-pxa/pxa27x.c | 4 +--
arch/arm/mach-sa1100/pm.c | 6 ++---
arch/arm/plat-s3c24xx/pm.c | 6 ++---
arch/blackfin/mach-common/pm.c | 4 +--
arch/powerpc/platforms/52xx/mpc52xx_pm.c | 4 +--
arch/sh/boards/hp6xx/pm.c | 6 ++---
drivers/acpi/sleep/main.c | 6 ++---
include/linux/suspend.h | 20 +++++++++---------
kernel/power/main.c | 34 +++++++++++++++----------------
16 files changed, 63 insertions(+), 63 deletions(-)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -26,16 +26,16 @@ typedef int __bitwise suspend_state_t;
#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
/**
- * struct pm_ops - Callbacks for managing platform dependent system sleep
- * states.
+ * struct platform_suspend_ops - Callbacks for managing platform dependent
+ * system sleep states.
*
* @valid: Callback to determine if given system sleep state is supported by
* the platform.
* Valid (ie. supported) states are advertised in /sys/power/state. Note
* that it still may be impossible to enter given system sleep state if the
* conditions aren't right.
- * There is the %pm_valid_only_mem function available that can be assigned
- * to this if the platform only supports mem sleep.
+ * There is the %suspend_valid_only_mem function available that can be
+ * assigned to this if the platform only supports mem sleep.
*
* @set_target: Tell the platform which system sleep state is going to be
* entered.
@@ -72,7 +72,7 @@ typedef int __bitwise suspend_state_t;
* that implement @prepare(). If implemented, it is always called after
* @enter() (even if @enter() fails).
*/
-struct pm_ops {
+struct platform_suspend_ops {
int (*valid)(suspend_state_t state);
int (*set_target)(suspend_state_t state);
int (*prepare)(suspend_state_t state);
@@ -80,14 +80,14 @@ struct pm_ops {
int (*finish)(suspend_state_t state);
};
-extern struct pm_ops *pm_ops;
+extern struct platform_suspend_ops *suspend_ops;
/**
- * pm_set_ops - set platform dependent power management ops
- * @pm_ops: The new power management operations to set.
+ * suspend_set_ops - set platform dependent suspend operations
+ * @ops: The new suspend operations to set.
*/
-extern void pm_set_ops(struct pm_ops *pm_ops);
-extern int pm_valid_only_mem(suspend_state_t state);
+extern void suspend_set_ops(struct platform_suspend_ops *ops);
+extern int suspend_valid_only_mem(suspend_state_t state);
/**
* arch_suspend_disable_irqs - disable IRQs for suspend
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -21,7 +21,7 @@
u8 sleep_states[ACPI_S_STATE_COUNT];
-static struct pm_ops acpi_pm_ops;
+static struct platform_suspend_ops acpi_pm_ops;
extern void do_suspend_lowlevel(void);
@@ -193,7 +193,7 @@ static int acpi_pm_state_valid(suspend_s
}
}
-static struct pm_ops acpi_pm_ops = {
+static struct platform_suspend_ops acpi_pm_ops = {
.valid = acpi_pm_state_valid,
.set_target = acpi_pm_set_target,
.prepare = acpi_pm_prepare,
@@ -368,7 +368,7 @@ int __init acpi_sleep_init(void)
}
printk(")\n");
- pm_set_ops(&acpi_pm_ops);
+ suspend_set_ops(&acpi_pm_ops);
#ifdef CONFIG_SOFTWARE_SUSPEND
if (sleep_states[ACPI_STATE_S4])
Index: linux-2.6.22-git5/kernel/power/main.c
===================================================================
--- linux-2.6.22-git5.orig/kernel/power/main.c
+++ linux-2.6.22-git5/kernel/power/main.c
@@ -30,28 +30,28 @@ BLOCKING_NOTIFIER_HEAD(pm_chain_head);
DEFINE_MUTEX(pm_mutex);
-struct pm_ops *pm_ops;
+struct platform_suspend_ops *suspend_ops;
/**
- * pm_set_ops - Set the global power method table.
+ * suspend_set_ops - Set the global suspend method table.
* @ops: Pointer to ops structure.
*/
-void pm_set_ops(struct pm_ops * ops)
+void suspend_set_ops(struct platform_suspend_ops *ops)
{
mutex_lock(&pm_mutex);
- pm_ops = ops;
+ suspend_ops = ops;
mutex_unlock(&pm_mutex);
}
/**
- * pm_valid_only_mem - generic memory-only valid callback
+ * suspend_valid_only_mem - generic memory-only valid callback
*
- * pm_ops drivers that implement mem suspend only and only need
+ * Platform drivers that implement mem suspend only and only need
* to check for that in their .valid callback can use this instead
* of rolling their own .valid callback.
*/
-int pm_valid_only_mem(suspend_state_t state)
+int suspend_valid_only_mem(suspend_state_t state)
{
return state == PM_SUSPEND_MEM;
}
@@ -59,8 +59,8 @@ int pm_valid_only_mem(suspend_state_t st
static inline void pm_finish(suspend_state_t state)
{
- if (pm_ops->finish)
- pm_ops->finish(state);
+ if (suspend_ops->finish)
+ suspend_ops->finish(state);
}
/**
@@ -74,7 +74,7 @@ static int suspend_prepare(void)
int error;
unsigned int free_pages;
- if (!pm_ops || !pm_ops->enter)
+ if (!suspend_ops || !suspend_ops->enter)
return -EPERM;
error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
@@ -137,7 +137,7 @@ int suspend_enter(suspend_state_t state)
printk(KERN_ERR "Some devices failed to power down\n");
goto Done;
}
- error = pm_ops->enter(state);
+ error = suspend_ops->enter(state);
device_power_up();
Done:
arch_suspend_enable_irqs();
@@ -154,11 +154,11 @@ int suspend_devices_and_enter(suspend_st
{
int error;
- if (!pm_ops)
+ if (!suspend_ops)
return -ENOSYS;
- if (pm_ops->set_target) {
- error = pm_ops->set_target(state);
+ if (suspend_ops->set_target) {
+ error = suspend_ops->set_target(state);
if (error)
return error;
}
@@ -168,8 +168,8 @@ int suspend_devices_and_enter(suspend_st
printk(KERN_ERR "Some devices failed to suspend\n");
goto Resume_console;
}
- if (pm_ops->prepare) {
- error = pm_ops->prepare(state);
+ if (suspend_ops->prepare) {
+ error = suspend_ops->prepare(state);
if (error)
goto Resume_devices;
}
@@ -212,7 +212,7 @@ static inline int valid_state(suspend_st
/* All states need lowlevel support and need to be valid
* to the lowlevel implementation, no valid callback
* implies that none are valid. */
- if (!pm_ops || !pm_ops->valid || !pm_ops->valid(state))
+ if (!suspend_ops || !suspend_ops->valid || !suspend_ops->valid(state))
return 0;
return 1;
}
Index: linux-2.6.22-git5/Documentation/power/interface.txt
===================================================================
--- linux-2.6.22-git5.orig/Documentation/power/interface.txt
+++ linux-2.6.22-git5/Documentation/power/interface.txt
@@ -20,7 +20,7 @@ states.
/sys/power/disk controls the operating mode of the suspend-to-disk
mechanism. Suspend-to-disk can be handled in several ways. We have a
few options for putting the system to sleep - using the platform driver
-(e.g. ACPI or other pm_ops), powering off the system or rebooting the
+(e.g. ACPI or other suspend_ops), powering off the system or rebooting the
system (for testing).
Additionally, /sys/power/disk can be used to turn on one of the two testing
Index: linux-2.6.22-git5/arch/arm/common/sharpsl_pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/common/sharpsl_pm.c
+++ linux-2.6.22-git5/arch/arm/common/sharpsl_pm.c
@@ -766,9 +766,9 @@ static void sharpsl_apm_get_power_status
info->battery_life = sharpsl_pm.battstat.mainbat_percent;
}
-static struct pm_ops sharpsl_pm_ops = {
+static struct platform_suspend_ops sharpsl_pm_ops = {
.enter = corgi_pxa_pm_enter,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
static int __init sharpsl_pm_probe(struct platform_device *pdev)
@@ -800,7 +800,7 @@ static int __init sharpsl_pm_probe(struc
apm_get_power_status = sharpsl_apm_get_power_status;
- pm_set_ops(&sharpsl_pm_ops);
+ suspend_set_ops(&sharpsl_pm_ops);
mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
@@ -809,7 +809,7 @@ static int __init sharpsl_pm_probe(struc
static int sharpsl_pm_remove(struct platform_device *pdev)
{
- pm_set_ops(NULL);
+ suspend_set_ops(NULL);
device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
Index: linux-2.6.22-git5/arch/arm/mach-at91/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-at91/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-at91/pm.c
@@ -198,7 +198,7 @@ error:
}
-static struct pm_ops at91_pm_ops ={
+static struct platform_suspend_ops at91_pm_ops ={
.valid = at91_pm_valid_state,
.set_target = at91_pm_set_target,
.enter = at91_pm_enter,
@@ -219,7 +219,7 @@ static int __init at91_pm_init(void)
/* Disable SDRAM low-power mode. Cannot be used with self-refresh. */
at91_sys_write(AT91_SDRAMC_LPR, 0);
- pm_set_ops(&at91_pm_ops);
+ suspend_set_ops(&at91_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap1/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
@@ -687,11 +687,11 @@ static struct irqaction omap_wakeup_irq
-static struct pm_ops omap_pm_ops ={
+static struct platform_suspend_ops omap_pm_ops ={
.prepare = omap_pm_prepare,
.enter = omap_pm_enter,
.finish = omap_pm_finish,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
static int __init omap_pm_init(void)
@@ -748,7 +748,7 @@ static int __init omap_pm_init(void)
else if (cpu_is_omap16xx())
omap_writel(OMAP1610_IDLECT3_VAL, OMAP1610_IDLECT3);
- pm_set_ops(&omap_pm_ops);
+ suspend_set_ops(&omap_pm_ops);
#if defined(DEBUG) && defined(CONFIG_PROC_FS)
omap_pm_init_proc();
Index: linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap2/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
@@ -362,11 +362,11 @@ static int omap2_pm_finish(suspend_state
return 0;
}
-static struct pm_ops omap_pm_ops = {
+static struct platform_suspend_ops omap_pm_ops = {
.prepare = omap2_pm_prepare,
.enter = omap2_pm_enter,
.finish = omap2_pm_finish,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
int __init omap2_pm_init(void)
@@ -390,7 +390,7 @@ int __init omap2_pm_init(void)
omap2_sram_suspend = omap_sram_push(omap24xx_cpu_suspend,
omap24xx_cpu_suspend_sz);
- pm_set_ops(&omap_pm_ops);
+ suspend_set_ops(&omap_pm_ops);
pm_idle = omap2_pm_idle;
pmdomain_init();
Index: linux-2.6.22-git5/arch/arm/mach-pnx4008/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pnx4008/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-pnx4008/pm.c
@@ -117,7 +117,7 @@ static int pnx4008_pm_valid(suspend_stat
(state == PM_SUSPEND_MEM);
}
-static struct pm_ops pnx4008_pm_ops = {
+static struct platform_suspend_ops pnx4008_pm_ops = {
.enter = pnx4008_pm_enter,
.valid = pnx4008_pm_valid,
};
@@ -146,7 +146,7 @@ static int __init pnx4008_pm_init(void)
return -ENOMEM;
}
- pm_set_ops(&pnx4008_pm_ops);
+ suspend_set_ops(&pnx4008_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/arm/mach-sa1100/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-sa1100/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-sa1100/pm.c
@@ -122,14 +122,14 @@ unsigned long sleep_phys_sp(void *sp)
return virt_to_phys(sp);
}
-static struct pm_ops sa11x0_pm_ops = {
+static struct platform_suspend_ops sa11x0_pm_ops = {
.enter = sa11x0_pm_enter,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
static int __init sa11x0_pm_init(void)
{
- pm_set_ops(&sa11x0_pm_ops);
+ suspend_set_ops(&sa11x0_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/arm/plat-s3c24xx/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/plat-s3c24xx/pm.c
+++ linux-2.6.22-git5/arch/arm/plat-s3c24xx/pm.c
@@ -612,9 +612,9 @@ static int s3c2410_pm_enter(suspend_stat
return 0;
}
-static struct pm_ops s3c2410_pm_ops = {
+static struct platform_suspend_ops s3c2410_pm_ops = {
.enter = s3c2410_pm_enter,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
/* s3c2410_pm_init
@@ -628,6 +628,6 @@ int __init s3c2410_pm_init(void)
{
printk("S3C2410 Power Management, (c) 2004 Simtec Electronics\n");
- pm_set_ops(&s3c2410_pm_ops);
+ suspend_set_ops(&s3c2410_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/arm/mach-pxa/pxa25x.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pxa/pxa25x.c
+++ linux-2.6.22-git5/arch/arm/mach-pxa/pxa25x.c
@@ -126,9 +126,9 @@ void pxa_cpu_pm_enter(suspend_state_t st
}
}
-static struct pm_ops pxa25x_pm_ops = {
+static struct platform_suspend_ops pxa25x_pm_ops = {
.enter = pxa_pm_enter,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
#endif
@@ -159,7 +159,7 @@ static int __init pxa25x_init(void)
if ((ret = pxa_init_dma(16)))
return ret;
#ifdef CONFIG_PM
- pm_set_ops(&pxa25x_pm_ops);
+ suspend_set_ops(&pxa25x_pm_ops);
#endif
ret = platform_add_devices(pxa25x_devices,
ARRAY_SIZE(pxa25x_devices));
Index: linux-2.6.22-git5/arch/arm/mach-pxa/pxa27x.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-pxa/pxa27x.c
+++ linux-2.6.22-git5/arch/arm/mach-pxa/pxa27x.c
@@ -160,7 +160,7 @@ static int pxa27x_pm_valid(suspend_state
return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
}
-static struct pm_ops pxa27x_pm_ops = {
+static struct platform_suspend_ops pxa27x_pm_ops = {
.enter = pxa_pm_enter,
.valid = pxa27x_pm_valid,
};
@@ -249,7 +249,7 @@ static int __init pxa27x_init(void)
if ((ret = pxa_init_dma(32)))
return ret;
#ifdef CONFIG_PM
- pm_set_ops(&pxa27x_pm_ops);
+ suspend_set_ops(&pxa27x_pm_ops);
#endif
ret = platform_add_devices(devices, ARRAY_SIZE(devices));
}
Index: linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/blackfin/mach-common/pm.c
+++ linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
@@ -158,7 +158,7 @@ static int bfin_pm_finish(suspend_state_
return 0;
}
-struct pm_ops bfin_pm_ops = {
+struct platform_suspend_ops bfin_pm_ops = {
.prepare = bfin_pm_prepare,
.enter = bfin_pm_enter,
.finish = bfin_pm_finish,
@@ -166,7 +166,7 @@ struct pm_ops bfin_pm_ops = {
static int __init bfin_pm_init(void)
{
- pm_set_ops(&bfin_pm_ops);
+ suspend_set_ops(&bfin_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/powerpc/platforms/52xx/mpc52xx_pm.c
+++ linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
@@ -177,7 +177,7 @@ int mpc52xx_pm_finish(suspend_state_t st
return 0;
}
-static struct pm_ops mpc52xx_pm_ops = {
+static struct platform_suspend_ops mpc52xx_pm_ops = {
.valid = mpc52xx_pm_valid,
.prepare = mpc52xx_pm_prepare,
.enter = mpc52xx_pm_enter,
@@ -186,6 +186,6 @@ static struct pm_ops mpc52xx_pm_ops = {
int __init mpc52xx_pm_init(void)
{
- pm_set_ops(&mpc52xx_pm_ops);
+ suspend_set_ops(&mpc52xx_pm_ops);
return 0;
}
Index: linux-2.6.22-git5/arch/sh/boards/hp6xx/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/sh/boards/hp6xx/pm.c
+++ linux-2.6.22-git5/arch/sh/boards/hp6xx/pm.c
@@ -67,14 +67,14 @@ static int hp6x0_pm_enter(suspend_state_
return 0;
}
-static struct pm_ops hp6x0_pm_ops = {
+static struct platform_suspend_ops hp6x0_pm_ops = {
.enter = hp6x0_pm_enter,
- .valid = pm_valid_only_mem,
+ .valid = suspend_valid_only_mem,
};
static int __init hp6x0_pm_init(void)
{
- pm_set_ops(&hp6x0_pm_ops);
+ suspend_set_ops(&hp6x0_pm_ops);
return 0;
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 5/9] PM: Rework struct platform_suspend_ops
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (3 preceding siblings ...)
2007-07-17 20:43 ` [Resend][PATCH 4/9] PM: Rename struct pm_ops and related things Rafael J. Wysocki
@ 2007-07-17 20:44 ` Rafael J. Wysocki
2007-07-17 20:45 ` [Resend][PATCH 6/9] PM: Fix compilation of suspend code if CONFIG_PM is unset Rafael J. Wysocki
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:44 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
There is no reason why the .prepare() and .finish() methods in 'struct
platform_suspend_ops' should take any arguments, since architectures
don't use these methods' argument in any practically meaningful way (ie. either
the target system sleep state is conveyed to the platform by .set_target(), or
there is only one suspend state supported and it is indicated to the PM core by
.valid(), or .prepare() and .finish() aren't defined at all). There also is
no reason why .finish() should return any result.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
arch/arm/mach-omap1/pm.c | 20 +-----------
arch/arm/mach-omap2/pm.c | 20 +-----------
arch/blackfin/mach-common/pm.c | 49 +++----------------------------
arch/powerpc/platforms/52xx/mpc52xx_pm.c | 9 +----
drivers/acpi/sleep/main.c | 7 +---
include/asm-arm/arch-pxa/pm.h | 1
include/linux/suspend.h | 13 +++-----
kernel/power/main.c | 12 +------
8 files changed, 24 insertions(+), 107 deletions(-)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -45,12 +45,10 @@ typedef int __bitwise suspend_state_t;
* @prepare() fails. If @set_target() fails (ie. returns nonzero),
* @prepare(), @enter() and @finish() will not be called by the PM core.
* This callback is optional. However, if it is implemented, the argument
- * passed to @prepare(), @enter() and @finish() is meaningless and should
- * be ignored.
+ * passed to @enter() is meaningless and should be ignored.
*
* @prepare: Prepare the platform for entering the system sleep state indicated
- * by @set_target() or represented by the argument if @set_target() is not
- * implemented.
+ * by @set_target().
* @prepare() is called right after devices have been suspended (ie. the
* appropriate .suspend() method has been executed for each device) and
* before the nonboot CPUs are disabled (it is executed with IRQs enabled).
@@ -66,8 +64,7 @@ typedef int __bitwise suspend_state_t;
*
* @finish: Called when the system has just left a sleep state, right after
* the nonboot CPUs have been enabled and before devices are resumed (it is
- * executed with IRQs enabled). If @set_target() is not implemented, the
- * argument represents the sleep state being left.
+ * executed with IRQs enabled).
* This callback is optional, but should be implemented by the platforms
* that implement @prepare(). If implemented, it is always called after
* @enter() (even if @enter() fails).
@@ -75,9 +72,9 @@ typedef int __bitwise suspend_state_t;
struct platform_suspend_ops {
int (*valid)(suspend_state_t state);
int (*set_target)(suspend_state_t state);
- int (*prepare)(suspend_state_t state);
+ int (*prepare)(void);
int (*enter)(suspend_state_t state);
- int (*finish)(suspend_state_t state);
+ void (*finish)(void);
};
extern struct platform_suspend_ops *suspend_ops;
Index: linux-2.6.22-git5/kernel/power/main.c
===================================================================
--- linux-2.6.22-git5.orig/kernel/power/main.c
+++ linux-2.6.22-git5/kernel/power/main.c
@@ -56,13 +56,6 @@ int suspend_valid_only_mem(suspend_state
return state == PM_SUSPEND_MEM;
}
-
-static inline void pm_finish(suspend_state_t state)
-{
- if (suspend_ops->finish)
- suspend_ops->finish(state);
-}
-
/**
* suspend_prepare - Do prep work before entering low-power state.
*
@@ -169,7 +162,7 @@ int suspend_devices_and_enter(suspend_st
goto Resume_console;
}
if (suspend_ops->prepare) {
- error = suspend_ops->prepare(state);
+ error = suspend_ops->prepare();
if (error)
goto Resume_devices;
}
@@ -178,7 +171,8 @@ int suspend_devices_and_enter(suspend_st
suspend_enter(state);
enable_nonboot_cpus();
- pm_finish(state);
+ if (suspend_ops->finish)
+ suspend_ops->finish();
Resume_devices:
device_resume();
Resume_console:
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -61,13 +61,12 @@ static int acpi_pm_set_target(suspend_st
/**
* acpi_pm_prepare - Do preliminary suspend work.
- * @pm_state: ignored
*
* If necessary, set the firmware waking vector and do arch-specific
* nastiness to get the wakeup code to the waking vector.
*/
-static int acpi_pm_prepare(suspend_state_t pm_state)
+static int acpi_pm_prepare(void)
{
int error = acpi_sleep_prepare(acpi_target_sleep_state);
@@ -137,13 +136,12 @@ static int acpi_pm_enter(suspend_state_t
/**
* acpi_pm_finish - Finish up suspend sequence.
- * @pm_state: ignored
*
* This is called after we wake back up (or if entering the sleep state
* failed).
*/
-static int acpi_pm_finish(suspend_state_t pm_state)
+static void acpi_pm_finish(void)
{
u32 acpi_state = acpi_target_sleep_state;
@@ -159,7 +157,6 @@ static int acpi_pm_finish(suspend_state_
printk("Broken toshiba laptop -> kicking interrupts\n");
init_8259A(0);
}
- return 0;
}
int acpi_suspend(u32 acpi_state)
Index: linux-2.6.22-git5/include/asm-arm/arch-pxa/pm.h
===================================================================
--- linux-2.6.22-git5.orig/include/asm-arm/arch-pxa/pm.h
+++ linux-2.6.22-git5/include/asm-arm/arch-pxa/pm.h
@@ -9,5 +9,4 @@
#include <linux/suspend.h>
-extern int pxa_pm_prepare(suspend_state_t state);
extern int pxa_pm_enter(suspend_state_t state);
Index: linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap1/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap1/pm.c
@@ -613,27 +613,15 @@ static void (*saved_idle)(void) = NULL;
/*
* omap_pm_prepare - Do preliminary suspend work.
- * @state: suspend state we're entering.
*
*/
-static int omap_pm_prepare(suspend_state_t state)
+static int omap_pm_prepare(void)
{
- int error = 0;
-
/* We cannot sleep in idle until we have resumed */
saved_idle = pm_idle;
pm_idle = NULL;
- switch (state)
- {
- case PM_SUSPEND_STANDBY:
- case PM_SUSPEND_MEM:
- break;
- default:
- return -EINVAL;
- }
-
- return error;
+ return 0;
}
@@ -661,16 +649,14 @@ static int omap_pm_enter(suspend_state_t
/**
* omap_pm_finish - Finish up suspend sequence.
- * @state: State we're coming out of.
*
* This is called after we wake back up (or if entering the sleep state
* failed).
*/
-static int omap_pm_finish(suspend_state_t state)
+static void omap_pm_finish(void)
{
pm_idle = saved_idle;
- return 0;
}
Index: linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/arm/mach-omap2/pm.c
+++ linux-2.6.22-git5/arch/arm/mach-omap2/pm.c
@@ -70,25 +70,12 @@ void omap2_pm_idle(void)
local_irq_enable();
}
-static int omap2_pm_prepare(suspend_state_t state)
+static int omap2_pm_prepare(void)
{
- int error = 0;
-
/* We cannot sleep in idle until we have resumed */
saved_idle = pm_idle;
pm_idle = NULL;
-
- switch (state)
- {
- case PM_SUSPEND_STANDBY:
- case PM_SUSPEND_MEM:
- break;
-
- default:
- return -EINVAL;
- }
-
- return error;
+ return 0;
}
#define INT0_WAKE_MASK (OMAP_IRQ_BIT(INT_24XX_GPIO_BANK1) | \
@@ -356,10 +343,9 @@ static int omap2_pm_enter(suspend_state_
return ret;
}
-static int omap2_pm_finish(suspend_state_t state)
+static void omap2_pm_finish(void)
{
pm_idle = saved_idle;
- return 0;
}
static struct platform_suspend_ops omap_pm_ops = {
Index: linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/blackfin/mach-common/pm.c
+++ linux-2.6.22-git5/arch/blackfin/mach-common/pm.c
@@ -89,28 +89,15 @@ void bfin_pm_suspend_standby_enter(void)
#endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */
}
-
/*
- * bfin_pm_prepare - Do preliminary suspend work.
- * @state: suspend state we're entering.
+ * bfin_pm_valid - Tell the PM core that we only support the standby sleep
+ * state
+ * @state: suspend state we're checking.
*
*/
-static int bfin_pm_prepare(suspend_state_t state)
+static int bfin_pm_valid(suspend_state_t state)
{
- int error = 0;
-
- switch (state) {
- case PM_SUSPEND_STANDBY:
- break;
-
- case PM_SUSPEND_MEM:
- return -ENOTSUPP;
-
- default:
- return -EINVAL;
- }
-
- return error;
+ return (state == PM_SUSPEND_STANDBY);
}
/*
@@ -135,33 +122,9 @@ static int bfin_pm_enter(suspend_state_t
return 0;
}
-/*
- * bfin_pm_finish - Finish up suspend sequence.
- * @state: State we're coming out of.
- *
- * This is called after we wake back up (or if entering the sleep state
- * failed).
- */
-static int bfin_pm_finish(suspend_state_t state)
-{
- switch (state) {
- case PM_SUSPEND_STANDBY:
- break;
-
- case PM_SUSPEND_MEM:
- return -ENOTSUPP;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
struct platform_suspend_ops bfin_pm_ops = {
- .prepare = bfin_pm_prepare,
+ .valid = bfin_pm_valid,
.enter = bfin_pm_enter,
- .finish = bfin_pm_finish,
};
static int __init bfin_pm_init(void)
Index: linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
===================================================================
--- linux-2.6.22-git5.orig/arch/powerpc/platforms/52xx/mpc52xx_pm.c
+++ linux-2.6.22-git5/arch/powerpc/platforms/52xx/mpc52xx_pm.c
@@ -57,11 +57,8 @@ int mpc52xx_set_wakeup_gpio(u8 pin, u8 l
return 0;
}
-int mpc52xx_pm_prepare(suspend_state_t state)
+static int mpc52xx_pm_prepare(void)
{
- if (state != PM_SUSPEND_STANDBY)
- return -EINVAL;
-
/* map the whole register space */
mbar = mpc52xx_find_and_map("mpc5200");
if (!mbar) {
@@ -166,15 +163,13 @@ int mpc52xx_pm_enter(suspend_state_t sta
return 0;
}
-int mpc52xx_pm_finish(suspend_state_t state)
+static void mpc52xx_pm_finish(void)
{
/* call board resume code */
if (mpc52xx_suspend.board_resume_finish)
mpc52xx_suspend.board_resume_finish(mbar);
iounmap(mbar);
-
- return 0;
}
static struct platform_suspend_ops mpc52xx_pm_ops = {
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 6/9] PM: Fix compilation of suspend code if CONFIG_PM is unset
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (4 preceding siblings ...)
2007-07-17 20:44 ` [Resend][PATCH 5/9] PM: Rework struct platform_suspend_ops Rafael J. Wysocki
@ 2007-07-17 20:45 ` Rafael J. Wysocki
2007-07-17 20:46 ` [Resend][PATCH 7/9] PM: Make suspend_ops static Rafael J. Wysocki
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:45 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
Some platforms, particualrly in the ARM tree, require that suspend_set_ops() and
pm_suspend() be defined even if CONFIG_PM is not set. Make this requirement be
satisfied.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
include/linux/suspend.h | 7 +++++++
1 file changed, 7 insertions(+)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -79,6 +79,7 @@ struct platform_suspend_ops {
extern struct platform_suspend_ops *suspend_ops;
+#ifdef CONFIG_PM
/**
* suspend_set_ops - set platform dependent suspend operations
* @ops: The new suspend operations to set.
@@ -105,6 +106,12 @@ extern void arch_suspend_disable_irqs(vo
extern void arch_suspend_enable_irqs(void);
extern int pm_suspend(suspend_state_t state);
+#else /* CONFIG_PM */
+#define suspend_valid_only_mem NULL
+
+static inline void suspend_set_ops(struct platform_suspend_ops *ops) {}
+static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
+#endif /* CONFIG_PM */
/* struct pbe is used for creating lists of pages that should be restored
* atomically during the resume from disk, because the page frames they have
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 7/9] PM: Make suspend_ops static
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (5 preceding siblings ...)
2007-07-17 20:45 ` [Resend][PATCH 6/9] PM: Fix compilation of suspend code if CONFIG_PM is unset Rafael J. Wysocki
@ 2007-07-17 20:46 ` Rafael J. Wysocki
2007-07-17 20:47 ` [Resend][PATCH 8/9] PM: Rework struct hibernation_ops Rafael J. Wysocki
2007-07-17 20:48 ` [Resend][PATCH 9/9] PM: Rename hibernation_ops to platform_hibernation_ops Rafael J. Wysocki
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:46 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
The variable suspend_ops representing the set of global platform-specific
suspend-related operations, used by the PM core, need not be exported outside of
kernel/power/main.c . Make it static.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
include/linux/suspend.h | 2 --
kernel/power/main.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -77,8 +77,6 @@ struct platform_suspend_ops {
void (*finish)(void);
};
-extern struct platform_suspend_ops *suspend_ops;
-
#ifdef CONFIG_PM
/**
* suspend_set_ops - set platform dependent suspend operations
Index: linux-2.6.22-git5/kernel/power/main.c
===================================================================
--- linux-2.6.22-git5.orig/kernel/power/main.c
+++ linux-2.6.22-git5/kernel/power/main.c
@@ -30,7 +30,7 @@ BLOCKING_NOTIFIER_HEAD(pm_chain_head);
DEFINE_MUTEX(pm_mutex);
-struct platform_suspend_ops *suspend_ops;
+static struct platform_suspend_ops *suspend_ops;
/**
* suspend_set_ops - Set the global suspend method table.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 8/9] PM: Rework struct hibernation_ops
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (6 preceding siblings ...)
2007-07-17 20:46 ` [Resend][PATCH 7/9] PM: Make suspend_ops static Rafael J. Wysocki
@ 2007-07-17 20:47 ` Rafael J. Wysocki
2007-07-17 20:48 ` [Resend][PATCH 9/9] PM: Rename hibernation_ops to platform_hibernation_ops Rafael J. Wysocki
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:47 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
During hibernation we also need to tell the ACPI core that we're going to put
the system into the S4 sleep state. For this reason, an additional method
in 'struct hibernation_ops' is needed, playing the role of set_target() in
'struct platform_suspend_operations'. Moreover, the role of the .prepare()
method is now different, so it's better to introduce another method, that in
general may be different from .prepare(), that will be used to prepare the
platform for creating the hibernation image (.prepare() is used anyway to
notify the platform that we're going to enter the low power state after the
image has been saved).
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/acpi/sleep/main.c | 12 +++++++++++-
include/linux/suspend.h | 38 ++++++++++++++++++++++++++++++++------
kernel/power/disk.c | 27 +++++++++++++++++++++------
3 files changed, 64 insertions(+), 13 deletions(-)
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -133,16 +133,42 @@ extern void mark_free_pages(struct zone
*
* All three methods must be assigned.
*
- * @prepare: prepare system for hibernation
- * @enter: shut down system after state has been saved to disk
- * @finish: finish/clean up after state has been reloaded
- * @pre_restore: prepare system for the restoration from a hibernation image
- * @restore_cleanup: clean up after a failing image restoration
+ * @start: Tell the platform driver that we're starting hibernation.
+ * Called right after shrinking memory and before freezing devices.
+ *
+ * @pre_snapshot: Prepare the platform for creating the hibernation image.
+ * Called right after devices have been frozen and before the nonboot
+ * CPUs are disabled (runs with IRQs on).
+ *
+ * @finish: Restore the previous state of the platform after the hibernation
+ * image has been created *or* put the platform into the normal operation
+ * mode after the hibernation (the same method is executed in both cases).
+ * Called right after the nonboot CPUs have been enabled and before
+ * thawing devices (runs with IRQs on).
+ *
+ * @prepare: Prepare the platform for entering the low power state.
+ * Called right after the hibernation image has been saved and before
+ * devices are prepared for entering the low power state.
+ *
+ * @enter: Put the system into the low power state after the hibernation image
+ * has been saved to disk.
+ * Called after the nonboot CPUs have been disabled and all of the low
+ * level devices have been shut down (runs with IRQs off).
+ *
+ * @pre_restore: Prepare system for the restoration from a hibernation image.
+ * Called right after devices have been frozen and before the nonboot
+ * CPUs are disabled (runs with IRQs on).
+ *
+ * @restore_cleanup: Clean up after a failing image restoration.
+ * Called right after the nonboot CPUs have been enabled and before
+ * thawing devices (runs with IRQs on).
*/
struct hibernation_ops {
+ int (*start)(void);
+ int (*pre_snapshot)(void);
+ void (*finish)(void);
int (*prepare)(void);
int (*enter)(void);
- void (*finish)(void);
int (*pre_restore)(void);
void (*restore_cleanup)(void);
};
Index: linux-2.6.22-git5/kernel/power/disk.c
===================================================================
--- linux-2.6.22-git5.orig/kernel/power/disk.c
+++ linux-2.6.22-git5/kernel/power/disk.c
@@ -54,8 +54,9 @@ struct hibernation_ops *hibernation_ops;
void hibernation_set_ops(struct hibernation_ops *ops)
{
- if (ops && !(ops->prepare && ops->enter && ops->finish
- && ops->pre_restore && ops->restore_cleanup)) {
+ if (ops && !(ops->start && ops->pre_snapshot && ops->finish
+ && ops->prepare && ops->enter && ops->pre_restore
+ && ops->restore_cleanup)) {
WARN_ON(1);
return;
}
@@ -69,16 +70,26 @@ void hibernation_set_ops(struct hibernat
mutex_unlock(&pm_mutex);
}
+/**
+ * platform_start - tell the platform driver that we're starting
+ * hibernation
+ */
+
+static int platform_start(int platform_mode)
+{
+ return (platform_mode && hibernation_ops) ?
+ hibernation_ops->start() : 0;
+}
/**
- * platform_prepare - prepare the machine for hibernation using the
+ * platform_pre_snapshot - prepare the machine for hibernation using the
* platform driver if so configured and return an error code if it fails
*/
-static int platform_prepare(int platform_mode)
+static int platform_pre_snapshot(int platform_mode)
{
return (platform_mode && hibernation_ops) ?
- hibernation_ops->prepare() : 0;
+ hibernation_ops->pre_snapshot() : 0;
}
/**
@@ -135,12 +146,16 @@ int hibernation_snapshot(int platform_mo
if (error)
return error;
+ error = platform_start(platform_mode);
+ if (error)
+ return error;
+
suspend_console();
error = device_suspend(PMSG_FREEZE);
if (error)
goto Resume_console;
- error = platform_prepare(platform_mode);
+ error = platform_pre_snapshot(platform_mode);
if (error)
goto Resume_devices;
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -199,6 +199,12 @@ static struct platform_suspend_ops acpi_
};
#ifdef CONFIG_SOFTWARE_SUSPEND
+static int acpi_hibernation_start(void)
+{
+ acpi_target_sleep_state = ACPI_STATE_S4;
+ return 0;
+}
+
static int acpi_hibernation_prepare(void)
{
return acpi_sleep_prepare(ACPI_STATE_S4);
@@ -227,6 +233,8 @@ static void acpi_hibernation_finish(void
/* reset firmware waking vector */
acpi_set_firmware_waking_vector((acpi_physical_address) 0);
+
+ acpi_target_sleep_state = ACPI_STATE_S0;
}
static int acpi_hibernation_pre_restore(void)
@@ -244,9 +252,11 @@ static void acpi_hibernation_restore_cle
}
static struct hibernation_ops acpi_hibernation_ops = {
+ .start = acpi_hibernation_start,
+ .pre_snapshot = acpi_hibernation_prepare,
+ .finish = acpi_hibernation_finish,
.prepare = acpi_hibernation_prepare,
.enter = acpi_hibernation_enter,
- .finish = acpi_hibernation_finish,
.pre_restore = acpi_hibernation_pre_restore,
.restore_cleanup = acpi_hibernation_restore_cleanup,
};
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Resend][PATCH 9/9] PM: Rename hibernation_ops to platform_hibernation_ops
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
` (7 preceding siblings ...)
2007-07-17 20:47 ` [Resend][PATCH 8/9] PM: Rework struct hibernation_ops Rafael J. Wysocki
@ 2007-07-17 20:48 ` Rafael J. Wysocki
8 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-17 20:48 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
From: Rafael J. Wysocki <rjw@sisk.pl>
Rename 'struct hibernation_ops' to 'struct platform_hibernation_ops' in analogy
with 'struct platform_suspend_ops'.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/acpi/sleep/main.c | 2 +-
include/linux/suspend.h | 8 ++++----
kernel/power/disk.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -251,7 +251,7 @@ static void acpi_hibernation_restore_cle
acpi_hw_enable_all_runtime_gpes();
}
-static struct hibernation_ops acpi_hibernation_ops = {
+static struct platform_hibernation_ops acpi_hibernation_ops = {
.start = acpi_hibernation_start,
.pre_snapshot = acpi_hibernation_prepare,
.finish = acpi_hibernation_finish,
Index: linux-2.6.22-git5/include/linux/suspend.h
===================================================================
--- linux-2.6.22-git5.orig/include/linux/suspend.h
+++ linux-2.6.22-git5/include/linux/suspend.h
@@ -126,7 +126,7 @@ extern void drain_local_pages(void);
extern void mark_free_pages(struct zone *zone);
/**
- * struct hibernation_ops - hibernation platform support
+ * struct platform_hibernation_ops - hibernation platform support
*
* The methods in this structure allow a platform to override the default
* mechanism of shutting down the machine during a hibernation transition.
@@ -163,7 +163,7 @@ extern void mark_free_pages(struct zone
* Called right after the nonboot CPUs have been enabled and before
* thawing devices (runs with IRQs on).
*/
-struct hibernation_ops {
+struct platform_hibernation_ops {
int (*start)(void);
int (*pre_snapshot)(void);
void (*finish)(void);
@@ -190,14 +190,14 @@ extern void swsusp_set_page_free(struct
extern void swsusp_unset_page_free(struct page *);
extern unsigned long get_safe_page(gfp_t gfp_mask);
-extern void hibernation_set_ops(struct hibernation_ops *ops);
+extern void hibernation_set_ops(struct platform_hibernation_ops *ops);
extern int hibernate(void);
#else /* CONFIG_SOFTWARE_SUSPEND */
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
static inline void swsusp_set_page_free(struct page *p) {}
static inline void swsusp_unset_page_free(struct page *p) {}
-static inline void hibernation_set_ops(struct hibernation_ops *ops) {}
+static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
static inline int hibernate(void) { return -ENOSYS; }
#endif /* CONFIG_SOFTWARE_SUSPEND */
Index: linux-2.6.22-git5/kernel/power/disk.c
===================================================================
--- linux-2.6.22-git5.orig/kernel/power/disk.c
+++ linux-2.6.22-git5/kernel/power/disk.c
@@ -45,14 +45,14 @@ enum {
static int hibernation_mode = HIBERNATION_SHUTDOWN;
-struct hibernation_ops *hibernation_ops;
+struct platform_hibernation_ops *hibernation_ops;
/**
* hibernation_set_ops - set the global hibernate operations
* @ops: the hibernation operations to use in subsequent hibernation transitions
*/
-void hibernation_set_ops(struct hibernation_ops *ops)
+void hibernation_set_ops(struct platform_hibernation_ops *ops)
{
if (ops && !(ops->start && ops->pre_snapshot && ops->finish
&& ops->prepare && ops->enter && ops->pre_restore
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
@ 2007-07-18 0:02 ` Andrew Morton
2007-07-18 6:41 ` Rafael J. Wysocki
2007-07-19 2:05 ` Len Brown
2007-07-21 19:26 ` David Brownell
1 sibling, 2 replies; 16+ messages in thread
From: Andrew Morton @ 2007-07-18 0:02 UTC (permalink / raw)
To: Rafael J. Wysocki, linux-acpi
Cc: LKML, Alan Stern, David Brownell, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
On Tue, 17 Jul 2007 22:40:06 +0200
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> In the future some drivers may need to use ACPI to determine the low power
> states in which to place their devices, but to provide the drivers with this
> information the ACPI core needs to know what sleep state the system is going to
> enter. Namely, the device's state should not be too high power for given system
> sleep state and, if the device is supposed to be able to wake up the system, its
> state should not be too low power for the wake up to be possible). For this
> purpose, the ACPI core needs to implement the set_target() method in 'struct
> pm_ops' and store the target system sleep state passed by the PM core in a
> variable.
>
Len, I can add this to the to-send-to-Len queue, but it would be more
convenient at this end if you were to ack it and I'll send it in.
Preferences?
>
> Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
> ===================================================================
> --- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
> +++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
> @@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
>
> static int init_8259A_after_S1;
>
> +extern int acpi_sleep_prepare(u32 acpi_state);
> +extern void acpi_power_off(void);
weep. Please don't do this.
checkpatch will detect this error. Please check patches with checkpatch.
(Full patch reproduced below for the benefit of the newly-added linux-acpi
cc):
From: Rafael J. Wysocki <rjw@sisk.pl>
In the future some drivers may need to use ACPI to determine the low power
states in which to place their devices, but to provide the drivers with this
information the ACPI core needs to know what sleep state the system is going to
enter. Namely, the device's state should not be too high power for given system
sleep state and, if the device is supposed to be able to wake up the system, its
state should not be too low power for the wake up to be possible). For this
purpose, the ACPI core needs to implement the set_target() method in 'struct
pm_ops' and store the target system sleep state passed by the PM core in a
variable.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
drivers/acpi/sleep/main.c | 84 ++++++++++++++++++++++++++++------------------
1 file changed, 52 insertions(+), 32 deletions(-)
Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
@@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
static int init_8259A_after_S1;
+extern int acpi_sleep_prepare(u32 acpi_state);
+extern void acpi_power_off(void);
+
+static u32 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ * acpi_pm_set_target - Set the target system sleep state to the state
+ * associated with given @pm_state, if supported.
+ */
+
+static int acpi_pm_set_target(suspend_state_t pm_state)
+{
+ u32 acpi_state = acpi_suspend_states[pm_state];
+ int error = 0;
+
+ if (sleep_states[acpi_state]) {
+ acpi_target_sleep_state = acpi_state;
+ } else {
+ printk(KERN_ERR "ACPI does not support this state: %d\n",
+ pm_state);
+ error = -ENOSYS;
+ }
+ return error;
+}
+
/**
* acpi_pm_prepare - Do preliminary suspend work.
- * @pm_state: suspend state we're entering.
+ * @pm_state: ignored
*
- * Make sure we support the state. If we do, and we need it, set the
- * firmware waking vector and do arch-specific nastiness to get the
- * wakeup code to the waking vector.
+ * If necessary, set the firmware waking vector and do arch-specific
+ * nastiness to get the wakeup code to the waking vector.
*/
-extern int acpi_sleep_prepare(u32 acpi_state);
-extern void acpi_power_off(void);
-
static int acpi_pm_prepare(suspend_state_t pm_state)
{
- u32 acpi_state = acpi_suspend_states[pm_state];
+ int error = acpi_sleep_prepare(acpi_target_sleep_state);
- if (!sleep_states[acpi_state]) {
- printk("acpi_pm_prepare does not support %d \n", pm_state);
- return -EPERM;
- }
- return acpi_sleep_prepare(acpi_state);
+ if (error)
+ acpi_target_sleep_state = ACPI_STATE_S0;
+
+ return error;
}
/**
* acpi_pm_enter - Actually enter a sleep state.
- * @pm_state: State we're entering.
+ * @pm_state: ignored
*
- * Flush caches and go to sleep. For STR or STD, we have to call
+ * Flush caches and go to sleep. For STR or S2, we have to call
* arch-specific assembly, which in turn call acpi_enter_sleep_state().
* It's unfortunate, but it works. Please fix if you're feeling frisky.
*/
@@ -70,31 +90,32 @@ static int acpi_pm_enter(suspend_state_t
{
acpi_status status = AE_OK;
unsigned long flags = 0;
- u32 acpi_state = acpi_suspend_states[pm_state];
+ u32 acpi_state = acpi_target_sleep_state;
ACPI_FLUSH_CPU_CACHE();
/* Do arch specific saving of state. */
- if (pm_state > PM_SUSPEND_STANDBY) {
+ if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3) {
int error = acpi_save_state_mem();
- if (error)
+
+ if (error) {
+ acpi_target_sleep_state = ACPI_STATE_S0;
return error;
+ }
}
local_irq_save(flags);
acpi_enable_wakeup_device(acpi_state);
- switch (pm_state) {
- case PM_SUSPEND_STANDBY:
+ switch (acpi_state) {
+ case ACPI_STATE_S1:
barrier();
status = acpi_enter_sleep_state(acpi_state);
break;
- case PM_SUSPEND_MEM:
+ case ACPI_STATE_S2:
+ case ACPI_STATE_S3:
do_suspend_lowlevel();
break;
-
- default:
- return -EINVAL;
}
/* ACPI 3.0 specs (P62) says that it's the responsabilty
@@ -107,12 +128,8 @@ static int acpi_pm_enter(suspend_state_t
local_irq_restore(flags);
printk(KERN_DEBUG "Back to C!\n");
- /* restore processor state
- * We should only be here if we're coming back from STR or STD.
- * And, in the case of the latter, the memory image should have already
- * been loaded from disk.
- */
- if (pm_state > PM_SUSPEND_STANDBY)
+ /* restore processor state */
+ if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3)
acpi_restore_state_mem();
return ACPI_SUCCESS(status) ? 0 : -EFAULT;
@@ -120,7 +137,7 @@ static int acpi_pm_enter(suspend_state_t
/**
* acpi_pm_finish - Finish up suspend sequence.
- * @pm_state: State we're coming out of.
+ * @pm_state: ignored
*
* This is called after we wake back up (or if entering the sleep state
* failed).
@@ -128,7 +145,7 @@ static int acpi_pm_enter(suspend_state_t
static int acpi_pm_finish(suspend_state_t pm_state)
{
- u32 acpi_state = acpi_suspend_states[pm_state];
+ u32 acpi_state = acpi_target_sleep_state;
acpi_leave_sleep_state(acpi_state);
acpi_disable_wakeup_device(acpi_state);
@@ -136,6 +153,8 @@ static int acpi_pm_finish(suspend_state_
/* reset firmware waking vector */
acpi_set_firmware_waking_vector((acpi_physical_address) 0);
+ acpi_target_sleep_state = ACPI_STATE_S0;
+
if (init_8259A_after_S1) {
printk("Broken toshiba laptop -> kicking interrupts\n");
init_8259A(0);
@@ -176,6 +195,7 @@ static int acpi_pm_state_valid(suspend_s
static struct pm_ops acpi_pm_ops = {
.valid = acpi_pm_state_valid,
+ .set_target = acpi_pm_set_target,
.prepare = acpi_pm_prepare,
.enter = acpi_pm_enter,
.finish = acpi_pm_finish,
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-18 0:02 ` Andrew Morton
@ 2007-07-18 6:41 ` Rafael J. Wysocki
2007-07-19 2:05 ` Len Brown
1 sibling, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-18 6:41 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-acpi, LKML, Alan Stern, David Brownell, Len Brown,
Nigel Cunningham, Pavel Machek, Shaohua Li, Johannes Berg,
Paul Mackerras, Russell King
On Wednesday, 18 July 2007 02:02, Andrew Morton wrote:
> On Tue, 17 Jul 2007 22:40:06 +0200
> "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
>
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> >
> > In the future some drivers may need to use ACPI to determine the low power
> > states in which to place their devices, but to provide the drivers with this
> > information the ACPI core needs to know what sleep state the system is going to
> > enter. Namely, the device's state should not be too high power for given system
> > sleep state and, if the device is supposed to be able to wake up the system, its
> > state should not be too low power for the wake up to be possible). For this
> > purpose, the ACPI core needs to implement the set_target() method in 'struct
> > pm_ops' and store the target system sleep state passed by the PM core in a
> > variable.
> >
>
> Len, I can add this to the to-send-to-Len queue, but it would be more
> convenient at this end if you were to ack it and I'll send it in.
> Preferences?
>
>
> >
> > Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
> > ===================================================================
> > --- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
> > +++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
> > @@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
> >
> > static int init_8259A_after_S1;
> >
> > +extern int acpi_sleep_prepare(u32 acpi_state);
> > +extern void acpi_power_off(void);
>
> weep. Please don't do this.
Well, in fact I didn't add those. They were just moved from below the comment
before acpi_pm_prepare(). Seems logical to me ...
> checkpatch will detect this error.
Well, I'd call it a false positive. :-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-18 0:02 ` Andrew Morton
2007-07-18 6:41 ` Rafael J. Wysocki
@ 2007-07-19 2:05 ` Len Brown
2007-07-19 9:17 ` Rafael J. Wysocki
1 sibling, 1 reply; 16+ messages in thread
From: Len Brown @ 2007-07-19 2:05 UTC (permalink / raw)
To: Andrew Morton, Rafael J. Wysocki
Cc: linux-acpi, LKML, Alan Stern, David Brownell, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
Rafael,
Please delete the instances of the string ACPI_STATE_S2 -- it doesn't exist in practice
and we don't want to imply it exists by inventing it here.
otherwise:
Acked-by: Len Brown <len.brown@intel.com>
thanks,
-Len
On Tuesday 17 July 2007 20:02, Andrew Morton wrote:
> On Tue, 17 Jul 2007 22:40:06 +0200
> "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
>
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> >
> > In the future some drivers may need to use ACPI to determine the low power
> > states in which to place their devices, but to provide the drivers with this
> > information the ACPI core needs to know what sleep state the system is going to
> > enter. Namely, the device's state should not be too high power for given system
> > sleep state and, if the device is supposed to be able to wake up the system, its
> > state should not be too low power for the wake up to be possible). For this
> > purpose, the ACPI core needs to implement the set_target() method in 'struct
> > pm_ops' and store the target system sleep state passed by the PM core in a
> > variable.
> >
>
> Len, I can add this to the to-send-to-Len queue, but it would be more
> convenient at this end if you were to ack it and I'll send it in.
> Preferences?
>
>
> >
> > Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
> > ===================================================================
> > --- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
> > +++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
> > @@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
> >
> > static int init_8259A_after_S1;
> >
> > +extern int acpi_sleep_prepare(u32 acpi_state);
> > +extern void acpi_power_off(void);
>
> weep. Please don't do this.
>
> checkpatch will detect this error. Please check patches with checkpatch.
>
>
> (Full patch reproduced below for the benefit of the newly-added linux-acpi
> cc):
>
>
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> In the future some drivers may need to use ACPI to determine the low power
> states in which to place their devices, but to provide the drivers with this
> information the ACPI core needs to know what sleep state the system is going to
> enter. Namely, the device's state should not be too high power for given system
> sleep state and, if the device is supposed to be able to wake up the system, its
> state should not be too low power for the wake up to be possible). For this
> purpose, the ACPI core needs to implement the set_target() method in 'struct
> pm_ops' and store the target system sleep state passed by the PM core in a
> variable.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Acked-by: Pavel Machek <pavel@ucw.cz>
> ---
> drivers/acpi/sleep/main.c | 84 ++++++++++++++++++++++++++++------------------
> 1 file changed, 52 insertions(+), 32 deletions(-)
>
> Index: linux-2.6.22-git5/drivers/acpi/sleep/main.c
> ===================================================================
> --- linux-2.6.22-git5.orig/drivers/acpi/sleep/main.c
> +++ linux-2.6.22-git5/drivers/acpi/sleep/main.c
> @@ -34,34 +34,54 @@ static u32 acpi_suspend_states[] = {
>
> static int init_8259A_after_S1;
>
> +extern int acpi_sleep_prepare(u32 acpi_state);
> +extern void acpi_power_off(void);
> +
> +static u32 acpi_target_sleep_state = ACPI_STATE_S0;
> +
> +/**
> + * acpi_pm_set_target - Set the target system sleep state to the state
> + * associated with given @pm_state, if supported.
> + */
> +
> +static int acpi_pm_set_target(suspend_state_t pm_state)
> +{
> + u32 acpi_state = acpi_suspend_states[pm_state];
> + int error = 0;
> +
> + if (sleep_states[acpi_state]) {
> + acpi_target_sleep_state = acpi_state;
> + } else {
> + printk(KERN_ERR "ACPI does not support this state: %d\n",
> + pm_state);
> + error = -ENOSYS;
> + }
> + return error;
> +}
> +
> /**
> * acpi_pm_prepare - Do preliminary suspend work.
> - * @pm_state: suspend state we're entering.
> + * @pm_state: ignored
> *
> - * Make sure we support the state. If we do, and we need it, set the
> - * firmware waking vector and do arch-specific nastiness to get the
> - * wakeup code to the waking vector.
> + * If necessary, set the firmware waking vector and do arch-specific
> + * nastiness to get the wakeup code to the waking vector.
> */
>
> -extern int acpi_sleep_prepare(u32 acpi_state);
> -extern void acpi_power_off(void);
> -
> static int acpi_pm_prepare(suspend_state_t pm_state)
> {
> - u32 acpi_state = acpi_suspend_states[pm_state];
> + int error = acpi_sleep_prepare(acpi_target_sleep_state);
>
> - if (!sleep_states[acpi_state]) {
> - printk("acpi_pm_prepare does not support %d \n", pm_state);
> - return -EPERM;
> - }
> - return acpi_sleep_prepare(acpi_state);
> + if (error)
> + acpi_target_sleep_state = ACPI_STATE_S0;
> +
> + return error;
> }
>
> /**
> * acpi_pm_enter - Actually enter a sleep state.
> - * @pm_state: State we're entering.
> + * @pm_state: ignored
> *
> - * Flush caches and go to sleep. For STR or STD, we have to call
> + * Flush caches and go to sleep. For STR or S2, we have to call
> * arch-specific assembly, which in turn call acpi_enter_sleep_state().
> * It's unfortunate, but it works. Please fix if you're feeling frisky.
> */
> @@ -70,31 +90,32 @@ static int acpi_pm_enter(suspend_state_t
> {
> acpi_status status = AE_OK;
> unsigned long flags = 0;
> - u32 acpi_state = acpi_suspend_states[pm_state];
> + u32 acpi_state = acpi_target_sleep_state;
>
> ACPI_FLUSH_CPU_CACHE();
>
> /* Do arch specific saving of state. */
> - if (pm_state > PM_SUSPEND_STANDBY) {
> + if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3) {
> int error = acpi_save_state_mem();
> - if (error)
> +
> + if (error) {
> + acpi_target_sleep_state = ACPI_STATE_S0;
> return error;
> + }
> }
>
> local_irq_save(flags);
> acpi_enable_wakeup_device(acpi_state);
> - switch (pm_state) {
> - case PM_SUSPEND_STANDBY:
> + switch (acpi_state) {
> + case ACPI_STATE_S1:
> barrier();
> status = acpi_enter_sleep_state(acpi_state);
> break;
>
> - case PM_SUSPEND_MEM:
> + case ACPI_STATE_S2:
> + case ACPI_STATE_S3:
> do_suspend_lowlevel();
> break;
> -
> - default:
> - return -EINVAL;
> }
>
> /* ACPI 3.0 specs (P62) says that it's the responsabilty
> @@ -107,12 +128,8 @@ static int acpi_pm_enter(suspend_state_t
> local_irq_restore(flags);
> printk(KERN_DEBUG "Back to C!\n");
>
> - /* restore processor state
> - * We should only be here if we're coming back from STR or STD.
> - * And, in the case of the latter, the memory image should have already
> - * been loaded from disk.
> - */
> - if (pm_state > PM_SUSPEND_STANDBY)
> + /* restore processor state */
> + if (acpi_state == ACPI_STATE_S2 || acpi_state == ACPI_STATE_S3)
> acpi_restore_state_mem();
>
> return ACPI_SUCCESS(status) ? 0 : -EFAULT;
> @@ -120,7 +137,7 @@ static int acpi_pm_enter(suspend_state_t
>
> /**
> * acpi_pm_finish - Finish up suspend sequence.
> - * @pm_state: State we're coming out of.
> + * @pm_state: ignored
> *
> * This is called after we wake back up (or if entering the sleep state
> * failed).
> @@ -128,7 +145,7 @@ static int acpi_pm_enter(suspend_state_t
>
> static int acpi_pm_finish(suspend_state_t pm_state)
> {
> - u32 acpi_state = acpi_suspend_states[pm_state];
> + u32 acpi_state = acpi_target_sleep_state;
>
> acpi_leave_sleep_state(acpi_state);
> acpi_disable_wakeup_device(acpi_state);
> @@ -136,6 +153,8 @@ static int acpi_pm_finish(suspend_state_
> /* reset firmware waking vector */
> acpi_set_firmware_waking_vector((acpi_physical_address) 0);
>
> + acpi_target_sleep_state = ACPI_STATE_S0;
> +
> if (init_8259A_after_S1) {
> printk("Broken toshiba laptop -> kicking interrupts\n");
> init_8259A(0);
> @@ -176,6 +195,7 @@ static int acpi_pm_state_valid(suspend_s
>
> static struct pm_ops acpi_pm_ops = {
> .valid = acpi_pm_state_valid,
> + .set_target = acpi_pm_set_target,
> .prepare = acpi_pm_prepare,
> .enter = acpi_pm_enter,
> .finish = acpi_pm_finish,
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-19 2:05 ` Len Brown
@ 2007-07-19 9:17 ` Rafael J. Wysocki
0 siblings, 0 replies; 16+ messages in thread
From: Rafael J. Wysocki @ 2007-07-19 9:17 UTC (permalink / raw)
To: Len Brown
Cc: Andrew Morton, linux-acpi, LKML, Alan Stern, David Brownell,
Nigel Cunningham, Pavel Machek, Shaohua Li, Johannes Berg,
Paul Mackerras, Russell King
On Thursday, 19 July 2007 04:05, Len Brown wrote:
> Rafael,
> Please delete the instances of the string ACPI_STATE_S2 -- it doesn't exist in practice
> and we don't want to imply it exists by inventing it here.
OK, I will.
> otherwise:
> Acked-by: Len Brown <len.brown@intel.com>
Thanks!
Greetings,
Rafael
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
2007-07-18 0:02 ` Andrew Morton
@ 2007-07-21 19:26 ` David Brownell
1 sibling, 0 replies; 16+ messages in thread
From: David Brownell @ 2007-07-21 19:26 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andrew Morton, LKML, Alan Stern, Len Brown, Nigel Cunningham,
Pavel Machek, Shaohua Li, Johannes Berg, Paul Mackerras,
Russell King
On Tuesday 17 July 2007, Rafael J. Wysocki wrote:
> In the future some drivers may need to use ACPI to determine the low power
> states in which to place their devices, but to provide the drivers with this
> information the ACPI core needs to know what sleep state the system is going to
> enter. Namely, the device's state should not be too high power for given system
> sleep state and, if the device is supposed to be able to wake up the system, its
> state should not be too low power for the wake up to be possible). For this
> purpose, the ACPI core needs to implement the set_target() method in 'struct
> pm_ops' and store the target system sleep state passed by the PM core in a
> variable.
Modulo Len's "please remove non-existent S2 state", ACK.
We still have a general issue that most platforms implement
at most one of the sleep states the hardware allows (plus,
sometimes, hibernation).
A key differentiator of those different sleep states is usually
that they have characteristics which allow various devices to
work, or not. Like, oh, USB controllers which need a 48 MHz
oscillator to process wakeup events ... but the deepest sleep
states must disable that oscillator.
So it's a Good Thing that this patch (and #2) expose that more
complete model of system sleep states to drivers running on x86.
- Dave
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine
2007-07-17 20:40 ` [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine Rafael J. Wysocki
@ 2007-07-22 9:00 ` Len Brown
0 siblings, 0 replies; 16+ messages in thread
From: Len Brown @ 2007-07-22 9:00 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andrew Morton, LKML, Alan Stern, David Brownell, Len Brown,
Nigel Cunningham, Pavel Machek, Shaohua Li, Johannes Berg,
Paul Mackerras, Russell King
Ugh,
this breaks the build if CONFIG_ACPI_SLEEP=n
maybe it is time to delete the CONFIG_ACPI_SLEEP config option....
-Len
On Tuesday 17 July 2007 16:40, Rafael J. Wysocki wrote:
> From: Shaohua Li <shaohua.li@intel.com>, Rafael J. Wysocki <rjw@sisk.pl>
>
> Based on the David Brownell's patch at
> http://marc.info/?l=linux-acpi&m=117873972806360&w=2
>
> Add a helper routine returning the lowest power (highest number) ACPI device
> power state that given device can be in while the system is in the sleep state
> indicated by acpi_target_sleep_state .
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Acked-by: Pavel Machek <pavel@ucw.cz>
> ---
> drivers/acpi/sleep/main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
> include/acpi/acpi_bus.h | 2 +
> 2 files changed, 77 insertions(+)
>
> Index: linux-2.6.22-git9/drivers/acpi/sleep/main.c
> ===================================================================
> --- linux-2.6.22-git9.orig/drivers/acpi/sleep/main.c
> +++ linux-2.6.22-git9/drivers/acpi/sleep/main.c
> @@ -255,6 +255,81 @@ static struct hibernation_ops acpi_hiber
> };
> #endif /* CONFIG_SOFTWARE_SUSPEND */
>
> +/**
> + * acpi_pm_device_sleep_state - return preferred power state of ACPI device
> + * in the system sleep state given by %acpi_target_sleep_state
> + * @dev: device to examine
> + * @wake: if set, the device should be able to wake up the system
> + * @d_min_p: used to store the upper limit of allowed states range
> + * Return value: preferred power state of the device on success, -ENODEV on
> + * failure (ie. if there's no 'struct acpi_device' for @dev)
> + *
> + * Find the lowest power (highest number) ACPI device power state that
> + * device @dev can be in while the system is in the sleep state represented
> + * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
> + * able to wake up the system from this sleep state. If @d_min_p is set,
> + * the highest power (lowest number) device power state of @dev allowed
> + * in this system sleep state is stored at the location pointed to by it.
> + *
> + * The caller must ensure that @dev is valid before using this function.
> + * The caller is also responsible for figuring out if the device is
> + * supposed to be able to wake up the system and passing this information
> + * via @wake.
> + */
> +
> +int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
> +{
> + acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
> + struct acpi_device *adev;
> + char acpi_method[] = "_SxD";
> + unsigned long d_min, d_max;
> +
> + if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
> + printk(KERN_ERR "ACPI handle has no context!\n");
> + return -ENODEV;
> + }
> +
> + acpi_method[2] = '0' + acpi_target_sleep_state;
> + /*
> + * If the sleep state is S0, we will return D3, but if the device has
> + * _S0W, we will use the value from _S0W
> + */
> + d_min = ACPI_STATE_D0;
> + d_max = ACPI_STATE_D3;
> +
> + /*
> + * If present, _SxD methods return the minimum D-state (highest power
> + * state) we can use for the corresponding S-states. Otherwise, the
> + * minimum D-state is D0 (ACPI 3.x).
> + *
> + * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
> + * provided -- that's our fault recovery, we ignore retval.
> + */
> + if (acpi_target_sleep_state > ACPI_STATE_S0)
> + acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
> +
> + /*
> + * If _PRW says we can wake up the system from the target sleep state,
> + * the D-state returned by _SxD is sufficient for that (we assume a
> + * wakeup-aware driver if wake is set). Still, if _SxW exists
> + * (ACPI 3.x), it should return the maximum (lowest power) D-state that
> + * can wake the system. _S0W may be valid, too.
> + */
> + if (acpi_target_sleep_state == ACPI_STATE_S0 ||
> + (wake && adev->wakeup.state.enabled &&
> + adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
> + acpi_method[3] = 'W';
> + acpi_evaluate_integer(handle, acpi_method, NULL, &d_max);
> + /* Sanity check */
> + if (d_max < d_min)
> + d_min = d_max;
> + }
> +
> + if (d_min_p)
> + *d_min_p = d_min;
> + return d_max;
> +}
> +
> /*
> * Toshiba fails to preserve interrupts over S1, reinitialization
> * of 8259 is needed after S1 resume.
> Index: linux-2.6.22-git9/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-2.6.22-git9.orig/include/acpi/acpi_bus.h
> +++ linux-2.6.22-git9/include/acpi/acpi_bus.h
> @@ -364,6 +364,8 @@ acpi_handle acpi_get_child(acpi_handle,
> acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
> #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
>
> +int acpi_pm_device_sleep_state(struct device *, int, int *);
> +
> #endif /* CONFIG_ACPI */
>
> #endif /*__ACPI_BUS_H__*/
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2007-07-22 9:02 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
2007-07-18 0:02 ` Andrew Morton
2007-07-18 6:41 ` Rafael J. Wysocki
2007-07-19 2:05 ` Len Brown
2007-07-19 9:17 ` Rafael J. Wysocki
2007-07-21 19:26 ` David Brownell
2007-07-17 20:40 ` [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine Rafael J. Wysocki
2007-07-22 9:00 ` Len Brown
2007-07-17 20:42 ` [Resend][PATCH 3/9] PM: Move definition of struct pm_ops to suspend.h Rafael J. Wysocki
2007-07-17 20:43 ` [Resend][PATCH 4/9] PM: Rename struct pm_ops and related things Rafael J. Wysocki
2007-07-17 20:44 ` [Resend][PATCH 5/9] PM: Rework struct platform_suspend_ops Rafael J. Wysocki
2007-07-17 20:45 ` [Resend][PATCH 6/9] PM: Fix compilation of suspend code if CONFIG_PM is unset Rafael J. Wysocki
2007-07-17 20:46 ` [Resend][PATCH 7/9] PM: Make suspend_ops static Rafael J. Wysocki
2007-07-17 20:47 ` [Resend][PATCH 8/9] PM: Rework struct hibernation_ops Rafael J. Wysocki
2007-07-17 20:48 ` [Resend][PATCH 9/9] PM: Rename hibernation_ops to platform_hibernation_ops Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).