From: Hasso Tepper Date: Tue, 2 Sep 2008 18:12:48 +0000 (+0000) Subject: Fix coretemp(4) to provide temperatures from all cores (instead of reading X-Git-Tag: v2.1.1~513 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/d7ef97d3577b06d573448c32ba41f0078cb49686 Fix coretemp(4) to provide temperatures from all cores (instead of reading temperature only from the core current thread runs on). Also use CPU device unit number as cpu identifier, not the one from coretemp device (it doesn't matter in practice though, but still ...). --- diff --git a/sys/dev/powermng/coretemp/coretemp.c b/sys/dev/powermng/coretemp/coretemp.c index c9de4cedce..abc3429b83 100644 --- a/sys/dev/powermng/coretemp/coretemp.c +++ b/sys/dev/powermng/coretemp/coretemp.c @@ -24,7 +24,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/coretemp/coretemp.c,v 1.2 2007/08/23 10:53:03 des Exp $ - * $DragonFly: src/sys/dev/powermng/coretemp/coretemp.c,v 1.1 2007/10/02 13:16:42 hasso Exp $ + * $DragonFly: src/sys/dev/powermng/coretemp/coretemp.c,v 1.2 2008/09/02 18:12:48 hasso Exp $ */ /* @@ -212,20 +212,26 @@ static int coretemp_get_temp(device_t dev) { uint64_t msr; - int temp; - int cpu = device_get_unit(dev); + int temp, cpu, origcpu; struct coretemp_softc *sc = device_get_softc(dev); char stemp[16]; + cpu = device_get_unit(device_get_parent(dev)); + /* * Bind to specific CPU to read the correct temperature. * If not all CPUs are initialised, then only read from * cpu0, returning -1 on all other CPUs. */ if (ncpus > 1) { + origcpu = mycpuid; + lwkt_migratecpu(cpu); + spin_lock_rd(&coretemp_lock); msr = rdmsr(MSR_THERM_STATUS); spin_unlock_rd(&coretemp_lock); + + lwkt_migratecpu(origcpu); } else if (cpu != 0) return (-1); else