From owner-svn-src-all@freebsd.org Mon May 30 09:20:09 2016 Return-Path: Delivered-To: svn-src-all@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 ABC15B540C3; Mon, 30 May 2016 09:20:09 +0000 (UTC) (envelope-from sephe@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 833FC1E77; Mon, 30 May 2016 09:20:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4U9K8Qi000705; Mon, 30 May 2016 09:20:08 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4U9K8iu000702; Mon, 30 May 2016 09:20:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201605300920.u4U9K8iu000702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 30 May 2016 09:20:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300992 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2016 09:20:09 -0000 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 #include -#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 #include -#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;