public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Linux-pm mailing list" <linux-pm@lists.linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>
Subject: [PATCH 2/3] PM / Wakeup: Make pm_save_wakeup_count() work as documented
Date: Tue, 25 Jan 2011 01:15:33 +0100	[thread overview]
Message-ID: <201101250115.34088.rjw@sisk.pl> (raw)
In-Reply-To: <201101250112.40350.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

According to Documentation/ABI/testing/sysfs-power, the
/sys/power/wakeup_count interface should only make the kernel react
to wakeup events during suspend if the last write to it has been
successful.  However, if /sys/power/wakeup_count is written to two
times in a row, where the first write is successful and the second
is not, the kernel will still react to wakeup events during suspend
due to a bug in pm_save_wakeup_count().

Fix the bug by making pm_save_wakeup_count() clear
events_check_enabled unconditionally before checking if there are
any new wakeup events registered since the previous read from
/sys/power/wakeup_count.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/wakeup.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Index: linux-2.6/drivers/base/power/wakeup.c
===================================================================
--- linux-2.6.orig/drivers/base/power/wakeup.c
+++ linux-2.6/drivers/base/power/wakeup.c
@@ -644,23 +644,22 @@ bool pm_get_wakeup_count(unsigned int *c
  *
  * If @count is equal to the current number of registered wakeup events and the
  * current number of wakeup events being processed is zero, store @count as the
- * old number of registered wakeup events to be used by pm_check_wakeup_events()
- * and return true.  Otherwise return false.
+ * old number of registered wakeup events for pm_check_wakeup_events(), enable
+ * wakeup events detection and return 'true'.  Otherwise disable wakeup events
+ * detection and return 'false'.
  */
 bool pm_save_wakeup_count(unsigned int count)
 {
-	bool ret = false;
-
+	events_check_enabled = false;
 	spin_lock_irq(&events_lock);
 	if (!__pm_wakeup_pending(count)) {
 		saved_count = count;
 		events_check_enabled = true;
-		ret = true;
 	}
 	spin_unlock_irq(&events_lock);
-	if (!ret)
+	if (!events_check_enabled)
 		pm_wakeup_update_hit_counts();
-	return ret;
+	return events_check_enabled;
 }
 
 static struct dentry *wakeup_sources_stats_dentry;


  parent reply	other threads:[~2011-01-25  0:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25  0:12 [PATCH 0/3] PM / Wakeup: Fixes in wakeup.c Rafael J. Wysocki
2011-01-25  0:14 ` [PATCH 1/3] PM / Wakeup: Add missing memory barriers Rafael J. Wysocki
2011-01-26 20:21   ` Alan Stern
2011-01-26 20:36     ` Rafael J. Wysocki
2011-01-26 22:53     ` Rafael J. Wysocki
2011-01-27 19:00       ` Alan Stern
2011-01-27 21:19         ` Rafael J. Wysocki
2011-01-28 20:23           ` Alan Stern
2011-01-25  0:15 ` Rafael J. Wysocki [this message]
2011-01-25  0:16 ` [PATCH 3/3] PM / Wakeup: Don't update events_check_enabled in pm_get_wakeup_count() Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201101250115.34088.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox