Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Feb 2018 00:36:12 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r329767 - in stable/11: share/man/man4 stand/forth sys/amd64/conf sys/conf sys/dev/amdsmn sys/dev/amdtemp sys/modules sys/modules/amdsmn
Message-ID:  <201802220036.w1M0aCBe011443@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Thu Feb 22 00:36:12 2018
New Revision: 329767
URL: https://svnweb.freebsd.org/changeset/base/329767

Log:
  MFC r323067, r323184, r323185, r323195, r323196 (by cem)
  
  ------------------------------------------------------------------------
  r323067 | cem | 2017-08-31 11:39:18 -0700 (Thu, 31 Aug 2017) | 4 lines
  
  amdtemp.4: Update BKDG URL to current location
  
  Sponsored by:	Dell EMC Isilon
  
  ------------------------------------------------------------------------
  r323184 | cem | 2017-09-05 08:13:41 -0700 (Tue, 05 Sep 2017) | 10 lines
  
  Add smn(4) driver for AMD System Management Network
  
  AMD Family 17h CPUs have an internal network used to communicate between
  the host CPU and the PSP and SMU coprocessors.  It exposes a simple
  32-bit register space.
  
  Reviewed by:	avg (no +1), mjoras, truckman
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D12217
  
  ------------------------------------------------------------------------
  r323185 | cem | 2017-09-05 08:19:14 -0700 (Tue, 05 Sep 2017) | 13 lines
  
  amdtemp(4): Add support for Family 17h temperature sensor
  
  The sensor value is formatted similarly to previous models (same
  bitfield sizes, same units), but must be read off of the internal
  System Management Network (SMN) from the System Management Unit (SMU)
  co-processor.
  
  PR:		218264
  Reported and tested by:	Nils Beyer <nbe AT renzel.net>
  Reviewed by:	avg (no +1), mjoras, truckman
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D12217
  
  ------------------------------------------------------------------------
  r323195 | cem | 2017-09-05 13:35:25 -0700 (Tue, 05 Sep 2017) | 8 lines
  
  amdtemp(4): Do not probe not matching hostbridges
  
  Some systems have hostbs that do not match our PCI device id criteria.
  Detect and ignore these devices in probe.
  
  PR:		218264
  Sponsored by:	Dell EMC Isilon
  
  ------------------------------------------------------------------------
  r323196 | cem | 2017-09-05 14:00:33 -0700 (Tue, 05 Sep 2017) | 8 lines
  
  amdsmn(4): Do not probe not matching hostbridges
  
  Similar to r323195, but for amdsmn(4) driver (which borrowed some design).
  
  Ignore hostbs that do not match our PCI device id criteria.
  
  Sponsored by:	Dell EMC Isilon
  
  PR:		218264
  Differential Revision:	https://reviews.freebsd.org/D12217

Added:
  stable/11/share/man/man4/amdsmn.4
     - copied unchanged from r323184, head/share/man/man4/amdsmn.4
  stable/11/sys/dev/amdsmn/
     - copied from r323184, head/sys/dev/amdsmn/
  stable/11/sys/modules/amdsmn/
     - copied from r323184, head/sys/modules/amdsmn/
Modified:
  stable/11/share/man/man4/Makefile
  stable/11/share/man/man4/amdtemp.4
  stable/11/stand/forth/loader.conf
  stable/11/sys/amd64/conf/NOTES
  stable/11/sys/conf/files.amd64
  stable/11/sys/conf/files.i386
  stable/11/sys/dev/amdsmn/amdsmn.c
  stable/11/sys/dev/amdtemp/amdtemp.c
  stable/11/sys/modules/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/Makefile
==============================================================================
--- stable/11/share/man/man4/Makefile	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/share/man/man4/Makefile	Thu Feb 22 00:36:12 2018	(r329767)
@@ -46,6 +46,7 @@ MAN=	aac.4 \
 	amdpm.4 \
 	${_amdsbwd.4} \
 	${_amdsmb.4} \
+	${_amdsmn.4} \
 	${_amdtemp.4} \
 	${_bxe.4} \
 	amr.4 \
@@ -792,6 +793,7 @@ _attimer.4=	attimer.4
 _aibs.4=	aibs.4
 _amdsbwd.4=	amdsbwd.4
 _amdsmb.4=	amdsmb.4
+_amdsmn.4=	amdsmn.4
 _amdtemp.4=	amdtemp.4
 _asmc.4=	asmc.4
 _bxe.4=		bxe.4

