Deleted Added
full compact
vmbus_et.c (298568) vmbus_et.c (300827)
1/*-
2 * Copyright (c) 2015,2016 Microsoft Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2015,2016 Microsoft Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hv_et.c 298568 2016-04-25 04:58:14Z sephe $");
28__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hv_et.c 300827 2016-05-27 06:12:43Z sephe $");
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/kernel.h>
33#include <sys/module.h>
34#include <sys/proc.h>
35#include <sys/systm.h>
36#include <sys/smp.h>
37#include <sys/time.h>
38#include <sys/timeet.h>
39
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/kernel.h>
33#include <sys/module.h>
34#include <sys/proc.h>
35#include <sys/systm.h>
36#include <sys/smp.h>
37#include <sys/time.h>
38#include <sys/timeet.h>
39
40#include "hv_vmbus_priv.h"
40#include <dev/hyperv/vmbus/hv_vmbus_priv.h>
41#include <dev/hyperv/vmbus/hyperv_reg.h>
41
42#define HV_TIMER_FREQUENCY (10 * 1000 * 1000LL) /* 100ns period */
43#define HV_MAX_DELTA_TICKS 0xffffffffLL
44#define HV_MIN_DELTA_TICKS 1LL
45
42
43#define HV_TIMER_FREQUENCY (10 * 1000 * 1000LL) /* 100ns period */
44#define HV_MAX_DELTA_TICKS 0xffffffffLL
45#define HV_MIN_DELTA_TICKS 1LL
46
47#define MSR_HV_STIMER0_CFG_SINT \
48 ((((uint64_t)HV_VMBUS_TIMER_SINT) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \
49 MSR_HV_STIMER_CFG_SINT_MASK)
50
46static struct eventtimer *et;
47
48static inline uint64_t
49sbintime2tick(sbintime_t time)
50{
51 struct timespec val;
52
53 val = sbttots(time);
54 return val.tv_sec * HV_TIMER_FREQUENCY + val.tv_nsec / 100;
55}
56
57static int
58hv_et_start(struct eventtimer *et, sbintime_t firsttime, sbintime_t periodtime)
59{
51static struct eventtimer *et;
52
53static inline uint64_t
54sbintime2tick(sbintime_t time)
55{
56 struct timespec val;
57
58 val = sbttots(time);
59 return val.tv_sec * HV_TIMER_FREQUENCY + val.tv_nsec / 100;
60}
61
62static int
63hv_et_start(struct eventtimer *et, sbintime_t firsttime, sbintime_t periodtime)
64{
60 union hv_timer_config timer_cfg;
61 uint64_t current;
65 uint64_t current, config;
62
66
63 timer_cfg.as_uint64 = 0;
64 timer_cfg.auto_enable = 1;
65 timer_cfg.sintx = HV_VMBUS_TIMER_SINT;
67 config = MSR_HV_STIMER_CFG_AUTOEN | MSR_HV_STIMER0_CFG_SINT;
66
68
67 current = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
69 current = rdmsr(MSR_HV_TIME_REF_COUNT);
68 current += sbintime2tick(firsttime);
69
70 current += sbintime2tick(firsttime);
71
70 wrmsr(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
71 wrmsr(HV_X64_MSR_STIMER0_COUNT, current);
72 wrmsr(MSR_HV_STIMER0_CONFIG, config);
73 wrmsr(MSR_HV_STIMER0_COUNT, current);
72
73 return (0);
74}
75
76static int
77hv_et_stop(struct eventtimer *et)
78{
74
75 return (0);
76}
77
78static int
79hv_et_stop(struct eventtimer *et)
80{
79 wrmsr(HV_X64_MSR_STIMER0_CONFIG, 0);
80 wrmsr(HV_X64_MSR_STIMER0_COUNT, 0);
81 wrmsr(MSR_HV_STIMER0_CONFIG, 0);
82 wrmsr(MSR_HV_STIMER0_COUNT, 0);
81
82 return (0);
83}
84
85void
86hv_et_intr(struct trapframe *frame)
87{
88 struct trapframe *oldframe;

--- 73 unchanged lines hidden ---
83
84 return (0);
85}
86
87void
88hv_et_intr(struct trapframe *frame)
89{
90 struct trapframe *oldframe;

--- 73 unchanged lines hidden ---