From patchwork Sun Mar 6 07:34:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: plongepe X-Patchwork-Id: 8512361 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 314699FC5C for ; Sun, 6 Mar 2016 07:33:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 601832014A for ; Sun, 6 Mar 2016 07:33:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4136E2017D for ; Sun, 6 Mar 2016 07:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751250AbcCFHc7 (ORCPT ); Sun, 6 Mar 2016 02:32:59 -0500 Received: from mga09.intel.com ([134.134.136.24]:20429 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbcCFHc6 (ORCPT ); Sun, 6 Mar 2016 02:32:58 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 05 Mar 2016 23:32:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,545,1449561600"; d="scan'208";a="917847811" Received: from tllab185.tl.intel.com ([10.102.161.63]) by fmsmga001.fm.intel.com with ESMTP; 05 Mar 2016 23:32:56 -0800 From: Philippe Longepe To: linux-pm@vger.kernel.org Cc: srinivas.pandruvada@linux.intel.com, rafael@kernel.org Subject: [PATCH V5 1/4] Remove extra conversions in pid calculation Date: Sun, 6 Mar 2016 08:34:03 +0100 Message-Id: <1457249646-23072-2-git-send-email-philippe.longepe@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457249646-23072-1-git-send-email-philippe.longepe@linux.intel.com> References: <1457249646-23072-1-git-send-email-philippe.longepe@linux.intel.com> 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.9 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 pid->setpoint and pid->deadband can be initialize in float so we can remove the int_tofp in pid_calc. Signed-off-by: Philippe Longepe --- drivers/cpufreq/intel_pstate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index eb0aef0..114e4e0 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -198,8 +198,8 @@ static struct perf_limits *limits = &powersave_limits; static inline void pid_reset(struct _pid *pid, int setpoint, int busy, int deadband, int integral) { - pid->setpoint = setpoint; - pid->deadband = deadband; + pid->setpoint = int_tofp(setpoint); + pid->deadband = int_tofp(deadband); pid->integral = int_tofp(integral); pid->last_err = int_tofp(setpoint) - int_tofp(busy); } @@ -225,9 +225,9 @@ static signed int pid_calc(struct _pid *pid, int32_t busy) int32_t pterm, dterm, fp_error; int32_t integral_limit; - fp_error = int_tofp(pid->setpoint) - busy; + fp_error = pid->setpoint - busy; - if (abs(fp_error) <= int_tofp(pid->deadband)) + if (abs(fp_error) <= pid->deadband) return 0; pterm = mul_fp(pid->p_gain, fp_error);