Skip to content

Commit

Permalink
[Kernel/Power] .35 Backport
Browse files Browse the repository at this point in the history
  • Loading branch information
thepasto committed Sep 28, 2012
1 parent 54e5ff8 commit 3f17336
Show file tree
Hide file tree
Showing 23 changed files with 977 additions and 499 deletions.
31 changes: 31 additions & 0 deletions drivers/char/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,37 @@ struct tty_driver *console_driver;

#ifdef CONFIG_VT_CONSOLE

/**
* vt_kmsg_redirect() - Sets/gets the kernel message console
* @new: The new virtual terminal number or -1 if the console should stay
* unchanged
*
* By default, the kernel messages are always printed on the current virtual
* console. However, the user may modify that default with the
* TIOCL_SETKMSGREDIRECT ioctl call.
*
* This function sets the kernel message console to be @new. It returns the old
* virtual console number. The virtual terminal number 0 (both as parameter and
* return value) means no redirection (i.e. always printed on the currently
* active console).
*
* The parameter -1 means that only the current console is returned, but the
* value is not modified. You may use the macro vt_get_kmsg_redirect() in that
* case to make the code more understandable.
*
* When the kernel is compiled without CONFIG_VT_CONSOLE, this function ignores
* the parameter and always returns 0.
*/
int vt_kmsg_redirect(int new)
{
static int kmsg_con;

if (new != -1)
return xchg(&kmsg_con, new);
else
return kmsg_con;
}

/*
* Console on virtual terminal
*
Expand Down
9 changes: 9 additions & 0 deletions include/linux/gfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct vm_area_struct;
#define GFP_HIGHUSER_MOVABLE (__GFP_WAIT | __GFP_IO | __GFP_FS | \
__GFP_HARDWALL | __GFP_HIGHMEM | \
__GFP_MOVABLE)
#define GFP_IOFS (__GFP_IO | __GFP_FS)

#ifdef CONFIG_NUMA
#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
Expand All @@ -84,6 +85,9 @@ struct vm_area_struct;
__GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\
__GFP_NORETRY|__GFP_NOMEMALLOC)

/* Control slab gfp mask during early boot */
#define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_WAIT|__GFP_IO|__GFP_FS))

/* Control allocation constraints */
#define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)

Expand Down Expand Up @@ -244,4 +248,9 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp);
void drain_all_pages(void);
void drain_local_pages(void *dummy);

extern gfp_t gfp_allowed_mask;

extern void pm_restrict_gfp_mask(void);
extern void pm_restore_gfp_mask(void);

#endif /* __LINUX_GFP_H */
1 change: 0 additions & 1 deletion include/linux/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ extern void disable_irq_nosync(unsigned int irq);
extern void disable_irq(unsigned int irq);
extern void enable_irq(unsigned int irq);

/* The following three functions are for the core kernel use only. */
#ifdef CONFIG_GENERIC_HARDIRQS
extern void suspend_device_irqs(void);
extern void resume_device_irqs(void);
Expand Down
134 changes: 3 additions & 131 deletions include/linux/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
#define _LINUX_PM_H

#include <linux/list.h>
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/timer.h>
#include <linux/completion.h>

/*
* Callbacks for platform drivers to implement.
Expand Down Expand Up @@ -170,29 +165,6 @@ typedef struct pm_message {
* It is allowed to unregister devices while the above callbacks are being
* executed. However, it is not allowed to unregister a device from within any
* of its own callbacks.
*
* There also are the following callbacks related to run-time power management
* of devices:
*
* @runtime_suspend: Prepare the device for a condition in which it won't be
* able to communicate with the CPU(s) and RAM due to power management.
* This need not mean that the device should be put into a low power state.
* For example, if the device is behind a link which is about to be turned
* off, the device may remain at full power. If the device does go to low
* power and is capable of generating run-time wake-up events, remote
* wake-up (i.e., a hardware mechanism allowing the device to request a
* change of its power state via a wake-up event, such as PCI PME) should
* be enabled for it.
*
* @runtime_resume: Put the device into the fully active state in response to a
* wake-up event generated by hardware or at the request of software. If
* necessary, put the device into the full power state and restore its
* registers, so that it is fully operational.
*
* @runtime_idle: Device appears to be inactive and it might be put into a low
* power state if all of the necessary conditions are satisfied. Check
* these conditions and handle the device as appropriate, possibly queueing
* a suspend request for it. The return value is ignored by the PM core.
*/

