Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Feb 2017 12:47:51 +0000 (UTC)
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
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
Message-ID:  <201702171247.v1HClp0G006203@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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