From owner-svn-src-stable@FreeBSD.ORG Thu May 15 18:07:36 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07C4BA19; Thu, 15 May 2014 18:07:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8998226E; Thu, 15 May 2014 18:07:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4FI7Z8d023707; Thu, 15 May 2014 18:07:35 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4FI7ZHg023706; Thu, 15 May 2014 18:07:35 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201405151807.s4FI7ZHg023706@svn.freebsd.org> From: Colin Percival Date: Thu, 15 May 2014 18:07:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266165 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2014 18:07:36 -0000 Author: cperciva Date: Thu May 15 18:07:35 2014 New Revision: 266165 URL: http://svnweb.freebsd.org/changeset/base/266165 Log: MFC r265876: In cf_get_method, when we don't already know what clock speed the CPU is running at, guess the nearest value instead of looking for a value within 25 MHz of the observed frequency. Prior to this change, if a system booted with Intel Turbo Boost enabled, the dev.cpu.0.freq sysctl is nonfunctional, since the ACPI-reported frequency for Turbo Boost states does not match the actual clock frequency (and thus no levels are within 25 MHz of the observed frequency) and the current performance level is read before a new level is set. Relnotes: Bug fix in power management on CPUs with Intel Turbo Boost Modified: stable/10/sys/kern/kern_cpu.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_cpu.c ============================================================================== --- stable/10/sys/kern/kern_cpu.c Thu May 15 18:05:51 2014 (r266164) +++ stable/10/sys/kern/kern_cpu.c Thu May 15 18:07:35 2014 (r266165) @@ -418,7 +418,7 @@ cf_get_method(device_t dev, struct cf_le struct cf_setting *curr_set, set; struct pcpu *pc; device_t *devs; - int count, error, i, n, numdevs; + int bdiff, count, diff, error, i, n, numdevs; uint64_t rate; sc = device_get_softc(dev); @@ -494,14 +494,15 @@ cf_get_method(device_t dev, struct cf_le } cpu_est_clockrate(pc->pc_cpuid, &rate); rate /= 1000000; + bdiff = 1 << 30; for (i = 0; i < count; i++) { - if (CPUFREQ_CMP(rate, levels[i].total_set.freq)) { + diff = abs(levels[i].total_set.freq - rate); + if (diff < bdiff) { + bdiff = diff; sc->curr_level = levels[i]; - CF_DEBUG("get estimated freq %d\n", curr_set->freq); - goto out; } } - error = ENXIO; + CF_DEBUG("get estimated freq %d\n", curr_set->freq); out: if (error == 0)