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: 4873071 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9E4F59F32E for ; Tue, 9 Sep 2014 22:13:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE075201B9 for ; Tue, 9 Sep 2014 22:13:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAFA92018B for ; Tue, 9 Sep 2014 22:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705AbaIIWNf (ORCPT ); Tue, 9 Sep 2014 18:13:35 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:55005 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbaIIWMf (ORCPT ); Tue, 9 Sep 2014 18:12:35 -0400 Received: by mail-pa0-f49.google.com with SMTP id lf10so4342274pab.8 for ; Tue, 09 Sep 2014 15:12: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xSjp2QBj6Z/MUS4HH5ZWTJL0JitiI6nkjBVjErtG/M4=; b=CHoP7YtesSF0cMrbqMtkqTEKXyaK4RGWl4JXeLc0YK/OqWUuJ/+ybBcfSdkXuEuglY 3BC62+va8kX/U1nUXoRvoAHIcZu74oSa9UxGC3pLgkQM2V3pMNCeM4FUpsnJq4v/5ZCE Am4/jTGep8JPJYBs8pfqE/On7gBoWnosXgRIwjNNOBFxQdzzbHlI+spTvDgaxqGLBHep uvKHDdpl00A+RVWqK6ZgrVwhHktAGS+CZMkaROqlnKoIOnx36FYv84+GEblqbReUxkvg NH+bY35s5x4uZQVsVgpU3HZg48pqq8g5HrtTFHFBU/nXM4lOQdIWIfNC3Mi4Qkk9YqBN 0fJg== X-Gm-Message-State: ALoCoQljV243xew7k4tNrp/rp5q/i/1/gBsvPF0VIUOmdUs4mjdvTgeL/spylQ8LC7LpTRdoHd3C 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 {