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>
This commit is contained in:
Viresh Kumar 2015-07-16 16:28:48 +05:30 committed by Thomas Gleixner
parent ca53d434f7
commit 955381dd65

View File

@ -274,30 +274,18 @@ static s64 get_abs_timeout(unsigned long delta)
return xen_clocksource_read() + delta; return xen_clocksource_read() + delta;
} }
static void xen_timerop_set_mode(enum clock_event_mode mode, static int xen_timerop_shutdown(struct clock_event_device *evt)
struct clock_event_device *evt)
{ {
switch (mode) { /* cancel timeout */
case CLOCK_EVT_MODE_PERIODIC: HYPERVISOR_set_timer_op(0);
/* unsupported */
WARN_ON(1);
break;
case CLOCK_EVT_MODE_ONESHOT: return 0;
case CLOCK_EVT_MODE_RESUME:
break;
case CLOCK_EVT_MODE_UNUSED:
case CLOCK_EVT_MODE_SHUTDOWN:
HYPERVISOR_set_timer_op(0); /* cancel timeout */
break;
}
} }
static int xen_timerop_set_next_event(unsigned long delta, static int xen_timerop_set_next_event(unsigned long delta,
struct clock_event_device *evt) struct clock_event_device *evt)
{ {
WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); WARN_ON(!clockevent_state_oneshot(evt));
if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0) if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
BUG(); BUG();
@ -320,36 +308,29 @@ static const struct clock_event_device xen_timerop_clockevent = {
.shift = 0, .shift = 0,
.rating = 500, .rating = 500,
.set_mode = xen_timerop_set_mode, .set_state_shutdown = xen_timerop_shutdown,
.set_next_event = xen_timerop_set_next_event, .set_next_event = xen_timerop_set_next_event,
}; };
static int xen_vcpuop_shutdown(struct clock_event_device *evt)
static void xen_vcpuop_set_mode(enum clock_event_mode mode,
struct clock_event_device *evt)
{ {
int cpu = smp_processor_id(); int cpu = smp_processor_id();
switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
WARN_ON(1); /* unsupported */
break;
case CLOCK_EVT_MODE_ONESHOT:
if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
BUG();
break;
case CLOCK_EVT_MODE_UNUSED:
case CLOCK_EVT_MODE_SHUTDOWN:
if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) || if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
BUG(); BUG();
break;
case CLOCK_EVT_MODE_RESUME: return 0;
break; }
}
static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
{
int cpu = smp_processor_id();
if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
BUG();
return 0;
} }
static int xen_vcpuop_set_next_event(unsigned long delta, static int xen_vcpuop_set_next_event(unsigned long delta,
@ -359,7 +340,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
struct vcpu_set_singleshot_timer single; struct vcpu_set_singleshot_timer single;
int ret; int ret;
WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT); WARN_ON(!clockevent_state_oneshot(evt));
single.timeout_abs_ns = get_abs_timeout(delta); single.timeout_abs_ns = get_abs_timeout(delta);
single.flags = VCPU_SSHOTTMR_future; single.flags = VCPU_SSHOTTMR_future;
@ -382,7 +363,8 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
.shift = 0, .shift = 0,
.rating = 500, .rating = 500,
.set_mode = xen_vcpuop_set_mode, .set_state_shutdown = xen_vcpuop_shutdown,
.set_state_oneshot = xen_vcpuop_set_oneshot,
.set_next_event = xen_vcpuop_set_next_event, .set_next_event = xen_vcpuop_set_next_event,
}; };