From patchwork Fri Sep 13 13:02:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20235 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C276420358 for ; Fri, 13 Sep 2013 13:24:35 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id b4sf1232956qen.5 for ; Fri, 13 Sep 2013 06:24:35 -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: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=yybPOzDLpTDhJ1isKaePGjSKiSbsYbQtcF1BgWPp6Gc=; b=I5YrdjazMRrYpjntR/FVTOMLl4f+vxPKJII3FDcAK2/dyC5tszs1cYuACuoCJGuJ/x sAj7fDsD5gMIdqlxI6tS5JWOonN2LbzI7fB3M5NEapajR2N9qRHSgOoj1wUzzAAZmApk hHNVi3vPKCEVXKcgrWaznik8lBI/n1iHoNQj/zouGV87yYlrmRyTkUU2PrxF757nDMi+ OShROBETiW4Di9C15RKbcOmLl6whGODae9LeIElkLdxOGXWe+6t1oYIxMc9eVOfWQqmE mrBvf7gNxXy4QibSNd+tFHQM6EcTP1VEfJJ8MZbzUps6NgKTkX26GwabL9Pne800+38u MfPw== X-Gm-Message-State: ALoCoQm/YRP05Bg7O0ajGOdCKFHKaA3JK0UZWrBnv0HDQfCOmAJ/Unt4hb14nSiYhV0TkTTfjRK3 X-Received: by 10.236.110.168 with SMTP id u28mr4996869yhg.40.1379078675596; Fri, 13 Sep 2013 06:24:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.10 with SMTP id em10ls1112469qeb.82.gmail; Fri, 13 Sep 2013 06:24:35 -0700 (PDT) X-Received: by 10.58.152.3 with SMTP id uu3mr11960493veb.16.1379078675395; Fri, 13 Sep 2013 06:24:35 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id om2si3111858vec.113.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:24:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 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.45; Received: by mail-vb0-f45.google.com with SMTP id e15so914145vbg.32 for ; Fri, 13 Sep 2013 06:24:35 -0700 (PDT) X-Received: by 10.58.168.205 with SMTP id zy13mr10068465veb.19.1379078675324; Fri, 13 Sep 2013 06:24:35 -0700 (PDT) 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 u4csp80572vcz; Fri, 13 Sep 2013 06:24:34 -0700 (PDT) X-Received: by 10.68.143.199 with SMTP id sg7mr13511089pbb.13.1379078674292; Fri, 13 Sep 2013 06:24:34 -0700 (PDT) Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by mx.google.com with ESMTPS id hk5si11268923pac.38.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:24:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.169 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.169; Received: by mail-pd0-f169.google.com with SMTP id r10so1262686pdi.0 for ; Fri, 13 Sep 2013 06:24:33 -0700 (PDT) X-Received: by 10.68.132.103 with SMTP id ot7mr13315524pbb.158.1379078673895; Fri, 13 Sep 2013 06:24:33 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id ye1sm18072854pab.19.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:24:33 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Viresh Kumar Subject: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core Date: Fri, 13 Sep 2013 18:32:07 +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.45 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: , Most of the drivers do following in their ->target_index() routines: struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead. There are few special cases though, like exynos5440, which doesn't do everything on the call to ->target_index() routine and call some kind of bottom halves for doing this work, work/tasklet/etc.. They may continue doing notification from their own code and so this patch introduces another flag: CPUFREQ_ASYNC_NOTIFICATION, which will be set by such drivers. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3fd24b1..79f89c3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1787,6 +1787,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, retval = cpufreq_driver->target(policy, target_freq, relation); else if (cpufreq_driver->target_index) { struct cpufreq_frequency_table *freq_table; + struct cpufreq_freqs freqs; + unsigned long flags; + bool notify; int index; freq_table = cpufreq_frequency_get_table(policy->cpu); @@ -1807,7 +1810,39 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, goto out; } + read_lock_irqsave(&cpufreq_driver_lock, flags); + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); + read_unlock_irqrestore(&cpufreq_driver_lock, flags); + + if (notify) { + freqs.old = policy->cur; + freqs.new = freq_table[index].frequency; + freqs.flags = 0; + + pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", + __func__, policy->cpu, freqs.old, + freqs.new); + + cpufreq_notify_transition(policy, &freqs, + CPUFREQ_PRECHANGE); + } + retval = cpufreq_driver->target_index(policy, index); + if (retval) + pr_err("%s: Failed to change cpu frequency: %d\n", + __func__, retval); + + if (notify) { + /* + * Notify with old freq in case we failed to change + * frequency + */ + if (retval) + freqs.new = freqs.old; + + cpufreq_notify_transition(policy, &freqs, + CPUFREQ_POSTCHANGE); + } } out: