Skip to content

Commit

Permalink
Merge branch 'pm-qos'
Browse files Browse the repository at this point in the history
* pm-qos:
  PM / QoS: Handle device PM QoS flags while removing constraints
  PM / QoS: Resume device before exposing/hiding PM QoS flags
  PM / QoS: Document request manipulation requirement for flags
  PM / QoS: Fix a free error in the dev_pm_qos_constraints_destroy()
  PM / QoS: Fix the return value of dev_pm_qos_update_request()
  PM / ACPI: Take device PM QoS flags into account
  PM / Domains: Check device PM QoS flags in pm_genpd_poweroff()
  PM / QoS: Make it possible to expose PM QoS device flags to user space
  PM / QoS: Introduce PM QoS device flags support
  PM / QoS: Prepare struct dev_pm_qos_request for more request types
  PM / QoS: Introduce request and constraint data types for PM QoS flags
  PM / QoS: Prepare device structure for adding more constraint types
  • Loading branch information
Rafael J. Wysocki committed Nov 29, 2012
2 parents 9489e9d + 35546bd commit c8b6817
Show file tree
Hide file tree
Showing 12 changed files with 551 additions and 90 deletions.
31 changes: 31 additions & 0 deletions Documentation/ABI/testing/sysfs-devices-power
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,34 @@ Description:

This attribute has no effect on system-wide suspend/resume and
hibernation.

What: /sys/devices/.../power/pm_qos_no_power_off
Date: September 2012
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../power/pm_qos_no_power_off attribute
is used for manipulating the PM QoS "no power off" flag. If
set, this flag indicates to the kernel that power should not
be removed entirely from the device.

Not all drivers support this attribute. If it isn't supported,
it is not present.

This attribute has no effect on system-wide suspend/resume and
hibernation.

What: /sys/devices/.../power/pm_qos_remote_wakeup
Date: September 2012
Contact: Rafael J. Wysocki <rjw@sisk.pl>
Description:
The /sys/devices/.../power/pm_qos_remote_wakeup attribute
is used for manipulating the PM QoS "remote wakeup required"
flag. If set, this flag indicates to the kernel that the
device is a source of user events that have to be signaled from
its low-power states.

Not all drivers support this attribute. If it isn't supported,
it is not present.

This attribute has no effect on system-wide suspend/resume and
hibernation.
2 changes: 1 addition & 1 deletion Documentation/power/pm_qos_interface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ reading the aggregated value does not require any locking mechanism.

From kernel mode the use of this interface is the following:

int dev_pm_qos_add_request(device, handle, value):
int dev_pm_qos_add_request(device, handle, type, value):
Will insert an element into the list for that identified device with the
target value. Upon change to this list the new target is recomputed and any
registered notifiers are called only if the target value is now different.
Expand Down
21 changes: 17 additions & 4 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/pm_qos.h>

#include <asm/io.h>

Expand Down Expand Up @@ -711,13 +712,21 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
struct acpi_device *adev;
char acpi_method[] = "_SxD";
unsigned long long d_min, d_max;
bool wakeup = false;

if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3)
return -EINVAL;
if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
printk(KERN_DEBUG "ACPI handle has no context!\n");
return -ENODEV;
}
if (d_max_in > ACPI_STATE_D3_HOT) {
enum pm_qos_flags_status stat;

stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
if (stat == PM_QOS_FLAGS_ALL)
d_max_in = ACPI_STATE_D3_HOT;
}

acpi_method[2] = '0' + acpi_target_sleep_state;
/*
Expand All @@ -737,8 +746,14 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
* NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
* provided -- that's our fault recovery, we ignore retval.
*/
if (acpi_target_sleep_state > ACPI_STATE_S0)
if (acpi_target_sleep_state > ACPI_STATE_S0) {
acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
&& adev->wakeup.sleep_state >= acpi_target_sleep_state;
} else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) !=
PM_QOS_FLAGS_NONE) {
wakeup = adev->wakeup.flags.valid;
}

/*
* If _PRW says we can wake up the system from the target sleep state,
Expand All @@ -747,9 +762,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
* (ACPI 3.x), it should return the maximum (lowest power) D-state that
* can wake the system. _S0W may be valid, too.
*/
if (acpi_target_sleep_state == ACPI_STATE_S0 ||
(device_may_wakeup(dev) && adev->wakeup.flags.valid &&
adev->wakeup.sleep_state >= acpi_target_sleep_state)) {
if (wakeup) {
acpi_status status;

acpi_method[3] = 'W';
Expand Down
11 changes: 10 additions & 1 deletion drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,19 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd)
return -EBUSY;

not_suspended = 0;
list_for_each_entry(pdd, &genpd->dev_list, list_node)
list_for_each_entry(pdd, &genpd->dev_list, list_node) {
enum pm_qos_flags_status stat;

stat = dev_pm_qos_flags(pdd->dev,
PM_QOS_FLAG_NO_POWER_OFF
| PM_QOS_FLAG_REMOTE_WAKEUP);
if (stat > PM_QOS_FLAGS_NONE)
return -EBUSY;

if (pdd->dev->driver && (!pm_runtime_suspended(pdd->dev)
|| pdd->dev->power.irq_safe))
not_suspended++;
}

if (not_suspended > genpd->in_progress)
return -EBUSY;
Expand Down
6 changes: 4 additions & 2 deletions drivers/base/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ extern void dpm_sysfs_remove(struct device *dev);
extern void rpm_sysfs_remove(struct device *dev);
extern int wakeup_sysfs_add(struct device *dev);
extern void wakeup_sysfs_remove(struct device *dev);
extern int pm_qos_sysfs_add(struct device *dev);
extern void pm_qos_sysfs_remove(struct device *dev);
extern int pm_qos_sysfs_add_latency(struct device *dev);
extern void pm_qos_sysfs_remove_latency(struct device *dev);
extern int pm_qos_sysfs_add_flags(struct device *dev);
extern void pm_qos_sysfs_remove_flags(struct device *dev);

#else /* CONFIG_PM */

Expand Down
Loading

0 comments on commit c8b6817

Please sign in to comment.