From patchwork Mon Sep 26 19:13:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 4353 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 E126B23F57 for ; Mon, 26 Sep 2011 19:14:49 +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 D5DB2A1860E for ; Mon, 26 Sep 2011 19:14:49 +0000 (UTC) Received: by fxe23 with SMTP id 23so8798799fxe.11 for ; Mon, 26 Sep 2011 12:14:49 -0700 (PDT) Received: by 10.223.94.134 with SMTP id z6mr10999579fam.8.1317064489698; Mon, 26 Sep 2011 12:14:49 -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.3.234 with SMTP id f10cs48621laf; Mon, 26 Sep 2011 12:14:49 -0700 (PDT) Received: by 10.150.54.11 with SMTP id c11mr6427760yba.439.1317064488576; Mon, 26 Sep 2011 12:14:48 -0700 (PDT) Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com. [32.97.182.145]) by mx.google.com with ESMTPS id q4si71749ybb.55.2011.09.26.12.14.48 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Sep 2011 12:14:48 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) client-ip=32.97.182.145; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8QIhnpu007642; Mon, 26 Sep 2011 14:43:49 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8QJE5tg321254; Mon, 26 Sep 2011 15:14:13 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8QJE4lH025925; Mon, 26 Sep 2011 16:14:05 -0300 Received: from kernel.beaverton.ibm.com ([9.47.67.96]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p8QJE30b025794; Mon, 26 Sep 2011 16:14:03 -0300 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id EBE221E7513; Mon, 26 Sep 2011 12:14:02 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , "Rafael J. Wysocki" , arve@android.com, markgross@thegnar.org, Alan Stern , amit.kucheria@linaro.org, farrowg@sg.ibm.com, "Dmitry Fink (Palm GBU)" , linux-pm@lists.linux-foundation.org, khilman@ti.com, Magnus Damm , mjg@redhat.com, peterz@infradead.org Subject: [PATCH 4/6] [RFC] rtc: interface: Add pm_stay_awake/pm_relax chaining rtc workqueue processing Date: Mon, 26 Sep 2011 12:13:52 -0700 Message-Id: <1317064434-1829-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1317064434-1829-1-git-send-email-john.stultz@linaro.org> References: <1317064434-1829-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. CC: Rafael J. Wysocki CC: arve@android.com CC: markgross@thegnar.org CC: Alan Stern CC: amit.kucheria@linaro.org CC: farrowg@sg.ibm.com CC: Dmitry Fink (Palm GBU) CC: linux-pm@lists.linux-foundation.org CC: khilman@ti.com CC: Magnus Damm CC: mjg@redhat.com CC: peterz@infradead.org 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); }