From patchwork Mon Jul 10 23:23:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 9833863 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B5F660318 for ; Mon, 10 Jul 2017 23:24:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 608A828403 for ; Mon, 10 Jul 2017 23:24:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5088D28459; Mon, 10 Jul 2017 23:24:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D61E328403 for ; Mon, 10 Jul 2017 23:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754801AbdGJXYP (ORCPT ); Mon, 10 Jul 2017 19:24:15 -0400 Received: from mga02.intel.com ([134.134.136.20]:45910 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754656AbdGJXYP (ORCPT ); Mon, 10 Jul 2017 19:24:15 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2017 16:24:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,343,1496127600"; d="scan'208";a="106786399" Received: from spandruv-desk.jf.intel.com ([10.54.75.11]) by orsmga004.jf.intel.com with ESMTP; 10 Jul 2017 16:24:13 -0700 From: Srinivas Pandruvada To: rjw@rjwysocki.net Cc: lenb@kernel.org, linux-pm@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH] cpufreq: intel_pstate: Fix ratio setting for min_perf_pct Date: Mon, 10 Jul 2017 16:23:52 -0700 Message-Id: <1499729032-22038-1-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.7.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the minimum performance limit percentage is set to power-up default, it is possible that minimum performance ratio is set to one more than the desired. During set_policy() callback the minimum ratio is calculated by applying global.min_perf_pct to the turbo_ratio and rounding up. But the power-up default global.min_perf_pct is already rounded up to next percent in the function min_perf_pct_min(). So this will result in two round up operations. So for the default min_perf_pct, one of the rounding up is not required. It is better to remove rounding up in min_perf_pct_min() as this matches the displayed min_perf_pct prior to the commit c5a2ee7dde89 ("cpufreq: intel_pstate: Active mode P-state limits rework") in the kernel version 4,12. For example on a platform with max turbo ratio of 37 and minimum ratio of 10, the min_perf_pct resulted in 28 with the above commit. Before this commit it was 27 and same after this change. Fixes: 1a4fe38add8b ("cpufreq: intel_pstate: Remove max/min fractions to limit performance") Reported-by: Artem Bityutskiy Signed-off-by: Srinivas Pandruvada --- drivers/cpufreq/intel_pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 48a98f11a84e..2a65bd313938 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -572,7 +572,7 @@ static int min_perf_pct_min(void) int turbo_pstate = cpu->pstate.turbo_pstate; return turbo_pstate ? - DIV_ROUND_UP(cpu->pstate.min_pstate * 100, turbo_pstate) : 0; + (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; } static s16 intel_pstate_get_epb(struct cpudata *cpu_data)