Date: Mon, 30 May 2016 09:20:08 +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: r300992 - head/sys/dev/hyperv/vmbus Message-ID: <201605300920.u4U9K8iu000702@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sephe Date: Mon May 30 09:20:08 2016 New Revision: 300992 URL: https://svnweb.freebsd.org/changeset/base/300992 Log: hyperv: Move timer frequency definition to common place. And cleanup event timer period settings. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6597 Modified: head/sys/dev/hyperv/vmbus/hv_et.c head/sys/dev/hyperv/vmbus/hv_hv.c head/sys/dev/hyperv/vmbus/hyperv_var.h Modified: head/sys/dev/hyperv/vmbus/hv_et.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_et.c Mon May 30 09:18:12 2016 (r300991) +++ head/sys/dev/hyperv/vmbus/hv_et.c Mon May 30 09:20:08 2016 (r300992) @@ -41,10 +41,6 @@ __FBSDID("$FreeBSD$"); #include <dev/hyperv/vmbus/hyperv_var.h> #include <dev/hyperv/vmbus/vmbus_var.h> -#define HV_TIMER_FREQUENCY (10 * 1000 * 1000LL) /* 100ns period */ -#define HV_MAX_DELTA_TICKS 0xffffffffLL -#define HV_MIN_DELTA_TICKS 1LL - #define MSR_HV_STIMER0_CFG_SINT \ ((((uint64_t)VMBUS_SINT_TIMER) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \ MSR_HV_STIMER_CFG_SINT_MASK) @@ -67,7 +63,8 @@ sbintime2tick(sbintime_t time) struct timespec val; val = sbttots(time); - return (val.tv_sec * HV_TIMER_FREQUENCY) + (val.tv_nsec / 100); + return (val.tv_sec * HYPERV_TIMER_FREQ) + + (val.tv_nsec / HYPERV_TIMER_NS_FACTOR); } static int @@ -151,11 +148,9 @@ hv_et_attach(device_t dev) vmbus_et.et_name = "Hyper-V"; vmbus_et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERCPU; vmbus_et.et_quality = 1000; - vmbus_et.et_frequency = HV_TIMER_FREQUENCY; - vmbus_et.et_min_period = - HV_MIN_DELTA_TICKS * ((1LL << 32) / HV_TIMER_FREQUENCY); - vmbus_et.et_max_period = - HV_MAX_DELTA_TICKS * ((1LL << 32) / HV_TIMER_FREQUENCY); + vmbus_et.et_frequency = HYPERV_TIMER_FREQ; + vmbus_et.et_min_period = (0x00000001ULL << 32) / HYPERV_TIMER_FREQ; + vmbus_et.et_max_period = (0xfffffffeULL << 32) / HYPERV_TIMER_FREQ; vmbus_et.et_start = hv_et_start; /* Modified: head/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_hv.c Mon May 30 09:18:12 2016 (r300991) +++ head/sys/dev/hyperv/vmbus/hv_hv.c Mon May 30 09:20:08 2016 (r300992) @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$"); #include <dev/hyperv/vmbus/hyperv_var.h> #include <dev/hyperv/vmbus/vmbus_var.h> -#define HV_NANOSECONDS_PER_SEC 1000000000L - #define HYPERV_FREEBSD_BUILD 0ULL #define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version) #define HYPERV_FREEBSD_OSID 0ULL @@ -87,7 +85,7 @@ static struct timecounter hyperv_timecou .tc_get_timecount = hyperv_get_timecount, .tc_poll_pps = NULL, .tc_counter_mask = 0xffffffff, - .tc_frequency = HV_NANOSECONDS_PER_SEC/100, + .tc_frequency = HYPERV_TIMER_FREQ, .tc_name = "Hyper-V", .tc_quality = 2000, .tc_flags = 0, Modified: head/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- head/sys/dev/hyperv/vmbus/hyperv_var.h Mon May 30 09:18:12 2016 (r300991) +++ head/sys/dev/hyperv/vmbus/hyperv_var.h Mon May 30 09:20:08 2016 (r300992) @@ -29,6 +29,12 @@ #ifndef _HYPERV_VAR_H_ #define _HYPERV_VAR_H_ +#ifndef NANOSEC +#define NANOSEC 1000000000ULL +#endif +#define HYPERV_TIMER_NS_FACTOR 100ULL +#define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) + extern u_int hyperv_features; extern u_int hyperv_recommends;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605300920.u4U9K8iu000702>