Skip to content

Commit

Permalink
xen/time: Free onlined per-cpu data structure if we want to online it…
Browse files Browse the repository at this point in the history
… again.

If the per-cpu time data structure has been onlined already and
we are trying to online it again, then free the previous copy
before blindly over-writting it.

A developer naturally should not call this function multiple times
but just in case.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Konrad Rzeszutek Wilk committed Jun 10, 2013
1 parent a05e2c3 commit 09e99da
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions arch/x86/xen/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ static irqreturn_t xen_timer_interrupt(int irq, void *dev_id)
return ret;
}

void xen_teardown_timer(int cpu)
{
struct clock_event_device *evt;
BUG_ON(cpu == 0);
evt = &per_cpu(xen_clock_events, cpu).evt;

if (evt->irq >= 0) {
unbind_from_irqhandler(evt->irq, NULL);
evt->irq = -1;
kfree(per_cpu(xen_clock_events, cpu).name);
per_cpu(xen_clock_events, cpu).name = NULL;
}
}

void xen_setup_timer(int cpu)
{
char *name;
Expand All @@ -409,6 +423,8 @@ void xen_setup_timer(int cpu)

evt = &per_cpu(xen_clock_events, cpu).evt;
WARN(evt->irq >= 0, "IRQ%d for CPU%d is already allocated\n", evt->irq, cpu);
if (evt->irq >= 0)
xen_teardown_timer(cpu);

printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu);

Expand All @@ -429,19 +445,6 @@ void xen_setup_timer(int cpu)
per_cpu(xen_clock_events, cpu).name = name;
}

void xen_teardown_timer(int cpu)
{
struct clock_event_device *evt;
BUG_ON(cpu == 0);
evt = &per_cpu(xen_clock_events, cpu).evt;

if (evt->irq >= 0) {
unbind_from_irqhandler(evt->irq, NULL);
evt->irq = -1;
kfree(per_cpu(xen_clock_events, cpu).name);
per_cpu(xen_clock_events, cpu).name = NULL;
}
}

void xen_setup_cpu_clockevents(void)
{
Expand Down

0 comments on commit 09e99da

Please sign in to comment.