Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Apr 2018 18:24:31 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r333026 - head/sys/x86/x86
Message-ID:  <201804261824.w3QIOVl8024974@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Apr 26 18:24:31 2018
New Revision: 333026
URL: https://svnweb.freebsd.org/changeset/base/333026

Log:
  Handle Appolo Lake errata APL31.
  
  If the workaround is activated, always send IPI for wake up, not rely
  on the write to the monitor line.  This fixes Appolo Lake machines
  early hang in sched_bind(), without requiring user to manually select
  idle method.
  
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

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

Modified: head/sys/x86/x86/cpu_machdep.c
==============================================================================
--- head/sys/x86/x86/cpu_machdep.c	Thu Apr 26 18:12:40 2018	(r333025)
+++ head/sys/x86/x86/cpu_machdep.c	Thu Apr 26 18:24:31 2018	(r333026)
@@ -575,6 +575,11 @@ out:
 	    busy, curcpu);
 }
 
+static int cpu_idle_apl31_workaround;
+SYSCTL_INT(_machdep, OID_AUTO, idle_apl31, CTLFLAG_RW,
+    &cpu_idle_apl31_workaround, 0,
+    "Appolo Lake APL31 MWAIT bug workaround");
+
 int
 cpu_idle_wakeup(int cpu)
 {
@@ -586,7 +591,7 @@ cpu_idle_wakeup(int cpu)
 		return (0);
 	case STATE_MWAIT:
 		atomic_store_int(state, STATE_RUNNING);
-		return (1);
+		return (cpu_idle_apl31_workaround ? 0 : 1);
 	case STATE_RUNNING:
 		return (1);
 	default:
@@ -689,6 +694,13 @@ cpu_idle_tun(void *unused __unused)
 
 	if (TUNABLE_STR_FETCH("machdep.idle", tunvar, sizeof(tunvar)))
 		cpu_idle_selector(tunvar);
+	if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_id == 0x506c9) {
+		/*
+		 * Appolo Lake errata APL31.
+		 */
+		cpu_idle_apl31_workaround = 1;
+	}
+	TUNABLE_INT_FETCH("machdep.idle_apl31", &cpu_idle_apl31_workaround);
 }
 SYSINIT(cpu_idle_tun, SI_SUB_CPU, SI_ORDER_MIDDLE, cpu_idle_tun, NULL);
 



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