Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Viresh Kumar and committed by
Thomas Gleixner
955381dd ca53d434

+31 -49
+31 -49
arch/x86/xen/time.c
··· 274 274 return xen_clocksource_read() + delta; 275 275 } 276 276 277 - static void xen_timerop_set_mode(enum clock_event_mode mode, 278 - struct clock_event_device *evt) 277 + static int xen_timerop_shutdown(struct clock_event_device *evt) 279 278 { 280 - switch (mode) { 281 - case CLOCK_EVT_MODE_PERIODIC: 282 - /* unsupported */ 283 - WARN_ON(1); 284 - break; 279 + /* cancel timeout */ 280 + HYPERVISOR_set_timer_op(0); 285 281 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 - } 282 + return 0; 295 283 } 296 284 297 285 static int xen_timerop_set_next_event(unsigned long delta, 298 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 290 if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0) 303 291 BUG(); ··· 298 310 } 299 311 300 312 static const struct clock_event_device xen_timerop_clockevent = { 301 - .name = "xen", 302 - .features = CLOCK_EVT_FEAT_ONESHOT, 313 + .name = "xen", 314 + .features = CLOCK_EVT_FEAT_ONESHOT, 303 315 304 - .max_delta_ns = 0xffffffff, 305 - .min_delta_ns = TIMER_SLOP, 316 + .max_delta_ns = 0xffffffff, 317 + .min_delta_ns = TIMER_SLOP, 306 318 307 - .mult = 1, 308 - .shift = 0, 309 - .rating = 500, 319 + .mult = 1, 320 + .shift = 0, 321 + .rating = 500, 310 322 311 - .set_mode = xen_timerop_set_mode, 312 - .set_next_event = xen_timerop_set_next_event, 323 + .set_state_shutdown = xen_timerop_shutdown, 324 + .set_next_event = xen_timerop_set_next_event, 313 325 }; 314 326 315 - 316 - 317 - static void xen_vcpuop_set_mode(enum clock_event_mode mode, 318 - struct clock_event_device *evt) 327 + static int xen_vcpuop_shutdown(struct clock_event_device *evt) 319 328 { 320 329 int cpu = smp_processor_id(); 321 330 322 - switch (mode) { 323 - case CLOCK_EVT_MODE_PERIODIC: 324 - WARN_ON(1); /* unsupported */ 325 - break; 331 + if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) || 332 + HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 333 + BUG(); 326 334 327 - case CLOCK_EVT_MODE_ONESHOT: 328 - if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 329 - BUG(); 330 - break; 335 + return 0; 336 + } 331 337 332 - case CLOCK_EVT_MODE_UNUSED: 333 - case CLOCK_EVT_MODE_SHUTDOWN: 334 - if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) || 335 - HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 336 - BUG(); 337 - break; 338 - case CLOCK_EVT_MODE_RESUME: 339 - break; 340 - } 338 + static int xen_vcpuop_set_oneshot(struct clock_event_device *evt) 339 + { 340 + int cpu = smp_processor_id(); 341 + 342 + if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 343 + BUG(); 344 + 345 + return 0; 341 346 } 342 347 343 348 static int xen_vcpuop_set_next_event(unsigned long delta, ··· 340 359 struct vcpu_set_singleshot_timer single; 341 360 int ret; 342 361 343 - WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); 362 + WARN_ON(!clockevent_state_oneshot(evt)); 344 363 345 364 single.timeout_abs_ns = get_abs_timeout(delta); 346 365 single.flags = VCPU_SSHOTTMR_future; ··· 363 382 .shift = 0, 364 383 .rating = 500, 365 384 366 - .set_mode = xen_vcpuop_set_mode, 385 + .set_state_shutdown = xen_vcpuop_shutdown, 386 + .set_state_oneshot = xen_vcpuop_set_oneshot, 367 387 .set_next_event = xen_vcpuop_set_next_event, 368 388 }; 369 389