From patchwork Wed Jun 12 19:55:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julius Werner X-Patchwork-Id: 2711991 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 702F8C1459 for ; Wed, 12 Jun 2013 19:56:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C690C20203 for ; Wed, 12 Jun 2013 19:56:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C90A520180 for ; Wed, 12 Jun 2013 19:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755388Ab3FLTz7 (ORCPT ); Wed, 12 Jun 2013 15:55:59 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:38940 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753331Ab3FLTz6 (ORCPT ); Wed, 12 Jun 2013 15:55:58 -0400 Received: by mail-pa0-f51.google.com with SMTP id lf11so4517300pab.38 for ; Wed, 12 Jun 2013 12:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:x-mailer; bh=pxfpWHEyKBS3kMDuC8vWJ2DmvwDwVL1N6ps+BEmFQzg=; b=O9T09tzuD6yH8rR72B4Smurjvugs1Rw7ojTuDuCO6Yt/uf0BDNz0JIKrdcfQpjYGde fs388oDuIQNaAGEX6s8mx6U/mxGjc9SK4ONVH+WHc/+MIY2FOV5V1Uu2eMz00D7dRxNQ Her/8XJN83RKU0T72kHG4AuQ69OBlUGERTmVU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=pxfpWHEyKBS3kMDuC8vWJ2DmvwDwVL1N6ps+BEmFQzg=; b=L/xOouIZsyyjn573ki4mbnRU33GUwhLa+k2v+yXGr/p6gja8DnPfmW0gXmNfidqndo qPAw3ZWazAo+S0UPVeUj2SuZ6kvgPLJ4w+frUcfYcrTLMjA8MuECkppGLVrcrdlSzsFo VvHUkcBSpAdEdTxQnoJEhKs/FZ4M+Q11K69pPK8icSiZULxSE2hIZcDSW31q1xJAmQh6 TVX4BECTcxA8k0wg1s6qnpqF0GDscYZFUNBWU3uYXtyNQL+8KK6fXdTm/GTt06stNycu L4f4cU0pzWSnRxfEs2L4RVENk35sxQicWNAwhIiixeAm+XKVHFL1+nSw7nmIaJIuJ7fp 9OLw== X-Received: by 10.68.132.34 with SMTP id or2mr21169975pbb.99.1371066957889; Wed, 12 Jun 2013 12:55:57 -0700 (PDT) Received: from jwerner-linux.mtv.corp.google.com (jwerner-linux.mtv.corp.google.com [172.22.72.75]) by mx.google.com with ESMTPSA id tb7sm20268587pbc.14.2013.06.12.12.55.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 12:55:57 -0700 (PDT) From: Julius Werner To: "Rafael J. Wysocki" Cc: Len Brown , Pavel Machek , Todd Poynor , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sameer Nanda , Julius Werner Subject: [PATCH v2] PM / Sleep: Print last wakeup source on failed wakeup_count write Date: Wed, 12 Jun 2013 12:55:22 -0700 Message-Id: <1371066922-23577-1-git-send-email-jwerner@chromium.org> X-Mailer: git-send-email 1.8.3 X-Gm-Message-State: ALoCoQlEL/Q8flEbHPJlTytBCjrY1TK1Ajti5PYALItmIjR5+O6d34qxsifbrXnMN/EcrpFL17go Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit a938da06 introduced a useful little log message to tell users/debuggers which wakeup source aborted a suspend. However, this message is only printed if the abort happens during the in-kernel suspend path (after writing /sys/power/state). The full specification of the /sys/power/wakeup_count facility allows user-space power managers to double-check if wakeups have already happened before it actually tries to suspend (e.g. while it was running user-space pre-suspend hooks), by writing the last known wakeup_count value to /sys/power/wakeup_count. This patch changes the sysfs handler for that node to also print said log message if that write fails, so that we can figure out the offending wakeup source for both kinds of suspend aborts. Signed-off-by: Julius Werner --- drivers/base/power/wakeup.c | 5 +++-- include/linux/suspend.h | 1 + kernel/power/main.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 79715e7..90f83ca5 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -659,7 +659,7 @@ void pm_wakeup_event(struct device *dev, unsigned int msec) } EXPORT_SYMBOL_GPL(pm_wakeup_event); -static void print_active_wakeup_sources(void) +void pm_print_active_wakeup_sources(void) { struct wakeup_source *ws; int active = 0; @@ -683,6 +683,7 @@ static void print_active_wakeup_sources(void) last_activity_ws->name); rcu_read_unlock(); } +EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources); /** * pm_wakeup_pending - Check if power transition in progress should be aborted. @@ -708,7 +709,7 @@ bool pm_wakeup_pending(void) spin_unlock_irqrestore(&events_lock, flags); if (ret) - print_active_wakeup_sources(); + pm_print_active_wakeup_sources(); return ret; } diff --git a/include/linux/suspend.h b/include/linux/suspend.h index d4e3f16..f73cabf 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -363,6 +363,7 @@ extern bool pm_wakeup_pending(void); extern bool pm_get_wakeup_count(unsigned int *count, bool block); extern bool pm_save_wakeup_count(unsigned int count); extern void pm_wakep_autosleep_enabled(bool set); +extern void pm_print_active_wakeup_sources(void); static inline void lock_system_sleep(void) { diff --git a/kernel/power/main.c b/kernel/power/main.c index d77663b..0828070 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -424,6 +424,8 @@ static ssize_t wakeup_count_store(struct kobject *kobj, if (sscanf(buf, "%u", &val) == 1) { if (pm_save_wakeup_count(val)) error = n; + else + pm_print_active_wakeup_sources(); } out: