PERFORCE change 119595 for review
Rui Paulo
rpaulo at FreeBSD.org
Wed May 9 20:54:51 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119595
Change 119595 by rpaulo at rpaulo_epsilon on 2007/05/09 20:54:28
Bring back the sched_bind() changes so that rdmsr executes on
the proper CPU.
Pointed out by: John Baldwin
Affected files ...
.. //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#7 edit
Differences ...
==== //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#7 (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#6 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/msrtemp/msrtemp.c#7 $
*
*/
@@ -64,7 +64,7 @@
static int msrtemp_attach(device_t);
static int msrtemp_detach(device_t);
-static int msrtemp_get_temp(void);
+static int msrtemp_get_temp(int);
static int msrtemp_get_temp_sysctl(SYSCTL_HANDLER_ARGS);
static device_method_t msrtemp_methods[] = {
@@ -130,25 +130,11 @@
static int
msrtemp_attach(device_t dev)
{
- int regs[4];
struct msrtemp_softc *sc = device_get_softc(dev);
device_t pdev;
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.
*/
@@ -157,7 +143,7 @@
device_get_sysctl_tree(pdev)),
OID_AUTO, "temperature",
CTLTYPE_INT | CTLFLAG_RD,
- NULL, 0, msrtemp_get_temp_sysctl, "I",
+ dev, 0, msrtemp_get_temp_sysctl, "I",
"Current temperature in degC");
return 0;
}
@@ -174,10 +160,14 @@
static int
-msrtemp_get_temp(void)
+msrtemp_get_temp(int cpu)
{
uint64_t temp;
+ mtx_lock_spin(&sched_lock);
+ sched_bind(curthread, cpu);
+ mtx_unlock_spin(&sched_lock);
+
/*
* The digital temperature reading is located at bit 16
* of MSR_THERM_STATUS.
@@ -212,9 +202,10 @@
static int
msrtemp_get_temp_sysctl(SYSCTL_HANDLER_ARGS)
{
+ device_t dev = (device_t) arg1;
int temp;
- temp = msrtemp_get_temp();
+ temp = msrtemp_get_temp(device_get_unit(dev));
return sysctl_handle_int(oidp, &temp, 0, req);
}
More information about the p4-projects
mailing list