From patchwork Tue Jun 17 20:36:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 4370011 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 3DC509F26E for ; Tue, 17 Jun 2014 20:36:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AAE42025B for ; Tue, 17 Jun 2014 20:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C40C2013D for ; Tue, 17 Jun 2014 20:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933502AbaFQUgd (ORCPT ); Tue, 17 Jun 2014 16:36:33 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:58081 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933275AbaFQUgc (ORCPT ); Tue, 17 Jun 2014 16:36:32 -0400 Received: by mail-pa0-f50.google.com with SMTP id bj1so4320290pad.9 for ; Tue, 17 Jun 2014 13:36:32 -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; bh=MiklF17ieuwCJKqJt9i70F9adld2L89NBD2T0drotjc=; b=02C8i8QT2dFQTO6H+jfxLjcpiB84mM5/Is/UQ9TnKrg5ofWlgMRV6vVta6H6A5+OSs 5yHP/zf6embVPM56FCSPRWWQAOBzwPAwsN0MirxsFhnxJlAVANKUSf36afHE88FDBUXu s4TxHttzJgJ8XiHIou/+rMb1VHrNUEXOdBcc8o6jPg7nkEeQjx0XtTq+EUxpxZM+R74c ZzyVdVXYMW5B1OH9wIBgd4PGE0E9u3u8rQp9TBmtnR+7pWb8bWuY5HMMEJvWaPoNFZXQ /Xca/hJy4wtz2cuh0rSGr4D6CrK/MjNi76sCImguLKoiZ3yUOx2APe7nIhCAXQZQuIlv r1+g== X-Received: by 10.66.146.105 with SMTP id tb9mr2083422pab.157.1403037392076; Tue, 17 Jun 2014 13:36:32 -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 jq6sm25432761pbb.76.2014.06.17.13.36.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jun 2014 13:36:31 -0700 (PDT) From: Doug Smythies X-Google-Original-From: Doug Smythies To: linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, dsmythies@telus.net, dirk.brandewie@gmail.com Subject: [PATCH] intel_pstate: Correct rounding in busy calculation Date: Tue, 17 Jun 2014 13:36:10 -0700 Message-Id: <1403037370-3484-1-git-send-email-dsmythies@telus.net> 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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 There was a mistake in the actual rounding portion this previous patch: f0fe3cd7e12d8290c82284b5c8aee723cbd0371a intel_pstate: Correct rounding in busy calculation such that the rounding was asymetric and incorrect. Severity: Not very serious, but can increase target pstate by one extra value. For real world work flows the issue should self correct (but I have no proof). It is the equivalent of different PID gains for positive and negative numbers. Examples: -3.000000 used to round to -4, rounds to -3 with this patch. -3.503906 used to round to -5, rounds to -4 with this patch. Signed-off-by: Doug Smythies --- drivers/cpufreq/intel_pstate.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 4e7f492..924bb2d 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy) pid->last_err = fp_error; result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; - if (result >= 0) - result = result + (1 << (FRAC_BITS-1)); - else - result = result - (1 << (FRAC_BITS-1)); + result = result + (1 << (FRAC_BITS-1)); return (signed int)fp_toint(result); }