From owner-p4-projects@FreeBSD.ORG Sun May 6 21:10:36 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6DDA416A40B; Sun, 6 May 2007 21:10:36 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1C7DA16A403 for ; Sun, 6 May 2007 21:10:36 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 0D74413C4B9 for ; Sun, 6 May 2007 21:10:36 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l46LAZXt011586 for ; Sun, 6 May 2007 21:10:35 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l46LAZqE011583 for perforce@freebsd.org; Sun, 6 May 2007 21:10:35 GMT (envelope-from rpaulo@FreeBSD.org) Date: Sun, 6 May 2007 21:10:35 GMT Message-Id: <200705062110.l46LAZqE011583@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo To: Perforce Change Reviews Cc: Subject: PERFORCE change 119371 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2007 21:10:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=119371 Change 119371 by rpaulo@rpaulo_epsilon on 2007/05/06 21:10:15 We don't need any scheduler support because: 1) msrtemp is a child of cpu - this implies that every rdmsr/cpuid instruction will be executed on that CPU. 2) rdmsr/cpuid are atomic, so I don't need to worry about any threads interfering. Bring back the device_printf()'s in the attach routine. Explained by: Attilio Rao Affected files ... .. //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#5 edit Differences ... ==== //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#5 (text+ko) ==== @@ -23,7 +23,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#4 $ + * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#5 $ * */ @@ -59,7 +59,7 @@ static int msrtemp_attach(device_t); static int msrtemp_detach(device_t); -static int msrtemp_get_temp(int); +static int msrtemp_get_temp(void); static int msrtemp_get_temp_sysctl(SYSCTL_HANDLER_ARGS); static device_method_t msrtemp_methods[] = { @@ -131,6 +131,19 @@ pdev = device_get_parent(dev); + if (bootverbose) { + /* + * CPUID 0x06 returns 1 if the processor has on-die thermal + * sensors. We already checked that in the identify routine. + * EBX[0:3] contains the number of sensors. + */ + do_cpuid(0x06, regs); + device_printf(dev, "%d digital thermal sensor(s)\n", + regs[2] & 0x03); + } + device_printf(dev, "current temperature: %d degC\n", + msrtemp_get_temp()); + /* * Add the "temperature" MIB to dev.cpu.N. */ @@ -139,7 +152,7 @@ device_get_sysctl_tree(pdev)), OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, - dev, 0, msrtemp_get_temp_sysctl, "I", + NULL, 0, msrtemp_get_temp_sysctl, "I", "Current temperature in degC"); return 0; } @@ -156,12 +169,10 @@ static int -msrtemp_get_temp(int cpu) +msrtemp_get_temp(void) { uint64_t temp; - mtx_lock_spin(&sched_lock); - sched_bind(curthread, cpu); /* * The digital temperature reading is located at bit 16 * of MSR_THERM_STATUS. @@ -177,9 +188,6 @@ * 100 degC for everyone. */ temp = rdmsr(MSR_THERM_STATUS); - - sched_unbind(curthread); - mtx_unlock_spin(&sched_lock); /* * Bit 31 contains "Reading valid" @@ -200,9 +208,8 @@ msrtemp_get_temp_sysctl(SYSCTL_HANDLER_ARGS) { int temp; - device_t dev = (device_t) arg1; - temp = msrtemp_get_temp(device_get_unit(dev)); + temp = msrtemp_get_temp(); return sysctl_handle_int(oidp, &temp, 0, req); }