From patchwork Fri Apr 11 10:40:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 28260 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA1A520822 for ; Fri, 11 Apr 2014 10:40:23 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf17516109pab.2 for ; Fri, 11 Apr 2014 03:40:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=L3n0QaWq8xq7gATodgRPgVb4trUcsC2XeTt6OV1PX3Q=; b=Gbp9xGd/xfGogmNM1uqeRdHX3Th7BlTypTQGQt+YhXpIRxOK8Ydd2APRz1r+OT4gwn ifp7v3DNHqtuIobgKc9r/sykU3uL3zHF5U0x0Rlfr+OZkjtz0THmrp0/kMnYDwgaX6QC t8cb3SCMVoYQ1tvghx4fqG5S4ZhorRfM0YeXbIdFZ9bMyOi0eYEkR7NABPB2dw5bbyZl sdxbnLNPlQPh/zTr9J8nV+aHtvjlLCisgAvMtRZKCE9l1dpMhsYxSqBezzDzoZ1dOEli urSearehEELnkVyj7G1qguM5BO0KIGQVlxFMswj/pXXm6Qb/4seFSXAqqnfl7b15uUOD xMlg== X-Gm-Message-State: ALoCoQlWLbsf2DYYqXxxf6J/1fOaISFC7VDhsfc1vHZgmyHu9y1kWmnOvDlUw2ZszK1tbBPSC+uJ X-Received: by 10.69.29.33 with SMTP id jt1mr10901807pbd.7.1397212823145; Fri, 11 Apr 2014 03:40:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.11 with SMTP id t11ls1433089qga.96.gmail; Fri, 11 Apr 2014 03:40:23 -0700 (PDT) X-Received: by 10.52.26.161 with SMTP id m1mr16092332vdg.24.1397212823043; Fri, 11 Apr 2014 03:40:23 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id wd2si1229290veb.5.2014.04.11.03.40.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 03:40:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so4676370vcb.11 for ; Fri, 11 Apr 2014 03:40:22 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr19457815veb.1.1397212822795; Fri, 11 Apr 2014 03:40:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp46117vcb; Fri, 11 Apr 2014 03:40:22 -0700 (PDT) X-Received: by 10.66.124.232 with SMTP id ml8mr26352204pab.38.1397212822022; Fri, 11 Apr 2014 03:40:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xy8si3963775pab.160.2014.04.11.03.40.21; Fri, 11 Apr 2014 03:40:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934492AbaDKKkK (ORCPT + 8 others); Fri, 11 Apr 2014 06:40:10 -0400 Received: from mail-we0-f182.google.com ([74.125.82.182]:52273 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756766AbaDKKkI (ORCPT ); Fri, 11 Apr 2014 06:40:08 -0400 Received: by mail-we0-f182.google.com with SMTP id p61so5257577wes.13 for ; Fri, 11 Apr 2014 03:40:07 -0700 (PDT) X-Received: by 10.180.78.200 with SMTP id d8mr2856638wix.34.1397212807467; Fri, 11 Apr 2014 03:40:07 -0700 (PDT) Received: from localhost.localdomain (AToulouse-654-1-377-242.w86-199.abo.wanadoo.fr. [86.199.232.242]) by mx.google.com with ESMTPSA id eq8sm3683033wib.16.2014.04.11.03.40.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 03:40:06 -0700 (PDT) From: Daniel Lezcano To: kgene.kim@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, t.figa@samsung.com, linaro-kernel@lists.linaro.org, rjw@rjwysocki.net Subject: [PATCH V5 08/20] ARM: exynos: cpuidle: Use the cpu_pm notifier Date: Fri, 11 Apr 2014 12:40:03 +0200 Message-Id: <1397212815-16068-9-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397212815-16068-1-git-send-email-daniel.lezcano@linaro.org> References: <1397212815-16068-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the cpu_pm_enter/exit notifier to group some pm code inside the pm file. The save and restore code is duplicated across pm.c and cpuidle.c. By using the cpu_pm notifier, we can factor out the routine. Signed-off-by: Daniel Lezcano Reviewed-by: Viresh Kumar Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Tomasz Figa --- arch/arm/mach-exynos/cpuidle.c | 24 ------------------------ arch/arm/mach-exynos/pm.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c index 346c2d0..aa8ab1b 100644 --- a/arch/arm/mach-exynos/cpuidle.c +++ b/arch/arm/mach-exynos/cpuidle.c @@ -46,26 +46,6 @@ static void exynos_set_wakeupmask(void) __raw_writel(0x0000ff3e, S5P_WAKEUP_MASK); } -static unsigned int g_pwr_ctrl, g_diag_reg; - -static void save_cpu_arch_register(void) -{ - /*read power control register*/ - asm("mrc p15, 0, %0, c15, c0, 0" : "=r"(g_pwr_ctrl) : : "cc"); - /*read diagnostic register*/ - asm("mrc p15, 0, %0, c15, c0, 1" : "=r"(g_diag_reg) : : "cc"); - return; -} - -static void restore_cpu_arch_register(void) -{ - /*write power control register*/ - asm("mcr p15, 0, %0, c15, c0, 0" : : "r"(g_pwr_ctrl) : "cc"); - /*write diagnostic register*/ - asm("mcr p15, 0, %0, c15, c0, 1" : : "r"(g_diag_reg) : "cc"); - return; -} - static int idle_finisher(unsigned long flags) { exynos_set_wakeupmask(); @@ -87,8 +67,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, { unsigned long tmp; - save_cpu_arch_register(); - /* Setting Central Sequence Register for power down mode */ tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); tmp &= ~S5P_CENTRAL_LOWPWR_CFG; @@ -103,8 +81,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, #endif cpu_pm_exit(); - restore_cpu_arch_register(); - /* * If PMU failed while entering sleep mode, WFI will be * ignored by PMU and then exiting cpu_do_idle(). diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c index adfdf4b..67d75fe 100644 --- a/arch/arm/mach-exynos/pm.c +++ b/arch/arm/mach-exynos/pm.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -321,10 +322,38 @@ static const struct platform_suspend_ops exynos_suspend_ops = { .valid = suspend_valid_only_mem, }; +static int exynos_cpu_pm_notifier(struct notifier_block *self, + unsigned long cmd, void *v) +{ + int cpu = smp_processor_id(); + + switch (cmd) { + case CPU_PM_ENTER: + if (cpu == 0) { + exynos_cpu_save_register(); + } + break; + + case CPU_PM_EXIT: + if (cpu == 0) { + exynos_cpu_restore_register(); + } + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block exynos_cpu_pm_notifier_block = { + .notifier_call = exynos_cpu_pm_notifier, +}; + void __init exynos_pm_init(void) { u32 tmp; + cpu_pm_register_notifier(&exynos_cpu_pm_notifier_block); + /* Platform-specific GIC callback */ gic_arch_extn.irq_set_wake = exynos_irq_set_wake;