From owner-freebsd-stable@FreeBSD.ORG Thu Jul 21 21:53:56 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id B83A0106567B; Thu, 21 Jul 2011 21:53:55 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-amd64@FreeBSD.org Date: Thu, 21 Jul 2011 17:53:39 -0400 User-Agent: KMail/1.6.2 References: <20110719112033.GA51765@omma.gibson.athome> <201107211207.41663.jkim@FreeBSD.org> <20110721205600.GA52261@omma.gibson.athome> In-Reply-To: <20110721205600.GA52261@omma.gibson.athome> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_m/JKO1yz80K9iDR" Message-Id: <201107211753.42373.jkim@FreeBSD.org> Cc: Callum Gibson , freebsd-stable@freebsd.org Subject: Re: powernow regression in 8-STABLE X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2011 21:53:56 -0000 --Boundary-00=_m/JKO1yz80K9iDR Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thursday 21 July 2011 04:56 pm, Callum Gibson wrote: > On 21Jul11 12:07, Jung-uk Kim wrote: > }Can you please do "set debug.cpufreq.verbose=1" from loader prompt > and }show me the dmesg output? I want to see intial settings. You > can }reset it from command line with "sysctl > debug.cpufreq.verbose=0" }later. > > http://members.optusnet.com.au/callumgibson/boot_verboser.out > > Also, as suggested by jhb@, with legacy usb disabled: > http://members.optusnet.com.au/callumgibson/boot_verboser_nousb.out > and dev.cpu.0.freq reappears! Spooky. Is that a solution or a > workaround? I noticed this disables usb keyboard support at the > boot menus. It is a workaround. Please try the attached patch. Jung-uk Kim --Boundary-00=_m/JKO1yz80K9iDR Content-Type: text/plain; charset="iso-8859-1"; name="kern_cpu2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kern_cpu2.diff" Index: sys/kern/kern_cpu.c =================================================================== --- sys/kern/kern_cpu.c (revision 224245) +++ sys/kern/kern_cpu.c (working copy) @@ -157,17 +157,18 @@ cpufreq_attach(device_t dev) sysctl_ctx_init(&sc->sysctl_ctx); TAILQ_INIT(&sc->all_levels); CF_MTX_INIT(&sc->lock); - sc->curr_level.total_set.freq = CPUFREQ_VAL_UNKNOWN; SLIST_INIT(&sc->saved_freq); /* Try to get nominal CPU freq to use it as maximum later if needed */ - sc->max_mhz = cpu_get_nominal_mhz(dev); - /* If that fails, try to measure the current rate */ - if (sc->max_mhz <= 0) { - 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; + if (sc->max_mhz == CPUFREQ_VAL_UNKNOWN) { + sc->max_mhz = cpu_get_nominal_mhz(dev); + /* If that fails, try to measure the current rate */ + if (sc->max_mhz <= 0) { + 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; + } } /* @@ -1000,8 +1001,11 @@ out: int cpufreq_register(device_t dev) { + struct cf_setting set; + struct cf_setting *sets; struct cpufreq_softc *sc; device_t cf_dev, cpu_dev; + int error, freq, max, set_count, type; /* Add a sysctl to get each driver's settings separately. */ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), @@ -1009,14 +1013,34 @@ cpufreq_register(device_t dev) OID_AUTO, "freq_settings", CTLTYPE_STRING | CTLFLAG_RD, dev, 0, cpufreq_settings_sysctl, "A", "CPU frequency driver settings"); + /* Get settings from the device and find current and maximum frequencies */ + freq = max = CPUFREQ_VAL_UNKNOWN; + if (CPUFREQ_DRV_TYPE(dev, &type) == 0 && + (type & CPUFREQ_TYPE_MASK) == CPUFREQ_TYPE_ABSOLUTE) { + if (CPUFREQ_DRV_GET(dev, &set) == 0) + freq = set.freq; + set_count = MAX_SETTINGS; + sets = malloc(set_count * sizeof(*sets), M_TEMP, M_NOWAIT); + if (sets != NULL) { + if (CPUFREQ_DRV_SETTINGS(dev, sets, &set_count) == 0 && + set_count > 0) + max = sets[0].freq; + free(sets, M_TEMP); + } + } + /* * Add only one cpufreq device to each CPU. Currently, all CPUs * must offer the same levels and be switched at the same time. */ cpu_dev = device_get_parent(dev); - if ((cf_dev = device_find_child(cpu_dev, "cpufreq", -1))) { + cf_dev = device_find_child(cpu_dev, "cpufreq", -1); + if (cf_dev != NULL) { sc = device_get_softc(cf_dev); - sc->max_mhz = CPUFREQ_VAL_UNKNOWN; + if (sc->curr_level.total_set.freq == CPUFREQ_VAL_UNKNOWN) + sc->curr_level.total_set.freq = freq; + if (sc->max_mhz == CPUFREQ_VAL_UNKNOWN) + sc->max_mhz = max; return (0); } @@ -1025,8 +1049,13 @@ cpufreq_register(device_t dev) if (cf_dev == NULL) return (ENOMEM); device_quiet(cf_dev); - - return (device_probe_and_attach(cf_dev)); + error = device_probe(cf_dev); + if (error != 0) + return (error); + sc = device_get_softc(cf_dev); + sc->curr_level.total_set.freq = freq; + sc->max_mhz = max; + return (device_attach(cf_dev)); } int --Boundary-00=_m/JKO1yz80K9iDR--