From patchwork Fri Apr 4 13:42:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 27824 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D572120369 for ; Fri, 4 Apr 2014 13:43:09 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf10141482yha.7 for ; Fri, 04 Apr 2014 06:43:09 -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=1VDlcwtxnTynlwXfKDUUpVtnglECVpjPAggxdQnI2Vw=; b=gSfMuTSAkzpHfTr6bReuGBu5j4dJ4MlPKWXKUIXxgMMUPr9Pfps21o0zFs+chqnO23 qHI++lC0Fa7fXMRU5Usx32ef2RO7VFRdhXnMmE5fV/IvSJoEd+FfHWVn5NjrctyHpsuj elKTgzOdrIYQgFWl4gu8Yt0Xw7W4CdVBrOPstkWD0YrbexSckhUf+qQMfGMF/pbSJCPv uvOV/v5gTgbjIMon+Je8QxbAhS5evsIeVt4tuX+vBwUSFjkxwR4e3hTX8WvdX4Fu6TXh u3Kg8B6wCWOzFF6S/uSYBM+TRWj/5sUiro4WbqMZ5h4nycTqt7BVKpYe85AaJ9MsAypj 5+0Q== X-Gm-Message-State: ALoCoQn7Ar35WSU3k4GXcH9n5IsmawwlX7G3Hpdarqmk7oifbSXI31P8+8S2egybvJDbC6t/TzaE X-Received: by 10.236.118.38 with SMTP id k26mr7689601yhh.35.1396618989441; Fri, 04 Apr 2014 06:43:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.69 with SMTP id e63ls1053053qgd.29.gmail; Fri, 04 Apr 2014 06:43:09 -0700 (PDT) X-Received: by 10.58.96.36 with SMTP id dp4mr5301855veb.21.1396618989201; Fri, 04 Apr 2014 06:43:09 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id kj3si1776891vdb.105.2014.04.04.06.43.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 06:43:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so1481085veb.13 for ; Fri, 04 Apr 2014 06:43:09 -0700 (PDT) X-Received: by 10.52.163.145 with SMTP id yi17mr113241vdb.46.1396618989094; Fri, 04 Apr 2014 06:43:09 -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.12.8 with SMTP id v8csp115329vcv; Fri, 4 Apr 2014 06:43:08 -0700 (PDT) X-Received: by 10.66.231.73 with SMTP id te9mr15121153pac.17.1396618987629; Fri, 04 Apr 2014 06:43:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk5si4616090pbc.252.2014.04.04.06.43.07; Fri, 04 Apr 2014 06:43:07 -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 S1752809AbaDDNnG (ORCPT + 9 others); Fri, 4 Apr 2014 09:43:06 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:55441 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752774AbaDDNnF (ORCPT ); Fri, 4 Apr 2014 09:43:05 -0400 Received: by mail-wg0-f52.google.com with SMTP id k14so3436613wgh.11 for ; Fri, 04 Apr 2014 06:43:04 -0700 (PDT) X-Received: by 10.194.80.7 with SMTP id n7mr20345676wjx.8.1396618984538; Fri, 04 Apr 2014 06:43:04 -0700 (PDT) Received: from localhost.localdomain (AToulouse-654-1-451-172.w83-205.abo.wanadoo.fr. [83.205.74.172]) by mx.google.com with ESMTPSA id cu6sm2845053wjb.8.2014.04.04.06.43.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 06:43:03 -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 V2 07/17] ARM: exynos: cpuidle: Use the cpu_pm notifier Date: Fri, 4 Apr 2014 15:42:59 +0200 Message-Id: <1396618989-2897-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396618989-2897-1-git-send-email-daniel.lezcano@linaro.org> References: <1396618989-2897-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.128.182 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 --- 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 6663349..7f1f4ef 100644 --- a/arch/arm/mach-exynos/cpuidle.c +++ b/arch/arm/mach-exynos/cpuidle.c @@ -65,26 +65,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(); @@ -106,8 +86,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; @@ -122,8 +100,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;