Commit 1f112cee authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PM / Hibernate: Introduce CONFIG_HIBERNATE_CALLBACKS

Xen save/restore is going to use hibernate device callbacks for
quiescing devices and putting them back to normal operations and it
would need to select CONFIG_HIBERNATION for this purpose.  However,
that also would cause the hibernate interfaces for user space to be
enabled, which might confuse user space, because the Xen kernels
don't support hibernation.  Moreover, it would be wasteful, as it
would make the Xen kernels include a substantial amount of code that
they would never use.

To address this issue introduce new power management Kconfig option
CONFIG_HIBERNATE_CALLBACKS, such that it will only select the code
that is necessary for the hibernate device callbacks to work and make
CONFIG_HIBERNATION select it.  Then, Xen save/restore will be able to
select CONFIG_HIBERNATE_CALLBACKS without dragging the entire
hibernate code along with it.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Tested-by: default avatarShriram Rajagopalan <rshriram@cs.ubc.ca>
parent b42282e5
...@@ -527,7 +527,7 @@ static int ibmebus_bus_pm_resume_noirq(struct device *dev) ...@@ -527,7 +527,7 @@ static int ibmebus_bus_pm_resume_noirq(struct device *dev)
#endif /* !CONFIG_SUSPEND */ #endif /* !CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
static int ibmebus_bus_pm_freeze(struct device *dev) static int ibmebus_bus_pm_freeze(struct device *dev)
{ {
...@@ -665,7 +665,7 @@ static int ibmebus_bus_pm_restore_noirq(struct device *dev) ...@@ -665,7 +665,7 @@ static int ibmebus_bus_pm_restore_noirq(struct device *dev)
return ret; return ret;
} }
#else /* !CONFIG_HIBERNATION */ #else /* !CONFIG_HIBERNATE_CALLBACKS */
#define ibmebus_bus_pm_freeze NULL #define ibmebus_bus_pm_freeze NULL
#define ibmebus_bus_pm_thaw NULL #define ibmebus_bus_pm_thaw NULL
...@@ -676,7 +676,7 @@ static int ibmebus_bus_pm_restore_noirq(struct device *dev) ...@@ -676,7 +676,7 @@ static int ibmebus_bus_pm_restore_noirq(struct device *dev)
#define ibmebus_bus_pm_poweroff_noirq NULL #define ibmebus_bus_pm_poweroff_noirq NULL
#define ibmebus_bus_pm_restore_noirq NULL #define ibmebus_bus_pm_restore_noirq NULL
#endif /* !CONFIG_HIBERNATION */ #endif /* !CONFIG_HIBERNATE_CALLBACKS */
static struct dev_pm_ops ibmebus_bus_dev_pm_ops = { static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
.prepare = ibmebus_bus_pm_prepare, .prepare = ibmebus_bus_pm_prepare,
......
...@@ -214,7 +214,7 @@ static int amba_pm_resume_noirq(struct device *dev) ...@@ -214,7 +214,7 @@ static int amba_pm_resume_noirq(struct device *dev)
#endif /* !CONFIG_SUSPEND */ #endif /* !CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
static int amba_pm_freeze(struct device *dev) static int amba_pm_freeze(struct device *dev)
{ {
...@@ -352,7 +352,7 @@ static int amba_pm_restore_noirq(struct device *dev) ...@@ -352,7 +352,7 @@ static int amba_pm_restore_noirq(struct device *dev)
return ret; return ret;
} }
#else /* !CONFIG_HIBERNATION */ #else /* !CONFIG_HIBERNATE_CALLBACKS */
#define amba_pm_freeze NULL #define amba_pm_freeze NULL
#define amba_pm_thaw NULL #define amba_pm_thaw NULL
...@@ -363,7 +363,7 @@ static int amba_pm_restore_noirq(struct device *dev) ...@@ -363,7 +363,7 @@ static int amba_pm_restore_noirq(struct device *dev)
#define amba_pm_poweroff_noirq NULL #define amba_pm_poweroff_noirq NULL
#define amba_pm_restore_noirq NULL #define amba_pm_restore_noirq NULL
#endif /* !CONFIG_HIBERNATION */ #endif /* !CONFIG_HIBERNATE_CALLBACKS */
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -771,7 +771,7 @@ int __weak platform_pm_resume_noirq(struct device *dev) ...@@ -771,7 +771,7 @@ int __weak platform_pm_resume_noirq(struct device *dev)
#endif /* !CONFIG_SUSPEND */ #endif /* !CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
static int platform_pm_freeze(struct device *dev) static int platform_pm_freeze(struct device *dev)
{ {
...@@ -909,7 +909,7 @@ static int platform_pm_restore_noirq(struct device *dev) ...@@ -909,7 +909,7 @@ static int platform_pm_restore_noirq(struct device *dev)
return ret; return ret;
} }
#else /* !CONFIG_HIBERNATION */ #else /* !CONFIG_HIBERNATE_CALLBACKS */
#define platform_pm_freeze NULL #define platform_pm_freeze NULL
#define platform_pm_thaw NULL #define platform_pm_thaw NULL
...@@ -920,7 +920,7 @@ static int platform_pm_restore_noirq(struct device *dev) ...@@ -920,7 +920,7 @@ static int platform_pm_restore_noirq(struct device *dev)
#define platform_pm_poweroff_noirq NULL #define platform_pm_poweroff_noirq NULL
#define platform_pm_restore_noirq NULL #define platform_pm_restore_noirq NULL
#endif /* !CONFIG_HIBERNATION */ #endif /* !CONFIG_HIBERNATE_CALLBACKS */
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
......
...@@ -233,7 +233,7 @@ static int pm_op(struct device *dev, ...@@ -233,7 +233,7 @@ static int pm_op(struct device *dev,
} }
break; break;
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
case PM_EVENT_FREEZE: case PM_EVENT_FREEZE:
case PM_EVENT_QUIESCE: case PM_EVENT_QUIESCE:
if (ops->freeze) { if (ops->freeze) {
...@@ -260,7 +260,7 @@ static int pm_op(struct device *dev, ...@@ -260,7 +260,7 @@ static int pm_op(struct device *dev,
suspend_report_result(ops->restore, error); suspend_report_result(ops->restore, error);
} }
break; break;
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATE_CALLBACKS */
default: default:
error = -EINVAL; error = -EINVAL;
} }
...@@ -308,7 +308,7 @@ static int pm_noirq_op(struct device *dev, ...@@ -308,7 +308,7 @@ static int pm_noirq_op(struct device *dev,
} }
break; break;
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
case PM_EVENT_FREEZE: case PM_EVENT_FREEZE:
case PM_EVENT_QUIESCE: case PM_EVENT_QUIESCE:
if (ops->freeze_noirq) { if (ops->freeze_noirq) {
...@@ -335,7 +335,7 @@ static int pm_noirq_op(struct device *dev, ...@@ -335,7 +335,7 @@ static int pm_noirq_op(struct device *dev,
suspend_report_result(ops->restore_noirq, error); suspend_report_result(ops->restore_noirq, error);
} }
break; break;
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATE_CALLBACKS */
default: default:
error = -EINVAL; error = -EINVAL;
} }
......
...@@ -781,7 +781,7 @@ static int pci_pm_resume(struct device *dev) ...@@ -781,7 +781,7 @@ static int pci_pm_resume(struct device *dev)
#endif /* !CONFIG_SUSPEND */ #endif /* !CONFIG_SUSPEND */
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
static int pci_pm_freeze(struct device *dev) static int pci_pm_freeze(struct device *dev)
{ {
...@@ -970,7 +970,7 @@ static int pci_pm_restore(struct device *dev) ...@@ -970,7 +970,7 @@ static int pci_pm_restore(struct device *dev)
return error; return error;
} }
#else /* !CONFIG_HIBERNATION */ #else /* !CONFIG_HIBERNATE_CALLBACKS */
#define pci_pm_freeze NULL #define pci_pm_freeze NULL
#define pci_pm_freeze_noirq NULL #define pci_pm_freeze_noirq NULL
...@@ -981,7 +981,7 @@ static int pci_pm_restore(struct device *dev) ...@@ -981,7 +981,7 @@ static int pci_pm_restore(struct device *dev)
#define pci_pm_restore NULL #define pci_pm_restore NULL
#define pci_pm_restore_noirq NULL #define pci_pm_restore_noirq NULL
#endif /* !CONFIG_HIBERNATION */ #endif /* !CONFIG_HIBERNATE_CALLBACKS */
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
......
...@@ -61,7 +61,7 @@ static void xen_post_suspend(int cancelled) ...@@ -61,7 +61,7 @@ static void xen_post_suspend(int cancelled)
xen_mm_unpin_all(); xen_mm_unpin_all();
} }
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
static int xen_suspend(void *data) static int xen_suspend(void *data)
{ {
struct suspend_info *si = data; struct suspend_info *si = data;
...@@ -173,7 +173,7 @@ static void do_suspend(void) ...@@ -173,7 +173,7 @@ static void do_suspend(void)
#endif #endif
shutting_down = SHUTDOWN_INVALID; shutting_down = SHUTDOWN_INVALID;
} }
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATE_CALLBACKS */
struct shutdown_handler { struct shutdown_handler {
const char *command; const char *command;
...@@ -202,7 +202,7 @@ static void shutdown_handler(struct xenbus_watch *watch, ...@@ -202,7 +202,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
{ "poweroff", do_poweroff }, { "poweroff", do_poweroff },
{ "halt", do_poweroff }, { "halt", do_poweroff },
{ "reboot", do_reboot }, { "reboot", do_reboot },
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATE_CALLBACKS
{ "suspend", do_suspend }, { "suspend", do_suspend },
#endif #endif
{NULL, NULL}, {NULL, NULL},
......
...@@ -249,6 +249,8 @@ extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); ...@@ -249,6 +249,8 @@ extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
extern int hibernate(void); extern int hibernate(void);
extern bool system_entering_hibernation(void); extern bool system_entering_hibernation(void);
#else /* CONFIG_HIBERNATION */ #else /* CONFIG_HIBERNATION */
static inline void register_nosave_region(unsigned long b, unsigned long e) {}
static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } 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_set_page_free(struct page *p) {}
static inline void swsusp_unset_page_free(struct page *p) {} static inline void swsusp_unset_page_free(struct page *p) {}
...@@ -297,14 +299,7 @@ static inline bool pm_wakeup_pending(void) { return false; } ...@@ -297,14 +299,7 @@ static inline bool pm_wakeup_pending(void) { return false; }
extern struct mutex pm_mutex; extern struct mutex pm_mutex;
#ifndef CONFIG_HIBERNATION #ifndef CONFIG_HIBERNATE_CALLBACKS
static inline void register_nosave_region(unsigned long b, unsigned long e)
{
}
static inline void register_nosave_region_late(unsigned long b, unsigned long e)
{
}
static inline void lock_system_sleep(void) {} static inline void lock_system_sleep(void) {}
static inline void unlock_system_sleep(void) {} static inline void unlock_system_sleep(void) {}
......
...@@ -18,9 +18,13 @@ config SUSPEND_FREEZER ...@@ -18,9 +18,13 @@ config SUSPEND_FREEZER
Turning OFF this setting is NOT recommended! If in doubt, say Y. Turning OFF this setting is NOT recommended! If in doubt, say Y.
config HIBERNATE_CALLBACKS
bool
config HIBERNATION config HIBERNATION
bool "Hibernation (aka 'suspend to disk')" bool "Hibernation (aka 'suspend to disk')"
depends on SWAP && ARCH_HIBERNATION_POSSIBLE depends on SWAP && ARCH_HIBERNATION_POSSIBLE
select HIBERNATE_CALLBACKS
select LZO_COMPRESS select LZO_COMPRESS
select LZO_DECOMPRESS select LZO_DECOMPRESS
---help--- ---help---
...@@ -85,7 +89,7 @@ config PM_STD_PARTITION ...@@ -85,7 +89,7 @@ config PM_STD_PARTITION
config PM_SLEEP config PM_SLEEP
def_bool y def_bool y
depends on SUSPEND || HIBERNATION || XEN_SAVE_RESTORE depends on SUSPEND || HIBERNATE_CALLBACKS || XEN_SAVE_RESTORE
config PM_SLEEP_SMP config PM_SLEEP_SMP
def_bool y def_bool y
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment