From patchwork Tue Sep 9 22:12:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Chaugule X-Patchwork-Id: 37159 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9AB4320566 for ; Tue, 9 Sep 2014 22:13:40 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf4180176iga.6 for ; Tue, 09 Sep 2014 15:13:40 -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=o6+CXKcDYoz+ud7+vui2UBZasWPhNK7mOwmfARLQYqQ=; b=YinpRUSYi/ViNaK9cka4ER8EB0+1M6bBwGg2IJxXgX/IEO6vVp2UgqqexDx/8qdc9d FdD4h1ILZIMzm7I6Rr3cItM5H97SeAEql3QUEUb+elC4L5sql2lL6A2l+mzowq+724u/ /z7YcFAYUrXfCRVB2oFnBXWwb7FJJqLSyghCaNnbaxqQW0ex697p1xh06mWFeXiF0Va/ 1cnyJ1lGINXPnaN5GS8wQlkFUfwOk7q8J7MQcdq+PZVUkvuiW9ldKogPpGnl0Mj5VTZ7 AjDMznD3Mz+pAsKuTDC7nmRgJJmJQqj6lMYiZmYZAruzccK3TJ0/pZ+z86uFA9rQXxLH LeAA== X-Gm-Message-State: ALoCoQl6yKi/T5BferkehXUwgJSEY/ctjQldcFcTpMwsyfQr1zHgJB1B2gRnwydVb1vzt3aAh/gk X-Received: by 10.182.56.200 with SMTP id c8mr14394861obq.7.1410300820097; Tue, 09 Sep 2014 15:13:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.130 with SMTP id a2ls2354018qgf.90.gmail; Tue, 09 Sep 2014 15:13:40 -0700 (PDT) X-Received: by 10.220.116.196 with SMTP id n4mr32416612vcq.6.1410300819966; Tue, 09 Sep 2014 15:13:39 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id jz15si6265083vdb.94.2014.09.09.15.13.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 15:13:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id la4so1182763vcb.22 for ; Tue, 09 Sep 2014 15:13:39 -0700 (PDT) X-Received: by 10.52.34.104 with SMTP id y8mr956581vdi.37.1410300819667; Tue, 09 Sep 2014 15:13:39 -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.221.45.67 with SMTP id uj3csp349900vcb; Tue, 9 Sep 2014 15:13:39 -0700 (PDT) X-Received: by 10.67.3.70 with SMTP id bu6mr60459344pad.118.1410300819020; Tue, 09 Sep 2014 15:13:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wo10si25005059pab.222.2014.09.09.15.13.38 for ; Tue, 09 Sep 2014 15:13:39 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbaIIWNg (ORCPT + 27 others); Tue, 9 Sep 2014 18:13:36 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:49263 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636AbaIIWMf (ORCPT ); Tue, 9 Sep 2014 18:12:35 -0400 Received: by mail-pd0-f174.google.com with SMTP id v10so9771886pde.5 for ; Tue, 09 Sep 2014 15:12:35 -0700 (PDT) X-Received: by 10.70.35.67 with SMTP id f3mr60426858pdj.34.1410300755113; Tue, 09 Sep 2014 15:12:35 -0700 (PDT) Received: from esagroth.qualcomm.com (rrcs-67-52-130-30.west.biz.rr.com. [67.52.130.30]) by mx.google.com with ESMTPSA id gr5sm12524216pbc.33.2014.09.09.15.12.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Sep 2014 15:12:34 -0700 (PDT) From: Ashwin Chaugule To: dirk.j.brandewie@intel.com Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Ashwin Chaugule Subject: [PATCH 3/6] PID: Move Baytrail specific accessors into backend driver Date: Tue, 9 Sep 2014 18:12:05 -0400 Message-Id: <1410300728-26637-4-git-send-email-ashwin.chaugule@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410300728-26637-1-git-send-email-ashwin.chaugule@linaro.org> References: <1410300728-26637-1-git-send-email-ashwin.chaugule@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ashwin.chaugule@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) 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: , The Baytrail series uses additional information while setting a target CPU performance value. To keep the PID governor generic, move this out into the platform specific backend driver. Signed-off-by: Ashwin Chaugule --- drivers/cpufreq/intel_pid_ctrl.c | 57 ++++++++++++++++++++++++---------------- drivers/cpufreq/pid_ctrl.c | 4 --- drivers/cpufreq/pid_ctrl.h | 9 ------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/cpufreq/intel_pid_ctrl.c b/drivers/cpufreq/intel_pid_ctrl.c index 9ad7d5e..a858981 100644 --- a/drivers/cpufreq/intel_pid_ctrl.c +++ b/drivers/cpufreq/intel_pid_ctrl.c @@ -29,6 +29,15 @@ #define BYT_TURBO_RATIOS 0x66c #define BYT_TURBO_VIDS 0x66d +struct vid_data { + int min; + int max; + int turbo; + int32_t ratio; +}; + +static struct vid_data vid_data; + struct perf_limits limits = { .no_turbo = 0, .max_perf_pct = 100, @@ -39,6 +48,21 @@ struct perf_limits limits = { .max_sysfs_pct = 100, }; +static void byt_get_vid(int max, int min) +{ + u64 value; + + rdmsrl(BYT_VIDS, value); + vid_data.min = int_tofp((value >> 8) & 0x7f); + vid_data.max = int_tofp((value >> 16) & 0x7f); + vid_data.ratio = div_fp( + vid_data.max - vid_data.min, + int_tofp(max - min)); + + rdmsrl(BYT_TURBO_VIDS, value); + vid_data.turbo = value & 0x7f; +} + static int byt_get_min_pstate(void) { u64 value; @@ -50,9 +74,15 @@ static int byt_get_min_pstate(void) static int byt_get_max_pstate(void) { u64 value; + int max, min; rdmsrl(BYT_RATIOS, value); - return (value >> 16) & 0x7F; + max = (value >> 16) & 0x7F; + min = byt_get_min_pstate(); + + byt_get_vid(max, min); + + return max; } static int byt_get_turbo_pstate(void) @@ -78,37 +108,21 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) if (limits.no_turbo && !limits.turbo_disabled) val |= (u64)1 << 32; - vid_fp = cpudata->vid.min + mul_fp( + vid_fp = vid_data.min + mul_fp( int_tofp(pstate - cpudata->pstate.min_pstate), - cpudata->vid.ratio); + vid_data.ratio); - vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); + vid_fp = clamp_t(int32_t, vid_fp, vid_data.min, vid_data.max); vid = fp_toint(vid_fp); if (pstate > cpudata->pstate.max_pstate) - vid = cpudata->vid.turbo; + vid = vid_data.turbo; val |= vid; wrmsrl(MSR_IA32_PERF_CTL, val); } -static void byt_get_vid(struct cpudata *cpudata) -{ - u64 value; - - rdmsrl(BYT_VIDS, value); - cpudata->vid.min = int_tofp((value >> 8) & 0x7f); - cpudata->vid.max = int_tofp((value >> 16) & 0x7f); - cpudata->vid.ratio = div_fp( - cpudata->vid.max - cpudata->vid.min, - int_tofp(cpudata->pstate.max_pstate - - cpudata->pstate.min_pstate)); - - rdmsrl(BYT_TURBO_VIDS, value); - cpudata->vid.turbo = value & 0x7f; -} - static int core_get_min_pstate(void) { u64 value; @@ -188,7 +202,6 @@ static struct cpu_defaults byt_params = { .get_min = byt_get_min_pstate, .get_turbo = byt_get_turbo_pstate, .set = byt_set_pstate, - .get_vid = byt_get_vid, }, }; diff --git a/drivers/cpufreq/pid_ctrl.c b/drivers/cpufreq/pid_ctrl.c index 516b95f..8eb9739 100644 --- a/drivers/cpufreq/pid_ctrl.c +++ b/drivers/cpufreq/pid_ctrl.c @@ -319,9 +319,6 @@ static void pid_ctrl_get_cpu_pstates(struct cpudata *cpu) else cpu->pstate.turbo_pstate = cpu->pstate.max_pstate; - if (pstate_funcs.get_vid) - pstate_funcs.get_vid(cpu); - pid_ctrl_set_pstate(cpu, cpu->pstate.min_pstate); } @@ -592,7 +589,6 @@ void register_cpu_funcs(struct pstate_funcs *funcs) pstate_funcs.get_min = funcs->get_min; pstate_funcs.get_turbo = funcs->get_turbo; pstate_funcs.set = funcs->set; - pstate_funcs.get_vid = funcs->get_vid; } EXPORT_SYMBOL_GPL(register_cpu_funcs); diff --git a/drivers/cpufreq/pid_ctrl.h b/drivers/cpufreq/pid_ctrl.h index ab56415..40b352a 100644 --- a/drivers/cpufreq/pid_ctrl.h +++ b/drivers/cpufreq/pid_ctrl.h @@ -30,13 +30,6 @@ struct sample { ktime_t time; }; -struct vid_data { - int min; - int max; - int turbo; - int32_t ratio; -}; - struct _pid { int setpoint; int32_t integral; @@ -69,7 +62,6 @@ struct cpudata { struct timer_list timer; struct pstate_data pstate; - struct vid_data vid; struct _pid pid; ktime_t last_sample_time; @@ -83,7 +75,6 @@ struct pstate_funcs { int (*get_min)(void); int (*get_turbo)(void); void (*set)(struct cpudata*, int pstate); - void (*get_vid)(struct cpudata *); }; struct cpu_defaults {