From owner-svn-src-stable@FreeBSD.ORG Fri Jan 9 11:36:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E06F1065688; Fri, 9 Jan 2009 11:36:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A3488FC19; Fri, 9 Jan 2009 11:36:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09BaU6R055482; Fri, 9 Jan 2009 11:36:30 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09BaU39055481; Fri, 9 Jan 2009 11:36:30 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200901091136.n09BaU39055481@svn.freebsd.org> From: Alexander Motin Date: Fri, 9 Jan 2009 11:36:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186939 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 09 Jan 2009 11:36:31 -0000 Author: mav Date: Fri Jan 9 11:36:30 2009 New Revision: 186939 URL: http://svn.freebsd.org/changeset/base/186939 Log: MFC rev. 186154 If possible, try to obtain max_mhz on cpufreq attach instead of first request. On HyperThreading CPUs logical cores have same frequency, so setting it on any core will change the other's one. In most cases first request to the second core will be the "set" request, done after setting frequency of the first core. In such case second CPU will obtain throttled frequency of the first core as it's max_mhz making cpufreq broken due to different frequency sets. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_cpu.c Modified: stable/7/sys/kern/kern_cpu.c ============================================================================== --- stable/7/sys/kern/kern_cpu.c Fri Jan 9 11:21:25 2009 (r186938) +++ stable/7/sys/kern/kern_cpu.c Fri Jan 9 11:36:30 2009 (r186939) @@ -144,7 +144,9 @@ static int cpufreq_attach(device_t dev) { struct cpufreq_softc *sc; + struct pcpu *pc; device_t parent; + uint64_t rate; int numdevs; CF_DEBUG("initializing %s\n", device_get_nameunit(dev)); @@ -156,7 +158,12 @@ cpufreq_attach(device_t dev) CF_MTX_INIT(&sc->lock); sc->curr_level.total_set.freq = CPUFREQ_VAL_UNKNOWN; SLIST_INIT(&sc->saved_freq); - sc->max_mhz = CPUFREQ_VAL_UNKNOWN; + /* Try to get current CPU freq to use it as maximum later if needed */ + pc = cpu_get_pcpu(dev); + if (cpu_est_clockrate(pc->pc_cpuid, &rate) == 0) + sc->max_mhz = rate / 1000000; + else + sc->max_mhz = CPUFREQ_VAL_UNKNOWN; /* * Only initialize one set of sysctls for all CPUs. In the future,