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: 4873101 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 804B79F32E for ; Tue, 9 Sep 2014 22:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEA8D2018B for ; Tue, 9 Sep 2014 22:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64A09201BC for ; Tue, 9 Sep 2014 22:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbaIIWNy (ORCPT ); Tue, 9 Sep 2014 18:13:54 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:36816 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbaIIWMd (ORCPT ); Tue, 9 Sep 2014 18:12:33 -0400 Received: by mail-pd0-f179.google.com with SMTP id g10so10951903pdj.10 for ; Tue, 09 Sep 2014 15:12:32 -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=GrwJnIWetFlQ+Ty5b+FxoTNYimSi9qh1YOyllm5I1i8=; b=KvuuLGXFRr/zBvjd2VsKAo+jreTlYI3gL+yEPZbZa/vC0CDMI3Ns/zD0C6j9gNR3Ie SNaF9zG4g5ujfhGbtG4j8XdP1V/9oCh6Hi5X/+AodQshYXTA0bHWmh4mGJbuTA12d0Aw tc/rqDjaAnofcml77OhLNU91AcbvxzSrJl9adg/jx61/lS1/qNBv5ltYMJ0vXSOC7DYO D8QKiUPQuqVpNdgGxXpaDPDS6kXwbaLZ0OlMcbjw4PgcC6LuddjHVbxdhwO4+y9oRGld bSs5nhUra9H8P+u/GrIBK3W8rH1pjinwkXhnMozSGWxZy25r+0eAwW+6xYK6hZ6UYBOl 2vDQ== X-Gm-Message-State: ALoCoQmdWHqaZsBVSIUMyTfik0CQ8ciWNciYAE/V1b02YevJGyV4Q06LxGD+ZBx3IUZEynq+AUU4 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-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 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 ||