From patchwork Tue Jun 2 04:12:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 6526541 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 52C55C0020 for ; Tue, 2 Jun 2015 04:12:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F3CF201C0 for ; Tue, 2 Jun 2015 04:12:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FF2E2051F for ; Tue, 2 Jun 2015 04:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbbFBEMu (ORCPT ); Tue, 2 Jun 2015 00:12:50 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:34875 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752243AbbFBEMt (ORCPT ); Tue, 2 Jun 2015 00:12:49 -0400 Received: by padjw17 with SMTP id jw17so51914320pad.2 for ; Mon, 01 Jun 2015 21:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=ZIZSGAwhZCqsfiJMS8lQMZCxY6m6ApryyMky7E1UiJ8=; b=Quw9qAOeTtHo7UKm0+5qz9lxTdMD620Mqa4F1UnXstkecKi5t5iE3iNn/73gUZ0iDi J0NO3+Qm8OrOLLbabdYdCl2djH//BvvjJ1BpPU6dsB7FSU/bDyLUX+AA7ix2NVB2ki0O a5ALaMG+9s1Tts7VmKijUoHkV6UB4z6UQusH2PgvLQlt/xGM+qaTtmJ6l6pgZH9bc5ak enPwgn3AbYeS4xjagJ4mxEgUarvhc/iuaTWcbROVP63ORkHRkNq+eMksDaxL2AXoJlWH YHzXYtfKcgF0oQCEDqjpVPZsm/AGwBZ+qTFE3WxWojfDo7jvpXYw7pYP7w/d80dBOTHX Zzug== X-Received: by 10.68.137.162 with SMTP id qj2mr8961211pbb.135.1433218368924; Mon, 01 Jun 2015 21:12:48 -0700 (PDT) Received: from s15.smythies.com (s173-180-45-4.bc.hsia.telus.net. [173.180.45.4]) by mx.google.com with ESMTPSA id oa14sm6258800pdb.47.2015.06.01.21.12.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 21:12:48 -0700 (PDT) From: Doug Smythies X-Google-Original-From: Doug Smythies To: kristen@linux.intel.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org Cc: dsmythies@telus.net Subject: [PATCH v2] intel_pstate: Force setting target pstate when required. Date: Mon, 1 Jun 2015 21:12:34 -0700 Message-Id: <1433218354-2607-1-git-send-email-dsmythies@telus.net> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 During initialization and exit it is possible that the target pstate might not actually be set. Furthermore, the result can be that the driver and the processor are out of synch and, under some conditions, the driver might never send the processor the proper target pstate. This patch adds a bypass or do_checks flag to the call to intel_pstate_set_pstate. If bypass, then specifically bypass clamp checks and the do not send if it is the same as last time check. If do_checks, then, and as before, do the current policy clamp checks, and do not do actual send if the new target is the same as the old. Signed-off-by: Doug Smythies Reported-by: Marien Zwart Reported-by: Alex Lochmann Reported-by: Piotr Ko?aczkowski Reported-by: Clemens Eisserer Tested-by: Marien Zwart Tested-by: Doug Smythies --- drivers/cpufreq/intel_pstate.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 6414661..52c720c 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -33,6 +33,9 @@ #include #include +#define PSTATE_BYPASS_CHECKS false +#define PSTATE_DO_CHECKS true + #define BYT_RATIOS 0x66a #define BYT_VIDS 0x66b #define BYT_TURBO_RATIOS 0x66c @@ -704,19 +707,20 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf); } -static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) +static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate, bool mode) { int max_perf, min_perf; - update_turbo_state(); + if (mode == PSTATE_DO_CHECKS) { + update_turbo_state(); - intel_pstate_get_min_max(cpu, &min_perf, &max_perf); + intel_pstate_get_min_max(cpu, &min_perf, &max_perf); - pstate = clamp_t(int, pstate, min_perf, max_perf); - - if (pstate == cpu->pstate.current_pstate) - return; + pstate = clamp_t(int, pstate, min_perf, max_perf); + if (pstate == cpu->pstate.current_pstate) + return; + } trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); cpu->pstate.current_pstate = pstate; @@ -733,7 +737,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) if (pstate_funcs.get_vid) pstate_funcs.get_vid(cpu); - intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); + intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, PSTATE_BYPASS_CHECKS); } static inline void intel_pstate_calc_busy(struct cpudata *cpu) @@ -844,7 +848,7 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) ctl = pid_calc(pid, busy_scaled); /* Negative values of ctl increase the pstate and vice versa */ - intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl); + intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl, PSTATE_DO_CHECKS); } static void intel_hwp_timer_func(unsigned long __data) @@ -1007,7 +1011,7 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy) if (hwp_active) return; - intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); + intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, PSTATE_BYPASS_CHECKS); } static int intel_pstate_cpu_init(struct cpufreq_policy *policy)