17 #include <linux/module.h>
20 #include <linux/errno.h>
25 #include <linux/ptrace.h>
26 #include <linux/signal.h>
29 #include <linux/bitops.h>
33 #include <linux/sched.h>
35 #include <asm/delay.h>
36 #include <asm/intrinsics.h>
38 #include <asm/hw_irq.h>
39 #include <asm/machvec.h>
40 #include <asm/pgtable.h>
41 #include <asm/tlbflush.h>
44 # include <asm/perfmon.h>
49 #define IRQ_VECTOR_UNASSIGNED (0)
51 #define IRQ_UNUSED (0)
70 0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
71 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
92 static int irq_status[
NR_IRQS] = {
104 static inline int find_unassigned_irq(
void)
119 cpumask_and(&mask, &domain, cpu_online_mask);
125 cpus_and(mask, domain, vector_table[vector]);
133 static int __bind_irq_vector(
int irq,
int vector,
cpumask_t domain)
139 BUG_ON((
unsigned)irq >= NR_IRQS);
142 cpumask_and(&mask, &domain, cpu_online_mask);
150 per_cpu(vector_irq, cpu)[vector] = irq;
151 cfg->vector = vector;
152 cfg->domain = domain;
154 cpus_or(vector_table[vector], vector_table[vector], domain);
164 ret = __bind_irq_vector(irq, vector, domain);
169 static void __clear_irq_vector(
int irq)
176 BUG_ON((
unsigned)irq >= NR_IRQS);
180 cpumask_and(&mask, &cfg->
domain, cpu_online_mask);
182 per_cpu(vector_irq, cpu)[vector] = -1;
186 cpus_andnot(vector_table[vector], vector_table[vector], domain);
189 static
void clear_irq_vector(
int irq)
194 __clear_irq_vector(irq);
195 spin_unlock_irqrestore(&vector_lock, flags);
209 domain = vector_allocation_domain(cpu);
210 vector = find_unassigned_vector(domain);
218 BUG_ON(__bind_irq_vector(irq, vector, domain));
230 clear_irq_vector(vector);
254 for (irq = 0; irq <
NR_IRQS; ++irq) {
257 vector = irq_to_vector(irq);
262 #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
264 static enum vector_domain_type {
267 } vector_domain_type = VECTOR_DOMAIN_NONE;
269 static cpumask_t vector_allocation_domain(
int cpu)
271 if (vector_domain_type == VECTOR_DOMAIN_PERCPU)
276 static int __irq_prepare_move(
int irq,
int cpu)
288 domain = vector_allocation_domain(cpu);
289 vector = find_unassigned_vector(domain);
296 BUG_ON(__bind_irq_vector(irq, vector, domain));
300 int irq_prepare_move(
int irq,
int cpu)
306 ret = __irq_prepare_move(irq, cpu);
307 spin_unlock_irqrestore(&vector_lock, flags);
311 void irq_complete_move(
unsigned irq)
323 cpumask_and(&cleanup_mask, &cfg->
old_domain, cpu_online_mask);
357 spin_unlock_irqrestore(&vector_lock, flags);
365 static struct irqaction irq_move_irqaction = {
366 .
handler = smp_irq_move_cleanup_interrupt,
371 static int __init parse_vector_domain(
char *
arg)
375 if (!
strcmp(arg,
"percpu")) {
376 vector_domain_type = VECTOR_DOMAIN_PERCPU;
383 static cpumask_t vector_allocation_domain(
int cpu)
397 __clear_irq_vector(irq);
414 domain = vector_allocation_domain(cpu);
415 vector = find_unassigned_vector(domain);
421 irq = find_unassigned_irq();
424 BUG_ON(__bind_irq_vector(irq, vector, domain));
428 dynamic_irq_init(irq);
435 clear_irq_vector(irq);
439 # define IS_RESCHEDULE(vec) (vec == IA64_IPI_RESCHEDULE)
440 # define IS_LOCAL_TLB_FLUSH(vec) (vec == IA64_IPI_LOCAL_TLB_FLUSH)
442 # define IS_RESCHEDULE(vec) (0)
443 # define IS_LOCAL_TLB_FLUSH(vec) (0)
453 struct pt_regs *old_regs = set_irq_regs(regs);
454 unsigned long saved_tpr;
458 unsigned long bsp,
sp;
470 if ((sp - bsp) < 1024) {
474 printk(
"ia64_handle_irq: DANGER: less than "
475 "1KB of free stack space!!\n"
476 "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
491 int irq = local_vector_to_irq(vector);
496 kstat_incr_irqs_this_cpu(irq, desc);
499 kstat_incr_irqs_this_cpu(irq, desc);
506 "vector %d on CPU %d is not mapped "
507 "to any IRQ!\n", __func__, vector,
519 vector = ia64_get_ivr();
527 set_irq_regs(old_regs);
530 #ifdef CONFIG_HOTPLUG_CPU
535 void ia64_process_pending_intr(
void)
538 unsigned long saved_tpr;
539 extern unsigned int vectors_in_migration[
NR_IRQS];
541 vector = ia64_get_ivr();
551 int irq = local_vector_to_irq(vector);
556 kstat_incr_irqs_this_cpu(irq, desc);
558 kstat_incr_irqs_this_cpu(irq, desc);
573 "vector %d on CPU %d not being mapped "
574 "to any IRQ!!\n", __func__, vector,
577 vectors_in_migration[irq]=0;
580 set_irq_regs(old_regs);
589 vector = ia64_get_ivr();
603 static struct irqaction ipi_irqaction = {
612 static struct irqaction resched_irqaction = {
618 static struct irqaction tlb_irqaction = {
659 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG)
660 if (vector_domain_type != VECTOR_DOMAIN_NONE)
664 #ifdef CONFIG_PERFMON
675 unsigned long phys_cpu_id;
683 ipi_data = (delivery_mode << 8) | (vector & 0xff);
684 ipi_addr =
ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
686 writeq(ipi_data, ipi_addr);