aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-07-16 06:58:48 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-07-30 15:25:38 -0400
commit955381dd65654bd6f066408823691db8fa7d05bb (patch)
tree2c21e38e306e43e440c0e7340b2b893a02791d31
parentca53d434f7e63352c9edd1ad8cde4dfe11da44aa (diff)
x86/xen/time: Migrate to new set-state interface
Migrate xen 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. Callbacks aren't implemented for modes where we weren't doing anything. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Cc: linaro-kernel@lists.linaro.org Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: xen-devel@lists.xenproject.org (moderated list:XEN HYPERVISOR INTERFACE) Link: http://lkml.kernel.org/r/881eea6e1a3d483cd33e044cd34827cce26a57fd.1437042675.git.viresh.kumar@linaro.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/xen/time.c80
1 files changed, 31 insertions, 49 deletions
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 55da33b1d51c..f1ba6a092854 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -274,30 +274,18 @@ static s64 get_abs_timeout(unsigned long delta)
274 return xen_clocksource_read() + delta; 274 return xen_clocksource_read() + delta;
275} 275}
276 276
277static void xen_timerop_set_mode(enum clock_event_mode mode, 277static int xen_timerop_shutdown(struct clock_event_device *evt)
278 struct clock_event_device *evt)
279{ 278{
280 switch (mode) { 279 /* cancel timeout */
281 case CLOCK_EVT_MODE_PERIODIC: 280 HYPERVISOR_set_timer_op(0);
282 /* unsupported */ 281
283 WARN_ON(1); 282 return 0;
284 break;
285
286 case CLOCK_EVT_MODE_ONESHOT:
287 case CLOCK_EVT_MODE_RESUME:
288 break;
289
290 case CLOCK_EVT_MODE_UNUSED:
291 case CLOCK_EVT_MODE_SHUTDOWN:
292 HYPERVISOR_set_timer_op(0); /* cancel timeout */
293 break;
294 }
295} 283}
296 284
297static int xen_timerop_set_next_event(unsigned long delta, 285static int xen_timerop_set_next_event(unsigned long delta,
298 struct clock_event_device *evt) 286 struct clock_event_device *evt)
299{ 287{
300 WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); 288 WARN_ON(!clockevent_state_oneshot(evt));
301 289
302 if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0) 290 if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
303 BUG(); 291 BUG();
@@ -310,46 +298,39 @@ static int xen_timerop_set_next_event(unsigned long delta,
310} 298}
311 299
312static const struct clock_event_device xen_timerop_clockevent = { 300static const struct clock_event_device xen_timerop_clockevent = {
313 .name = "xen", 301 .name = "xen",
314 .features = CLOCK_EVT_FEAT_ONESHOT, 302 .features = CLOCK_EVT_FEAT_ONESHOT,
315 303
316 .max_delta_ns = 0xffffffff, 304 .max_delta_ns = 0xffffffff,
317 .min_delta_ns = TIMER_SLOP, 305 .min_delta_ns = TIMER_SLOP,
318 306
319 .mult = 1, 307 .mult = 1,
320 .shift = 0, 308 .shift = 0,
321 .rating = 500, 309 .rating = 500,
322 310
323 .set_mode = xen_timerop_set_mode, 311 .set_state_shutdown = xen_timerop_shutdown,
324 .set_next_event = xen_timerop_set_next_event, 312 .set_next_event = xen_timerop_set_next_event,
325}; 313};
326 314
315static int xen_vcpuop_shutdown(struct clock_event_device *evt)
316{
317 int cpu = smp_processor_id();
327 318
319 if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
320 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
321 BUG();
322
323 return 0;
324}
328 325
329static void xen_vcpuop_set_mode(enum clock_event_mode mode, 326static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
330 struct clock_event_device *evt)
331{ 327{
332 int cpu = smp_processor_id(); 328 int cpu = smp_processor_id();
333 329
334 switch (mode) { 330 if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
335 case CLOCK_EVT_MODE_PERIODIC: 331 BUG();
336 WARN_ON(1); /* unsupported */
337 break;
338
339 case CLOCK_EVT_MODE_ONESHOT:
340 if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
341 BUG();
342 break;
343 332
344 case CLOCK_EVT_MODE_UNUSED: 333 return 0;
345 case CLOCK_EVT_MODE_SHUTDOWN:
346 if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
347 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
348 BUG();
349 break;
350 case CLOCK_EVT_MODE_RESUME:
351 break;
352 }
353} 334}
354 335
355static int xen_vcpuop_set_next_event(unsigned long delta, 336static int xen_vcpuop_set_next_event(unsigned long delta,
@@ -359,7 +340,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
359 struct vcpu_set_singleshot_timer single; 340 struct vcpu_set_singleshot_timer single;
360 int ret; 341 int ret;
361 342
362 WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); 343 WARN_ON(!clockevent_state_oneshot(evt));
363 344
364 single.timeout_abs_ns = get_abs_timeout(delta); 345 single.timeout_abs_ns = get_abs_timeout(delta);
365 single.flags = VCPU_SSHOTTMR_future; 346 single.flags = VCPU_SSHOTTMR_future;
@@ -382,7 +363,8 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
382 .shift = 0, 363 .shift = 0,
383 .rating = 500, 364 .rating = 500,
384 365
385 .set_mode = xen_vcpuop_set_mode, 366 .set_state_shutdown = xen_vcpuop_shutdown,
367 .set_state_oneshot = xen_vcpuop_set_oneshot,
386 .set_next_event = xen_vcpuop_set_next_event, 368 .set_next_event = xen_vcpuop_set_next_event,
387}; 369};
388 370