From patchwork Fri Nov 22 11:29:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21679 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB6872096D for ; Fri, 22 Nov 2013 11:30:07 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id o6sf3549338oag.11 for ; Fri, 22 Nov 2013 03:30:07 -0800 (PST) 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:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=aXHZaeumFhVUqS4kijpEHgdESdvMZ3a5IV0pouZJX7I=; b=iJZuY0RB7/OasCN4oCYLS0roWHP1ZRuxriRHxzHy5XGAu5AfZMqctj87IYp3+rAEJ3 /WmMdmIhQSKXywNGitj388zaxUUY2YoQah6xyELR3RQLJwJavVz+cxHketlq0p/fqxw+ xatP4W3+tiW+/95sRZkVOCst3VtLp3dljgZNSLSAhBUx84kSP3dyc/uBM+4keDgx81yX hUIbMNeB/ImRHrpBNuXeujJxbCIt5XjYCc+byp4BvAbLJfACxQ/2KmyXSU35RV+2Kt7M EpMBCxMnObRiYgNPC/kDrf6QH87xtdO7Xj03nLgy6d7mCASjo2FjAq/YG2h+KEAMCtWj +qxQ== X-Gm-Message-State: ALoCoQkGsAzuWIXIi+TcyRdzrJyFVDp3uTFSTZsxDXLddf1RST7AugFMf3tBdlA10OgmyyaBe3bK X-Received: by 10.42.247.68 with SMTP id mb4mr3329439icb.14.1385119807005; Fri, 22 Nov 2013 03:30:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.106 with SMTP id 10ls964575qed.55.gmail; Fri, 22 Nov 2013 03:30:06 -0800 (PST) X-Received: by 10.220.95.139 with SMTP id d11mr11078968vcn.21.1385119806879; Fri, 22 Nov 2013 03:30:06 -0800 (PST) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id fe2si12537376vcb.16.2013.11.22.03.30.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 03:30:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.51 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.51; Received: by mail-vb0-f51.google.com with SMTP id m10so772596vbh.10 for ; Fri, 22 Nov 2013 03:30:06 -0800 (PST) X-Received: by 10.58.168.205 with SMTP id zy13mr10986618veb.19.1385119806781; Fri, 22 Nov 2013 03:30:06 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp32845vcz; Fri, 22 Nov 2013 03:30:06 -0800 (PST) X-Received: by 10.49.117.41 with SMTP id kb9mr19947224qeb.79.1385119806300; Fri, 22 Nov 2013 03:30:06 -0800 (PST) Received: from mail-qe0-f50.google.com (mail-qe0-f50.google.com [209.85.128.50]) by mx.google.com with ESMTPS id 6si2693395qam.119.2013.11.22.03.30.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 03:30:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.128.50; Received: by mail-qe0-f50.google.com with SMTP id 1so791662qee.37 for ; Fri, 22 Nov 2013 03:30:06 -0800 (PST) X-Received: by 10.49.42.99 with SMTP id n3mr20395644qel.52.1385119806138; Fri, 22 Nov 2013 03:30:06 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id r5sm88246631qaj.13.2013.11.22.03.30.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Nov 2013 03:30:05 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, tianyu.lan@intel.com, nm@ti.com, jinchoi@broadcom.com, sebastian.capella@linaro.org, Viresh Kumar Subject: [PATCH V2 2/2] cpufreq: Change freq before suspending governors Date: Fri, 22 Nov 2013 16:59:49 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.51 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Some platforms might want to change frequency before suspending governors. Like: - Some platform which want to set freq to max to speed up suspend/hibernation process. - Some platform (like: Tegra or exynos), set this to min or bootloader's frequency. This patch adds an option for those, so that they can specify this at call to ->init(), so that cpufreq core can take care of this before suspending system. If this variable is not updated by ->init() then its value would be zero and so core wouldn't do anything. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 17 +++++++++++++++++ include/linux/cpufreq.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 540bd87..e609102 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1476,6 +1476,7 @@ void cpufreq_suspend(void) { struct cpufreq_policy *policy; unsigned long flags; + int ret; if (!has_target()) return; @@ -1487,6 +1488,22 @@ void cpufreq_suspend(void) pr_err("%s: Failed to stop governor for policy: %p\n", __func__, policy); + /* + * In case platform wants some specific frequency to be configured + * during suspend + */ + if (policy->suspend_freq) { + pr_debug("%s: Suspending Governors: Setting suspend-freq: %u\n", + __func__, policy->suspend_freq); + + ret = __cpufreq_driver_target(policy, policy->suspend_freq, + CPUFREQ_RELATION_H); + /* We can still suspend even if this failed */ + if (ret) + pr_err("%s: Unable to set suspend-freq: %u. Err: %d\n", + __func__, policy->suspend_freq, ret); + } + write_lock_irqsave(&cpufreq_driver_lock, flags); cpufreq_suspended = true; write_unlock_irqrestore(&cpufreq_driver_lock, flags); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 6d93f91..867fdd4 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -72,6 +72,8 @@ struct cpufreq_policy { unsigned int max; /* in kHz */ unsigned int cur; /* in kHz, only needed if cpufreq * governors are used */ + unsigned int suspend_freq; /* freq to set during suspend */ + unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ void *governor_data;