From patchwork Tue Aug 13 17:29:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep KarkadaNagesha X-Patchwork-Id: 2843914 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E6909F239 for ; Tue, 13 Aug 2013 17:31:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B5122063C for ; Tue, 13 Aug 2013 17:31:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D251B2063A for ; Tue, 13 Aug 2013 17:31:29 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9IQk-0002S9-Eb; Tue, 13 Aug 2013 17:30:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9IQZ-0006vN-FE; Tue, 13 Aug 2013 17:30:39 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9IQC-0006qd-W2 for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2013 17:30:19 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 13 Aug 2013 18:29:56 +0100 Received: from e103737-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 13 Aug 2013 18:29:54 +0100 From: Sudeep KarkadaNagesha To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/6] drivers: clocksource: add CPU PM notifier for ARM architected timer Date: Tue, 13 Aug 2013 18:29:44 +0100 Message-Id: <1376414984-14182-7-git-send-email-Sudeep.KarkadaNagesha@arm.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1376414984-14182-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> References: <1374492082-13686-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> <1376414984-14182-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> X-OriginalArrivalTime: 13 Aug 2013 17:29:54.0394 (UTC) FILETIME=[B949B3A0:01CE984A] X-MC-Unique: 113081318295603801 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130813_133017_224102_CB5F9A00 X-CRM114-Status: GOOD ( 13.17 ) X-Spam-Score: -2.6 (--) Cc: Lorenzo Pieralisi , Sudeep KarkadaNagesha , Catalin Marinas , Daniel Lezcano , Will Deacon , Thomas Gleixner X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 From: Sudeep KarkadaNagesha Few control settings done in architected timer as part of initialisation can be lost when CPU enters deeper power states. They need to be re-initialised when the CPU is (warm)reset again. This patch adds CPU PM notifiers to do the timer initialisation on warm resets. It also save the event stream divider value calculated during cold reset and uses the same in warm reset path. Reviewed-by: Lorenzo Pieralisi Reviewed-by: Will Deacon Signed-off-by: Sudeep KarkadaNagesha --- drivers/clocksource/arm_arch_timer.c | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 05d1e13..2ce9638 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,8 @@ static struct clock_event_device __percpu *arch_timer_evt; static bool arch_timer_use_virtual = true; +static int arch_timer_evtstream_div; + /* * Architected system timer support. */ @@ -160,7 +163,9 @@ static int arch_timer_setup(struct clock_event_device *clk) pos = fls(evt_stream_div); if (pos > 1 && !(evt_stream_div & (1 << (pos - 2)))) pos--; - arch_counter_set_user_access(min(pos, 15)); + /* save divider value for use in CPU PM notifier */ + arch_timer_evtstream_div = min(pos, 15); + arch_counter_set_user_access(arch_timer_evtstream_div); /* enable hwcap definition to the users for event stream feature */ arch_timer_set_hwcap_evtstrm(); @@ -270,6 +275,31 @@ static struct notifier_block arch_timer_cpu_nb = { .notifier_call = arch_timer_cpu_notify, }; +#ifdef CONFIG_CPU_PM +static int arch_timer_cpu_pm_notify(struct notifier_block *self, + unsigned long action, void *hcpu) +{ + if (action == CPU_PM_EXIT) + arch_counter_set_user_access(arch_timer_evtstream_div); + + return NOTIFY_OK; +} + +static struct notifier_block arch_timer_cpu_pm_notifier = { + .notifier_call = arch_timer_cpu_pm_notify, +}; + +static int __init arch_timer_cpu_pm_init(void) +{ + return cpu_pm_register_notifier(&arch_timer_cpu_pm_notifier); +} +#else +static int __init arch_timer_cpu_pm_init(void) +{ + return 0; +} +#endif + static int __init arch_timer_register(void) { int err; @@ -319,11 +349,17 @@ static int __init arch_timer_register(void) if (err) goto out_free_irq; + err = arch_timer_cpu_pm_init(); + if (err) + goto out_unreg_notify; + /* Immediately configure the timer on the boot CPU */ arch_timer_setup(this_cpu_ptr(arch_timer_evt)); return 0; +out_unreg_notify: + unregister_cpu_notifier(&arch_timer_cpu_nb); out_free_irq: if (arch_timer_use_virtual) free_percpu_irq(arch_timer_ppi[VIRT_PPI], arch_timer_evt);