diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-08-05 03:52:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-05 14:44:29 -0400 |
commit | bc609cb47fb2e74654e23cef0a1d4db38b6570a3 (patch) | |
tree | 64cc0d29522eb5d40466bc16d35f50826e51ccaf | |
parent | a5cca686ce0ef4909deaee4ed46dd991e3a9ece4 (diff) |
drivers/hv: Migrate to new 'set-state' interface
Migrate hv driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.
This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: devel@linuxdriverproject.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/hv.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index fd93cfde96d0..c641faf92e60 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c | |||
@@ -274,7 +274,7 @@ static int hv_ce_set_next_event(unsigned long delta, | |||
274 | { | 274 | { |
275 | cycle_t current_tick; | 275 | cycle_t current_tick; |
276 | 276 | ||
277 | WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); | 277 | WARN_ON(!clockevent_state_oneshot(evt)); |
278 | 278 | ||
279 | rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick); | 279 | rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick); |
280 | current_tick += delta; | 280 | current_tick += delta; |
@@ -282,31 +282,24 @@ static int hv_ce_set_next_event(unsigned long delta, | |||
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | static void hv_ce_setmode(enum clock_event_mode mode, | 285 | static int hv_ce_shutdown(struct clock_event_device *evt) |
286 | struct clock_event_device *evt) | 286 | { |
287 | wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0); | ||
288 | wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0); | ||
289 | |||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static int hv_ce_set_oneshot(struct clock_event_device *evt) | ||
287 | { | 294 | { |
288 | union hv_timer_config timer_cfg; | 295 | union hv_timer_config timer_cfg; |
289 | 296 | ||
290 | switch (mode) { | 297 | timer_cfg.enable = 1; |
291 | case CLOCK_EVT_MODE_PERIODIC: | 298 | timer_cfg.auto_enable = 1; |
292 | /* unsupported */ | 299 | timer_cfg.sintx = VMBUS_MESSAGE_SINT; |
293 | break; | 300 | wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64); |
294 | 301 | ||
295 | case CLOCK_EVT_MODE_ONESHOT: | 302 | return 0; |
296 | timer_cfg.enable = 1; | ||
297 | timer_cfg.auto_enable = 1; | ||
298 | timer_cfg.sintx = VMBUS_MESSAGE_SINT; | ||
299 | wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64); | ||
300 | break; | ||
301 | |||
302 | case CLOCK_EVT_MODE_UNUSED: | ||
303 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
304 | wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0); | ||
305 | wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0); | ||
306 | break; | ||
307 | case CLOCK_EVT_MODE_RESUME: | ||
308 | break; | ||
309 | } | ||
310 | } | 303 | } |
311 | 304 | ||
312 | static void hv_init_clockevent_device(struct clock_event_device *dev, int cpu) | 305 | static void hv_init_clockevent_device(struct clock_event_device *dev, int cpu) |
@@ -321,7 +314,8 @@ static void hv_init_clockevent_device(struct clock_event_device *dev, int cpu) | |||
321 | * references to the hv_vmbus module making it impossible to unload. | 314 | * references to the hv_vmbus module making it impossible to unload. |
322 | */ | 315 | */ |
323 | 316 | ||
324 | dev->set_mode = hv_ce_setmode; | 317 | dev->set_state_shutdown = hv_ce_shutdown; |
318 | dev->set_state_oneshot = hv_ce_set_oneshot; | ||
325 | dev->set_next_event = hv_ce_set_next_event; | 319 | dev->set_next_event = hv_ce_set_next_event; |
326 | } | 320 | } |
327 | 321 | ||
@@ -515,8 +509,7 @@ void hv_synic_cleanup(void *arg) | |||
515 | 509 | ||
516 | /* Turn off clockevent device */ | 510 | /* Turn off clockevent device */ |
517 | if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) | 511 | if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) |
518 | hv_ce_setmode(CLOCK_EVT_MODE_SHUTDOWN, | 512 | hv_ce_shutdown(hv_context.clk_evt[cpu]); |
519 | hv_context.clk_evt[cpu]); | ||
520 | 513 | ||
521 | rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); | 514 | rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); |
522 | 515 | ||