From patchwork Mon Aug 12 17:49:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19040 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B835246B8 for ; Mon, 12 Aug 2013 17:53:06 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ht10sf3607557vcb.9 for ; Mon, 12 Aug 2013 10:53:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state: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=t2qQoKPTqnf9SYEBav8BaJZPCQyDjf23of2E7YNf88I=; b=RncNYZ85TO+VAlT08BhLV81n20XJgRmNkKJAZgbHyUjM2xzIvdqku6qpQadvSDp3Ds AG8+5irQIMTdNluA34/YzA7jJTXiEl1zW2FddDFBMrQ4Vo4GCP46uqIOLIiBlwIHdPMk iPhj+Cu+6E7Drh5yk0kdBory+eNWpbaGKDAZpfDOARwWTlStvYQhX8HT4Rkzt3D61T93 fF2UmXbakG4npfiBhbDKCibIYntFSfHRSKVqocUEtI88sdOfrVXJHOTyu8r/dVsqqDap oFb4xwHqkPQip0NV88ytLWFZVExUE42UyrxX07ThtaLauWprQZCyHkCh2kqpgU2TBta5 BMKQ== X-Received: by 10.236.109.199 with SMTP id s47mr83084yhg.2.1376329986143; Mon, 12 Aug 2013 10:53:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.108.198 with SMTP id hm6ls2316145qeb.40.gmail; Mon, 12 Aug 2013 10:53:06 -0700 (PDT) X-Received: by 10.220.169.203 with SMTP id a11mr160254vcz.26.1376329985950; Mon, 12 Aug 2013 10:53:05 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id sd9si8592551vdc.39.2013.08.12.10.53.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 Aug 2013 10:53:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 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.174; Received: by mail-vc0-f174.google.com with SMTP id gd11so3075564vcb.33 for ; Mon, 12 Aug 2013 10:53:05 -0700 (PDT) X-Gm-Message-State: ALoCoQmmBGGxl6XsWsoc9wmEpiDo8ojuvC7HR38Rxvb1fr5iQbWIVwrKuuze36i43J9sGxLXmbs/ X-Received: by 10.52.168.10 with SMTP id zs10mr136814vdb.21.1376329985847; Mon, 12 Aug 2013 10:53:05 -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 u4csp108337vcz; Mon, 12 Aug 2013 10:53:05 -0700 (PDT) X-Received: by 10.68.225.164 with SMTP id rl4mr253857pbc.100.1376329984849; Mon, 12 Aug 2013 10:53:04 -0700 (PDT) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by mx.google.com with ESMTPS id zo4si22165354pbc.222.2013.08.12.10.53.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 Aug 2013 10:53:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.175 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.175; Received: by mail-pd0-f175.google.com with SMTP id q10so3697888pdj.20 for ; Mon, 12 Aug 2013 10:53:04 -0700 (PDT) X-Received: by 10.68.223.34 with SMTP id qr2mr250710pbc.75.1376329984445; Mon, 12 Aug 2013 10:53:04 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id sz6sm41398498pab.5.2013.08.12.10.53.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 Aug 2013 10:53:03 -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, Viresh Kumar , "David S. Miller" Subject: [PATCH 30/31] cpufreq: speedstep: Covert to light weight ->target() routine Date: Mon, 12 Aug 2013 23:19:06 +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.220.174 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: , This patch converts existing .target_old() to newly defined light weight .target() routine for this driver. CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it. Cc: David S. Miller Signed-off-by: Viresh Kumar --- drivers/cpufreq/speedstep-centrino.c | 26 +++++++------------------- drivers/cpufreq/speedstep-ich.c | 24 ++++++------------------ drivers/cpufreq/speedstep-smi.c | 20 +++++--------------- 3 files changed, 18 insertions(+), 52 deletions(-) diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 4fa5779..9993f52 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c @@ -422,21 +422,17 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy) /** * centrino_setpolicy - set a new CPUFreq policy * @policy: new policy - * @target_freq: the target frequency - * @relation: how that frequency relates to achieved frequency - * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) + * @index: index of target frequency * * Sets a new CPUFreq policy. */ -static int centrino_target (struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) +static int centrino_target(struct cpufreq_policy *policy, unsigned int index) { - unsigned int newstate = 0; unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu; struct cpufreq_freqs freqs; int retval = 0; unsigned int j, first_cpu, tmp; + struct cpufreq_frequency_table *op_points; cpumask_var_t covered_cpus; if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) @@ -447,16 +443,8 @@ static int centrino_target (struct cpufreq_policy *policy, goto out; } - if (unlikely(cpufreq_frequency_table_target(policy, - per_cpu(centrino_model, cpu)->op_points, - target_freq, - relation, - &newstate))) { - retval = -EINVAL; - goto out; - } - first_cpu = 1; + op_points = &per_cpu(centrino_model, cpu)->op_points[index]; for_each_cpu(j, policy->cpus) { int good_cpu; @@ -480,7 +468,7 @@ static int centrino_target (struct cpufreq_policy *policy, break; } - msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data; + msr = op_points->driver_data; if (first_cpu) { rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); @@ -495,7 +483,7 @@ static int centrino_target (struct cpufreq_policy *policy, freqs.new = extract_clock(msr, cpu, 0); pr_debug("target=%dkHz old=%d new=%d msr=%04x\n", - target_freq, freqs.old, freqs.new, msr); + op_points->frequency, freqs.old, freqs.new, msr); cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); @@ -546,7 +534,7 @@ static struct cpufreq_driver centrino_driver = { .init = centrino_cpu_init, .exit = centrino_cpu_exit, .verify = cpufreq_generic_frequency_table_verify, - .target_old = centrino_target, + .target = centrino_target, .get = get_cur_freq, .attr = cpufreq_generic_attr, }; diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c index d6ff71e..9ac5586 100644 --- a/drivers/cpufreq/speedstep-ich.c +++ b/drivers/cpufreq/speedstep-ich.c @@ -251,36 +251,24 @@ static unsigned int speedstep_get(unsigned int cpu) /** * speedstep_target - set a new CPUFreq policy * @policy: new policy - * @target_freq: the target frequency - * @relation: how that frequency relates to achieved frequency - * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) + * @index: index of target frequency * * Sets a new CPUFreq policy. */ -static int speedstep_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) +static int speedstep_target(struct cpufreq_policy *policy, unsigned int index) { - unsigned int newstate = 0, policy_cpu; + unsigned int policy_cpu; struct cpufreq_freqs freqs; - if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], - target_freq, relation, &newstate)) - return -EINVAL; - policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); freqs.old = speedstep_get(policy_cpu); - freqs.new = speedstep_freqs[newstate].frequency; + freqs.new = speedstep_freqs[index].frequency; pr_debug("transiting from %u to %u kHz\n", freqs.old, freqs.new); - /* no transition necessary */ - if (freqs.old == freqs.new) - return 0; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - smp_call_function_single(policy_cpu, _speedstep_set_state, &newstate, + smp_call_function_single(policy_cpu, _speedstep_set_state, &index, true); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); @@ -343,7 +331,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) static struct cpufreq_driver speedstep_driver = { .name = "speedstep-ich", .verify = cpufreq_generic_frequency_table_verify, - .target_old = speedstep_target, + .target = speedstep_target, .init = speedstep_cpu_init, .exit = cpufreq_generic_exit, .get = speedstep_get, diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c index fd8ad6e..8e219ef 100644 --- a/drivers/cpufreq/speedstep-smi.c +++ b/drivers/cpufreq/speedstep-smi.c @@ -235,29 +235,19 @@ static void speedstep_set_state(unsigned int state) /** * speedstep_target - set a new CPUFreq policy * @policy: new policy - * @target_freq: new freq - * @relation: + * @index: index of new freq * * Sets a new CPUFreq policy/freq. */ -static int speedstep_target(struct cpufreq_policy *policy, - unsigned int target_freq, unsigned int relation) +static int speedstep_target(struct cpufreq_policy *policy, unsigned int index) { - unsigned int newstate = 0; struct cpufreq_freqs freqs; - if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], - target_freq, relation, &newstate)) - return -EINVAL; - freqs.old = speedstep_freqs[speedstep_get_state()].frequency; - freqs.new = speedstep_freqs[newstate].frequency; - - if (freqs.old == freqs.new) - return 0; + freqs.new = speedstep_freqs[index].frequency; cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - speedstep_set_state(newstate); + speedstep_set_state(index); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); return 0; @@ -340,7 +330,7 @@ static int speedstep_resume(struct cpufreq_policy *policy) static struct cpufreq_driver speedstep_driver = { .name = "speedstep-smi", .verify = cpufreq_generic_frequency_table_verify, - .target_old = speedstep_target, + .target = speedstep_target, .init = speedstep_cpu_init, .exit = cpufreq_generic_exit, .get = speedstep_get,