From patchwork Fri Jul 18 15:37:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 4586321 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 DB4A49F26C for ; Fri, 18 Jul 2014 15:38:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 253212011D for ; Fri, 18 Jul 2014 15:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0BB8201BA for ; Fri, 18 Jul 2014 15:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422808AbaGRPhx (ORCPT ); Fri, 18 Jul 2014 11:37:53 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:52275 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422773AbaGRPhv (ORCPT ); Fri, 18 Jul 2014 11:37:51 -0400 Received: by mail-pa0-f48.google.com with SMTP id et14so5589987pad.7 for ; Fri, 18 Jul 2014 08:37:51 -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:in-reply-to:references; bh=Id5Y6voZFMLZ2MvkIT35SSCgmfMHoFdlznJmvrDYlN4=; b=fodxviM08unzgSV4afxVaaaOWfg/Ct4PoaDwExN2qB9BPV9+Nk28KtS9GbjS8cvrWi wKRvtMoGGiqj86Ag67uO7JSFs+eAWNFIjJh32xnL1ivhmjdukpafglral87MatULuHHa R7uYC5ue/smAzOjPGzoUhEHw5rAKkOJXDDshxRjSLaWNesQZ885JYXLbwO4CwjZe+vro FFTtFGtZkyNwPl3DQO8K0XghCfvO7V1oJZviMQkuDUKUYma64Yp7tfHDZrhfBFjybZnw vUv5DoFdiK6cjYzYUJlGVlrJjNVU3uvfIO9/5YhVZ1Mb1VrVxXC7oLat3d2278SwW/UX pOmA== X-Received: by 10.66.100.170 with SMTP id ez10mr6254770pab.12.1405697871442; Fri, 18 Jul 2014 08:37:51 -0700 (PDT) Received: from echolake.localdomain (static-50-43-41-81.bvtn.or.frontiernet.net. [50.43.41.81]) by mx.google.com with ESMTPSA id be7sm7894439pdb.37.2014.07.18.08.37.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 08:37:50 -0700 (PDT) From: dirk.brandewie@gmail.com X-Google-Original-From: dirk.j.brandewie@intel.com To: linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, Stratos Karafotis , Dirk Brandewie Subject: [PATCH 08/11] cpufreq: intel_pstate: Disable interrupts during MSRs reading Date: Fri, 18 Jul 2014 08:37:24 -0700 Message-Id: <1405697848-13546-9-git-send-email-dirk.j.brandewie@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1405697848-13546-1-git-send-email-dirk.j.brandewie@intel.com> References: <1405697848-13546-1-git-send-email-dirk.j.brandewie@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.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=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 From: Stratos Karafotis According to Intel 64 and IA-32 Architectures SDM, Volume 3, Chapter 14.2, "Software needs to exercise care to avoid delays between the two RDMSRs (for example interrupts)". So, disable interrupts during reading MSRs IA32_APERF and IA32_MPERF. This should increase the accuracy of the calculations. Signed-off-by: Stratos Karafotis Signed-off-by: Dirk Brandewie --- drivers/cpufreq/intel_pstate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 9d75bd6..ff3c562 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -577,9 +577,12 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) static inline void intel_pstate_sample(struct cpudata *cpu) { u64 aperf, mperf; + unsigned long flags; + local_irq_save(flags); rdmsrl(MSR_IA32_APERF, aperf); rdmsrl(MSR_IA32_MPERF, mperf); + local_irq_restore(flags); aperf = aperf >> FRAC_BITS; mperf = mperf >> FRAC_BITS;