Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Mar 2017 07:46:48 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314700 - head/sys/x86/x86
Message-ID:  <201703050746.v257knU2040681@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sun Mar  5 07:46:48 2017
New Revision: 314700
URL: https://svnweb.freebsd.org/changeset/base/314700

Log:
  mca: fix up couple of issues introduced with amd thresholding in r314636
  
  1. There a was a typo in one place where the processor family is
     checked (16 vs 0x16).  Now the checks are consolidated in a single
     function.
  2. Instead of an array of struct amd_et_state objects the code allocated
     an array of pointers.  That was no problem on amd64 where the sizes
     are the same, but could be a problem on i386.
  
  Reported by:	tuexen and others
  Tested by:	tuexen (earlier version of the fix)
  Pointyhat to:	avg
  MFC after:	5 days
  X-MFC with:	r314636

Modified:
  head/sys/x86/x86/mca.c

Modified: head/sys/x86/x86/mca.c
==============================================================================
--- head/sys/x86/x86/mca.c	Sun Mar  5 07:13:29 2017	(r314699)
+++ head/sys/x86/x86/mca.c	Sun Mar  5 07:46:48 2017	(r314700)
@@ -128,6 +128,13 @@ static struct amd_et_state *amd_et_state
 static int cmc_throttle = 60;	/* Time in seconds to throttle CMCI. */
 
 static int amd_elvt = -1;
+
+static inline bool
+amd_thresholding_supported(void)
+{
+	return (cpu_vendor_id == CPU_VENDOR_AMD &&
+	    CPUID_TO_FAMILY(cpu_id) >= 0x10 && CPUID_TO_FAMILY(cpu_id) <= 0x16);
+}
 #endif
 
 static int
@@ -809,7 +816,7 @@ static void
 amd_thresholding_setup(void)
 {
 
-	amd_et_state = malloc((mp_maxid + 1) * sizeof(struct amd_et_state *),
+	amd_et_state = malloc((mp_maxid + 1) * sizeof(struct amd_et_state),
 	    M_MCA, M_WAITOK | M_ZERO);
 	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
 	    "cmc_throttle", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
@@ -854,8 +861,7 @@ mca_setup(uint64_t mcg_cap)
 #ifdef DEV_APIC
 	if (mcg_cap & MCG_CAP_CMCI_P)
 		cmci_setup();
-	else if (cpu_vendor_id == CPU_VENDOR_AMD &&
-	    CPUID_TO_FAMILY(cpu_id) >= 0x10 && CPUID_TO_FAMILY(cpu_id) <= 16)
+	else if (amd_thresholding_supported())
 		amd_thresholding_setup();
 #endif
 }
@@ -1095,9 +1101,7 @@ _mca_init(int boot)
 		 * At the moment only the DRAM Error Threshold Group is
 		 * supported.
 		 */
-		if (cpu_vendor_id == CPU_VENDOR_AMD &&
-		    CPUID_TO_FAMILY(cpu_id) >= 0x10 &&
-		    CPUID_TO_FAMILY(cpu_id) <= 0x16 &&
+		if (amd_thresholding_supported() &&
 		    (mcg_cap & MCG_CAP_COUNT) >= 4) {
 			if (boot)
 				amd_thresholding_init();



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