struct dev_pm_ops {
Expand All @@ -215,59 +187,6 @@ struct dev_pm_ops {
int (*runtime_idle)(struct device *dev);
};

#ifdef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend = suspend_fn, \
.resume = resume_fn, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,
#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#endif

#ifdef CONFIG_PM_RUNTIME
#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
.runtime_suspend = suspend_fn, \
.runtime_resume = resume_fn, \
.runtime_idle = idle_fn,
#else
#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
#endif

/*
* Use this if you want to use the same suspend and resume callbacks for suspend
* to RAM and hibernation.
*/
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
}

/*
* Use this for defining a set of PM operations to be used in all situations
* (sustem suspend, hibernation or runtime PM).
*/
#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
const struct dev_pm_ops name = { \
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
}

/*
* Use this for subsystems (bus types, device types, device classes) that don't
* need any special suspend/resume handling in addition to invoking the PM
* callbacks provided by device drivers supporting both the system sleep PM and
* runtime PM, make the pm member point to generic_subsys_pm_ops.
*/
#ifdef CONFIG_PM_OPS
extern struct dev_pm_ops generic_subsys_pm_ops;
#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops)
#else
#define GENERIC_SUBSYS_PM_OPS NULL
#endif

/**
* PM_EVENT_ messages
*
Expand Down Expand Up @@ -399,48 +318,13 @@ enum dpm_state {
DPM_OFF_IRQ,
};

/**
* Device run-time power management status.
*
* These status labels are used internally by the PM core to indicate the
* current status of a device with respect to the PM core operations. They do
* not reflect the actual power state of the device or its status as seen by the
* driver.
*
* RPM_ACTIVE Device is fully operational. Indicates that the device
* bus type's ->runtime_resume() callback has completed
* successfully.
*
* RPM_SUSPENDED Device bus type's ->runtime_suspend() callback has
* completed successfully. The device is regarded as
* suspended.
*
* RPM_RESUMING Device bus type's ->runtime_resume() callback is being
* executed.
*
* RPM_SUSPENDING Device bus type's ->runtime_suspend() callback is being
* executed.
*/

enum rpm_status {
RPM_ACTIVE = 0,
RPM_RESUMING,
RPM_SUSPENDED,
RPM_SUSPENDING,
};

/**
* Device run-time power management request types.
*
* RPM_REQ_NONE Do nothing.
*
* RPM_REQ_IDLE Run the device bus type's ->runtime_idle() callback
*
* RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback
*
* RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback
*/

