From owner-freebsd-current@FreeBSD.ORG Wed May 5 19:10:09 2010 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [69.147.83.40]) by hub.freebsd.org (Postfix) with ESMTP id 8D3DC106567B; Wed, 5 May 2010 19:10:08 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: Norikatsu Shigemura Date: Wed, 5 May 2010 15:09:58 -0400 User-Agent: KMail/1.6.2 References: <20100505154312.49e7a2cc.nork@FreeBSD.org> <201005051351.15012.jkim@FreeBSD.org> In-Reply-To: <201005051351.15012.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005051510.00470.jkim@FreeBSD.org> Cc: freebsd-current@FreeBSD.org Subject: Re: amdtemp(4) issue X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2010 19:10:09 -0000 On Wednesday 05 May 2010 01:51 pm, Jung-uk Kim wrote: > On Wednesday 05 May 2010 02:43 am, Norikatsu Shigemura wrote: > > Hi jkim. > > > > I can't get CPU temperature via amdtemp(4). So I researched, > > but I can't fix this issue, maybe initialization problem. Please > > help me! > > > > 1st issue in amdtemp_gettemp function: > > now: offset += (diode_offset - 11) * 10; is BAD > > should fix: offset += (11 - diode_offset) * 10; is OK > > According to AMD's BIOS and Kernel Developer's Guid (BKDG) For > > AMD Family 10th Processors, Rev 3.48 - April 22, 2010 [*], > > P327 - F3xE4 Thermtrip Status Register: > > > > 01h to 3Fh: correction = +11C - DiodeOffset, or {01h to 3Fh} = > > {+10C to -52C}. > > > > In fact, in my environment, DiodeOffset = 0x18 so 11-0x18=-13C. > > > > 11 - 0x01 = +10C > > 11 - 0x18 = -13C > > 11 - 0x3f = -52C > > > > [*] http://support.amd.com/us/Processor_TechDocs/31116.pdf > > AMD keeps flipping the sign from core to core. :-( Please see > AMDTEMP_FLAG_DO_SIGN for Family 0Fh, for example. In fact, Linux > driver (k10temp) does not care about the DiodeOffset at all. > Instead, they just say "input" temperature. > > > 2nd issue, result of AMDTEMP_REPTMP_CTRL in amdtemp_gettemp > > function: I got following result: > > > > May 5 15:06:53 nadesico kernel: amdtemp0: > > AMDTEMP_REPTMP_CTRL(temp) = 0xc1880 > > > > So result (CurTmp: current temperature: 31:21) = 0C. (logic is > > OK) > > > > I got following thermal related registers in amdtemp_gettemp > > function: May 5 15:06:53 nadesico kernel: amdtemp0: F3x64 > > Hardware Thermal Control(HTC) Register = 0x3a4c0005 May 5 > > 15:06:53 nadesico kernel: amdtemp0: F3x68 Software Thermal > > Control(STC) Register = 0x10000000 May 5 15:06:53 nadesico > > kernel: amdtemp0: F3xA4 Reported Temperature Control Register = > > 0x000c1880 May 5 15:06:53 nadesico kernel: amdtemp0: F3xE4 > > Thermtrip Status Register = 0x1cc01830 May 5 15:06:53 nadesico > > kernel: amdtemp0: F3xE8 Northbridge Capabilities Register = > > 0x0207df19 > > > > But I don't have any idea to fix register's paraemters. Do you > > have any idea? > > Sorry, I don't. You may find Linux k10temp driver > (drivers/hwmon/k10temp.c) useful, though. Actually more useful reference code for us would be kate(4)/km(4) from OpenBSD and amdtemp(4) from NetBSD: http://www.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/kate.c http://www.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/km.c http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/x86/pci/amdtemp.c Jung-uk Kim