From patchwork Thu Oct 13 17:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 9375551 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 8B160607FD for ; Thu, 13 Oct 2016 17:42:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DCB42A18C for ; Thu, 13 Oct 2016 17:42:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 724D82A18E; Thu, 13 Oct 2016 17:42:10 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 E1FB72A18C for ; Thu, 13 Oct 2016 17:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934321AbcJMRmH (ORCPT ); Thu, 13 Oct 2016 13:42:07 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35021 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934248AbcJMRmF (ORCPT ); Thu, 13 Oct 2016 13:42:05 -0400 Received: by mail-pf0-f175.google.com with SMTP id s8so37900013pfj.2 for ; Thu, 13 Oct 2016 10:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=Q6Z28yKhE49P3SVY8iLGN2v7ANFM0NTasv+1DBL/6iY=; b=anV3Aim117OIb1NSJpod9VG/DlKDH+hrlnK39ZGuAN7iEV+NL2SNaOqIK7YSYG1XW9 NH79RxK/VyfL/4xNSMxsGRztf9+qIHh84fDhflPpvB031Za10kQaFP1QVX9vSbLlOmD6 pcqHpojqAqMSGVl8KLNKt189V7++uzgXFrark= 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; bh=Q6Z28yKhE49P3SVY8iLGN2v7ANFM0NTasv+1DBL/6iY=; b=Go+B4hr6lyRPUcP9k9AjfqVqBLg/tCzm17YNMmvBMJSpU7R68nnj7YnYK+hwLdvnRY ziPJJHZky8xi1pHG2zMlmiBrVc+NLPkTBZ9lOl587fTVX/yekuqWpKMjOUnXVFSP8/wr TJbpM7eH1ovjXp25O34KFZat37f+/wHqufOIq93ylMcgoJme0X178xsxMhhQ/hnehF4z H6rpCflpdTLk/0haDfQkkrUoWc5QDkcqbp0tfcB3FScuTTtu44MfEZz1l2TNiZI1961R /ttnPc2/IKTRAZcEMOawY6+CUTQ7fqiMQfNdKwRjErcUoBzqJLnxQWqsfEFm6WO0MaTN 1ypQ== X-Gm-Message-State: AA6/9RkwyIPlogPQuxHXgrKppH6hz+niDGkbukUFEhjKCKl64GoRCTmUaHhCFzLtBMYxEBd7 X-Received: by 10.98.150.79 with SMTP id c76mr11611239pfe.154.1476380059337; Thu, 13 Oct 2016 10:34:19 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id sa1sm21184469pac.34.2016.10.13.10.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Oct 2016 10:34:18 -0700 (PDT) From: Hoan Tran To: "Rafael J. Wysocki" , Viresh Kumar , pprakash@codeaurora.org, Al Stone Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, lho@apm.com, Duc Dang , Hoan Tran Subject: [PATCH v2] cpufreq: CPPC: Correct desired_perf calculation Date: Thu, 13 Oct 2016 10:33:35 -0700 Message-Id: <1476380015-21001-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 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 The desired_perf is an abstract performance number. Its value should be in the range of [lowest perf, highest perf] of CPPC. The correct calculation is desired_perf = freq * cppc_highest_perf / cppc_dmi_max_khz And cppc_cpufreq_set_target() returns if desired_perf is exactly the same with the old perf. Signed-off-by: Hoan Tran Reviewed-by: Prashanth Prakash --- v2 * Return if desired_perf is the same with the old one (Prashanth's suggestion) drivers/cpufreq/cppc_cpufreq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 1b2f28f..4852d9e 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -80,11 +80,17 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, { struct cppc_cpudata *cpu; struct cpufreq_freqs freqs; + u32 desired_perf; int ret = 0; cpu = all_cpu_data[policy->cpu]; - cpu->perf_ctrls.desired_perf = (u64)target_freq * policy->max / cppc_dmi_max_khz; + desired_perf = (u64)target_freq * cpu->perf_caps.highest_perf / cppc_dmi_max_khz; + /* Return if it is exactly the same perf */ + if (desired_perf == cpu->perf_ctrls.desired_perf) + return ret; + + cpu->perf_ctrls.desired_perf = desired_perf; freqs.old = policy->cur; freqs.new = target_freq;