enum rpm_request {
RPM_REQ_NONE = 0,
RPM_REQ_IDLE,
Expand All @@ -450,13 +334,11 @@ enum rpm_request {

struct dev_pm_info {
pm_message_t power_state;
unsigned int can_wakeup:1;
unsigned int should_wakeup:1;
unsigned async_suspend:1;
unsigned can_wakeup:1;
unsigned should_wakeup:1;
enum dpm_state status; /* Owned by the PM core */
#ifdef CONFIG_PM_SLEEP
#ifdef CONFIG_PM_SLEEP
struct list_head entry;
struct completion completion;
#endif
#ifdef CONFIG_PM_RUNTIME
struct timer_list suspend_timer;
Expand Down Expand Up @@ -551,7 +433,6 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
__suspend_report_result(__func__, fn, ret); \
} while (0)

extern void device_pm_wait_for_dev(struct device *sub, struct device *dev);
#else /* !CONFIG_PM_SLEEP */

#define device_pm_lock() do {} while (0)
Expand All @@ -564,17 +445,8 @@ static inline int dpm_suspend_start(pm_message_t state)

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

static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {}
#endif /* !CONFIG_PM_SLEEP */

/* How to reorder dpm_list after device_move() */
enum dpm_order {
DPM_ORDER_NONE,
DPM_ORDER_DEV_AFTER_PARENT,
DPM_ORDER_PARENT_BEFORE_DEV,
DPM_ORDER_DEV_LAST,
};

/*
* Global Power Management flags
* Used to keep APM and ACPI from both being active
Expand Down
19 changes: 19 additions & 0 deletions include/linux/vt.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,23 @@ struct vt_consize {
#define VT_UNLOCKSWITCH 0x560C /* allow vt switching */
#define VT_GETHIFONTMASK 0x560D /* return hi font mask */

#ifdef __KERNEL__

#ifdef CONFIG_VT_CONSOLE

extern int vt_kmsg_redirect(int new);

#else

static inline int vt_kmsg_redirect(int new)
{
return 0;
}

#endif

#endif /* __KERNEL__ */

#define vt_get_kmsg_redirect() vt_kmsg_redirect(-1)

#endif /* _LINUX_VT_H */
28 changes: 24 additions & 4 deletions kernel/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ config PM_DEBUG
code. This is helpful when debugging and reporting PM bugs, like
suspend support.

config PM_ADVANCED_DEBUG
bool "Extra PM attributes in sysfs for low-level debugging/testing"
depends on PM_DEBUG
default n
---help---
Add extra sysfs attributes allowing one to access some Power Management
fields of device objects from user space. If you are not a kernel
developer interested in debugging/testing Power Management, say "no".

config PM_VERBOSE
bool "Verbose Power Management debugging"
depends on PM_DEBUG
Expand Down Expand Up @@ -85,9 +94,18 @@ config PM_SLEEP
depends on SUSPEND || HIBERNATION || XEN_SAVE_RESTORE
default y

config PM_SLEEP_ADVANCED_DEBUG
bool
depends on PM_ADVANCED_DEBUG
default n

config SUSPEND_NVS
bool

config SUSPEND
bool "Suspend to RAM and standby"
depends on PM && ARCH_SUSPEND_POSSIBLE
select SUSPEND_NVS if HAS_IOMEM
default y
---help---
Allow the system to enter sleep states in which main memory is
Expand Down Expand Up @@ -116,9 +134,6 @@ config SUSPEND_FREEZER

Turning OFF this setting is NOT recommended! If in doubt, say Y.

config HIBERNATION_NVS
bool

config HAS_WAKELOCK
bool

Expand Down Expand Up @@ -189,7 +204,7 @@ endchoice
config HIBERNATION
bool "Hibernation (aka 'suspend to disk')"
depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
select HIBERNATION_NVS if HAS_IOMEM
select SUSPEND_NVS if HAS_IOMEM
---help---
Enable the suspend to disk (STD) functionality, which is usually
called "hibernation" in user interfaces. STD checkpoints the
Expand Down Expand Up @@ -289,3 +304,8 @@ config PM_RUNTIME
and the bus type drivers of the buses the devices are on are
responsible for the actual handling of the autosuspend requests and
wake-up events.

config PM_OPS
bool
depends on PM_SLEEP || PM_RUNTIME
default y
5 changes: 3 additions & 2 deletions kernel/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ obj-$(CONFIG_PM_SLEEP) += console.o
obj-$(CONFIG_FREEZER) += process.o
obj-$(CONFIG_SUSPEND) += suspend.o
obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o
obj-$(CONFIG_HIBERNATION) += swsusp.o hibernate.o snapshot.o swap.o user.o
obj-$(CONFIG_HIBERNATION_NVS) += hibernate_nvs.o
obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \
block_io.o
obj-$(CONFIG_SUSPEND_NVS) += nvs.o
obj-$(CONFIG_WAKELOCK) += wakelock.o
obj-$(CONFIG_USER_WAKELOCK) += userwakelock.o
obj-$(CONFIG_EARLYSUSPEND) += earlysuspend.o
Expand Down
Loading

0 comments on commit 3f17336

Please sign in to comment.