Module Name: src Committed By: martin Date: Mon Feb 5 13:06:55 UTC 2018
Modified Files: src/distrib/sets/lists/man [netbsd-8]: mi src/distrib/sets/lists/modules [netbsd-8]: md.amd64 md.i386 src/share/man/man4 [netbsd-8]: amdtemp.4 src/share/man/man4/man4.x86 [netbsd-8]: Makefile src/sys/arch/amd64/conf [netbsd-8]: ALL GENERIC XEN3_DOM0 src/sys/arch/x86/pci [netbsd-8]: files.pci Added Files: src/share/man/man4/man4.x86 [netbsd-8]: amdsmn.4 amdzentemp.4 src/sys/arch/x86/pci [netbsd-8]: amdsmn.c amdsmn.h amdzentemp.c src/sys/modules/amdzentemp [netbsd-8]: amdzentemp.ioconf Log Message: Pull up following revision(s) (requested by pgoyette in ticket #524): distrib/sets/lists/man/mi 1.1574 distrib/sets/lists/modules/md.amd64 1.73 distrib/sets/lists/modules/md.i386 1.76 share/man/man4/amdtemp.4 1.11 share/man/man4/man4.x86/Makefile 1.17 share/man/man4/man4.x86/amdsmn.4 1.1-1.3 share/man/man4/man4.x86/amdzentemp.4 1.1-1.6 sys/arch/amd64/conf/ALL 1.79,1.80 sys/arch/amd64/conf/GENERIC 1.482,1.484 sys/arch/amd64/conf/XEN3_DOM0 1.146,1.147 sys/arch/x86/pci/amdsmn.c 1.1-1.2 sys/arch/x86/pci/amdsmn.h 1.1 sys/arch/x86/pci/amdzentemp.c 1.1-1.7 sys/arch/x86/pci/files.pci 1.22,1.23 sys/modules/amdzentemp/amdzentemp.ioconf 1.2 Add amdzentemp from FreeBSD via Ian Clark. man pages for amdsmn and amdzentemp. Some clean-up on the HISTORY and AUTHORS sections, and addition of a BUGS section to document the fact that we don't yet handle the required temp offset, nor do we expose the available thermal-trip value. Add missing article 'a' KNF: Put back the blank line following the empty variable declarations Put back the variable declaration, too, and mark it __diagused Otherwise a DIAGNOSTIC kernel will complain about the variable being undeclared. Correct placement of __diagused attribute. Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4), Create amdsmn(4) amd amdzentemp(4) modules for X86. To generate a diff of this commit: cvs rdiff -u -r1.1557 -r1.1557.2.1 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.72 -r1.72.6.1 src/distrib/sets/lists/modules/md.amd64 cvs rdiff -u -r1.73 -r1.73.6.1 src/distrib/sets/lists/modules/md.i386 cvs rdiff -u -r1.9 -r1.9.18.1 src/share/man/man4/amdtemp.4 cvs rdiff -u -r1.16 -r1.16.8.1 src/share/man/man4/man4.x86/Makefile cvs rdiff -u -r0 -r1.3.2.2 src/share/man/man4/man4.x86/amdsmn.4 cvs rdiff -u -r0 -r1.6.2.2 src/share/man/man4/man4.x86/amdzentemp.4 cvs rdiff -u -r1.59.2.1 -r1.59.2.2 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.459.2.3 -r1.459.2.4 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.135.4.4 -r1.135.4.5 src/sys/arch/amd64/conf/XEN3_DOM0 cvs rdiff -u -r0 -r1.3.2.2 src/sys/arch/x86/pci/amdsmn.c cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/x86/pci/amdsmn.h cvs rdiff -u -r0 -r1.7.2.2 src/sys/arch/x86/pci/amdzentemp.c cvs rdiff -u -r1.20 -r1.20.10.1 src/sys/arch/x86/pci/files.pci cvs rdiff -u -r0 -r1.2.2.2 src/sys/modules/amdzentemp/amdzentemp.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1557 src/distrib/sets/lists/man/mi:1.1557.2.1 --- src/distrib/sets/lists/man/mi:1.1557 Sat May 27 21:02:55 2017 +++ src/distrib/sets/lists/man/mi Mon Feb 5 13:06:54 2018 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1557 2017/05/27 21:02:55 bouyer Exp $ +# $NetBSD: mi,v 1.1557.2.1 2018/02/05 13:06:54 martin Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1994,6 +1994,8 @@ ./usr/share/man/cat4/x68k/powsw.0 man-sys-catman .cat ./usr/share/man/cat4/x68k/vs.0 man-sys-catman .cat ./usr/share/man/cat4/x86/amdpcib.0 man-sys-catman .cat +./usr/share/man/cat4/x86/amdsmn.0 man-sys-catman .cat +./usr/share/man/cat4/x86/amdzentemp.0 man-sys-catman .cat ./usr/share/man/cat4/x86/apic.0 man-sys-catman .cat ./usr/share/man/cat4/x86/balloon.0 man-sys-catman .cat ./usr/share/man/cat4/x86/coretemp.0 man-sys-catman .cat @@ -5029,6 +5031,8 @@ ./usr/share/man/html4/x68k/powsw.html man-sys-htmlman html ./usr/share/man/html4/x68k/vs.html man-sys-htmlman html ./usr/share/man/html4/x86/amdpcib.html man-sys-htmlman html +./usr/share/man/html4/x86/amdsmn.html man-sys-htmlman html +./usr/share/man/html4/x86/amdzentemp.html man-sys-htmlman html ./usr/share/man/html4/x86/apic.html man-sys-htmlman html ./usr/share/man/html4/x86/balloon.html man-sys-htmlman html ./usr/share/man/html4/x86/coretemp.html man-sys-htmlman html @@ -7996,6 +8000,8 @@ ./usr/share/man/man4/x68k/powsw.4 man-sys-man .man ./usr/share/man/man4/x68k/vs.4 man-sys-man .man ./usr/share/man/man4/x86/amdpcib.4 man-sys-man .man +./usr/share/man/man4/x86/amdsmn.4 man-sys-man .man +./usr/share/man/man4/x86/amdzentemp.4 man-sys-man .man ./usr/share/man/man4/x86/apic.4 man-sys-man .man ./usr/share/man/man4/x86/balloon.4 man-sys-man .man ./usr/share/man/man4/x86/coretemp.4 man-sys-man .man Index: src/distrib/sets/lists/modules/md.amd64 diff -u src/distrib/sets/lists/modules/md.amd64:1.72 src/distrib/sets/lists/modules/md.amd64:1.72.6.1 --- src/distrib/sets/lists/modules/md.amd64:1.72 Thu Dec 15 12:56:52 2016 +++ src/distrib/sets/lists/modules/md.amd64 Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.72 2016/12/15 12:56:52 kre Exp $ +# $NetBSD: md.amd64,v 1.72.6.1 2018/02/05 13:06:55 martin Exp $ # # NOTE that there are two sets of files here: # @MODULEDIR@ and amd64-xen @@ -31,8 +31,12 @@ ./@MODULEDIR@/acpiwmi/acpiwmi.kmod base-kernel-modules kmod ./@MODULEDIR@/aibs base-kernel-modules kmod ./@MODULEDIR@/aibs/aibs.kmod base-kernel-modules kmod +./@MODULEDIR@/amdsmn base-kernel-modules kmod +./@MODULEDIR@/amdsmn/amdsmn.kmod base-kernel-modules kmod ./@MODULEDIR@/amdtemp base-kernel-modules kmod ./@MODULEDIR@/amdtemp/amdtemp.kmod base-kernel-modules kmod +./@MODULEDIR@/amdzentemp base-kernel-modules kmod +./@MODULEDIR@/amdzentemp/amdzentemp.kmod base-kernel-modules kmod ./@MODULEDIR@/aps base-kernel-modules kmod ./@MODULEDIR@/aps/aps.kmod base-kernel-modules kmod ./@MODULEDIR@/asus base-kernel-modules kmod Index: src/distrib/sets/lists/modules/md.i386 diff -u src/distrib/sets/lists/modules/md.i386:1.73 src/distrib/sets/lists/modules/md.i386:1.73.6.1 --- src/distrib/sets/lists/modules/md.i386:1.73 Thu Dec 15 12:56:52 2016 +++ src/distrib/sets/lists/modules/md.i386 Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: md.i386,v 1.73 2016/12/15 12:56:52 kre Exp $ +# $NetBSD: md.i386,v 1.73.6.1 2018/02/05 13:06:55 martin Exp $ # # NOTE that there are three sets of files here: # @MODULEDIR@, i386-xen, and i386pae-xen @@ -32,8 +32,12 @@ ./@MODULEDIR@/acpiwmi/acpiwmi.kmod base-kernel-modules kmod ./@MODULEDIR@/aibs base-kernel-modules kmod ./@MODULEDIR@/aibs/aibs.kmod base-kernel-modules kmod +./@MODULEDIR@/amdsmn base-kernel-modules kmod +./@MODULEDIR@/amdsmn/amdsmn.kmod base-kernel-modules kmod ./@MODULEDIR@/amdtemp base-kernel-modules kmod ./@MODULEDIR@/amdtemp/amdtemp.kmod base-kernel-modules kmod +./@MODULEDIR@/amdzentemp base-kernel-modules kmod +./@MODULEDIR@/amdzentemp/amdzentemp.kmod base-kernel-modules kmod ./@MODULEDIR@/aps base-kernel-modules kmod ./@MODULEDIR@/aps/aps.kmod base-kernel-modules kmod ./@MODULEDIR@/asus base-kernel-modules kmod Index: src/share/man/man4/amdtemp.4 diff -u src/share/man/man4/amdtemp.4:1.9 src/share/man/man4/amdtemp.4:1.9.18.1 --- src/share/man/man4/amdtemp.4:1.9 Tue Mar 18 18:20:39 2014 +++ src/share/man/man4/amdtemp.4 Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: amdtemp.4,v 1.9 2014/03/18 18:20:39 riastradh Exp $ +.\" $NetBSD: amdtemp.4,v 1.9.18.1 2018/02/05 13:06:55 martin Exp $ .\"- .\" Copyright (c) 2008 Christoph Egger .\" All rights reserved. @@ -26,14 +26,14 @@ .\" .\" $FreeBSD: src/share/man/man4/coretemp.4,v 1.4 2007/10/15 20:00:19 netchild Exp $ .\" -.Dd March 2, 2012 +.Dd January 28, 2018 .Dt AMDTEMP 4 .Os .Sh NAME .Nm amdtemp .Nd AMD CPU on-die digital thermal sensor .Sh SYNOPSIS -.Cd "amdtemp* at pchb?" +.Cd "amdtemp* at amdnb_miscbus?" .Sh DESCRIPTION The .Nm Index: src/share/man/man4/man4.x86/Makefile diff -u src/share/man/man4/man4.x86/Makefile:1.16 src/share/man/man4/man4.x86/Makefile:1.16.8.1 --- src/share/man/man4/man4.x86/Makefile:1.16 Mon May 4 02:43:18 2015 +++ src/share/man/man4/man4.x86/Makefile Mon Feb 5 13:06:55 2018 @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.16 2015/05/04 02:43:18 pgoyette Exp $ +# $NetBSD: Makefile,v 1.16.8.1 2018/02/05 13:06:55 martin Exp $ MAN= amdpcib.4 apic.4 balloon.4 coretemp.4 est.4 fdc.4 \ fwhrng.4 hpet.4 ichlpcib.4 lpt.4 mem.4 odcm.4 powernow.4 \ - soekrisgpio.4 tco.4 tprof_amdpmi.4 tprof_pmi.4 vmt.4 vmx.4 + soekrisgpio.4 tco.4 tprof_amdpmi.4 tprof_pmi.4 vmt.4 vmx.4 \ + amdsmn.4 amdzentemp.4 MLINKS+=apic.4 ioapic.4 \ apic.4 lapic.4 Index: src/sys/arch/amd64/conf/ALL diff -u src/sys/arch/amd64/conf/ALL:1.59.2.1 src/sys/arch/amd64/conf/ALL:1.59.2.2 --- src/sys/arch/amd64/conf/ALL:1.59.2.1 Sat Sep 9 17:29:40 2017 +++ src/sys/arch/amd64/conf/ALL Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.59.2.1 2017/09/09 17:29:40 snj Exp $ +# $NetBSD: ALL,v 1.59.2.2 2018/02/05 13:06:55 martin Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.59.2.1 $" +#ident "ALL-$Revision: 1.59.2.2 $" maxusers 64 # estimated number of users @@ -442,10 +442,6 @@ options PCIBIOS_SHARP_MM20_FIXUP # this # on anything else. #options PCIINTR_DEBUG # super-verbose PCI interrupt fixup -# Temperatures -amdnb_misc* at pci? # AMD NB Misc Configuration -amdtemp* at amdnb_misc? # AMD CPU Temperature sensors - # PCI bridges rdcpcib* at pci? dev ? function ? # RDC Vortex86/PMX-1000 PCI-ISA w/ pchb* at pci? dev ? function ? # PCI-Host bridges @@ -604,6 +600,10 @@ lpt2 at isa? port 0x3bc # Hardware monitors +# Temperatures +amdsmn* at pci? # AMD SMN Configuration +amdzentemp* at amdsmnbus? # AMD Ryzen Family 17h CPU temp sensors + amdnb_misc* at pci? # AMD NB Misc Configuration amdtemp* at amdnb_misc? # AMD CPU Temperature sensors Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.459.2.3 src/sys/arch/amd64/conf/GENERIC:1.459.2.4 --- src/sys/arch/amd64/conf/GENERIC:1.459.2.3 Tue Aug 29 09:42:19 2017 +++ src/sys/arch/amd64/conf/GENERIC Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.459.2.3 2017/08/29 09:42:19 martin Exp $ +# $NetBSD: GENERIC,v 1.459.2.4 2018/02/05 13:06:55 martin Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.459.2.3 $" +#ident "GENERIC-$Revision: 1.459.2.4 $" maxusers 64 # estimated number of users @@ -472,6 +472,9 @@ lpt1 at isa? port 0x278 amdnb_misc* at pci? # AMD NB Misc Configuration amdtemp* at amdnb_misc? # AMD CPU Temperature sensors +amdsmn* at pci? # AMD SMN Configuration +amdzentemp* at amdsmnbus? # AMD Ryzen Family 17h CPU temp sensors + # Winbond LPC Super I/O #wbsio* at isa? port 0x2e #wbsio* at isa? port 0x4e Index: src/sys/arch/amd64/conf/XEN3_DOM0 diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.135.4.4 src/sys/arch/amd64/conf/XEN3_DOM0:1.135.4.5 --- src/sys/arch/amd64/conf/XEN3_DOM0:1.135.4.4 Fri Jan 26 14:28:15 2018 +++ src/sys/arch/amd64/conf/XEN3_DOM0 Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.135.4.4 2018/01/26 14:28:15 martin Exp $ +# $NetBSD: XEN3_DOM0,v 1.135.4.5 2018/02/05 13:06:55 martin Exp $ include "arch/amd64/conf/std.xen" @@ -303,6 +303,9 @@ lpt0 at isa? port 0x378 irq 7 # standard amdnb_misc* at pci? # AMD NB Misc Configuration amdtemp* at amdnb_misc? # AMD CPU Temperature sensors +amdsmn* at pci? # AMD SMN Configuration +amdzentemp* at amdsmnbus? # AMD Ryzen Family 17h CPU temp sensors + # AMD 768 and 8111 power/ACPI controllers amdpm* at pci? dev ? function ? # RNG and SMBus 1.0 interface #iic* at amdpm? # sensors below are on this bus Index: src/sys/arch/x86/pci/files.pci diff -u src/sys/arch/x86/pci/files.pci:1.20 src/sys/arch/x86/pci/files.pci:1.20.10.1 --- src/sys/arch/x86/pci/files.pci:1.20 Sun May 3 02:50:59 2015 +++ src/sys/arch/x86/pci/files.pci Mon Feb 5 13:06:55 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.pci,v 1.20 2015/05/03 02:50:59 pgoyette Exp $ +# $NetBSD: files.pci,v 1.20.10.1 2018/02/05 13:06:55 martin Exp $ device aapic attach aapic at pci @@ -10,6 +10,7 @@ define agp_x86: agp_ali, agp_amd, agp_am defflag AGP_X86 define amdnb_miscbus {} +define amdsmnbus {} # PCI-Host bridge chipsets device pchb: pcibus, agpbus, agp_x86 @@ -34,6 +35,16 @@ file arch/x86/pci/amdpcib_hpet.c amd device amdnb_misc: amdnb_miscbus attach amdnb_misc at pci file arch/x86/pci/amdnb_misc.c amdnb_misc + +# AMD Family 17h system management network +device amdsmn: amdsmnbus +attach amdsmn at pci +file arch/x86/pci/amdsmn.c amdsmn + +# AMD Family 17h CPU temp sensor +device amdzentemp: sysmon_envsys +attach amdzentemp at amdsmnbus +file arch/x86/pci/amdzentemp.c amdzentemp device amdtemp: sysmon_envsys attach amdtemp at amdnb_miscbus Added files: Index: src/share/man/man4/man4.x86/amdsmn.4 diff -u /dev/null src/share/man/man4/man4.x86/amdsmn.4:1.3.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/share/man/man4/man4.x86/amdsmn.4 Mon Feb 5 13:06:55 2018 @@ -0,0 +1,88 @@ +.\" $NetBSD: amdsmn.4,v 1.3.2.2 2018/02/05 13:06:55 martin Exp $ +.\" +.\" Copyright (c) 2018 Ian Clark <mrroos...@gmail.com> +.\" All rights reserved. +.\" +.\" This code is derived from the FreeBSD amdsmn driver by +.\" Conrad Meyer <c...@freebsd.org> +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\"- +.\" Copyright (c) 2017 Conrad Meyer <c...@freebsd.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: head/share/man/man4/amdsmn.4 323184 2017-09-05 15:13:41Z cem $ +.\" +.Dd January 22, 2018 +.Dt AMDSMN 4 x86 +.Os +.Sh NAME +.Nm amdsmn +.Nd device driver for AMD processor System Management Network +.Sh SYNOPSIS +.Cd "amdsmn* at pci?" +.Sh DESCRIPTION +The +.Nm +driver provides support for resources on the System Management Network bus +in AMD Family 17h processors. +.Sh SEE ALSO +.Xr amdzentemp 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx +and +.Nx 9.0 . +.Sh AUTHORS +.An -nosplit +Based on the +.Fx +driver by +.An Conrad Meyer . +It was adapted to +.Nx +by +.An Ian Clark . Index: src/share/man/man4/man4.x86/amdzentemp.4 diff -u /dev/null src/share/man/man4/man4.x86/amdzentemp.4:1.6.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/share/man/man4/man4.x86/amdzentemp.4 Mon Feb 5 13:06:55 2018 @@ -0,0 +1,100 @@ +.\" $NetBSD: amdzentemp.4,v 1.6.2.2 2018/02/05 13:06:55 martin Exp $ +.\"- +.\" Copyright (c) 2008 Christoph Egger +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: src/share/man/man4/coretemp.4,v 1.4 2007/10/15 20:00:19 netchild Exp $ +.\" +.Dd January 28, 2018 +.Dt AMDZENTEMP 4 x86 +.Os +.Sh NAME +.Nm amdzentemp +.Nd AMD Zen CPU family on-die digital thermal sensor +.Sh SYNOPSIS +.Cd "amdzentemp* at amdsmnbus?" +.Sh DESCRIPTION +The +.Nm +driver provides support for the on-die digital thermal sensor present +on AMD Ryzen CPUs +.Pp +These sensors provide 0.125\(deC accuracy. +There is one sensor for each CPU socket. +.Pp +The +.Nm +driver reports temperatures through the +.Xr envsys 4 +API. +.Bl -column "CPUN sensor0" "Units" "Typical Use" -offset indent +.It Sy "Sensor" Ta Sy "Units" Ta Sy "Typical Use" +.It CPU Ns Em N No sensor0 Ta \(*mK Ta cpu Ns Em N No temperature +.El +.Sh SEE ALSO +.Xr amdtemp 4 , +.Xr envsys 4 , +.Xr envstat 8 , +.Xr powerd 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 4.4 +named +.Dq kate . +It was then ported to +.Nx 5.0 +under the name +.Xr amdtemp 4 . +The +.Fx +version of the driver was updated with support for newer AMD CPUs. +For +.Nx , +the support for the newer CPUs was separated into its own +.Nm +driver. +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Constantine A. Murenin Aq Mt c...@openbsd.org +whilst at the University of Waterloo. +Porting of support for the newer AMD CPUs from +.Fx +was provided by +.An Ian Clark . +.Sh BUGS +The temperature reading provided to +.Xr envsys 4 +needs to have a CPU-dependent offset applied. +For Ryzen X processors, the offset is 20\(deC, while for Threadripper +processors an offset of 27\(deC is needed. +.Pp +The sensor has a thermal-trip value which should be retrieved and +provided to +.Xr envsys 4 +as the sensors critical-maximum value. Index: src/sys/arch/x86/pci/amdsmn.c diff -u /dev/null src/sys/arch/x86/pci/amdsmn.c:1.3.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/sys/arch/x86/pci/amdsmn.c Mon Feb 5 13:06:55 2018 @@ -0,0 +1,183 @@ +/* $NetBSD: amdsmn.c,v 1.3.2.2 2018/02/05 13:06:55 martin Exp $ */ + +/*- + * Copyright (c) 2017 Conrad Meyer <c...@freebsd.org> + * All rights reserved. + * + * NetBSD port by Ian Clark <mrroos...@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.3.2.2 2018/02/05 13:06:55 martin Exp $ "); + +/* + * Driver for the AMD Family 17h CPU System Management Network. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/errno.h> +#include <sys/mutex.h> +#include <sys/systm.h> +#include <sys/cpu.h> +#include <sys/module.h> + +#include <machine/specialreg.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> +#include <dev/pci/pcidevs.h> + +#include "amdsmn.h" +#include "ioconf.h" + +#define SMN_ADDR_REG 0x60 +#define SMN_DATA_REG 0x64 +#define AMD_17H_MANAGEMENT_NETWORK_PCI_ID 0x14501022 + +struct amdsmn_softc { + kmutex_t smn_lock; + struct pci_attach_args pa; + pci_chipset_tag_t pc; + pcitag_t pcitag; +}; + +static int amdsmn_match(device_t, cfdata_t, void *); +static void amdsmn_attach(device_t, device_t, void *); +static int amdsmn_rescan(device_t, const char *, const int *); +static int amdsmn_detach(device_t, int); +static int amdsmn_misc_search(device_t, cfdata_t, const int *, void *); + +CFATTACH_DECL3_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match, + amdsmn_attach, amdsmn_detach, NULL, amdsmn_rescan, NULL, 0); + +static int +amdsmn_match(device_t parent, cfdata_t match, void *aux) +{ + struct pci_attach_args *pa = aux; + + return pa->pa_id == AMD_17H_MANAGEMENT_NETWORK_PCI_ID ? 2 : 0; +} + +static int +amdsmn_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux) +{ + if (config_match(parent, cf, aux)) + config_attach_loc(parent, cf, locs, aux, NULL); + + return 0; +} + +static void +amdsmn_attach(device_t parent, device_t self, void *aux) +{ + struct amdsmn_softc *sc = device_private(self); + struct pci_attach_args *pa = aux; + int flags = 0; + + mutex_init(&sc->smn_lock, MUTEX_DEFAULT, IPL_NONE); + sc->pa = *pa; + sc->pc = pa->pa_pc; + sc->pcitag = pa->pa_tag; + aprint_normal(": AMD Family 17h System Management Network\n"); + amdsmn_rescan(self, "amdsmn", &flags); +} + +static int +amdsmn_rescan(device_t self, const char *ifattr, const int *flags) +{ + struct amdsmn_softc *sc = device_private(self); + + config_search_loc(amdsmn_misc_search, self, ifattr, NULL, &sc->pa); + + return 0; +} + +static int +amdsmn_detach(device_t self, int flags) +{ + struct amdsmn_softc *sc = device_private(self); + + mutex_destroy(&sc->smn_lock); + aprint_normal_dev(self,"detach!\n"); + + return 0; +} + +int +amdsmn_read(device_t dev, uint32_t addr, uint32_t *value) +{ + struct amdsmn_softc *sc = device_private(dev); + + mutex_enter(&sc->smn_lock); + pci_conf_write(sc->pc, sc->pcitag, SMN_ADDR_REG, addr); + *value = pci_conf_read(sc->pc, sc->pcitag, SMN_DATA_REG); + mutex_exit(&sc->smn_lock); + + return 0; +} + +int +amdsmn_write(device_t dev, uint32_t addr, uint32_t value) +{ + struct amdsmn_softc *sc = device_private(dev); + + mutex_enter(&sc->smn_lock); + pci_conf_write(sc->pc, sc->pcitag, SMN_ADDR_REG, addr); + pci_conf_write(sc->pc, sc->pcitag, SMN_DATA_REG, value); + mutex_exit(&sc->smn_lock); + + return 0; +} + +MODULE(MODULE_CLASS_DRIVER, amdsmn, "pci"); + +#ifdef _MODULE +#include "ioconf.c" +#endif + +static int +amdsmn_modcmd(modcmd_t cmd, void *opaque) +{ + int error = 0; + +#ifdef _MODULE + switch (cmd) { + case MODULE_CMD_INIT: + error = config_init_component(cfdriver_ioconf_amdsmn, + cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn); + break; + case MODULE_CMD_FINI: + error = config_fini_component(cfdriver_ioconf_amdsmn, + cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn); + break; + default: + error = ENOTTY; + break; + } +#endif + + return error; +} + Index: src/sys/arch/x86/pci/amdsmn.h diff -u /dev/null src/sys/arch/x86/pci/amdsmn.h:1.1.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/sys/arch/x86/pci/amdsmn.h Mon Feb 5 13:06:55 2018 @@ -0,0 +1,32 @@ +/* $NetBSD: amdsmn.h,v 1.1.2.2 2018/02/05 13:06:55 martin Exp $ */ + +/*- + * Copyright (c) 2017 Conrad Meyer <c...@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: head/sys/dev/amdsmn/amdsmn.h 323184 2017-09-05 15:13:41Z cem $ + */ + +int amdsmn_read(device_t, uint32_t, uint32_t *); +int amdsmn_write(device_t, uint32_t, uint32_t); Index: src/sys/arch/x86/pci/amdzentemp.c diff -u /dev/null src/sys/arch/x86/pci/amdzentemp.c:1.7.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/sys/arch/x86/pci/amdzentemp.c Mon Feb 5 13:06:55 2018 @@ -0,0 +1,252 @@ +/* $NetBSD: amdzentemp.c,v 1.7.2.2 2018/02/05 13:06:55 martin Exp $ */ +/* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ + +/* + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christoph Egger. + * + * NetBSD port by Ian Clark <mrroos...@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 2008 Constantine A. Murenin <cnst+open...@bugmail.mojo.ru> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.7.2.2 2018/02/05 13:06:55 martin Exp $ "); + +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/cpu.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/kmem.h> +#include <sys/module.h> + +#include <machine/specialreg.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> +#include <dev/pci/pcidevs.h> + +#include <dev/sysmon/sysmonvar.h> + +#include "amdsmn.h" + +/* Address to query for temp on family 17h */ +#define AMD_17H_CUR_TMP 0x59800 + +struct amdzentemp_softc { + pci_chipset_tag_t sc_pc; + pcitag_t sc_pcitag; + struct sysmon_envsys *sc_sme; + device_t sc_smn; + envsys_data_t *sc_sensor; + size_t sc_sensor_len; + size_t sc_numsensors; +}; + + +static int amdzentemp_match(device_t, cfdata_t, void *); +static void amdzentemp_attach(device_t, device_t, void *); +static int amdzentemp_detach(device_t, int); + +static void amdzentemp_family17_init(struct amdzentemp_softc *); +static void amdzentemp_family17_setup_sensors(struct amdzentemp_softc *, int); +static void amdzentemp_family17_refresh(struct sysmon_envsys *, envsys_data_t *); + +CFATTACH_DECL_NEW(amdzentemp, sizeof(struct amdzentemp_softc), + amdzentemp_match, amdzentemp_attach, amdzentemp_detach, NULL); + +static int +amdzentemp_match(device_t parent, cfdata_t match, void *aux) +{ + struct pci_attach_args *pa __diagused = aux; + + KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD); + + cfdata_t parent_cfdata = device_cfdata(parent); + + /* Got AMD family 17h system management network */ + return parent_cfdata->cf_name && + memcmp(parent_cfdata->cf_name, "amdsmn", 6) == 0; +} + +static void +amdzentemp_attach(device_t parent, device_t self, void *aux) +{ + struct amdzentemp_softc *sc = device_private(self); + struct pci_attach_args *pa = aux; + int error; + size_t i; + + aprint_naive("\n"); + aprint_normal(": AMD CPU Temperature Sensors (Family17h)"); + + sc->sc_pc = pa->pa_pc; + sc->sc_pcitag = pa->pa_tag; + sc->sc_smn = parent; + + amdzentemp_family17_init(sc); + + aprint_normal("\n"); + + sc->sc_sme = sysmon_envsys_create(); + sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors; + sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP); + + amdzentemp_family17_setup_sensors(sc, device_unit(self)); + + /* + * Set properties in sensors. + */ + for (i = 0; i < sc->sc_numsensors; i++) { + if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor[i])) + goto bad; + } + + /* + * Register the sysmon_envsys device. + */ + sc->sc_sme->sme_name = device_xname(self); + sc->sc_sme->sme_cookie = sc; + + sc->sc_sme->sme_refresh = amdzentemp_family17_refresh; + + error = sysmon_envsys_register(sc->sc_sme); + if (error) { + aprint_error_dev(self, "unable to register with sysmon " + "(error=%d)\n", error); + goto bad; + } + + (void)pmf_device_register(self, NULL, NULL); + + return; + +bad: + if (sc->sc_sme != NULL) { + sysmon_envsys_destroy(sc->sc_sme); + sc->sc_sme = NULL; + } + + kmem_free(sc->sc_sensor, sc->sc_sensor_len); + sc->sc_sensor = NULL; +} + +static int +amdzentemp_detach(device_t self, int flags) +{ + struct amdzentemp_softc *sc = device_private(self); + + pmf_device_deregister(self); + if (sc->sc_sme != NULL) + sysmon_envsys_unregister(sc->sc_sme); + + if (sc->sc_sensor != NULL) + kmem_free(sc->sc_sensor, sc->sc_sensor_len); + + return 0; +} + + +static void +amdzentemp_family17_init(struct amdzentemp_softc *sc) +{ + sc->sc_numsensors = 1; +} + +static void +amdzentemp_family17_setup_sensors(struct amdzentemp_softc *sc, int dv_unit) +{ + sc->sc_sensor[0].units = ENVSYS_STEMP; + sc->sc_sensor[0].state = ENVSYS_SVALID; + sc->sc_sensor[0].flags = ENVSYS_FHAS_ENTROPY; + + snprintf(sc->sc_sensor[0].desc, sizeof(sc->sc_sensor[0].desc), + "cpu%u temperature", dv_unit); +} + +static void +amdzentemp_family17_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) +{ + struct amdzentemp_softc *sc = sme->sme_cookie; + uint32_t temp; + int error; + + error = amdsmn_read(sc->sc_smn, AMD_17H_CUR_TMP, &temp); + if (error) { + edata->state = ENVSYS_SINVALID; + return; + } + edata->state = ENVSYS_SVALID; + /* From C to uK. */ + edata->value_cur = ((temp >> 21) * 125000) + 273150000; +} + +MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys,amdsmn"); + +#ifdef _MODULE +#include "ioconf.c" +#endif + +static int +amdzentemp_modcmd(modcmd_t cmd, void *aux) +{ + int error = 0; + + switch (cmd) { + case MODULE_CMD_INIT: +#ifdef _MODULE + error = config_init_component(cfdriver_ioconf_amdzentemp, + cfattach_ioconf_amdzentemp, cfdata_ioconf_amdzentemp); +#endif + return error; + case MODULE_CMD_FINI: +#ifdef _MODULE + error = config_fini_component(cfdriver_ioconf_amdzentemp, + cfattach_ioconf_amdzentemp, cfdata_ioconf_amdzentemp); +#endif + return error; + default: + return ENOTTY; + } +} + Index: src/sys/modules/amdzentemp/amdzentemp.ioconf diff -u /dev/null src/sys/modules/amdzentemp/amdzentemp.ioconf:1.2.2.2 --- /dev/null Mon Feb 5 13:06:55 2018 +++ src/sys/modules/amdzentemp/amdzentemp.ioconf Mon Feb 5 13:06:55 2018 @@ -0,0 +1,11 @@ +# $NetBSD: amdzentemp.ioconf,v 1.2.2.2 2018/02/05 13:06:55 martin Exp $ + +ioconf amdzentemp + +include "conf/files" +include "dev/pci/files.pci" +include "arch/x86/pci/files.pci" + +pseudo-root amdsmnbus* + +amdzentemp* at amdsmnbus?