Module Name:    src
Committed By:   mlelstv
Date:           Sun Jun 16 09:12:51 UTC 2019

Modified Files:
        src/sys/arch/x86/pci: amdzentemp.c

Log Message:
correct for known temperature bias values.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.8 src/sys/arch/x86/pci/amdzentemp.c:1.9
--- src/sys/arch/x86/pci/amdzentemp.c:1.8	Wed Jul 25 19:10:41 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Sun Jun 16 09:12:51 2019
@@ -1,4 +1,4 @@
-/*      $NetBSD: amdzentemp.c,v 1.8 2018/07/25 19:10:41 para Exp $ */
+/*      $NetBSD: amdzentemp.c,v 1.9 2019/06/16 09:12:51 mlelstv Exp $ */
 /*      $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.8 2018/07/25 19:10:41 para Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9 2019/06/16 09:12:51 mlelstv Exp $ ");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -81,6 +81,7 @@ struct amdzentemp_softc {
 	envsys_data_t *sc_sensor;
 	size_t sc_sensor_len;
         size_t sc_numsensors;
+	int32_t sc_offset;
 };
 
 
@@ -123,7 +124,7 @@ amdzentemp_attach(device_t parent, devic
 	sc->sc_pc = pa->pa_pc;
 	sc->sc_pcitag = pa->pa_tag;
 	sc->sc_smn = parent;
-     
+
 	amdzentemp_family17_init(sc);
 
 	aprint_normal("\n");
@@ -190,7 +191,19 @@ amdzentemp_detach(device_t self, int fla
 static void
 amdzentemp_family17_init(struct amdzentemp_softc *sc) 
 {
+
 	sc->sc_numsensors = 1;
+	sc->sc_offset = 0;
+
+	if (strstr(cpu_brand_string, "AMD Ryzen 5 1600X")
+	    || strstr(cpu_brand_string, "AMD Ryzen 7 1700X")
+	    || strstr(cpu_brand_string, "AMD Ryzen 7 1800X"))
+		sc->sc_offset = -20000000;
+	else if (strstr(cpu_brand_string, "AMD Ryzen 7 2700X"))
+		sc->sc_offset = -10000000;
+	else if (strstr(cpu_brand_string, "AMD Ryzen Threadripper 19")
+	    || strstr(cpu_brand_string, "AMD Ryzen Threadripper 29"))
+		sc->sc_offset = -27000000;
 }
 
 static void
@@ -222,6 +235,7 @@ amdzentemp_family17_refresh(struct sysmo
 	/* adjust for possible offset of 49K */
 	if (temp & 0x80000) 
 		edata->value_cur -= 49000000;
+	edata->value_cur += sc->sc_offset;
 }
 
 MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys,amdsmn");

Reply via email to