From owner-svn-src-all@FreeBSD.ORG Wed Aug 4 00:25:13 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EF8D1065675; Wed, 4 Aug 2010 00:25:13 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 51A888FC0A; Wed, 4 Aug 2010 00:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o740PD03005807; Wed, 4 Aug 2010 00:25:13 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o740PDS3005805; Wed, 4 Aug 2010 00:25:13 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201008040025.o740PDS3005805@svn.freebsd.org> From: Xin LI Date: Wed, 4 Aug 2010 00:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210833 - head/sys/dev/coretemp X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2010 00:25:13 -0000 Author: delphij Date: Wed Aug 4 00:25:13 2010 New Revision: 210833 URL: http://svn.freebsd.org/changeset/base/210833 Log: Catch known CPUs before using IA32_TEMPERATURE_TARGET. This way we would have an opportunity to hide the Tj(target) value doesn't seem right stuff if we know it's not working there. Add temperature value for Core2 Duo Extreme Mobile that I have access to. Modified: head/sys/dev/coretemp/coretemp.c Modified: head/sys/dev/coretemp/coretemp.c ============================================================================== --- head/sys/dev/coretemp/coretemp.c Tue Aug 3 23:11:23 2010 (r210832) +++ head/sys/dev/coretemp/coretemp.c Wed Aug 4 00:25:13 2010 (r210833) @@ -178,34 +178,6 @@ coretemp_attach(device_t dev) */ sc->sc_tjmax = 100; - /* - * Attempt to get Tj(max) from MSR IA32_TEMPERATURE_TARGET. - * - * This method is described in Intel white paper - * "CPU Monitoring With DTS/PECI". (#322683) - */ - ret = rdmsr_safe(MSR_IA32_TEMPERATURE_TARGET, &msr); - if (ret == 0) { - tjtarget = (msr >> 16) & 0xff; - /* - * On earlier generation of processors, the value obtained - * from IA32_TEMPERATURE_TARGET register is an offset that - * needs to be summed with a model specific base. It is - * however not clear what these numbers are, with the - * publicly available documents from Intel. - * - * For now, we consider [70, 100]C range, as described in - * #322683, as "reasonable" and accept these values - * whenever the MSR is available for read, regardless the - * CPU model. - */ - if (tjtarget >= 70 && tjtarget <= 100) - sc->sc_tjmax = tjtarget; - else - device_printf(dev, "Tj(target) value %d does " - "not seem right.\n", tjtarget); - } - if ((cpu_model == 0xf && cpu_stepping >= 2) || cpu_model == 0xe) { /* * On some Core 2 CPUs, there's an undocumented MSR that @@ -217,6 +189,46 @@ coretemp_attach(device_t dev) msr = rdmsr(MSR_IA32_EXT_CONFIG); if (msr & (1 << 30)) sc->sc_tjmax = 85; + } else if (cpu_model == 0x17) { + switch (cpu_stepping) { + case 0x6: /* Mobile Core 2 Duo */ + sc->sc_tjmax = 104; + break; + default: /* Unknown stepping */ + break; + } + } else { + /* + * Attempt to get Tj(max) from MSR IA32_TEMPERATURE_TARGET. + * + * This method is described in Intel white paper "CPU + * Monitoring With DTS/PECI". (#322683) + */ + ret = rdmsr_safe(MSR_IA32_TEMPERATURE_TARGET, &msr); + if (ret == 0) { + tjtarget = (msr >> 16) & 0xff; + + /* + * On earlier generation of processors, the value + * obtained from IA32_TEMPERATURE_TARGET register is + * an offset that needs to be summed with a model + * specific base. It is however not clear what + * these numbers are, with the publicly available + * documents from Intel. + * + * For now, we consider [70, 100]C range, as + * described in #322683, as "reasonable" and accept + * these values whenever the MSR is available for + * read, regardless the CPU model. + */ + if (tjtarget >= 70 && tjtarget <= 100) + sc->sc_tjmax = tjtarget; + else + device_printf(dev, "Tj(target) value %d " + "does not seem right.\n", tjtarget); + } else + device_printf(dev, "Can not get Tj(target) " + "from your CPU, using 100C.\n"); } if (bootverbose)