Commit a8cbf225 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6: (26 commits)
  PM / Wakeup: Show wakeup sources statistics in debugfs
  PM: Introduce library for device-specific OPPs (v7)
  PM: Add sysfs attr for rechecking dev hash from PM trace
  PM: Lock PM device list mutex in show_dev_hash()
  PM / Runtime: Remove idle notification after failing suspend
  PM / Hibernate: Modify signature used to mark swap
  PM / Runtime: Reduce code duplication in core helper functions
  PM: Allow wakeup events to abort freezing of tasks
  PM: runtime: add missed pm_request_autosuspend
  PM / Hibernate: Make some boot messages look less scary
  PM / Runtime: Implement autosuspend support
  PM / Runtime: Add no_callbacks flag
  PM / Runtime: Combine runtime PM entry points
  PM / Runtime: Merge synchronous and async runtime routines
  PM / Runtime: Replace boolean arguments with bitflags
  PM / Runtime: Move code in drivers/base/power/runtime.c
  sysfs: Add sysfs_merge_group() and sysfs_unmerge_group()
  PM: Fix potential issue with failing asynchronous suspend
  PM / Wakeup: Introduce wakeup source objects and event statistics (v3)
  PM: Fix signed/unsigned warning in dpm_show_time()
  ...
parents e36f561a 9c034392
...@@ -77,3 +77,91 @@ Description: ...@@ -77,3 +77,91 @@ Description:
devices this attribute is set to "enabled" by bus type code or devices this attribute is set to "enabled" by bus type code or
device drivers and in that cases it should be safe to leave the device drivers and in that cases it should be safe to leave the
default value. default value.
What: /sys/devices/.../power/wakeup_count
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_count attribute contains the number
of signaled wakeup events associated with the device. This
attribute is read-only. If the device is not enabled to wake up
the system from sleep states, this attribute is empty.
What: /sys/devices/.../power/wakeup_active_count
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_active_count attribute contains the
number of times the processing of wakeup events associated with
the device was completed (at the kernel level). This attribute
is read-only. If the device is not enabled to wake up the
system from sleep states, this attribute is empty.
What: /sys/devices/.../power/wakeup_hit_count
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_hit_count attribute contains the
number of times the processing of a wakeup event associated with
the device might prevent the system from entering a sleep state.
This attribute is read-only. If the device is not enabled to
wake up the system from sleep states, this attribute is empty.
What: /sys/devices/.../power/wakeup_active
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_active attribute contains either 1,
or 0, depending on whether or not a wakeup event associated with
the device is being processed (1). This attribute is read-only.
If the device is not enabled to wake up the system from sleep
states, this attribute is empty.
What: /sys/devices/.../power/wakeup_total_time_ms
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_total_time_ms attribute contains
the total time of processing wakeup events associated with the
device, in milliseconds. This attribute is read-only. If the
device is not enabled to wake up the system from sleep states,
this attribute is empty.
What: /sys/devices/.../power/wakeup_max_time_ms
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_max_time_ms attribute contains
the maximum time of processing a single wakeup event associated
with the device, in milliseconds. This attribute is read-only.
If the device is not enabled to wake up the system from sleep
states, this attribute is empty.
What: /sys/devices/.../power/wakeup_last_time_ms
Date: September 2010
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../wakeup_last_time_ms attribute contains
the value of the monotonic clock corresponding to the time of
signaling the last wakeup event associated with the device, in
milliseconds. This attribute is read-only. If the device is
not enabled to wake up the system from sleep states, this
attribute is empty.
What: /sys/devices/.../power/autosuspend_delay_ms
Date: September 2010
Contact: Alan Stern <stern@rowland.harvard.edu>
Description:
The /sys/devices/.../power/autosuspend_delay_ms attribute
contains the autosuspend delay value (in milliseconds). Some
drivers do not want their device to suspend as soon as it
becomes idle at run time; they want the device to remain
inactive for a certain minimum period of time first. That
period is called the autosuspend delay. Negative values will
prevent the device from being suspended at run time (similar
to writing "on" to the power/control attribute). Values >=
1000 will cause the autosuspend timer expiration to be rounded
up to the nearest second.
Not all drivers support this attribute. If it isn't supported,
attempts to read or write it will yield I/O errors.
...@@ -99,9 +99,38 @@ Description: ...@@ -99,9 +99,38 @@ Description:
dmesg -s 1000000 | grep 'hash matches' dmesg -s 1000000 | grep 'hash matches'
If you do not get any matches (or they appear to be false
positives), it is possible that the last PM event point
referred to a device created by a loadable kernel module. In
this case cat /sys/power/pm_trace_dev_match (see below) after
your system is started up and the kernel modules are loaded.
CAUTION: Using it will cause your machine's real-time (CMOS) CAUTION: Using it will cause your machine's real-time (CMOS)
clock to be set to a random invalid time after a resume. clock to be set to a random invalid time after a resume.
What; /sys/power/pm_trace_dev_match
Date: October 2010
Contact: James Hogan <james@albanarts.com>
Description:
The /sys/power/pm_trace_dev_match file contains the name of the
device associated with the last PM event point saved in the RTC
across reboots when pm_trace has been used. More precisely it
contains the list of current devices (including those
registered by loadable kernel modules since boot) which match
the device hash in the RTC at boot, with a newline after each
one.
The advantage of this file over the hash matches printed to the
kernel log (see /sys/power/pm_trace), is that it includes
devices created after boot by loadable kernel modules.
Due to the small hash size necessary to fit in the RTC, it is
possible that more than one device matches the hash, in which
case further investigation is required to determine which
device is causing the problem. Note that genuine RTC clock
values (such as when pm_trace has not been used), can still
match a device and output it's name here.
What: /sys/power/pm_async What: /sys/power/pm_async
Date: January 2009 Date: January 2009
Contact: Rafael J. Wysocki <rjw@sisk.pl> Contact: Rafael J. Wysocki <rjw@sisk.pl>
......
...@@ -2170,6 +2170,11 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -2170,6 +2170,11 @@ and is between 256 and 4096 characters. It is defined in the file
in <PAGE_SIZE> units (needed only for swap files). in <PAGE_SIZE> units (needed only for swap files).
See Documentation/power/swsusp-and-swap-files.txt See Documentation/power/swsusp-and-swap-files.txt
hibernate= [HIBERNATION]
noresume Don't check if there's a hibernation image
present during boot.
nocompress Don't compress/decompress hibernation images.
retain_initrd [RAM] Keep initrd memory after extraction retain_initrd [RAM] Keep initrd memory after extraction
rhash_entries= [KNL,NET] rhash_entries= [KNL,NET]
......
...@@ -14,6 +14,8 @@ interface.txt ...@@ -14,6 +14,8 @@ interface.txt
- Power management user interface in /sys/power - Power management user interface in /sys/power
notifiers.txt notifiers.txt
- Registering suspend notifiers in device drivers - Registering suspend notifiers in device drivers
opp.txt
- Operating Performance Point library
pci.txt pci.txt
- How the PCI Subsystem Does Power Management - How the PCI Subsystem Does Power Management
pm_qos_interface.txt pm_qos_interface.txt
......
...@@ -57,7 +57,7 @@ smallest image possible. In particular, if "0" is written to this file, the ...@@ -57,7 +57,7 @@ smallest image possible. In particular, if "0" is written to this file, the
suspend image will be as small as possible. suspend image will be as small as possible.
Reading from this file will display the current image size limit, which Reading from this file will display the current image size limit, which
is set to 500 MB by default. is set to 2/5 of available RAM by default.
/sys/power/pm_trace controls the code which saves the last PM event point in /sys/power/pm_trace controls the code which saves the last PM event point in
the RTC across reboots, so that you can debug a machine that just hangs the RTC across reboots, so that you can debug a machine that just hangs
......
This diff is collapsed.
This diff is collapsed.
...@@ -49,6 +49,13 @@ machine that doesn't boot) is: ...@@ -49,6 +49,13 @@ machine that doesn't boot) is:
device (lspci and /sys/devices/pci* is your friend), and see if you can device (lspci and /sys/devices/pci* is your friend), and see if you can
fix it, disable it, or trace into its resume function. fix it, disable it, or trace into its resume function.
If no device matches the hash (or any matches appear to be false positives),
the culprit may be a device from a loadable kernel module that is not loaded
until after the hash is checked. You can check the hash against the current
devices again after more modules are loaded using sysfs:
cat /sys/power/pm_trace_dev_match
For example, the above happens to be the VGA device on my EVO, which I For example, the above happens to be the VGA device on my EVO, which I
used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
that "radeonfb" simply cannot resume that device - it tries to set the that "radeonfb" simply cannot resume that device - it tries to set the
......
...@@ -66,7 +66,8 @@ swsusp saves the state of the machine into active swaps and then reboots or ...@@ -66,7 +66,8 @@ swsusp saves the state of the machine into active swaps and then reboots or
powerdowns. You must explicitly specify the swap partition to resume from with powerdowns. You must explicitly specify the swap partition to resume from with
``resume='' kernel option. If signature is found it loads and restores saved ``resume='' kernel option. If signature is found it loads and restores saved
state. If the option ``noresume'' is specified as a boot parameter, it skips state. If the option ``noresume'' is specified as a boot parameter, it skips
the resuming. the resuming. If the option ``hibernate=nocompress'' is specified as a boot
parameter, it saves hibernation image without compression.
In the meantime while the system is suspended you should not add/remove any In the meantime while the system is suspended you should not add/remove any
of the hardware, write to the filesystems, etc. of the hardware, write to the filesystems, etc.
......
...@@ -3,6 +3,7 @@ obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o ...@@ -3,6 +3,7 @@ obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_RUNTIME) += runtime.o
obj-$(CONFIG_PM_OPS) += generic_ops.o obj-$(CONFIG_PM_OPS) += generic_ops.o
obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o
obj-$(CONFIG_PM_OPP) += opp.o
ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
ccflags-$(CONFIG_PM_VERBOSE) += -DDEBUG ccflags-$(CONFIG_PM_VERBOSE) += -DDEBUG
...@@ -46,7 +46,7 @@ int pm_generic_runtime_suspend(struct device *dev) ...@@ -46,7 +46,7 @@ int pm_generic_runtime_suspend(struct device *dev)
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int ret; int ret;
ret = pm && pm->runtime_suspend ? pm->runtime_suspend(dev) : -EINVAL; ret = pm && pm->runtime_suspend ? pm->runtime_suspend(dev) : 0;
return ret; return ret;
} }
...@@ -65,7 +65,7 @@ int pm_generic_runtime_resume(struct device *dev) ...@@ -65,7 +65,7 @@ int pm_generic_runtime_resume(struct device *dev)
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int ret; int ret;
ret = pm && pm->runtime_resume ? pm->runtime_resume(dev) : -EINVAL; ret = pm && pm->runtime_resume ? pm->runtime_resume(dev) : 0;
return ret; return ret;
} }
......
...@@ -51,6 +51,8 @@ static pm_message_t pm_transition; ...@@ -51,6 +51,8 @@ static pm_message_t pm_transition;
*/ */
static bool transition_started; static bool transition_started;
static int async_error;
/** /**
* device_pm_init - Initialize the PM-related part of a device object. * device_pm_init - Initialize the PM-related part of a device object.
* @dev: Device object being initialized. * @dev: Device object being initialized.
...@@ -60,7 +62,8 @@ void device_pm_init(struct device *dev) ...@@ -60,7 +62,8 @@ void device_pm_init(struct device *dev)
dev->power.status = DPM_ON; dev->power.status = DPM_ON;
init_completion(&dev->power.completion); init_completion(&dev->power.completion);
complete_all(&dev->power.completion); complete_all(&dev->power.completion);
dev->power.wakeup_count = 0; dev->power.wakeup = NULL;
spin_lock_init(&dev->power.lock);
pm_runtime_init(dev); pm_runtime_init(dev);
} }
...@@ -120,6 +123,7 @@ void device_pm_remove(struct device *dev) ...@@ -120,6 +123,7 @@ void device_pm_remove(struct device *dev)
mutex_lock(&dpm_list_mtx); mutex_lock(&dpm_list_mtx);
list_del_init(&dev->power.entry); list_del_init(&dev->power.entry);
mutex_unlock(&dpm_list_mtx); mutex_unlock(&dpm_list_mtx);
device_wakeup_disable(dev);
pm_runtime_remove(dev); pm_runtime_remove(dev);
} }
...@@ -407,7 +411,7 @@ static void pm_dev_err(struct device *dev, pm_message_t state, char *info, ...@@ -407,7 +411,7 @@ static void pm_dev_err(struct device *dev, pm_message_t state, char *info,
static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info) static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
{ {
ktime_t calltime; ktime_t calltime;
s64 usecs64; u64 usecs64;
int usecs; int usecs;
calltime = ktime_get(); calltime = ktime_get();
...@@ -600,6 +604,7 @@ static void dpm_resume(pm_message_t state) ...@@ -600,6 +604,7 @@ static void dpm_resume(pm_message_t state)
INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&list);
mutex_lock(&dpm_list_mtx); mutex_lock(&dpm_list_mtx);
pm_transition = state; pm_transition = state;
async_error = 0;
list_for_each_entry(dev, &dpm_list, power.entry) { list_for_each_entry(dev, &dpm_list, power.entry) {
if (dev->power.status < DPM_OFF) if (dev->power.status < DPM_OFF)
...@@ -829,8 +834,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state, ...@@ -829,8 +834,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state,
return error; return error;
} }
static int async_error;
/** /**
* device_suspend - Execute "suspend" callbacks for given device. * device_suspend - Execute "suspend" callbacks for given device.
* @dev: Device to handle. * @dev: Device to handle.
...@@ -885,6 +888,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) ...@@ -885,6 +888,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
device_unlock(dev); device_unlock(dev);
complete_all(&dev->power.completion); complete_all(&dev->power.completion);
if (error)
async_error = error;
return error; return error;
} }
...@@ -894,10 +900,8 @@ static void async_suspend(void *data, async_cookie_t cookie) ...@@ -894,10 +900,8 @@ static void async_suspend(void *data, async_cookie_t cookie)
int error; int error;
error = __device_suspend(dev, pm_transition, true); error = __device_suspend(dev, pm_transition, true);
if (error) { if (error)
pm_dev_err(dev, pm_transition, " async", error); pm_dev_err(dev, pm_transition, " async", error);
async_error = error;
}
put_device(dev); put_device(dev);
} }
...@@ -1085,8 +1089,9 @@ EXPORT_SYMBOL_GPL(__suspend_report_result); ...@@ -1085,8 +1089,9 @@ EXPORT_SYMBOL_GPL(__suspend_report_result);
* @dev: Device to wait for. * @dev: Device to wait for.
* @subordinate: Device that needs to wait for @dev. * @subordinate: Device that needs to wait for @dev.
*/ */
void device_pm_wait_for_dev(struct device *subordinate, struct device *dev) int device_pm_wait_for_dev(struct device *subordinate, struct device *dev)
{ {
dpm_wait(dev, subordinate->power.async_suspend); dpm_wait(dev, subordinate->power.async_suspend);
return async_error;
} }
EXPORT_SYMBOL_GPL(device_pm_wait_for_dev); EXPORT_SYMBOL_GPL(device_pm_wait_for_dev);
This diff is collapsed.
...@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct device *); ...@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct device *);
static inline void device_pm_init(struct device *dev) static inline void device_pm_init(struct device *dev)
{ {
spin_lock_init(&dev->power.lock);
pm_runtime_init(dev); pm_runtime_init(dev);
} }
...@@ -59,6 +60,7 @@ static inline void device_pm_move_last(struct device *dev) {} ...@@ -59,6 +60,7 @@ static inline void device_pm_move_last(struct device *dev) {}
extern int dpm_sysfs_add(struct device *); extern int dpm_sysfs_add(struct device *);
extern void dpm_sysfs_remove(struct device *); extern void dpm_sysfs_remove(struct device *);
extern void rpm_sysfs_remove(struct device *);
#else /* CONFIG_PM */ #else /* CONFIG_PM */
......
This diff is collapsed.
...@@ -75,12 +75,27 @@ ...@@ -75,12 +75,27 @@
* attribute is set to "enabled" by bus type code or device drivers and in * attribute is set to "enabled" by bus type code or device drivers and in
* that cases it should be safe to leave the default value. * that cases it should be safe to leave the default value.
* *
* autosuspend_delay_ms - Report/change a device's autosuspend_delay value
*
* Some drivers don't want to carry out a runtime suspend as soon as a
* device becomes idle; they want it always to remain idle for some period
* of time before suspending it. This period is the autosuspend_delay
* value (expressed in milliseconds) and it can be controlled by the user.
* If the value is negative then the device will never be runtime
* suspended.
*
* NOTE: The autosuspend_delay_ms attribute and the autosuspend_delay
* value are used only if the driver calls pm_runtime_use_autosuspend().
*
* wakeup_count - Report the number of wakeup events related to the device * wakeup_count - Report the number of wakeup events related to the device
*/ */
static const char enabled[] = "enabled"; static const char enabled[] = "enabled";
static const char disabled[] = "disabled"; static const char disabled[] = "disabled";
const char power_group_name[] = "power";
EXPORT_SYMBOL_GPL(power_group_name);
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
static const char ctrl_auto[] = "auto"; static const char ctrl_auto[] = "auto";
static const char ctrl_on[] = "on"; static const char ctrl_on[] = "on";
...@@ -170,6 +185,33 @@ static ssize_t rtpm_status_show(struct device *dev, ...@@ -170,6 +185,33 @@ static ssize_t rtpm_status_show(struct device *dev,
} }
static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
static ssize_t autosuspend_delay_ms_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
if (!dev->power.use_autosuspend)
return -EIO;
return sprintf(buf, "%d\n", dev->power.autosuspend_delay);
}
static ssize_t autosuspend_delay_ms_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
long delay;
if (!dev->power.use_autosuspend)
return -EIO;
if (strict_strtol(buf, 10, &delay) != 0 || delay != (int) delay)
return -EINVAL;
pm_runtime_set_autosuspend_delay(dev, delay);
return n;
}
static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show,
autosuspend_delay_ms_store);
#endif #endif
static ssize_t static ssize_t
...@@ -210,11 +252,122 @@ static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); ...@@ -210,11 +252,122 @@ static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
static ssize_t wakeup_count_show(struct device *dev, static ssize_t wakeup_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%lu\n", dev->power.wakeup_count); unsigned long count = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
count = dev->power.wakeup->event_count;
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_count, 0444, wakeup_count_show, NULL); static DEVICE_ATTR(wakeup_count, 0444, wakeup_count_show, NULL);
#endif
static ssize_t wakeup_active_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long count = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
count = dev->power.wakeup->active_count;
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL);
static ssize_t wakeup_hit_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned long count = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
count = dev->power.wakeup->hit_count;
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_hit_count, 0444, wakeup_hit_count_show, NULL);
static ssize_t wakeup_active_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int active = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
active = dev->power.wakeup->active;
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_active, 0444, wakeup_active_show, NULL);
static ssize_t wakeup_total_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
s64 msec = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
msec = ktime_to_ms(dev->power.wakeup->total_time);
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_total_time_ms, 0444, wakeup_total_time_show, NULL);
static ssize_t wakeup_max_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
s64 msec = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
msec = ktime_to_ms(dev->power.wakeup->max_time);
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_max_time_ms, 0444, wakeup_max_time_show, NULL);
static ssize_t wakeup_last_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
s64 msec = 0;
bool enabled = false;
spin_lock_irq(&dev->power.lock);
if (dev->power.wakeup) {
msec = ktime_to_ms(dev->power.wakeup->last_time);
enabled = true;
}
spin_unlock_irq(&dev->power.lock);
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
}
static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL);
#endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_PM_ADVANCED_DEBUG #ifdef CONFIG_PM_ADVANCED_DEBUG
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
...@@ -279,19 +432,20 @@ static DEVICE_ATTR(async, 0644, async_show, async_store); ...@@ -279,19 +432,20 @@ static DEVICE_ATTR(async, 0644, async_show, async_store);
#endif /* CONFIG_PM_ADVANCED_DEBUG */ #endif /* CONFIG_PM_ADVANCED_DEBUG */
static struct attribute * power_attrs[] = { static struct attribute * power_attrs[] = {
#ifdef CONFIG_PM_RUNTIME
&dev_attr_control.attr,
&dev_attr_runtime_status.attr,
&dev_attr_runtime_suspended_time.attr,
&dev_attr_runtime_active_time.attr,
#endif
&dev_attr_wakeup.attr, &dev_attr_wakeup.attr,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
&dev_attr_wakeup_count.attr, &dev_attr_wakeup_count.attr,
&dev_attr_wakeup_active_count.attr,
&dev_attr_wakeup_hit_count.attr,
&dev_attr_wakeup_active.attr,
&dev_attr_wakeup_total_time_ms.attr,
&dev_attr_wakeup_max_time_ms.attr,
&dev_attr_wakeup_last_time_ms.attr,
#endif #endif
#ifdef CONFIG_PM_ADVANCED_DEBUG #ifdef CONFIG_PM_ADVANCED_DEBUG
&dev_attr_async.attr, &dev_attr_async.attr,
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
&dev_attr_runtime_status.attr,
&dev_attr_runtime_usage.attr, &dev_attr_runtime_usage.attr,
&dev_attr_runtime_active_kids.attr, &dev_attr_runtime_active_kids.attr,
&dev_attr_runtime_enabled.attr, &dev_attr_runtime_enabled.attr,
...@@ -300,10 +454,53 @@ static struct attribute * power_attrs[] = { ...@@ -300,10 +454,53 @@ static struct attribute * power_attrs[] = {
NULL, NULL,
}; };
static struct attribute_group pm_attr_group = { static struct attribute_group pm_attr_group = {
.name = "power", .name = power_group_name,
.attrs = power_attrs, .attrs = power_attrs,
}; };
#ifdef CONFIG_PM_RUNTIME
static struct attribute *runtime_attrs[] = {
#ifndef CONFIG_PM_ADVANCED_DEBUG
&dev_attr_runtime_status.attr,
#endif
&dev_attr_control.attr,
&dev_attr_runtime_suspended_time.attr,
&dev_attr_runtime_active_time.attr,
&dev_attr_autosuspend_delay_ms.attr,
NULL,
};
static struct attribute_group pm_runtime_attr_group = {
.name = power_group_name,
.attrs = runtime_attrs,
};
int dpm_sysfs_add(struct device *dev)
{
int rc;
rc = sysfs_create_group(&dev->kobj, &pm_attr_group);
if (rc == 0 && !dev->power.no_callbacks) {
rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group);
if (rc)
sysfs_remove_group(&dev->kobj, &pm_attr_group);
}
return rc;
}
void rpm_sysfs_remove(struct device *dev)
{
sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
}
void dpm_sysfs_remove(struct device *dev)
{
rpm_sysfs_remove(dev);
sysfs_remove_group(&dev->kobj, &pm_attr_group);
}
#else /* CONFIG_PM_RUNTIME */
int dpm_sysfs_add(struct device * dev) int dpm_sysfs_add(struct device * dev)
{ {
return sysfs_create_group(&dev->kobj, &pm_attr_group); return sysfs_create_group(&dev->kobj, &pm_attr_group);
...@@ -313,3 +510,5 @@ void dpm_sysfs_remove(struct device * dev) ...@@ -313,3 +510,5 @@ void dpm_sysfs_remove(struct device * dev)
{ {
sysfs_remove_group(&dev->kobj, &pm_attr_group); sysfs_remove_group(&dev->kobj, &pm_attr_group);
} }
#endif
...@@ -188,8 +188,10 @@ static int show_file_hash(unsigned int value) ...@@ -188,8 +188,10 @@ static int show_file_hash(unsigned int value)
static int show_dev_hash(unsigned int value) static int show_dev_hash(unsigned int value)
{ {
int match = 0; int match = 0;
struct list_head *entry = dpm_list.prev; struct list_head *entry;
device_pm_lock();
entry = dpm_list.prev;
while (entry != &dpm_list) { while (entry != &dpm_list) {
struct device * dev = to_device(entry); struct device * dev = to_device(entry);
unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH); unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH);
...@@ -199,11 +201,43 @@ static int show_dev_hash(unsigned int value) ...@@ -199,11 +201,43 @@ static int show_dev_hash(unsigned int value)
} }
entry = entry->prev; entry = entry->prev;
} }
device_pm_unlock();
return match; return match;
} }
static unsigned int hash_value_early_read; static unsigned int hash_value_early_read;
int show_trace_dev_match(char *buf, size_t size)
{
unsigned int value = hash_value_early_read / (USERHASH * FILEHASH);
int ret = 0;
struct list_head *entry;
/*
* It's possible that multiple devices will match the hash and we can't
* tell which is the culprit, so it's best to output them all.
*/
device_pm_lock();
entry = dpm_list.prev;
while (size && entry != &dpm_list) {
struct device *dev = to_device(entry);
unsigned int hash = hash_string(DEVSEED, dev_name(dev),
DEVHASH);
if (hash == value) {
int len = snprintf(buf, size, "%s\n",
dev_driver_string(dev));
if (len > size)
len = size;
buf += len;
ret += len;
size -= len;
}
entry = entry->prev;
}
device_pm_unlock();
return ret;
}
static int early_resume_init(void) static int early_resume_init(void)
{ {
hash_value_early_read = read_magic_time(); hash_value_early_read = read_magic_time();
......
This diff is collapsed.
...@@ -148,6 +148,65 @@ void sysfs_remove_group(struct kobject * kobj, ...@@ -148,6 +148,65 @@ void sysfs_remove_group(struct kobject * kobj,
sysfs_put(sd); sysfs_put(sd);
} }
/**
* sysfs_merge_group - merge files into a pre-existing attribute group.
* @kobj: The kobject containing the group.
* @grp: The files to create and the attribute group they belong to.
*
* This function returns an error if the group doesn't exist or any of the
* files already exist in that group, in which case none of the new files
* are created.
*/
int sysfs_merge_group(struct kobject *kobj,
const struct attribute_group *grp)
{
struct sysfs_dirent *dir_sd;
int error = 0;
struct attribute *const *attr;
int i;
if (grp)
dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
else
dir_sd = sysfs_get(kobj->sd);
if (!dir_sd)
return -ENOENT;
for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr))
error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
if (error) {
while (--i >= 0)
sysfs_hash_and_remove(dir_sd, NULL, (*--attr)->name);
}
sysfs_put(dir_sd);
return error;
}
EXPORT_SYMBOL_GPL(sysfs_merge_group);
/**
* sysfs_unmerge_group - remove files from a pre-existing attribute group.
* @kobj: The kobject containing the group.
* @grp: The files to remove and the attribute group they belong to.
*/
void sysfs_unmerge_group(struct kobject *kobj,
const struct attribute_group *grp)
{
struct sysfs_dirent *dir_sd;
struct attribute *const *attr;
if (grp)
dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
else
dir_sd = sysfs_get(kobj->sd);
if (dir_sd) {
for (attr = grp->attrs; *attr; ++attr)
sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
sysfs_put(dir_sd);
}
}
EXPORT_SYMBOL_GPL(sysfs_unmerge_group);
EXPORT_SYMBOL_GPL(sysfs_create_group); EXPORT_SYMBOL_GPL(sysfs_create_group);
EXPORT_SYMBOL_GPL(sysfs_update_group); EXPORT_SYMBOL_GPL(sysfs_update_group);
......
/*
* Generic OPP Interface
*
* Copyright (C) 2009-2010 Texas Instruments Incorporated.
* Nishanth Menon
* Romit Dasgupta
* Kevin Hilman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __LINUX_OPP_H__
#define __LINUX_OPP_H__
#include <linux/err.h>
#include <linux/cpufreq.h>
struct opp;
#if defined(CONFIG_PM_OPP)
unsigned long opp_get_voltage(struct opp *opp);
unsigned long opp_get_freq(struct opp *opp);
int opp_get_opp_count(struct device *dev);
struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
bool available);
struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
int opp_enable(struct device *dev, unsigned long freq);
int opp_disable(struct device *dev, unsigned long freq);
#else
static inline unsigned long opp_get_voltage(struct opp *opp)
{
return 0;
}
static inline unsigned long opp_get_freq(struct opp *opp)
{
return 0;
}
static inline int opp_get_opp_count(struct device *dev)
{
return 0;
}
static inline struct opp *opp_find_freq_exact(struct device *dev,
unsigned long freq, bool available)
{
return ERR_PTR(-EINVAL);
}
static inline struct opp *opp_find_freq_floor(struct device *dev,
unsigned long *freq)
{
return ERR_PTR(-EINVAL);
}
static inline struct opp *opp_find_freq_ceil(struct device *dev,
unsigned long *freq)
{
return ERR_PTR(-EINVAL);
}
static inline int opp_add(struct device *dev, unsigned long freq,
unsigned long u_volt)
{
return -EINVAL;
}
static inline int opp_enable(struct device *dev, unsigned long freq)
{
return 0;
}
static inline int opp_disable(struct device *dev, unsigned long freq)
{
return 0;
}
#endif /* CONFIG_PM */
#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
int opp_init_cpufreq_table(struct device *dev,
struct cpufreq_frequency_table **table);
#else
static inline int opp_init_cpufreq_table(struct device *dev,
struct cpufreq_frequency_table **table)
{
return -EINVAL;
}
#endif /* CONFIG_CPU_FREQ */
#endif /* __LINUX_OPP_H__ */
...@@ -41,6 +41,12 @@ extern void (*pm_power_off_prepare)(void); ...@@ -41,6 +41,12 @@ extern void (*pm_power_off_prepare)(void);
struct device; struct device;
#ifdef CONFIG_PM
extern const char power_group_name[]; /* = "power" */
#else
#define power_group_name NULL
#endif
typedef struct pm_message { typedef struct pm_message {
int event; int event;
} pm_message_t; } pm_message_t;
...@@ -438,6 +444,9 @@ enum rpm_status { ...@@ -438,6 +444,9 @@ enum rpm_status {
* *
* RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback
* *
* RPM_REQ_AUTOSUSPEND Same as RPM_REQ_SUSPEND, but not until the device has
* been inactive for as long as power.autosuspend_delay
*
* RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback
*/ */
...@@ -445,26 +454,28 @@ enum rpm_request { ...@@ -445,26 +454,28 @@ enum rpm_request {
RPM_REQ_NONE = 0, RPM_REQ_NONE = 0,
RPM_REQ_IDLE, RPM_REQ_IDLE,
RPM_REQ_SUSPEND, RPM_REQ_SUSPEND,
RPM_REQ_AUTOSUSPEND,
RPM_REQ_RESUME, RPM_REQ_RESUME,
}; };
struct wakeup_source;
struct dev_pm_info { struct dev_pm_info {
pm_message_t power_state; pm_message_t power_state;
unsigned int can_wakeup:1; unsigned int can_wakeup:1;
unsigned int should_wakeup:1;
unsigned async_suspend:1; unsigned async_suspend:1;
enum dpm_state status; /* Owned by the PM core */ enum dpm_state status; /* Owned by the PM core */
spinlock_t lock;
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
struct list_head entry; struct list_head entry;
struct completion completion; struct completion completion;
unsigned long wakeup_count; struct wakeup_source *wakeup;
#endif #endif
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
struct timer_list suspend_timer; struct timer_list suspend_timer;
unsigned long timer_expires; unsigned long timer_expires;
struct work_struct work; struct work_struct work;
wait_queue_head_t wait_queue; wait_queue_head_t wait_queue;
spinlock_t lock;
atomic_t usage_count; atomic_t usage_count;
atomic_t child_count; atomic_t child_count;
unsigned int disable_depth:3; unsigned int disable_depth:3;
...@@ -474,9 +485,14 @@ struct dev_pm_info { ...@@ -474,9 +485,14 @@ struct dev_pm_info {
unsigned int deferred_resume:1; unsigned int deferred_resume:1;
unsigned int run_wake:1; unsigned int run_wake:1;
unsigned int runtime_auto:1; unsigned int runtime_auto:1;
unsigned int no_callbacks:1;
unsigned int use_autosuspend:1;
unsigned int timer_autosuspends:1;
enum rpm_request request; enum rpm_request request;
enum rpm_status runtime_status; enum rpm_status runtime_status;
int runtime_error; int runtime_error;
int autosuspend_delay;
unsigned long last_busy;
unsigned long active_jiffies; unsigned long active_jiffies;
unsigned long suspended_jiffies; unsigned long suspended_jiffies;
unsigned long accounting_timestamp; unsigned long accounting_timestamp;
...@@ -558,12 +574,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret); ...@@ -558,12 +574,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
__suspend_report_result(__func__, fn, ret); \ __suspend_report_result(__func__, fn, ret); \
} while (0) } while (0)
extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
/* drivers/base/power/wakeup.c */
extern void pm_wakeup_event(struct device *dev, unsigned int msec);
extern void pm_stay_awake(struct device *dev);
extern void pm_relax(void);
#else /* !CONFIG_PM_SLEEP */ #else /* !CONFIG_PM_SLEEP */
#define device_pm_lock() do {} while (0) #define device_pm_lock() do {} while (0)
...@@ -576,11 +587,10 @@ static inline int dpm_suspend_start(pm_message_t state) ...@@ -576,11 +587,10 @@ static inline int dpm_suspend_start(pm_message_t state)
#define suspend_report_result(fn, ret) do {} while (0) #define suspend_report_result(fn, ret) do {} while (0)
static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
{
static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} return 0;
static inline void pm_stay_awake(struct device *dev) {} }
static inline void pm_relax(void) {}
#endif /* !CONFIG_PM_SLEEP */ #endif /* !CONFIG_PM_SLEEP */
/* How to reorder dpm_list after device_move() */ /* How to reorder dpm_list after device_move() */
......
...@@ -12,18 +12,24 @@ ...@@ -12,18 +12,24 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/jiffies.h>
/* Runtime PM flag argument bits */
#define RPM_ASYNC 0x01 /* Request is asynchronous */
#define RPM_NOWAIT 0x02 /* Don't wait for concurrent
state change */
#define RPM_GET_PUT 0x04 /* Increment/decrement the
usage_count */
#define RPM_AUTO 0x08 /* Use autosuspend_delay */
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
extern struct workqueue_struct *pm_wq; extern struct workqueue_struct *pm_wq;
extern int pm_runtime_idle(struct device *dev); extern int __pm_runtime_idle(struct device *dev, int rpmflags);
extern int pm_runtime_suspend(struct device *dev); extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
extern int pm_runtime_resume(struct device *dev); extern int __pm_runtime_resume(struct device *dev, int rpmflags);
extern int pm_request_idle(struct device *dev);
extern int pm_schedule_suspend(struct device *dev, unsigned int delay); extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
extern int pm_request_resume(struct device *dev);
extern int __pm_runtime_get(struct device *dev, bool sync);
extern int __pm_runtime_put(struct device *dev, bool sync);
extern int __pm_runtime_set_status(struct device *dev, unsigned int status); extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
extern int pm_runtime_barrier(struct device *dev); extern int pm_runtime_barrier(struct device *dev);
extern void pm_runtime_enable(struct device *dev); extern void pm_runtime_enable(struct device *dev);
...@@ -33,6 +39,10 @@ extern void pm_runtime_forbid(struct device *dev); ...@@ -33,6 +39,10 @@ extern void pm_runtime_forbid(struct device *dev);
extern int pm_generic_runtime_idle(struct device *dev); extern int pm_generic_runtime_idle(struct device *dev);
extern int pm_generic_runtime_suspend(struct device *dev); extern int pm_generic_runtime_suspend(struct device *dev);
extern int pm_generic_runtime_resume(struct device *dev); extern int pm_generic_runtime_resume(struct device *dev);
extern void pm_runtime_no_callbacks(struct device *dev);
extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev);
static inline bool pm_children_suspended(struct device *dev) static inline bool pm_children_suspended(struct device *dev)
{ {
...@@ -70,19 +80,29 @@ static inline bool pm_runtime_suspended(struct device *dev) ...@@ -70,19 +80,29 @@ static inline bool pm_runtime_suspended(struct device *dev)
return dev->power.runtime_status == RPM_SUSPENDED; return dev->power.runtime_status == RPM_SUSPENDED;
} }
static inline void pm_runtime_mark_last_busy(struct device *dev)
{
ACCESS_ONCE(dev->power.last_busy) = jiffies;
}
#else /* !CONFIG_PM_RUNTIME */ #else /* !CONFIG_PM_RUNTIME */
static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; } static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; } {
static inline int pm_runtime_resume(struct device *dev) { return 0; } return -ENOSYS;
static inline int pm_request_idle(struct device *dev) { return -ENOSYS; } }
static inline int __pm_runtime_suspend(struct device *dev, int rpmflags)
{
return -ENOSYS;
}
static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
{
return 1;
}
static inline int pm_schedule_suspend(struct device *dev, unsigned int delay) static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
{ {
return -ENOSYS; return -ENOSYS;
} }
static inline int pm_request_resume(struct device *dev) { return 0; }
static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; }
static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; }
static inline int __pm_runtime_set_status(struct device *dev, static inline int __pm_runtime_set_status(struct device *dev,
unsigned int status) { return 0; } unsigned int status) { return 0; }
static inline int pm_runtime_barrier(struct device *dev) { return 0; } static inline int pm_runtime_barrier(struct device *dev) { return 0; }
...@@ -102,27 +122,82 @@ static inline bool pm_runtime_suspended(struct device *dev) { return false; } ...@@ -102,27 +122,82 @@ static inline bool pm_runtime_suspended(struct device *dev) { return false; }
static inline int pm_generic_runtime_idle(struct device *dev) { return 0; } static inline int pm_generic_runtime_idle(struct device *dev) { return 0; }
static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
static inline void pm_runtime_no_callbacks(struct device *dev) {}
static inline void pm_runtime_mark_last_busy(struct device *dev) {}
static inline void __pm_runtime_use_autosuspend(struct device *dev,
bool use) {}
static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
int delay) {}
static inline unsigned long pm_runtime_autosuspend_expiration(
struct device *dev) { return 0; }
#endif /* !CONFIG_PM_RUNTIME */ #endif /* !CONFIG_PM_RUNTIME */
static inline int pm_runtime_idle(struct device *dev)
{
return __pm_runtime_idle(dev, 0);
}
static inline int pm_runtime_suspend(struct device *dev)
{
return __pm_runtime_suspend(dev, 0);
}
static inline int pm_runtime_autosuspend(struct device *dev)
{
return __pm_runtime_suspend(dev, RPM_AUTO);
}
static inline int pm_runtime_resume(struct device *dev)
{
return __pm_runtime_resume(dev, 0);
}
static inline int pm_request_idle(struct device *dev)
{
return __pm_runtime_idle(dev, RPM_ASYNC);
}
static inline int pm_request_resume(struct device *dev)
{
return __pm_runtime_resume(dev, RPM_ASYNC);
}
static inline int pm_request_autosuspend(struct device *dev)
{
return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO);
}
static inline int pm_runtime_get(struct device *dev) static inline int pm_runtime_get(struct device *dev)
{ {
return __pm_runtime_get(dev, false); return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC);
} }
static inline int pm_runtime_get_sync(struct device *dev) static inline int pm_runtime_get_sync(struct device *dev)
{ {
return __pm_runtime_get(dev, true); return __pm_runtime_resume(dev, RPM_GET_PUT);
} }
static inline int pm_runtime_put(struct device *dev) static inline int pm_runtime_put(struct device *dev)
{ {
return __pm_runtime_put(dev, false); return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
}
static inline int pm_runtime_put_autosuspend(struct device *dev)
{
return __pm_runtime_suspend(dev,
RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
} }
static inline int pm_runtime_put_sync(struct device *dev) static inline int pm_runtime_put_sync(struct device *dev)
{ {
return __pm_runtime_put(dev, true); return __pm_runtime_idle(dev, RPM_GET_PUT);
}
static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
{
return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
} }
static inline int pm_runtime_set_active(struct device *dev) static inline int pm_runtime_set_active(struct device *dev)
...@@ -140,4 +215,14 @@ static inline void pm_runtime_disable(struct device *dev) ...@@ -140,4 +215,14 @@ static inline void pm_runtime_disable(struct device *dev)
__pm_runtime_disable(dev, true); __pm_runtime_disable(dev, true);
} }
static inline void pm_runtime_use_autosuspend(struct device *dev)
{
__pm_runtime_use_autosuspend(dev, true);
}
static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
{
__pm_runtime_use_autosuspend(dev, false);
}
#endif #endif
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* pm_wakeup.h - Power management wakeup interface * pm_wakeup.h - Power management wakeup interface
* *
* Copyright (C) 2008 Alan Stern * Copyright (C) 2008 Alan Stern
* Copyright (C) 2010 Rafael J. Wysocki, Novell Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -27,19 +28,77 @@ ...@@ -27,19 +28,77 @@
#include <linux/types.h> #include <linux/types.h>
#ifdef CONFIG_PM /**
* struct wakeup_source - Representation of wakeup sources
/* Changes to device_may_wakeup take effect on the next pm state change.
* *
* By default, most devices should leave wakeup disabled. The exceptions * @total_time: Total time this wakeup source has been active.
* are devices that everyone expects to be wakeup sources: keyboards, * @max_time: Maximum time this wakeup source has been continuously active.
* power buttons, possibly network interfaces, etc. * @last_time: Monotonic clock when the wakeup source's was activated last time.
* @event_count: Number of signaled wakeup events.
* @active_count: Number of times the wakeup sorce was activated.
* @relax_count: Number of times the wakeup sorce was deactivated.
* @hit_count: Number of times the wakeup sorce might abort system suspend.
* @active: Status of the wakeup source.
*/ */
static inline void device_init_wakeup(struct device *dev, bool val) struct wakeup_source {
char *name;
struct list_head entry;
spinlock_t lock;
struct timer_list timer;
unsigned long timer_expires;
ktime_t total_time;
ktime_t max_time;
ktime_t last_time;
unsigned long event_count;
unsigned long active_count;
unsigned long relax_count;
unsigned long hit_count;
unsigned int active:1;
};
#ifdef CONFIG_PM_SLEEP
/*
* Changes to device_may_wakeup take effect on the next pm state change.
*/
static inline void device_set_wakeup_capable(struct device *dev, bool capable)
{
dev->power.can_wakeup = capable;
}
static inline bool device_can_wakeup(struct device *dev)
{
return dev->power.can_wakeup;
}
static inline bool device_may_wakeup(struct device *dev)
{ {
dev->power.can_wakeup = dev->power.should_wakeup = val; return dev->power.can_wakeup && !!dev->power.wakeup;
} }
/* drivers/base/power/wakeup.c */
extern struct wakeup_source *wakeup_source_create(const char *name);
extern void wakeup_source_destroy(struct wakeup_source *ws);
extern void wakeup_source_add(struct wakeup_source *ws);
extern void wakeup_source_remove(struct wakeup_source *ws);
extern struct wakeup_source *wakeup_source_register(const char *name);
extern void wakeup_source_unregister(struct wakeup_source *ws);
extern int device_wakeup_enable(struct device *dev);
extern int device_wakeup_disable(struct device *dev);
extern int device_init_wakeup(struct device *dev, bool val);
extern int device_set_wakeup_enable(struct device *dev, bool enable);
extern void __pm_stay_awake(struct wakeup_source *ws);
extern void pm_stay_awake(struct device *dev);
extern void __pm_relax(struct wakeup_source *ws);
extern void pm_relax(struct device *dev);
extern void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec);
extern void pm_wakeup_event(struct device *dev, unsigned int msec);
#else /* !CONFIG_PM_SLEEP */
static inline void device_set_wakeup_capable(struct device *dev, bool capable) static inline void device_set_wakeup_capable(struct device *dev, bool capable)
{ {
dev->power.can_wakeup = capable; dev->power.can_wakeup = capable;
...@@ -50,43 +109,63 @@ static inline bool device_can_wakeup(struct device *dev) ...@@ -50,43 +109,63 @@ static inline bool device_can_wakeup(struct device *dev)
return dev->power.can_wakeup; return dev->power.can_wakeup;
} }
static inline void device_set_wakeup_enable(struct device *dev, bool enable) static inline bool device_may_wakeup(struct device *dev)
{ {
dev->power.should_wakeup = enable; return false;
} }
static inline bool device_may_wakeup(struct device *dev) static inline struct wakeup_source *wakeup_source_create(const char *name)
{ {
return dev->power.can_wakeup && dev->power.should_wakeup; return NULL;
} }
#else /* !CONFIG_PM */ static inline void wakeup_source_destroy(struct wakeup_source *ws) {}
static inline void wakeup_source_add(struct wakeup_source *ws) {}
/* For some reason the following routines work even without CONFIG_PM */ static inline void wakeup_source_remove(struct wakeup_source *ws) {}
static inline void device_init_wakeup(struct device *dev, bool val)
static inline struct wakeup_source *wakeup_source_register(const char *name)
{ {
dev->power.can_wakeup = val; return NULL;
} }
static inline void device_set_wakeup_capable(struct device *dev, bool capable) static inline void wakeup_source_unregister(struct wakeup_source *ws) {}
static inline int device_wakeup_enable(struct device *dev)
{ {
dev->power.can_wakeup = capable; return -EINVAL;
} }
static inline bool device_can_wakeup(struct device *dev) static inline int device_wakeup_disable(struct device *dev)
{ {
return dev->power.can_wakeup; return 0;
} }
static inline void device_set_wakeup_enable(struct device *dev, bool enable) static inline int device_init_wakeup(struct device *dev, bool val)
{ {
dev->power.can_wakeup = val;
return val ? -EINVAL : 0;
} }
static inline bool device_may_wakeup(struct device *dev)
static inline int device_set_wakeup_enable(struct device *dev, bool enable)
{ {
return false; return -EINVAL;
} }
#endif /* !CONFIG_PM */ static inline void __pm_stay_awake(struct wakeup_source *ws) {}
static inline void pm_stay_awake(struct device *dev) {}
static inline void __pm_relax(struct wakeup_source *ws) {}
static inline void pm_relax(struct device *dev) {}
static inline void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec) {}
static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
#endif /* !CONFIG_PM_SLEEP */
#endif /* _LINUX_PM_WAKEUP_H */ #endif /* _LINUX_PM_WAKEUP_H */
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#ifdef CONFIG_PM_TRACE #ifdef CONFIG_PM_TRACE
#include <asm/resume-trace.h> #include <asm/resume-trace.h>
#include <linux/types.h>
extern int pm_trace_enabled; extern int pm_trace_enabled;
...@@ -14,6 +15,7 @@ static inline int pm_trace_is_enabled(void) ...@@ -14,6 +15,7 @@ static inline int pm_trace_is_enabled(void)
struct device; struct device;
extern void set_trace_device(struct device *); extern void set_trace_device(struct device *);
extern void generate_resume_trace(const void *tracedata, unsigned int user); extern void generate_resume_trace(const void *tracedata, unsigned int user);
extern int show_trace_dev_match(char *buf, size_t size);
#define TRACE_DEVICE(dev) do { \ #define TRACE_DEVICE(dev) do { \
if (pm_trace_enabled) \ if (pm_trace_enabled) \
......
...@@ -293,8 +293,8 @@ extern int unregister_pm_notifier(struct notifier_block *nb); ...@@ -293,8 +293,8 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
extern bool events_check_enabled; extern bool events_check_enabled;
extern bool pm_check_wakeup_events(void); extern bool pm_check_wakeup_events(void);
extern bool pm_get_wakeup_count(unsigned long *count); extern bool pm_get_wakeup_count(unsigned int *count);
extern bool pm_save_wakeup_count(unsigned long count); extern bool pm_save_wakeup_count(unsigned int count);
#else /* !CONFIG_PM_SLEEP */ #else /* !CONFIG_PM_SLEEP */
static inline int register_pm_notifier(struct notifier_block *nb) static inline int register_pm_notifier(struct notifier_block *nb)
...@@ -308,6 +308,8 @@ static inline int unregister_pm_notifier(struct notifier_block *nb) ...@@ -308,6 +308,8 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
} }
#define pm_notifier(fn, pri) do { (void)(fn); } while (0) #define pm_notifier(fn, pri) do { (void)(fn); } while (0)
static inline bool pm_check_wakeup_events(void) { return true; }
#endif /* !CONFIG_PM_SLEEP */ #endif /* !CONFIG_PM_SLEEP */
extern struct mutex pm_mutex; extern struct mutex pm_mutex;
......
...@@ -164,6 +164,10 @@ int sysfs_add_file_to_group(struct kobject *kobj, ...@@ -164,6 +164,10 @@ int sysfs_add_file_to_group(struct kobject *kobj,
const struct attribute *attr, const char *group); const struct attribute *attr, const char *group);
void sysfs_remove_file_from_group(struct kobject *kobj, void sysfs_remove_file_from_group(struct kobject *kobj,
const struct attribute *attr, const char *group); const struct attribute *attr, const char *group);
int sysfs_merge_group(struct kobject *kobj,
const struct attribute_group *grp);
void sysfs_unmerge_group(struct kobject *kobj,
const struct attribute_group *grp);
void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
void sysfs_notify_dirent(struct sysfs_dirent *sd); void sysfs_notify_dirent(struct sysfs_dirent *sd);
...@@ -302,6 +306,17 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj, ...@@ -302,6 +306,17 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
{ {
} }
static inline int sysfs_merge_group(struct kobject *kobj,
const struct attribute_group *grp)
{
return 0;
}
static inline void sysfs_unmerge_group(struct kobject *kobj,
const struct attribute_group *grp)
{
}
static inline void sysfs_notify(struct kobject *kobj, const char *dir, static inline void sysfs_notify(struct kobject *kobj, const char *dir,
const char *attr) const char *attr)
{ {
......
...@@ -86,6 +86,7 @@ config PM_SLEEP_SMP ...@@ -86,6 +86,7 @@ config PM_SLEEP_SMP
depends on SMP depends on SMP
depends on ARCH_SUSPEND_POSSIBLE || ARCH_HIBERNATION_POSSIBLE depends on ARCH_SUSPEND_POSSIBLE || ARCH_HIBERNATION_POSSIBLE
depends on PM_SLEEP depends on PM_SLEEP
select HOTPLUG
select HOTPLUG_CPU select HOTPLUG_CPU
default y default y
...@@ -137,6 +138,8 @@ config SUSPEND_FREEZER ...@@ -137,6 +138,8 @@ config SUSPEND_FREEZER
config HIBERNATION config HIBERNATION
bool "Hibernation (aka 'suspend to disk')" bool "Hibernation (aka 'suspend to disk')"
depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
select LZO_COMPRESS
select LZO_DECOMPRESS
select SUSPEND_NVS if HAS_IOMEM select SUSPEND_NVS if HAS_IOMEM
---help--- ---help---
Enable the suspend to disk (STD) functionality, which is usually Enable the suspend to disk (STD) functionality, which is usually
...@@ -242,3 +245,17 @@ config PM_OPS ...@@ -242,3 +245,17 @@ config PM_OPS
bool bool
depends on PM_SLEEP || PM_RUNTIME depends on PM_SLEEP || PM_RUNTIME
default y default y
config PM_OPP
bool "Operating Performance Point (OPP) Layer library"
depends on PM
---help---
SOCs have a standard set of tuples consisting of frequency and
voltage pairs that the device will support per voltage domain. This
is called Operating Performance Point or OPP. The actual definitions
of OPP varies over silicon within the same family of devices.
OPP layer organizes the data internally using device pointers
representing individual voltage domains and provides SOC
implementations a ready to use framework to manage OPPs.
For more information, read <file:Documentation/power/opp.txt>
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "power.h" #include "power.h"
static int nocompress = 0;
static int noresume = 0; static int noresume = 0;
static char resume_file[256] = CONFIG_PM_STD_PARTITION; static char resume_file[256] = CONFIG_PM_STD_PARTITION;
dev_t swsusp_resume_device; dev_t swsusp_resume_device;
...@@ -638,6 +639,8 @@ int hibernate(void) ...@@ -638,6 +639,8 @@ int hibernate(void)
if (hibernation_mode == HIBERNATION_PLATFORM) if (hibernation_mode == HIBERNATION_PLATFORM)
flags |= SF_PLATFORM_MODE; flags |= SF_PLATFORM_MODE;
if (nocompress)
flags |= SF_NOCOMPRESS_MODE;
pr_debug("PM: writing image.\n"); pr_debug("PM: writing image.\n");
error = swsusp_write(flags); error = swsusp_write(flags);
swsusp_free(); swsusp_free();
...@@ -705,7 +708,7 @@ static int software_resume(void) ...@@ -705,7 +708,7 @@ static int software_resume(void)
goto Unlock; goto Unlock;
} }
pr_debug("PM: Checking image partition %s\n", resume_file); pr_debug("PM: Checking hibernation image partition %s\n", resume_file);
/* Check if the device is there */ /* Check if the device is there */
swsusp_resume_device = name_to_dev_t(resume_file); swsusp_resume_device = name_to_dev_t(resume_file);
...@@ -730,10 +733,10 @@ static int software_resume(void) ...@@ -730,10 +733,10 @@ static int software_resume(void)
} }
Check_image: Check_image:
pr_debug("PM: Resume from partition %d:%d\n", pr_debug("PM: Hibernation image partition %d:%d present\n",
MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device));
pr_debug("PM: Checking hibernation image.\n"); pr_debug("PM: Looking for hibernation image.\n");
error = swsusp_check(); error = swsusp_check();
if (error) if (error)
goto Unlock; goto Unlock;
...@@ -765,14 +768,14 @@ static int software_resume(void) ...@@ -765,14 +768,14 @@ static int software_resume(void)
goto Done; goto Done;
} }
pr_debug("PM: Reading hibernation image.\n"); pr_debug("PM: Loading hibernation image.\n");
error = swsusp_read(&flags); error = swsusp_read(&flags);
swsusp_close(FMODE_READ); swsusp_close(FMODE_READ);
if (!error) if (!error)
hibernation_restore(flags & SF_PLATFORM_MODE); hibernation_restore(flags & SF_PLATFORM_MODE);
printk(KERN_ERR "PM: Restore failed, recovering.\n"); printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n");
swsusp_free(); swsusp_free();
thaw_processes(); thaw_processes();
Done: Done:
...@@ -785,7 +788,7 @@ static int software_resume(void) ...@@ -785,7 +788,7 @@ static int software_resume(void)
/* For success case, the suspend path will release the lock */ /* For success case, the suspend path will release the lock */
Unlock: Unlock:
mutex_unlock(&pm_mutex); mutex_unlock(&pm_mutex);
pr_debug("PM: Resume from disk failed.\n"); pr_debug("PM: Hibernation image not present or could not be loaded.\n");
return error; return error;
close_finish: close_finish:
swsusp_close(FMODE_READ); swsusp_close(FMODE_READ);
...@@ -1004,6 +1007,15 @@ static int __init resume_offset_setup(char *str) ...@@ -1004,6 +1007,15 @@ static int __init resume_offset_setup(char *str)
return 1; return 1;
} }
static int __init hibernate_setup(char *str)
{
if (!strncmp(str, "noresume", 8))
noresume = 1;
else if (!strncmp(str, "nocompress", 10))
nocompress = 1;
return 1;
}
static int __init noresume_setup(char *str) static int __init noresume_setup(char *str)
{ {
noresume = 1; noresume = 1;
...@@ -1013,3 +1025,4 @@ static int __init noresume_setup(char *str) ...@@ -1013,3 +1025,4 @@ static int __init noresume_setup(char *str)
__setup("noresume", noresume_setup); __setup("noresume", noresume_setup);
__setup("resume_offset=", resume_offset_setup); __setup("resume_offset=", resume_offset_setup);
__setup("resume=", resume_setup); __setup("resume=", resume_setup);
__setup("hibernate=", hibernate_setup);
...@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(struct kobject *kobj, ...@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
char *buf) char *buf)
{ {
unsigned long val; unsigned int val;
return pm_get_wakeup_count(&val) ? sprintf(buf, "%lu\n", val) : -EINTR; return pm_get_wakeup_count(&val) ? sprintf(buf, "%u\n", val) : -EINTR;
} }
static ssize_t wakeup_count_store(struct kobject *kobj, static ssize_t wakeup_count_store(struct kobject *kobj,
struct kobj_attribute *attr, struct kobj_attribute *attr,
const char *buf, size_t n) const char *buf, size_t n)
{ {
unsigned long val; unsigned int val;
if (sscanf(buf, "%lu", &val) == 1) { if (sscanf(buf, "%u", &val) == 1) {
if (pm_save_wakeup_count(val)) if (pm_save_wakeup_count(val))
return n; return n;
} }
...@@ -281,12 +281,30 @@ pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr, ...@@ -281,12 +281,30 @@ pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr,
} }
power_attr(pm_trace); power_attr(pm_trace);
static ssize_t pm_trace_dev_match_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
{
return show_trace_dev_match(buf, PAGE_SIZE);
}
static ssize_t
pm_trace_dev_match_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
return -EINVAL;
}
power_attr(pm_trace_dev_match);
#endif /* CONFIG_PM_TRACE */ #endif /* CONFIG_PM_TRACE */
static struct attribute * g[] = { static struct attribute * g[] = {
&state_attr.attr, &state_attr.attr,
#ifdef CONFIG_PM_TRACE #ifdef CONFIG_PM_TRACE
&pm_trace_attr.attr, &pm_trace_attr.attr,
&pm_trace_dev_match_attr.attr,
#endif #endif
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
&pm_async_attr.attr, &pm_async_attr.attr,
...@@ -308,7 +326,7 @@ EXPORT_SYMBOL_GPL(pm_wq); ...@@ -308,7 +326,7 @@ EXPORT_SYMBOL_GPL(pm_wq);
static int __init pm_start_workqueue(void) static int __init pm_start_workqueue(void)
{ {
pm_wq = create_freezeable_workqueue("pm"); pm_wq = alloc_workqueue("pm", WQ_FREEZEABLE, 0);
return pm_wq ? 0 : -ENOMEM; return pm_wq ? 0 : -ENOMEM;
} }
...@@ -321,6 +339,7 @@ static int __init pm_init(void) ...@@ -321,6 +339,7 @@ static int __init pm_init(void)
int error = pm_start_workqueue(); int error = pm_start_workqueue();
if (error) if (error)
return error; return error;
hibernate_image_size_init();
power_kobj = kobject_create_and_add("power", NULL); power_kobj = kobject_create_and_add("power", NULL);
if (!power_kobj) if (!power_kobj)
return -ENOMEM; return -ENOMEM;
......
...@@ -14,6 +14,9 @@ struct swsusp_info { ...@@ -14,6 +14,9 @@ struct swsusp_info {
} __attribute__((aligned(PAGE_SIZE))); } __attribute__((aligned(PAGE_SIZE)));
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATION
/* kernel/power/snapshot.c */
extern void __init hibernate_image_size_init(void);
#ifdef CONFIG_ARCH_HIBERNATION_HEADER #ifdef CONFIG_ARCH_HIBERNATION_HEADER
/* Maximum size of architecture specific data in a hibernation header */ /* Maximum size of architecture specific data in a hibernation header */
#define MAX_ARCH_HEADER_SIZE (sizeof(struct new_utsname) + 4) #define MAX_ARCH_HEADER_SIZE (sizeof(struct new_utsname) + 4)
...@@ -49,7 +52,11 @@ static inline char *check_image_kernel(struct swsusp_info *info) ...@@ -49,7 +52,11 @@ static inline char *check_image_kernel(struct swsusp_info *info)
extern int hibernation_snapshot(int platform_mode); extern int hibernation_snapshot(int platform_mode);
extern int hibernation_restore(int platform_mode); extern int hibernation_restore(int platform_mode);
extern int hibernation_platform_enter(void); extern int hibernation_platform_enter(void);
#endif
#else /* !CONFIG_HIBERNATION */
static inline void hibernate_image_size_init(void) {}
#endif /* !CONFIG_HIBERNATION */
extern int pfn_is_nosave(unsigned long); extern int pfn_is_nosave(unsigned long);
...@@ -134,6 +141,7 @@ extern int swsusp_swap_in_use(void); ...@@ -134,6 +141,7 @@ extern int swsusp_swap_in_use(void);
* the image header. * the image header.
*/ */
#define SF_PLATFORM_MODE 1 #define SF_PLATFORM_MODE 1
#define SF_NOCOMPRESS_MODE 2
/* kernel/power/hibernate.c */ /* kernel/power/hibernate.c */
extern int swsusp_check(void); extern int swsusp_check(void);
......
...@@ -40,6 +40,7 @@ static int try_to_freeze_tasks(bool sig_only) ...@@ -40,6 +40,7 @@ static int try_to_freeze_tasks(bool sig_only)
struct timeval start, end; struct timeval start, end;
u64 elapsed_csecs64; u64 elapsed_csecs64;
unsigned int elapsed_csecs; unsigned int elapsed_csecs;
bool wakeup = false;
do_gettimeofday(&start); do_gettimeofday(&start);
...@@ -78,6 +79,11 @@ static int try_to_freeze_tasks(bool sig_only) ...@@ -78,6 +79,11 @@ static int try_to_freeze_tasks(bool sig_only)
if (!todo || time_after(jiffies, end_time)) if (!todo || time_after(jiffies, end_time))
break; break;
if (!pm_check_wakeup_events()) {
wakeup = true;
break;
}
/* /*
* We need to retry, but first give the freezing tasks some * We need to retry, but first give the freezing tasks some
* time to enter the regrigerator. * time to enter the regrigerator.
...@@ -97,8 +103,9 @@ static int try_to_freeze_tasks(bool sig_only) ...@@ -97,8 +103,9 @@ static int try_to_freeze_tasks(bool sig_only)
* but it cleans up leftover PF_FREEZE requests. * but it cleans up leftover PF_FREEZE requests.
*/ */
printk("\n"); printk("\n");
printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds " printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "
"(%d tasks refusing to freeze, wq_busy=%d):\n", "(%d tasks refusing to freeze, wq_busy=%d):\n",
wakeup ? "aborted" : "failed",
elapsed_csecs / 100, elapsed_csecs % 100, elapsed_csecs / 100, elapsed_csecs % 100,
todo - wq_busy, wq_busy); todo - wq_busy, wq_busy);
...@@ -107,7 +114,7 @@ static int try_to_freeze_tasks(bool sig_only) ...@@ -107,7 +114,7 @@ static int try_to_freeze_tasks(bool sig_only)
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_thread(g, p) { do_each_thread(g, p) {
task_lock(p); task_lock(p);
if (freezing(p) && !freezer_should_skip(p)) if (!wakeup && freezing(p) && !freezer_should_skip(p))
sched_show_task(p); sched_show_task(p);
cancel_freezing(p); cancel_freezing(p);
task_unlock(p); task_unlock(p);
......
...@@ -46,7 +46,12 @@ static void swsusp_unset_page_forbidden(struct page *); ...@@ -46,7 +46,12 @@ static void swsusp_unset_page_forbidden(struct page *);
* size will not exceed N bytes, but if that is impossible, it will * size will not exceed N bytes, but if that is impossible, it will
* try to create the smallest image possible. * try to create the smallest image possible.
*/ */
unsigned long image_size = 500 * 1024 * 1024; unsigned long image_size;
void __init hibernate_image_size_init(void)
{
image_size = ((totalram_pages * 2) / 5) * PAGE_SIZE;
}
/* List of PBEs needed for restoring the pages that were allocated before /* List of PBEs needed for restoring the pages that were allocated before
* the suspend and included in the suspend image, but have also been * the suspend and included in the suspend image, but have also been
...@@ -1318,12 +1323,14 @@ int hibernate_preallocate_memory(void) ...@@ -1318,12 +1323,14 @@ int hibernate_preallocate_memory(void)
/* Compute the maximum number of saveable pages to leave in memory. */ /* Compute the maximum number of saveable pages to leave in memory. */
max_size = (count - (size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES; max_size = (count - (size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES;
/* Compute the desired number of image pages specified by image_size. */
size = DIV_ROUND_UP(image_size, PAGE_SIZE); size = DIV_ROUND_UP(image_size, PAGE_SIZE);
if (size > max_size) if (size > max_size)
size = max_size; size = max_size;
/* /*
* If the maximum is not less than the current number of saveable pages * If the desired number of image pages is at least as large as the
* in memory, allocate page frames for the image and we're done. * current number of saveable pages in memory, allocate page frames for
* the image and we're done.
*/ */
if (size >= saveable) { if (size >= saveable) {
pages = preallocate_image_highmem(save_highmem); pages = preallocate_image_highmem(save_highmem);
......
This diff is collapsed.
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