PERFORCE change 119371 for review
Rui Paulo
rpaulo at FreeBSD.org
Sun May 6 21:10:36 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119371
Change 119371 by rpaulo at 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);
}
More information about the p4-projects
mailing list