From patchwork Tue Sep 9 22:12:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Chaugule X-Patchwork-Id: 37160 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 331DD20566 for ; Tue, 9 Sep 2014 22:13:59 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id dc16sf4188174qab.2 for ; Tue, 09 Sep 2014 15:13:59 -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=98z2PZikjX/Z4sBQ5YbWaf9tPAvDn7C/jwEbzvbZ74w=; b=nNgrR7v542BoKFl6d71yxieV2hlMI/ylglTKo9WOopy0EjOllqPGGFqH1cvNmlygZ6 LKDKGdRwHMqCis3aZKlWW/MwZUoLJu+jmEBF5Zg3OblPDc6owWKLN+M9UQCwuNte57ui Ph2RjGfRibB1KoTYXC80SR6GH8AIJGlodGUGm7IIGf/Eik7L2/Xi79pIqOBpJdBu00FH P94Siauw7EIbW8unhcnZH4qsFGnIZMlZoAWQP8HiWguOqtXnJYK2ivIqm0l1Kg8SFQkb HvUIwqVYX2Q28RPZvLbMbkMMYCMn7W44IygaEwWp9n+/MbIi88QpHhL3cUJzeMLg3qtd 98OA== X-Gm-Message-State: ALoCoQlZkpYzvSaz3Uor79WUAn+Q5LCg1bC2CJXzITW0QSz0MoMDGNOm4zK3IJGhe8fOn8o1rM8Z X-Received: by 10.236.118.37 with SMTP id k25mr22738582yhh.1.1410300839054; Tue, 09 Sep 2014 15:13:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.99 with SMTP id n90ls2433397qge.66.gmail; Tue, 09 Sep 2014 15:13:58 -0700 (PDT) X-Received: by 10.220.88.19 with SMTP id y19mr39412vcl.70.1410300838965; Tue, 09 Sep 2014 15:13:58 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id ty1si5680887vcb.101.2014.09.09.15.13.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 15:13:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so18001321vcb.11 for ; Tue, 09 Sep 2014 15:13:58 -0700 (PDT) X-Received: by 10.221.24.135 with SMTP id re7mr4302690vcb.53.1410300838876; Tue, 09 Sep 2014 15:13:58 -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 uj3csp349931vcb; Tue, 9 Sep 2014 15:13:58 -0700 (PDT) X-Received: by 10.66.141.165 with SMTP id rp5mr60380308pab.115.1410300837943; Tue, 09 Sep 2014 15:13:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si23535615pdk.119.2014.09.09.15.13.57 for ; Tue, 09 Sep 2014 15:13:57 -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 S1752889AbaIIWNz (ORCPT + 27 others); Tue, 9 Sep 2014 18:13:55 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:58755 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550AbaIIWMd (ORCPT ); Tue, 9 Sep 2014 18:12:33 -0400 Received: by mail-pd0-f169.google.com with SMTP id fp1so4358827pdb.14 for ; Tue, 09 Sep 2014 15:12:32 -0700 (PDT) X-Received: by 10.70.134.205 with SMTP id pm13mr61419982pdb.80.1410300752832; Tue, 09 Sep 2014 15:12:32 -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.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Sep 2014 15:12:31 -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 2/6] PID: Move Turbo detection into backend driver Date: Tue, 9 Sep 2014 18:12:04 -0400 Message-Id: <1410300728-26637-3-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.180 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: , Move X86 specific turbo detection logic into platform specific PID backend driver. Signed-off-by: Ashwin Chaugule --- drivers/cpufreq/intel_pid_ctrl.c | 15 ++++++++++++++- drivers/cpufreq/pid_ctrl.c | 13 +++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/intel_pid_ctrl.c b/drivers/cpufreq/intel_pid_ctrl.c index ebab074..9ad7d5e 100644 --- a/drivers/cpufreq/intel_pid_ctrl.c +++ b/drivers/cpufreq/intel_pid_ctrl.c @@ -58,6 +58,11 @@ static int byt_get_max_pstate(void) static int byt_get_turbo_pstate(void) { u64 value; + u64 misc_en; + + rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); + if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE) + return byt_get_max_pstate(); rdmsrl(BYT_TURBO_RATIOS, value); return value & 0x7F; @@ -124,12 +129,20 @@ static int core_get_turbo_pstate(void) { u64 value; int nont, ret; + u64 misc_en; - rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value); nont = core_get_max_pstate(); + rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); + + if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE) + return nont; + + rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value); ret = ((value) & 255); + if (ret <= nont) ret = nont; + return ret; } diff --git a/drivers/cpufreq/pid_ctrl.c b/drivers/cpufreq/pid_ctrl.c index b273ce1..516b95f 100644 --- a/drivers/cpufreq/pid_ctrl.c +++ b/drivers/cpufreq/pid_ctrl.c @@ -313,10 +313,15 @@ static void pid_ctrl_get_cpu_pstates(struct cpudata *cpu) { cpu->pstate.min_pstate = pstate_funcs.get_min(); cpu->pstate.max_pstate = pstate_funcs.get_max(); - cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); + + if (pstate_funcs.get_turbo) + cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); + 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); } @@ -532,7 +537,6 @@ static int pid_ctrl_cpu_init(struct cpufreq_policy *policy) { struct cpudata *cpu; int rc; - u64 misc_en; rc = pid_ctrl_init_cpu(policy->cpu); if (rc) @@ -540,9 +544,7 @@ static int pid_ctrl_cpu_init(struct cpufreq_policy *policy) cpu = all_cpu_data[policy->cpu]; - rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); - if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || - cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { + if (cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { limits.turbo_disabled = 1; limits.no_turbo = 1; } @@ -598,7 +600,6 @@ static int __init pid_ctrl_init(void) { int cpu, rc = 0; - if (!pstate_funcs.get_max || !pstate_funcs.get_min || !pstate_funcs.set ||