From patchwork Sat Sep 24 01:32:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 4312 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7CA4923F56 for ; Sat, 24 Sep 2011 01:33:21 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 72250A18411 for ; Sat, 24 Sep 2011 01:33:21 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so6092605fxe.11 for ; Fri, 23 Sep 2011 18:33:21 -0700 (PDT) Received: by 10.223.6.76 with SMTP id 12mr271541fay.27.1316828001358; Fri, 23 Sep 2011 18:33:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.18.198 with SMTP id y6cs9238lad; Fri, 23 Sep 2011 18:33:21 -0700 (PDT) Received: by 10.236.80.66 with SMTP id j42mr25393304yhe.98.1316828000276; Fri, 23 Sep 2011 18:33:20 -0700 (PDT) Received: from e38.co.us.ibm.com (e38.co.us.ibm.com. [32.97.110.159]) by mx.google.com with ESMTPS id r10si8199329anc.81.2011.09.23.18.33.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Sep 2011 18:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) client-ip=32.97.110.159; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8O1P8xG010120; Fri, 23 Sep 2011 19:25:08 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8O1XFmt194756; Fri, 23 Sep 2011 19:33:15 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8O1XEiI011735; Fri, 23 Sep 2011 19:33:14 -0600 Received: from kernel.beaverton.ibm.com ([9.47.67.96]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p8O1XEjc011708; Fri, 23 Sep 2011 19:33:14 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id E2F3B1E7513; Fri, 23 Sep 2011 18:33:13 -0700 (PDT) From: John Stultz To: markgross@thegnar.org Cc: John Stultz Subject: [PATCH 4/6] [RFC] rtc: interface: Add pm_stay_awake/pm_relax chaining rtc workqueue processing Date: Fri, 23 Sep 2011 18:32:41 -0700 Message-Id: <1316827963-13122-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1316827963-13122-1-git-send-email-john.stultz@linaro.org> References: <1316827963-13122-1-git-send-email-john.stultz@linaro.org> To ensure suspend events don't trigger between the irq and the rtc workqueue function running, use pm_stay_awake/pm_relax. Signed-off-by: John Stultz --- drivers/rtc/interface.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 44e91e5..ba1c437 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -19,6 +19,15 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer); static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer); +static struct wakeup_source *rtc_interface_wakelock; +static int __init rtc_interface_wakelock_init(void) +{ + rtc_interface_wakelock = wakeup_source_register("rtc_interface"); + return 0; +} +core_initcall(rtc_interface_wakelock_init); + + static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) { int err; @@ -563,6 +572,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer) void rtc_update_irq(struct rtc_device *rtc, unsigned long num, unsigned long events) { + __pm_stay_awake(rtc_interface_wakelock); schedule_work(&rtc->irqwork); } EXPORT_SYMBOL_GPL(rtc_update_irq); @@ -751,9 +761,10 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) alarm.time = rtc_ktime_to_tm(timer->node.expires); alarm.enabled = 1; err = __rtc_set_alarm(rtc, &alarm); - if (err == -ETIME) + if (err == -ETIME) { + __pm_stay_awake(rtc_interface_wakelock); schedule_work(&rtc->irqwork); - else if (err) { + } else if (err) { timerqueue_del(&rtc->timerqueue, &timer->node); timer->enabled = 0; return err; @@ -849,6 +860,7 @@ again: } mutex_unlock(&rtc->ops_lock); + __pm_relax(rtc_interface_wakelock); }