Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 351520a9 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-sleep'

* pm-sleep:
  PM / Sleep: User space wakeup sources garbage collector Kconfig option
  PM / Sleep: Make the limit of user space wakeup sources configurable
  PM / Documentation: suspend-and-cpuhotplug.txt: Fix typo
  PM / Sleep: Fix a mistake in a conditional in autosleep_store()
  epoll: Add a flag, EPOLLWAKEUP, to prevent suspend while epoll events are ready
  PM / Sleep: Add user space interface for manipulating wakeup sources, v3
  PM / Sleep: Add "prevent autosleep time" statistics to wakeup sources
  PM / Sleep: Implement opportunistic sleep, v2
  PM / Sleep: Add wakeup_source_activate and wakeup_source_deactivate tracepoints
  PM / Sleep: Change wakeup source statistics to follow Android
  PM / Sleep: Use wait queue to signal "no wakeup events in progress"
  PM / Sleep: Look for wakeup events in later stages of device suspend
  PM / Hibernate: Hibernate/thaw fixes/improvements
parents e6d18093 4e585d25
Loading
Loading
Loading
Loading
+28 −7
Original line number Diff line number Diff line
@@ -96,16 +96,26 @@ Description:
		is read-only.  If the device is not enabled to wake up the
		system from sleep states, this attribute is not present.

What:		/sys/devices/.../power/wakeup_hit_count
Date:		September 2010
What:		/sys/devices/.../power/wakeup_abort_count
Date:		February 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/devices/.../wakeup_hit_count attribute contains the
		The /sys/devices/.../wakeup_abort_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 not
		present.
		the device might have aborted system transition into a sleep
		state in progress.  This attribute is read-only.  If the device
		is not enabled to wake up the system from sleep states, this
		attribute is not present.

What:		/sys/devices/.../power/wakeup_expire_count
Date:		February 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/devices/.../wakeup_expire_count attribute contains the
		number of times a wakeup event associated with the device has
		been reported with a timeout that expired.  This attribute is
		read-only.  If the device is not enabled to wake up the system
		from sleep states, this attribute is not present.

What:		/sys/devices/.../power/wakeup_active
Date:		September 2010
@@ -148,6 +158,17 @@ Description:
		not enabled to wake up the system from sleep states, this
		attribute is not present.

What:		/sys/devices/.../power/wakeup_prevent_sleep_time_ms
Date:		February 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute
		contains the total time the device has been preventing
		opportunistic transitions to sleep states from occuring.
		This attribute is read-only.  If the device is not enabled to
		wake up the system from sleep states, this attribute is not
		present.

What:		/sys/devices/.../power/autosuspend_delay_ms
Date:		September 2010
Contact:	Alan Stern <stern@rowland.harvard.edu>
+59 −0
Original line number Diff line number Diff line
@@ -172,3 +172,62 @@ Description:

		Reading from this file will display the current value, which is
		set to 1 MB by default.

What:		/sys/power/autosleep
Date:		April 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/power/autosleep file can be written one of the strings
		returned by reads from /sys/power/state.  If that happens, a
		work item attempting to trigger a transition of the system to
		the sleep state represented by that string is queued up.  This
		attempt will only succeed if there are no active wakeup sources
		in the system at that time.  After every execution, regardless
		of whether or not the attempt to put the system to sleep has
		succeeded, the work item requeues itself until user space
		writes "off" to /sys/power/autosleep.

		Reading from this file causes the last string successfully
		written to it to be returned.

What:		/sys/power/wake_lock
Date:		February 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/power/wake_lock file allows user space to create
		wakeup source objects and activate them on demand (if one of
		those wakeup sources is active, reads from the
		/sys/power/wakeup_count file block or return false).  When a
		string without white space is written to /sys/power/wake_lock,
		it will be assumed to represent a wakeup source name.  If there
		is a wakeup source object with that name, it will be activated
		(unless active already).  Otherwise, a new wakeup source object
		will be registered, assigned the given name and activated.
		If a string written to /sys/power/wake_lock contains white
		space, the part of the string preceding the white space will be
		regarded as a wakeup source name and handled as descrived above.
		The other part of the string will be regarded as a timeout (in
		nanoseconds) such that the wakeup source will be automatically
		deactivated after it has expired.  The timeout, if present, is
		set regardless of the current state of the wakeup source object
		in question.

		Reads from this file return a string consisting of the names of
		wakeup sources created with the help of it that are active at
		the moment, separated with spaces.


What:		/sys/power/wake_unlock
Date:		February 2012
Contact:	Rafael J. Wysocki <rjw@sisk.pl>
Description:
		The /sys/power/wake_unlock file allows user space to deactivate
		wakeup sources created with the help of /sys/power/wake_lock.
		When a string is written to /sys/power/wake_unlock, it will be
		assumed to represent the name of a wakeup source to deactivate.
		If a wakeup source object of that name exists and is active at
		the moment, it will be deactivated.

		Reads from this file return a string consisting of the names of
		wakeup sources created with the help of /sys/power/wake_lock
		that are inactive at the moment, separated with spaces.
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ More details follow:

                                  Write 'mem' to
                                /sys/power/state
                                    syfs file
                                    sysfs file
                                        |
                                        v
                               Acquire pm_mutex lock
+10 −0
Original line number Diff line number Diff line
@@ -889,6 +889,11 @@ static int dpm_suspend_noirq(pm_message_t state)
		if (!list_empty(&dev->power.entry))
			list_move(&dev->power.entry, &dpm_noirq_list);
		put_device(dev);

		if (pm_wakeup_pending()) {
			error = -EBUSY;
			break;
		}
	}
	mutex_unlock(&dpm_list_mtx);
	if (error)
@@ -962,6 +967,11 @@ static int dpm_suspend_late(pm_message_t state)
		if (!list_empty(&dev->power.entry))
			list_move(&dev->power.entry, &dpm_late_early_list);
		put_device(dev);

		if (pm_wakeup_pending()) {
			error = -EBUSY;
			break;
		}
	}
	mutex_unlock(&dpm_list_mtx);
	if (error)
+49 −5
Original line number Diff line number Diff line
@@ -314,22 +314,41 @@ static ssize_t wakeup_active_count_show(struct device *dev,

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)
static ssize_t wakeup_abort_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->wakeup_count;
		enabled = true;
	}
	spin_unlock_irq(&dev->power.lock);
	return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
}

static DEVICE_ATTR(wakeup_abort_count, 0444, wakeup_abort_count_show, NULL);

static ssize_t wakeup_expire_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;
		count = dev->power.wakeup->expire_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 DEVICE_ATTR(wakeup_expire_count, 0444, wakeup_expire_count_show, NULL);

static ssize_t wakeup_active_show(struct device *dev,
				struct device_attribute *attr, char *buf)
@@ -398,6 +417,27 @@ static ssize_t wakeup_last_time_show(struct device *dev,
}

static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL);

#ifdef CONFIG_PM_AUTOSLEEP
static ssize_t wakeup_prevent_sleep_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->prevent_sleep_time);
		enabled = true;
	}
	spin_unlock_irq(&dev->power.lock);
	return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
}

static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444,
		   wakeup_prevent_sleep_time_show, NULL);
#endif /* CONFIG_PM_AUTOSLEEP */
#endif /* CONFIG_PM_SLEEP */

#ifdef CONFIG_PM_ADVANCED_DEBUG
@@ -486,11 +526,15 @@ static struct attribute *wakeup_attrs[] = {
	&dev_attr_wakeup.attr,
	&dev_attr_wakeup_count.attr,
	&dev_attr_wakeup_active_count.attr,
	&dev_attr_wakeup_hit_count.attr,
	&dev_attr_wakeup_abort_count.attr,
	&dev_attr_wakeup_expire_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,
#ifdef CONFIG_PM_AUTOSLEEP
	&dev_attr_wakeup_prevent_sleep_time_ms.attr,
#endif
#endif
	NULL,
};
Loading