aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hpet.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2011-10-21 09:44:47 +0200
committerJan Beulich <jbeulich@suse.com>2011-10-21 09:44:47 +0200
commitc567ffce5c30d41e46e6c93b6aacf11ed62989cc (patch)
tree3ce987630ad8d654c46683cdc0b73a0550fcaa25 /xen/arch/x86/hpet.c
parentf5f541c63e606ea3daf05234e8b7fb170ceff1fe (diff)
downloadxen-c567ffce5c30d41e46e6c93b6aacf11ed62989cc.tar.gz
xen-c567ffce5c30d41e46e6c93b6aacf11ed62989cc.tar.bz2
xen-c567ffce5c30d41e46e6c93b6aacf11ed62989cc.zip
x86/hpet: allocate CPU masks dynamically
Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/arch/x86/hpet.c')
-rw-r--r--xen/arch/x86/hpet.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index 2043502374..4c7f7dda4a 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -33,7 +33,7 @@ struct hpet_event_channel
unsigned long mult;
int shift;
s_time_t next_event;
- cpumask_t cpumask;
+ cpumask_var_t cpumask;
spinlock_t lock;
void (*event_handler)(struct hpet_event_channel *);
@@ -182,14 +182,14 @@ again:
now = NOW();
/* find all expired events */
- for_each_cpu_mask(cpu, ch->cpumask)
+ for_each_cpu_mask(cpu, *ch->cpumask)
{
s_time_t deadline;
rmb();
deadline = per_cpu(timer_deadline, cpu);
rmb();
- if ( !cpumask_test_cpu(cpu, &ch->cpumask) )
+ if ( !cpumask_test_cpu(cpu, ch->cpumask) )
continue;
if ( deadline <= now )
@@ -377,6 +377,16 @@ static void __init hpet_fsb_cap_lookup(void)
if ( !(cfg & HPET_TN_FSB_CAP) )
continue;
+ if ( !zalloc_cpumask_var(&ch->cpumask) )
+ {
+ if ( !num_hpets_used )
+ {
+ xfree(hpet_events);
+ hpet_events = NULL;
+ }
+ break;
+ }
+
ch->flags = 0;
ch->idx = i;
@@ -449,14 +459,14 @@ static void hpet_detach_channel(unsigned int cpu,
if ( cpu != ch->cpu )
return;
- if ( cpus_empty(ch->cpumask) )
+ if ( cpumask_empty(ch->cpumask) )
{
ch->cpu = -1;
clear_bit(HPET_EVT_USED_BIT, &ch->flags);
return;
}
- ch->cpu = first_cpu(ch->cpumask);
+ ch->cpu = cpumask_first(ch->cpumask);
hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu));
}
@@ -502,7 +512,14 @@ void __init hpet_broadcast_init(void)
return;
if ( !hpet_events )
+ {
hpet_events = xzalloc(struct hpet_event_channel);
+ if ( hpet_events && !zalloc_cpumask_var(&hpet_events->cpumask) )
+ {
+ xfree(hpet_events);
+ hpet_events = NULL;
+ }
+ }
if ( !hpet_events )
return;
hpet_events->irq = -1;
@@ -635,7 +652,7 @@ void hpet_broadcast_enter(void)
/* Disable LAPIC timer interrupts. */
disable_APIC_timer();
- cpu_set(cpu, ch->cpumask);
+ cpumask_set_cpu(cpu, ch->cpumask);
spin_lock(&ch->lock);
/* reprogram if current cpu expire time is nearer */
@@ -660,7 +677,7 @@ void hpet_broadcast_exit(void)
if ( !reprogram_timer(per_cpu(timer_deadline, cpu)) )
raise_softirq(TIMER_SOFTIRQ);
- cpu_clear(cpu, ch->cpumask);
+ cpumask_clear_cpu(cpu, ch->cpumask);
if ( !(ch->flags & HPET_EVT_LEGACY) )
{