Copied: stable/11/share/man/man4/amdsmn.4 (from r323184, head/share/man/man4/amdsmn.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/share/man/man4/amdsmn.4	Thu Feb 22 00:36:12 2018	(r329767, copy of r323184, head/share/man/man4/amdsmn.4)
@@ -0,0 +1,64 @@
+.\"-
+.\" Copyright (c) 2017 Conrad Meyer <cem@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$
+.\"
+.Dd September 5, 2017
+.Dt AMDSMN 4
+.Os
+.Sh NAME
+.Nm amdsmn
+.Nd device driver for
+.Tn AMD
+processor System Management Network
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following line in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device amdsmn"
+.Ed
+.Pp
+Alternatively, to load the driver as a module at boot time, place the
+following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+amdsmn_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for resources on the System Management Network bus
+in
+.Tn AMD
+Family 17h processors.
+.Sh SEE ALSO
+.Xr loader 8
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 12.0 .
+.Sh AUTHORS
+.An Conrad Meyer Aq Mt cem@FreeBSD.org

Modified: stable/11/share/man/man4/amdtemp.4
==============================================================================
--- stable/11/share/man/man4/amdtemp.4	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/share/man/man4/amdtemp.4	Thu Feb 22 00:36:12 2018	(r329767)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 27, 2015
+.Dd September 5, 2017
 .Dt AMDTEMP 4
 .Os
 .Sh NAME
@@ -53,7 +53,7 @@ The
 driver provides support for the on-die digital thermal sensor present
 in
 .Tn AMD
-Family 0Fh, 10h, 11h, 12h, 14h, 15h, and 16h processors.
+Family 0Fh, 10h, 11h, 12h, 14h, 15h, 16h, and 17h processors.
 .Pp
 For Family 0Fh processors, the
 .Nm
@@ -64,8 +64,8 @@ The driver also creates
 in the corresponding CPU device's sysctl tree, displaying the maximum
 temperature of the two sensors located in each CPU core.
 .Pp
-For Family 10h, 11h, 12h, 14h, 15h, and 16h processors, the driver reports each
-package's temperature through a sysctl node, named
+For Family 10h, 11h, 12h, 14h, 15h, 16h, and 17h processors, the driver reports
+each package's temperature through a sysctl node, named
 .Va dev.amdtemp.%d.core0.sensor0 .
 The driver also creates
 .Va dev.cpu.%d.temperature
@@ -107,5 +107,5 @@ specified maximum case temperature and maximum thermal
 according to
 .Rs
 .%T BIOS and Kernel Developer's Guide (BKDG) for AMD Processors
-.%U http://developer.amd.com/documentation/guides/Pages/default.aspx
+.%U http://developer.amd.com/resources/developer-guides-manuals/
 .Re

Modified: stable/11/stand/forth/loader.conf
==============================================================================
--- stable/11/stand/forth/loader.conf	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/stand/forth/loader.conf	Thu Feb 22 00:36:12 2018	(r329767)
@@ -533,6 +533,7 @@ coretemp_load="NO"		# Intel Core CPU temperature monit
 vkbd_load="NO"			# Virtual AT keyboard interface
 vpd_load="NO"			# Vital Product Data kernel interface
 vpo_load="NO"			# Parallel to SCSI interface driver
+amdsmn_load="NO"		# AMD Family 17h System Management Network
 amdtemp_load="NO"		# AMD K8/K10/K11 temperature monitor
 tpm_load="NO"			# Trusted Platform Module
 wbwd_load="NO"			# Winbond watchdog

Modified: stable/11/sys/amd64/conf/NOTES
==============================================================================
--- stable/11/sys/amd64/conf/NOTES	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/sys/amd64/conf/NOTES	Thu Feb 22 00:36:12 2018	(r329767)
@@ -599,6 +599,11 @@ device		cpuctl
 options 	ENABLE_ALART		# Control alarm on Intel intpm driver
 
 #
+# AMD System Management Network (SMN)
+#
+device		amdsmn
+
+#
 # Number of initial kernel page table pages used for early bootstrap.
 # This number should include enough pages to map the kernel and any
 # modules or other data loaded with the kernel by the loader.  Each

Modified: stable/11/sys/conf/files.amd64
==============================================================================
--- stable/11/sys/conf/files.amd64	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/sys/conf/files.amd64	Thu Feb 22 00:36:12 2018	(r329767)
@@ -192,6 +192,7 @@ dev/agp/agp_amd64.c		optional	agp
 dev/agp/agp_i810.c		optional	agp
 dev/agp/agp_via.c		optional	agp
 dev/amdsbwd/amdsbwd.c		optional	amdsbwd
+dev/amdsmn/amdsmn.c		optional	amdsmn | amdtemp
 dev/amdtemp/amdtemp.c		optional	amdtemp
 dev/arcmsr/arcmsr.c		optional	arcmsr pci
 dev/asmc/asmc.c			optional	asmc isa

Modified: stable/11/sys/conf/files.i386
==============================================================================
--- stable/11/sys/conf/files.i386	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/sys/conf/files.i386	Thu Feb 22 00:36:12 2018	(r329767)
@@ -175,6 +175,7 @@ dev/agp/agp_sis.c		optional agp
 dev/agp/agp_via.c		optional agp
 dev/aic/aic_isa.c		optional aic isa
 dev/amdsbwd/amdsbwd.c		optional amdsbwd
+dev/amdsmn/amdsmn.c		optional amdsmn | amdtemp
 dev/amdtemp/amdtemp.c		optional amdtemp
 dev/arcmsr/arcmsr.c		optional arcmsr pci
 dev/asmc/asmc.c			optional asmc isa

Modified: stable/11/sys/dev/amdsmn/amdsmn.c
==============================================================================
--- head/sys/dev/amdsmn/amdsmn.c	Tue Sep  5 15:13:41 2017	(r323184)
+++ stable/11/sys/dev/amdsmn/amdsmn.c	Thu Feb 22 00:36:12 2018	(r329767)
@@ -90,24 +90,29 @@ static devclass_t amdsmn_devclass;
 DRIVER_MODULE(amdsmn, hostb, amdsmn_driver, amdsmn_devclass, NULL, NULL);
 MODULE_VERSION(amdsmn, 1);
 
-static void
-amdsmn_identify(driver_t *driver, device_t parent)
+static bool
+amdsmn_match(device_t parent)
 {
-	device_t child;
 	uint32_t devid;
 	size_t i;
 
-	/* Make sure we're not being doubly invoked. */
-	if (device_find_child(parent, "amdsmn", -1) != NULL)
-		return;
-
 	devid = pci_get_devid(parent);
 	for (i = 0; i < nitems(amdsmn_ids); i++)
 		if (amdsmn_ids[i].device_id == devid)
-			break;
+			return (true);
+	return (false);
+}
 
-	if (i >= nitems(amdsmn_ids))
+static void
+amdsmn_identify(driver_t *driver, device_t parent)
+{
+	device_t child;
+
+	/* Make sure we're not being doubly invoked. */
+	if (device_find_child(parent, "amdsmn", -1) != NULL)
 		return;
+	if (!amdsmn_match(parent))
+		return;
 
 	child = device_add_child(parent, "amdsmn", -1);
 	if (child == NULL)
@@ -120,6 +125,8 @@ amdsmn_probe(device_t dev)
 	uint32_t family;
 
 	if (resource_disabled("amdsmn", 0))
+		return (ENXIO);
+	if (!amdsmn_match(device_get_parent(dev)))
 		return (ENXIO);
 
 	family = CPUID_TO_FAMILY(cpu_id);

Modified: stable/11/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- stable/11/sys/dev/amdtemp/amdtemp.c	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/sys/dev/amdtemp/amdtemp.c	Thu Feb 22 00:36:12 2018	(r329767)
@@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
 #include <dev/pci/pcivar.h>
 #include <x86/pci_cfgreg.h>
 
+#include <dev/amdsmn/amdsmn.h>
+
 typedef enum {
 	CORE0_SENSOR0,
 	CORE0_SENSOR1,
@@ -59,7 +61,6 @@ typedef enum {
 } amdsensor_t;
 
 struct amdtemp_softc {
-	device_t	sc_dev;
 	int		sc_ncores;
 	int		sc_ntemps;
 	int		sc_flags;
@@ -70,6 +71,7 @@ struct amdtemp_softc {
 	int32_t		(*sc_gettemp)(device_t, amdsensor_t);
 	struct sysctl_oid *sc_sysctl_cpu[MAXCPU];
 	struct intr_config_hook sc_ich;
+	device_t	sc_smn;
 };
 
 #define	VENDORID_AMD		0x1022
@@ -82,6 +84,7 @@ struct amdtemp_softc {
 #define	DEVICEID_AMD_MISC16	0x1533
 #define	DEVICEID_AMD_MISC16_M30H	0x1583
 #define	DEVICEID_AMD_MISC17	0x141d
+#define	DEVICEID_AMD_HOSTB17H	0x1450
 
 static struct amdtemp_product {
 	uint16_t	amdtemp_vendorid;
@@ -96,6 +99,7 @@ static struct amdtemp_product {
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC16 },
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC16_M30H },
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC17 },
+	{ VENDORID_AMD,	DEVICEID_AMD_HOSTB17H },
 	{ 0, 0 }
 };
 
@@ -105,6 +109,11 @@ static struct amdtemp_product {
 #define	AMDTEMP_REPTMP_CTRL	0xa4
 
 /*
+ * Reported Temperature, Family 17h
+ */
+#define	AMDTEMP_17H_CUR_TMP	0x59800
+
+/*
  * Thermaltrip Status Register (Family 0Fh only)
  */
 #define	AMDTEMP_THERMTP_STAT	0xe4
@@ -133,6 +142,7 @@ static int	amdtemp_detach(device_t dev);
 static int 	amdtemp_match(device_t dev);
 static int32_t	amdtemp_gettemp0f(device_t dev, amdsensor_t sensor);
 static int32_t	amdtemp_gettemp(device_t dev, amdsensor_t sensor);
+static int32_t	amdtemp_gettemp17h(device_t dev, amdsensor_t sensor);
 static int	amdtemp_sysctl(SYSCTL_HANDLER_ARGS);
 
 static device_method_t amdtemp_methods[] = {
@@ -153,6 +163,8 @@ static driver_t amdtemp_driver = {
 
 static devclass_t amdtemp_devclass;
 DRIVER_MODULE(amdtemp, hostb, amdtemp_driver, amdtemp_devclass, NULL, NULL);
+MODULE_VERSION(amdtemp, 1);
+MODULE_DEPEND(amdtemp, amdsmn, 1, 1, 1);
 
 static int
 amdtemp_match(device_t dev)
@@ -195,6 +207,8 @@ amdtemp_probe(device_t dev)
 
 	if (resource_disabled("amdtemp", 0))
 		return (ENXIO);
+	if (!amdtemp_match(device_get_parent(dev)))
+		return (ENXIO);
 
 	family = CPUID_TO_FAMILY(cpu_id);
 	model = CPUID_TO_MODEL(cpu_id);
@@ -211,6 +225,7 @@ amdtemp_probe(device_t dev)
 	case 0x14:
 	case 0x15:
 	case 0x16:
+	case 0x17:
 		break;
 	default:
 		return (ENXIO);
@@ -240,7 +255,7 @@ amdtemp_attach(device_t dev)
 	cpuid = cpu_id;
 	family = CPUID_TO_FAMILY(cpuid);
 	model = CPUID_TO_MODEL(cpuid);
-	if (family != 0x0f || model >= 0x40) {
+	if ((family != 0x0f || model >= 0x40) && family != 0x17) {
 		cpuid = pci_read_config(dev, AMDTEMP_CPUID, 4);
 		family = CPUID_TO_FAMILY(cpuid);
 		model = CPUID_TO_MODEL(cpuid);
@@ -342,6 +357,17 @@ amdtemp_attach(device_t dev)
 
 		sc->sc_gettemp = amdtemp_gettemp;
 		break;
+	case 0x17:
+		sc->sc_ntemps = 1;
+		sc->sc_gettemp = amdtemp_gettemp17h;
+		sc->sc_smn = device_find_child(
+		    device_get_parent(dev), "amdsmn", -1);
+		if (sc->sc_smn == NULL) {
+			if (bootverbose)
+				device_printf(dev, "No SMN device found\n");
+			return (ENXIO);
+		}
+		break;
 	}
 
 	/* Find number of cores per package. */
@@ -552,6 +578,22 @@ amdtemp_gettemp(device_t dev, amdsensor_t sensor)
 	uint32_t temp;
 
 	temp = pci_read_config(dev, AMDTEMP_REPTMP_CTRL, 4);
+	temp = ((temp >> 21) & 0x7ff) * 5 / 4;
+	temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;
+
+	return (temp);
+}
+
+static int32_t
+amdtemp_gettemp17h(device_t dev, amdsensor_t sensor)
+{
+	struct amdtemp_softc *sc = device_get_softc(dev);
+	uint32_t temp;
+	int error;
+
+	error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &temp);
+	KASSERT(error == 0, ("amdsmn_read"));
+
 	temp = ((temp >> 21) & 0x7ff) * 5 / 4;
 	temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;
 

Modified: stable/11/sys/modules/Makefile
==============================================================================
--- stable/11/sys/modules/Makefile	Thu Feb 22 00:09:15 2018	(r329766)
+++ stable/11/sys/modules/Makefile	Thu Feb 22 00:36:12 2018	(r329767)
@@ -36,6 +36,7 @@ SUBDIR=	\
 	alq \
 	${_amd_ecc_inject} \
 	${_amdsbwd} \
+	${_amdsmn} \
 	${_amdtemp} \
 	amr \
 	${_an} \
@@ -631,6 +632,7 @@ _aesni=		aesni
 .endif
 _amd_ecc_inject=amd_ecc_inject
 _amdsbwd=	amdsbwd
+_amdsmn=	amdsmn
 _amdtemp=	amdtemp
 _arcmsr=	arcmsr
 _asmc=		asmc



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802220036.w1M0aCBe011443>