Commit 787a0ba9 authored by David Howells's avatar David Howells Committed by Linus Torvalds

[PATCH] ppc32: openpic driver cpumask_t changes

This fixes the PPC openpic driver to use cpumask_t where appropriate.
Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
Signed-Off-By: default avatarLinus Torvalds <torvalds@osdl.org>
parent 859ffd4f
...@@ -64,14 +64,14 @@ static irqreturn_t openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *); ...@@ -64,14 +64,14 @@ static irqreturn_t openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *);
/* Timer Interrupts */ /* Timer Interrupts */
static void openpic_inittimer(u_int timer, u_int pri, u_int vector); static void openpic_inittimer(u_int timer, u_int pri, u_int vector);
static void openpic_maptimer(u_int timer, u_int cpumask); static void openpic_maptimer(u_int timer, cpumask_t cpumask);
/* Interrupt Sources */ /* Interrupt Sources */
static void openpic_enable_irq(u_int irq); static void openpic_enable_irq(u_int irq);
static void openpic_disable_irq(u_int irq); static void openpic_disable_irq(u_int irq);
static void openpic_initirq(u_int irq, u_int pri, u_int vector, int polarity, static void openpic_initirq(u_int irq, u_int pri, u_int vector, int polarity,
int is_level); int is_level);
static void openpic_mapirq(u_int irq, u_int cpumask, u_int keepmask); static void openpic_mapirq(u_int irq, cpumask_t cpumask, cpumask_t keepmask);
/* /*
* These functions are not used but the code is kept here * These functions are not used but the code is kept here
...@@ -89,17 +89,15 @@ static void openpic_set_sense(u_int irq, int sense); ...@@ -89,17 +89,15 @@ static void openpic_set_sense(u_int irq, int sense);
*/ */
static void openpic_end_irq(unsigned int irq_nr); static void openpic_end_irq(unsigned int irq_nr);
static void openpic_ack_irq(unsigned int irq_nr); static void openpic_ack_irq(unsigned int irq_nr);
static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask); static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask);
struct hw_interrupt_type open_pic = { struct hw_interrupt_type open_pic = {
" OpenPIC ", .typename = " OpenPIC ",
NULL, .enable = openpic_enable_irq,
NULL, .disable = openpic_disable_irq,
openpic_enable_irq, .ack = openpic_ack_irq,
openpic_disable_irq, .end = openpic_end_irq,
openpic_ack_irq, .set_affinity = openpic_set_affinity,
openpic_end_irq,
openpic_set_affinity
}; };
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -109,14 +107,11 @@ static void openpic_enable_ipi(unsigned int irq_nr); ...@@ -109,14 +107,11 @@ static void openpic_enable_ipi(unsigned int irq_nr);
static void openpic_disable_ipi(unsigned int irq_nr); static void openpic_disable_ipi(unsigned int irq_nr);
struct hw_interrupt_type open_pic_ipi = { struct hw_interrupt_type open_pic_ipi = {
" OpenPIC ", .typename = " OpenPIC ",
NULL, .enable = openpic_enable_ipi,
NULL, .disable = openpic_disable_ipi,
openpic_enable_ipi, .ack = openpic_ack_ipi,
openpic_disable_ipi, .end = openpic_end_ipi,
openpic_ack_ipi,
openpic_end_ipi,
0
}; };
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
...@@ -368,7 +363,7 @@ void __init openpic_init(int offset) ...@@ -368,7 +363,7 @@ void __init openpic_init(int offset)
/* Disabled, Priority 0 */ /* Disabled, Priority 0 */
openpic_inittimer(i, 0, OPENPIC_VEC_TIMER+i+offset); openpic_inittimer(i, 0, OPENPIC_VEC_TIMER+i+offset);
/* No processor */ /* No processor */
openpic_maptimer(i, 0); openpic_maptimer(i, CPU_MASK_NONE);
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -408,7 +403,7 @@ void __init openpic_init(int offset) ...@@ -408,7 +403,7 @@ void __init openpic_init(int offset)
openpic_initirq(i, 8, i+offset, (sense & IRQ_POLARITY_MASK), openpic_initirq(i, 8, i+offset, (sense & IRQ_POLARITY_MASK),
(sense & IRQ_SENSE_MASK)); (sense & IRQ_SENSE_MASK));
/* Processor 0 */ /* Processor 0 */
openpic_mapirq(i, 1<<0, 0); openpic_mapirq(i, CPU_MASK_CPU0, CPU_MASK_NONE);
} }
/* Init descriptors */ /* Init descriptors */
...@@ -509,14 +504,17 @@ static void openpic_set_spurious(u_int vec) ...@@ -509,14 +504,17 @@ static void openpic_set_spurious(u_int vec)
/* /*
* Convert a cpu mask from logical to physical cpu numbers. * Convert a cpu mask from logical to physical cpu numbers.
*/ */
static inline u32 physmask(u32 cpumask) static inline cpumask_t physmask(cpumask_t cpumask)
{ {
int i; int i;
u32 mask = 0; cpumask_t mask = CPU_MASK_NONE;
cpus_and(cpumask, cpu_online_map, cpumask);
for (i = 0; i < NR_CPUS; i++)
if (cpu_isset(i, cpumask))
cpu_set(smp_hw_index[i], mask);
for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
if (cpu_online(i))
mask |= (cpumask & 1) << smp_hw_index[i];
return mask; return mask;
} }
#else #else
...@@ -607,12 +605,12 @@ void __devinit do_openpic_setup_cpu(void) ...@@ -607,12 +605,12 @@ void __devinit do_openpic_setup_cpu(void)
{ {
#ifdef CONFIG_IRQ_ALL_CPUS #ifdef CONFIG_IRQ_ALL_CPUS
int i; int i;
u32 msk; cpumask_t msk = CPU_MASK_NONE;
#endif #endif
spin_lock(&openpic_setup_lock); spin_lock(&openpic_setup_lock);
#ifdef CONFIG_IRQ_ALL_CPUS #ifdef CONFIG_IRQ_ALL_CPUS
msk = 1 << smp_hw_index[smp_processor_id()]; cpu_set(smp_hw_index[smp_processor_id()], mask);
/* let the openpic know we want intrs. default affinity /* let the openpic know we want intrs. default affinity
* is 0xffffffff until changed via /proc * is 0xffffffff until changed via /proc
...@@ -621,7 +619,7 @@ void __devinit do_openpic_setup_cpu(void) ...@@ -621,7 +619,7 @@ void __devinit do_openpic_setup_cpu(void)
* in irq.c. * in irq.c.
*/ */
for (i = 0; i < NumSources; i++) for (i = 0; i < NumSources; i++)
openpic_mapirq(i, msk, ~0U); openpic_mapirq(i, msk, CPU_MASK_ALL);
#endif /* CONFIG_IRQ_ALL_CPUS */ #endif /* CONFIG_IRQ_ALL_CPUS */
openpic_set_priority(0); openpic_set_priority(0);
...@@ -649,11 +647,12 @@ static void __init openpic_inittimer(u_int timer, u_int pri, u_int vec) ...@@ -649,11 +647,12 @@ static void __init openpic_inittimer(u_int timer, u_int pri, u_int vec)
/* /*
* Map a timer interrupt to one or more CPUs * Map a timer interrupt to one or more CPUs
*/ */
static void __init openpic_maptimer(u_int timer, u_int cpumask) static void __init openpic_maptimer(u_int timer, cpumask_t cpumask)
{ {
cpumask_t phys = physmask(cpumask);
check_arg_timer(timer); check_arg_timer(timer);
openpic_write(&OpenPIC->Global.Timer[timer].Destination, openpic_write(&OpenPIC->Global.Timer[timer].Destination,
physmask(cpumask)); cpus_addr(phys)[0]);
} }
/* /*
...@@ -770,13 +769,16 @@ openpic_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense) ...@@ -770,13 +769,16 @@ openpic_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense)
/* /*
* Map an interrupt source to one or more CPUs * Map an interrupt source to one or more CPUs
*/ */
static void openpic_mapirq(u_int irq, u_int physmask, u_int keepmask) static void openpic_mapirq(u_int irq, cpumask_t physmask, cpumask_t keepmask)
{ {
if (ISR[irq] == 0) if (ISR[irq] == 0)
return; return;
if (keepmask != 0) if (!cpus_empty(keepmask)) {
physmask |= openpic_read(&ISR[irq]->Destination) & keepmask; cpumask_t irqdest = { .bits[0] = openpic_read(&ISR[irq]->Destination) };
openpic_write(&ISR[irq]->Destination, physmask); cpus_and(irqdest, irqdest, keepmask);
cpus_or(physmask, physmask, irqdest);
}
openpic_write(&ISR[irq]->Destination, cpus_addr(physmask)[0]);
} }
#ifdef notused #ifdef notused
...@@ -820,9 +822,9 @@ static void openpic_end_irq(unsigned int irq_nr) ...@@ -820,9 +822,9 @@ static void openpic_end_irq(unsigned int irq_nr)
#endif #endif
} }
static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask) static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask)
{ {
openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpumask), 0); openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpumask), CPU_MASK_NONE);
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
...@@ -252,6 +252,11 @@ static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits) ...@@ -252,6 +252,11 @@ static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
[0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \ [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
} }) } })
#define CPU_MASK_CPU0 \
((cpumask_t) { { \
[0] = 1UL \
} })
#define cpus_addr(src) ((src).bits) #define cpus_addr(src) ((src).bits)
#define cpumask_scnprintf(buf, len, src) \ #define cpumask_scnprintf(buf, len, src) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment