From owner-svn-src-all@freebsd.org Sun Mar 5 07:46:50 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D85CCFA7A4; Sun, 5 Mar 2017 07:46:50 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB4561F07; Sun, 5 Mar 2017 07:46:49 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v257knI3040682; Sun, 5 Mar 2017 07:46:49 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v257knU2040681; Sun, 5 Mar 2017 07:46:49 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703050746.v257knU2040681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 5 Mar 2017 07:46:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314700 - head/sys/x86/x86 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Mar 2017 07:46:50 -0000 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();