From owner-svn-src-head@freebsd.org Fri May 27 06:12:44 2016 Return-Path: Delivered-To: svn-src-head@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 BC623B4C897; Fri, 27 May 2016 06:12:44 +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 97E881E96; Fri, 27 May 2016 06:12:44 +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 u4R6ChHp023846; Fri, 27 May 2016 06:12:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4R6Chxh023842; Fri, 27 May 2016 06:12:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201605270612.u4R6Chxh023842@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 27 May 2016 06:12:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300827 - 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-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2016 06:12:44 -0000 Author: sephe Date: Fri May 27 06:12:43 2016 New Revision: 300827 URL: https://svnweb.freebsd.org/changeset/base/300827 Log: hyperv: Move timer related MSRs into hyperv_reg.h And avoid bit fields for event timer. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6566 Modified: head/sys/dev/hyperv/vmbus/hv_et.c head/sys/dev/hyperv/vmbus/hv_hv.c head/sys/dev/hyperv/vmbus/hyperv_reg.h Modified: head/sys/dev/hyperv/vmbus/hv_et.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_et.c Fri May 27 06:05:12 2016 (r300826) +++ head/sys/dev/hyperv/vmbus/hv_et.c Fri May 27 06:12:43 2016 (r300827) @@ -37,12 +37,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_vmbus_priv.h" +#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)HV_VMBUS_TIMER_SINT) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \ + MSR_HV_STIMER_CFG_SINT_MASK) + static struct eventtimer *et; static inline uint64_t @@ -57,18 +62,15 @@ sbintime2tick(sbintime_t time) static int hv_et_start(struct eventtimer *et, sbintime_t firsttime, sbintime_t periodtime) { - union hv_timer_config timer_cfg; - uint64_t current; + uint64_t current, config; - timer_cfg.as_uint64 = 0; - timer_cfg.auto_enable = 1; - timer_cfg.sintx = HV_VMBUS_TIMER_SINT; + config = MSR_HV_STIMER_CFG_AUTOEN | MSR_HV_STIMER0_CFG_SINT; - current = rdmsr(HV_X64_MSR_TIME_REF_COUNT); + current = rdmsr(MSR_HV_TIME_REF_COUNT); current += sbintime2tick(firsttime); - wrmsr(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64); - wrmsr(HV_X64_MSR_STIMER0_COUNT, current); + wrmsr(MSR_HV_STIMER0_CONFIG, config); + wrmsr(MSR_HV_STIMER0_COUNT, current); return (0); } @@ -76,8 +78,8 @@ hv_et_start(struct eventtimer *et, sbint static int hv_et_stop(struct eventtimer *et) { - wrmsr(HV_X64_MSR_STIMER0_CONFIG, 0); - wrmsr(HV_X64_MSR_STIMER0_COUNT, 0); + wrmsr(MSR_HV_STIMER0_CONFIG, 0); + wrmsr(MSR_HV_STIMER0_COUNT, 0); return (0); } Modified: head/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_hv.c Fri May 27 06:05:12 2016 (r300826) +++ head/sys/dev/hyperv/vmbus/hv_hv.c Fri May 27 06:12:43 2016 (r300827) @@ -91,8 +91,7 @@ static struct timecounter hv_timecounter static u_int hv_get_timecount(struct timecounter *tc) { - u_int now = rdmsr(HV_X64_MSR_TIME_REF_COUNT); - return (now); + return rdmsr(MSR_HV_TIME_REF_COUNT); } /** Modified: head/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- head/sys/dev/hyperv/vmbus/hyperv_reg.h Fri May 27 06:05:12 2016 (r300826) +++ head/sys/dev/hyperv/vmbus/hyperv_reg.h Fri May 27 06:12:43 2016 (r300827) @@ -54,6 +54,8 @@ #define MSR_HV_VP_INDEX 0x40000002 +#define MSR_HV_TIME_REF_COUNT 0x40000020 + #define MSR_HV_SCONTROL 0x40000080 #define MSR_HV_SCTRL_ENABLE 0x0001ULL #define MSR_HV_SCTRL_RSVD_MASK 0xfffffffffffffffeULL @@ -77,6 +79,16 @@ #define MSR_HV_SINT_RSVD_MASK (MSR_HV_SINT_RSVD1_MASK | \ MSR_HV_SINT_RSVD2_MASK) +#define MSR_HV_STIMER0_CONFIG 0x400000b0 +#define MSR_HV_STIMER_CFG_ENABLE 0x0001ULL +#define MSR_HV_STIMER_CFG_PERIODIC 0x0002ULL +#define MSR_HV_STIMER_CFG_LAZY 0x0004ULL +#define MSR_HV_STIMER_CFG_AUTOEN 0x0008ULL +#define MSR_HV_STIMER_CFG_SINT_MASK 0x000f0000ULL +#define MSR_HV_STIMER_CFG_SINT_SHIFT 16 + +#define MSR_HV_STIMER0_COUNT 0x400000b1 + /* * CPUID leaves */