From owner-svn-src-head@freebsd.org Fri Feb 17 12:47:53 2017 Return-Path: Delivered-To: svn-src-head@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 12CFDCE2019; Fri, 17 Feb 2017 12:47:53 +0000 (UTC) (envelope-from royger@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 B96BB1686; Fri, 17 Feb 2017 12:47:52 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1HClpie006205; Fri, 17 Feb 2017 12:47:51 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1HClp0G006203; Fri, 17 Feb 2017 12:47:51 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201702171247.v1HClp0G006203@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Fri, 17 Feb 2017 12:47:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313871 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Feb 2017 12:47:53 -0000 Author: royger Date: Fri Feb 17 12:47:51 2017 New Revision: 313871 URL: https://svnweb.freebsd.org/changeset/base/313871 Log: x86: fix MTRR initialization if EARLY_AP_STARTUP is used MTRR handlers are set in {amd64/i686}_mem_drvinit, which is called at SI_SUB_DRIVERS, and that's too late when EARLY_AP_STARTUP is set because APs have already started at this point. {amd64/i686}_mrinit is also called too late for the BSP, since that happens when the memory device is attached, also after APs have already started. Move the position to SI_SUB_CPU, and also initialize the state for the BSP, so that the APs can correctly get to the same state as the BSP. Sponsored by: Citrix Systems R&D MFC after: 1 week Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D9630 Modified: head/sys/amd64/amd64/amd64_mem.c head/sys/i386/i386/i686_mem.c Modified: head/sys/amd64/amd64/amd64_mem.c ============================================================================== --- head/sys/amd64/amd64/amd64_mem.c Fri Feb 17 11:31:27 2017 (r313870) +++ head/sys/amd64/amd64/amd64_mem.c Fri Feb 17 12:47:51 2017 (r313871) @@ -609,6 +609,10 @@ amd64_mrinit(struct mem_range_softc *sc) u_int regs[4]; int i, nmdesc = 0, pabits; + if (sc->mr_desc != NULL) + /* Already initialized. */ + return; + mtrrcap = rdmsr(MSR_MTRRcap); mtrrdef = rdmsr(MSR_MTRRdefType); @@ -750,5 +754,6 @@ amd64_mem_drvinit(void *unused) return; } mem_range_softc.mr_op = &amd64_mrops; + amd64_mrinit(&mem_range_softc); } -SYSINIT(amd64memdev, SI_SUB_DRIVERS, SI_ORDER_FIRST, amd64_mem_drvinit, NULL); +SYSINIT(amd64memdev, SI_SUB_CPU, SI_ORDER_ANY, amd64_mem_drvinit, NULL); Modified: head/sys/i386/i386/i686_mem.c ============================================================================== --- head/sys/i386/i386/i686_mem.c Fri Feb 17 11:31:27 2017 (r313870) +++ head/sys/i386/i386/i686_mem.c Fri Feb 17 12:47:51 2017 (r313871) @@ -588,6 +588,10 @@ i686_mrinit(struct mem_range_softc *sc) u_int regs[4]; int i, nmdesc = 0, pabits; + if (sc->mr_desc != NULL) + /* Already initialized. */ + return; + mtrrcap = rdmsr(MSR_MTRRcap); mtrrdef = rdmsr(MSR_MTRRdefType); @@ -716,5 +720,6 @@ i686_mem_drvinit(void *unused) return; } mem_range_softc.mr_op = &i686_mrops; + i686_mrinit(&mem_range_softc); } -SYSINIT(i686memdev, SI_SUB_DRIVERS, SI_ORDER_FIRST, i686_mem_drvinit, NULL); +SYSINIT(i686memdev, SI_SUB_CPU, SI_ORDER_ANY, i686_mem_drvinit, NULL);