Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Apr 2016 06:17:57 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r297481 - head/sys/dev/hyperv/vmbus
Message-ID:  <201604010617.u316HvJU013559@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Apr  1 06:17:57 2016
New Revision: 297481
URL: https://svnweb.freebsd.org/changeset/base/297481

Log:
  hyperv: Register Hyper-V timer early enough for TSC freq calibration
  
  The i8254 simulation in Hyper-V is kinda broken and is not available
  in Generation 2 Hyper-V VMs, so Hyper-V timer must be registered early
  enough so that it can be used to do the TSC freq calibration.
  
  This fixes the notorious warning like this:
  calcru: runtime went backwards from 50 usec to 25 usec for pid 0 (kernel)
  
  Submitted by:	Dexuan Cui <decui microsoft com>
  Reviewed by:	kib, sephe
  Tested by:	kib, sephe
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D5778

Modified:
  head/sys/dev/hyperv/vmbus/hv_hv.c

Modified: head/sys/dev/hyperv/vmbus/hv_hv.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_hv.c	Fri Apr  1 03:46:16 2016	(r297480)
+++ head/sys/dev/hyperv/vmbus/hv_hv.c	Fri Apr  1 06:17:57 2016	(r297481)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/pcpu.h>
 #include <sys/timetc.h>
+#include <sys/kernel.h>
 #include <machine/bus.h>
 #include <machine/md_var.h>
 #include <vm/vm.h>
@@ -207,8 +208,6 @@ hv_vmbus_init(void) 
 
 	hv_vmbus_g_context.hypercall_page = virt_addr;
 
-	tc_init(&hv_timecounter); /* register virtual timecount */
-
 	hv_et_init();
 	
 	return (0);
@@ -437,3 +436,14 @@ void hv_vmbus_synic_cleanup(void *arg)
 	wrmsr(HV_X64_MSR_SIEFP, siefp.as_uint64_t);
 }
 
+static void
+hv_tc_init(void)
+{
+	if (vm_guest != VM_GUEST_HV)
+		return;
+
+	/* register virtual timecounter */
+	tc_init(&hv_timecounter);
+}
+
+SYSINIT(hv_tc_init, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hv_tc_init, NULL);



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