irq_ia64.c 15.7 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * linux/arch/ia64/kernel/irq_ia64.c
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *
 * Copyright (C) 1998-2001 Hewlett-Packard Co
 *	Stephane Eranian <eranian@hpl.hp.com>
 *	David Mosberger-Tang <davidm@hpl.hp.com>
 *
 *  6/10/99: Updated to bring in sync with x86 version to facilitate
 *	     support for SMP and different interrupt controllers.
 *
 * 09/15/00 Goutham Rao <goutham.rao@intel.com> Implemented pci_irq_to_vector
 *                      PCI to vector allocation routine.
 * 04/14/2004 Ashok Raj <ashok.raj@intel.com>
 *						Added CPU Hotplug handling for IPF.
 */

#include <linux/module.h>

#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/kernel_stat.h>
#include <linux/ptrace.h>
#include <linux/random.h>	/* for rand_initialize_irq() */
#include <linux/signal.h>
#include <linux/smp.h>
#include <linux/threads.h>
#include <linux/bitops.h>
31
#include <linux/irq.h>
A
Akinobu Mita 已提交
32
#include <linux/ratelimit.h>
33
#include <linux/acpi.h>
L
Linus Torvalds 已提交
34 35 36 37 38 39 40 41

#include <asm/delay.h>
#include <asm/intrinsics.h>
#include <asm/io.h>
#include <asm/hw_irq.h>
#include <asm/machvec.h>
#include <asm/pgtable.h>
#include <asm/system.h>
42
#include <asm/tlbflush.h>
L
Linus Torvalds 已提交
43 44 45 46 47 48 49

#ifdef CONFIG_PERFMON
# include <asm/perfmon.h>
#endif

#define IRQ_DEBUG	0

50 51 52 53 54 55
#define IRQ_VECTOR_UNASSIGNED	(0)

#define IRQ_UNUSED		(0)
#define IRQ_USED		(1)
#define IRQ_RSVD		(2)

56 57 58 59
/* These can be overridden in platform_irq_init */
int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;

L
Linus Torvalds 已提交
60 61 62 63
/* default base addr of IPI table */
void __iomem *ipi_base_addr = ((void __iomem *)
			       (__IA64_UNCACHED_OFFSET | IA64_IPI_DEFAULT_BASE_ADDR));

64 65
static cpumask_t vector_allocation_domain(int cpu);

L
Linus Torvalds 已提交
66 67 68 69 70 71 72 73 74 75
/*
 * Legacy IRQ to IA-64 vector translation table.
 */
__u8 isa_irq_to_vector_map[16] = {
	/* 8259 IRQ translation, first 16 entries */
	0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
	0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
};
EXPORT_SYMBOL(isa_irq_to_vector_map);

76 77 78
DEFINE_SPINLOCK(vector_lock);

struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
79 80 81 82
	[0 ... NR_IRQS - 1] = {
		.vector = IRQ_VECTOR_UNASSIGNED,
		.domain = CPU_MASK_NONE
	}
83 84 85
};

DEFINE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq) = {
86
	[0 ... IA64_NUM_VECTORS - 1] = -1
87 88
};

89 90
static cpumask_t vector_table[IA64_NUM_VECTORS] = {
	[0 ... IA64_NUM_VECTORS - 1] = CPU_MASK_NONE
91 92
};

93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
static int irq_status[NR_IRQS] = {
	[0 ... NR_IRQS -1] = IRQ_UNUSED
};

int check_irq_used(int irq)
{
	if (irq_status[irq] == IRQ_USED)
		return 1;

	return -1;
}

static inline int find_unassigned_irq(void)
{
	int irq;

	for (irq = IA64_FIRST_DEVICE_VECTOR; irq < NR_IRQS; irq++)
		if (irq_status[irq] == IRQ_UNUSED)
			return irq;
	return -ENOSPC;
}

115
static inline int find_unassigned_vector(cpumask_t domain)
116
{
117
	cpumask_t mask;
118
	int pos, vector;
119 120 121 122

	cpus_and(mask, domain, cpu_online_map);
	if (cpus_empty(mask))
		return -EINVAL;
123

124
	for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) {
125 126
		vector = IA64_FIRST_DEVICE_VECTOR + pos;
		cpus_and(mask, domain, vector_table[vector]);
127 128
		if (!cpus_empty(mask))
			continue;
129
		return vector;
130
	}
131 132 133
	return -ENOSPC;
}

134
static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
135
{
136
	cpumask_t mask;
137
	int cpu;
138
	struct irq_cfg *cfg = &irq_cfg[irq];
139

140 141 142
	BUG_ON((unsigned)irq >= NR_IRQS);
	BUG_ON((unsigned)vector >= IA64_NUM_VECTORS);

143 144 145 146
	cpus_and(mask, domain, cpu_online_map);
	if (cpus_empty(mask))
		return -EINVAL;
	if ((cfg->vector == vector) && cpus_equal(cfg->domain, domain))
147
		return 0;
148
	if (cfg->vector != IRQ_VECTOR_UNASSIGNED)
149
		return -EBUSY;
150
	for_each_cpu_mask(cpu, mask)
151
		per_cpu(vector_irq, cpu)[vector] = irq;
152 153
	cfg->vector = vector;
	cfg->domain = domain;
154
	irq_status[irq] = IRQ_USED;
155
	cpus_or(vector_table[vector], vector_table[vector], domain);
156 157 158
	return 0;
}

159
int bind_irq_vector(int irq, int vector, cpumask_t domain)
160 161 162 163 164
{
	unsigned long flags;
	int ret;

	spin_lock_irqsave(&vector_lock, flags);
165
	ret = __bind_irq_vector(irq, vector, domain);
166 167 168 169
	spin_unlock_irqrestore(&vector_lock, flags);
	return ret;
}

170
static void __clear_irq_vector(int irq)
171
{
172
	int vector, cpu;
173 174 175
	cpumask_t mask;
	cpumask_t domain;
	struct irq_cfg *cfg = &irq_cfg[irq];
176 177

	BUG_ON((unsigned)irq >= NR_IRQS);
178 179 180 181 182
	BUG_ON(cfg->vector == IRQ_VECTOR_UNASSIGNED);
	vector = cfg->vector;
	domain = cfg->domain;
	cpus_and(mask, cfg->domain, cpu_online_map);
	for_each_cpu_mask(cpu, mask)
183
		per_cpu(vector_irq, cpu)[vector] = -1;
184 185
	cfg->vector = IRQ_VECTOR_UNASSIGNED;
	cfg->domain = CPU_MASK_NONE;
186
	irq_status[irq] = IRQ_UNUSED;
187
	cpus_andnot(vector_table[vector], vector_table[vector], domain);
188 189 190 191 192 193 194 195
}

static void clear_irq_vector(int irq)
{
	unsigned long flags;

	spin_lock_irqsave(&vector_lock, flags);
	__clear_irq_vector(irq);
196 197
	spin_unlock_irqrestore(&vector_lock, flags);
}
L
Linus Torvalds 已提交
198 199

int
200
ia64_native_assign_irq_vector (int irq)
L
Linus Torvalds 已提交
201
{
202
	unsigned long flags;
203
	int vector, cpu;
204
	cpumask_t domain = CPU_MASK_NONE;
205 206

	vector = -ENOSPC;
207

208 209 210 211 212 213 214
	spin_lock_irqsave(&vector_lock, flags);
	for_each_online_cpu(cpu) {
		domain = vector_allocation_domain(cpu);
		vector = find_unassigned_vector(domain);
		if (vector >= 0)
			break;
	}
215 216
	if (vector < 0)
		goto out;
217 218
	if (irq == AUTO_ASSIGN)
		irq = vector;
219
	BUG_ON(__bind_irq_vector(irq, vector, domain));
220
 out:
221
	spin_unlock_irqrestore(&vector_lock, flags);
L
Linus Torvalds 已提交
222 223 224 225
	return vector;
}

void
226
ia64_native_free_irq_vector (int vector)
L
Linus Torvalds 已提交
227
{
228 229
	if (vector < IA64_FIRST_DEVICE_VECTOR ||
	    vector > IA64_LAST_DEVICE_VECTOR)
L
Linus Torvalds 已提交
230
		return;
231
	clear_irq_vector(vector);
L
Linus Torvalds 已提交
232 233
}

234 235 236 237 238 239
int
reserve_irq_vector (int vector)
{
	if (vector < IA64_FIRST_DEVICE_VECTOR ||
	    vector > IA64_LAST_DEVICE_VECTOR)
		return -EINVAL;
240
	return !!bind_irq_vector(vector, vector, CPU_MASK_ALL);
241
}
242

243 244 245 246 247 248 249 250 251 252
/*
 * Initialize vector_irq on a new cpu. This function must be called
 * with vector_lock held.
 */
void __setup_vector_irq(int cpu)
{
	int irq, vector;

	/* Clear vector_irq */
	for (vector = 0; vector < IA64_NUM_VECTORS; ++vector)
253
		per_cpu(vector_irq, cpu)[vector] = -1;
254 255
	/* Mark the inuse vectors */
	for (irq = 0; irq < NR_IRQS; ++irq) {
256 257 258 259
		if (!cpu_isset(cpu, irq_cfg[irq].domain))
			continue;
		vector = irq_to_vector(irq);
		per_cpu(vector_irq, cpu)[vector] = irq;
260 261 262
	}
}

263
#if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
264

265 266 267 268 269
static enum vector_domain_type {
	VECTOR_DOMAIN_NONE,
	VECTOR_DOMAIN_PERCPU
} vector_domain_type = VECTOR_DOMAIN_NONE;

270 271
static cpumask_t vector_allocation_domain(int cpu)
{
272 273
	if (vector_domain_type == VECTOR_DOMAIN_PERCPU)
		return cpumask_of_cpu(cpu);
274 275 276
	return CPU_MASK_ALL;
}

277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
static int __irq_prepare_move(int irq, int cpu)
{
	struct irq_cfg *cfg = &irq_cfg[irq];
	int vector;
	cpumask_t domain;

	if (cfg->move_in_progress || cfg->move_cleanup_count)
		return -EBUSY;
	if (cfg->vector == IRQ_VECTOR_UNASSIGNED || !cpu_online(cpu))
		return -EINVAL;
	if (cpu_isset(cpu, cfg->domain))
		return 0;
	domain = vector_allocation_domain(cpu);
	vector = find_unassigned_vector(domain);
	if (vector < 0)
		return -ENOSPC;
	cfg->move_in_progress = 1;
	cfg->old_domain = cfg->domain;
	cfg->vector = IRQ_VECTOR_UNASSIGNED;
	cfg->domain = CPU_MASK_NONE;
	BUG_ON(__bind_irq_vector(irq, vector, domain));
	return 0;
}

int irq_prepare_move(int irq, int cpu)
{
	unsigned long flags;
	int ret;

	spin_lock_irqsave(&vector_lock, flags);
	ret = __irq_prepare_move(irq, cpu);
	spin_unlock_irqrestore(&vector_lock, flags);
	return ret;
}

void irq_complete_move(unsigned irq)
{
	struct irq_cfg *cfg = &irq_cfg[irq];
	cpumask_t cleanup_mask;
	int i;

	if (likely(!cfg->move_in_progress))
		return;

	if (unlikely(cpu_isset(smp_processor_id(), cfg->old_domain)))
		return;

	cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
	cfg->move_cleanup_count = cpus_weight(cleanup_mask);
	for_each_cpu_mask(i, cleanup_mask)
		platform_send_ipi(i, IA64_IRQ_MOVE_VECTOR, IA64_IPI_DM_INT, 0);
	cfg->move_in_progress = 0;
}

static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
{
	int me = smp_processor_id();
	ia64_vector vector;
	unsigned long flags;

	for (vector = IA64_FIRST_DEVICE_VECTOR;
	     vector < IA64_LAST_DEVICE_VECTOR; vector++) {
		int irq;
		struct irq_desc *desc;
		struct irq_cfg *cfg;
		irq = __get_cpu_var(vector_irq)[vector];
		if (irq < 0)
			continue;

346
		desc = irq_to_desc(irq);
347
		cfg = irq_cfg + irq;
348
		raw_spin_lock(&desc->lock);
349 350 351 352 353 354 355 356 357 358 359 360
		if (!cfg->move_cleanup_count)
			goto unlock;

		if (!cpu_isset(me, cfg->old_domain))
			goto unlock;

		spin_lock_irqsave(&vector_lock, flags);
		__get_cpu_var(vector_irq)[vector] = -1;
		cpu_clear(me, vector_table[vector]);
		spin_unlock_irqrestore(&vector_lock, flags);
		cfg->move_cleanup_count--;
	unlock:
361
		raw_spin_unlock(&desc->lock);
362 363 364 365 366 367 368 369 370 371
	}
	return IRQ_HANDLED;
}

static struct irqaction irq_move_irqaction = {
	.handler =	smp_irq_move_cleanup_interrupt,
	.flags =	IRQF_DISABLED,
	.name =		"irq_move"
};

372 373 374 375 376 377 378 379
static int __init parse_vector_domain(char *arg)
{
	if (!arg)
		return -EINVAL;
	if (!strcmp(arg, "percpu")) {
		vector_domain_type = VECTOR_DOMAIN_PERCPU;
		no_int_routing = 1;
	}
380
	return 0;
381 382 383 384 385 386 387 388 389
}
early_param("vector", parse_vector_domain);
#else
static cpumask_t vector_allocation_domain(int cpu)
{
	return CPU_MASK_ALL;
}
#endif

390

391 392
void destroy_and_reserve_irq(unsigned int irq)
{
393 394
	unsigned long flags;

395 396
	dynamic_irq_cleanup(irq);

397 398 399 400
	spin_lock_irqsave(&vector_lock, flags);
	__clear_irq_vector(irq);
	irq_status[irq] = IRQ_RSVD;
	spin_unlock_irqrestore(&vector_lock, flags);
401 402
}

403 404 405 406 407
/*
 * Dynamic irq allocate and deallocation for MSI
 */
int create_irq(void)
{
408
	unsigned long flags;
409
	int irq, vector, cpu;
410
	cpumask_t domain = CPU_MASK_NONE;
411

412
	irq = vector = -ENOSPC;
413
	spin_lock_irqsave(&vector_lock, flags);
414 415 416 417 418 419
	for_each_online_cpu(cpu) {
		domain = vector_allocation_domain(cpu);
		vector = find_unassigned_vector(domain);
		if (vector >= 0)
			break;
	}
420 421 422 423 424
	if (vector < 0)
		goto out;
	irq = find_unassigned_irq();
	if (irq < 0)
		goto out;
425
	BUG_ON(__bind_irq_vector(irq, vector, domain));
426 427 428 429 430
 out:
	spin_unlock_irqrestore(&vector_lock, flags);
	if (irq >= 0)
		dynamic_irq_init(irq);
	return irq;
431 432 433 434 435
}

void destroy_irq(unsigned int irq)
{
	dynamic_irq_cleanup(irq);
436
	clear_irq_vector(irq);
437 438
}

L
Linus Torvalds 已提交
439 440
#ifdef CONFIG_SMP
#	define IS_RESCHEDULE(vec)	(vec == IA64_IPI_RESCHEDULE)
441
#	define IS_LOCAL_TLB_FLUSH(vec)	(vec == IA64_IPI_LOCAL_TLB_FLUSH)
L
Linus Torvalds 已提交
442 443
#else
#	define IS_RESCHEDULE(vec)	(0)
444
#	define IS_LOCAL_TLB_FLUSH(vec)	(0)
L
Linus Torvalds 已提交
445 446 447 448 449 450 451 452 453
#endif
/*
 * That's where the IVT branches when we get an external
 * interrupt. This branches to the correct hardware IRQ handler via
 * function ptr.
 */
void
ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
{
454
	struct pt_regs *old_regs = set_irq_regs(regs);
L
Linus Torvalds 已提交
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
	unsigned long saved_tpr;

#if IRQ_DEBUG
	{
		unsigned long bsp, sp;

		/*
		 * Note: if the interrupt happened while executing in
		 * the context switch routine (ia64_switch_to), we may
		 * get a spurious stack overflow here.  This is
		 * because the register and the memory stack are not
		 * switched atomically.
		 */
		bsp = ia64_getreg(_IA64_REG_AR_BSP);
		sp = ia64_getreg(_IA64_REG_SP);

		if ((sp - bsp) < 1024) {
A
Akinobu Mita 已提交
472
			static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
L
Linus Torvalds 已提交
473

A
Akinobu Mita 已提交
474
			if (__ratelimit(&ratelimit)) {
L
Linus Torvalds 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
				printk("ia64_handle_irq: DANGER: less than "
				       "1KB of free stack space!!\n"
				       "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
			}
		}
	}
#endif /* IRQ_DEBUG */

	/*
	 * Always set TPR to limit maximum interrupt nesting depth to
	 * 16 (without this, it would be ~240, which could easily lead
	 * to kernel stack overflows).
	 */
	irq_enter();
	saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
	ia64_srlz_d();
	while (vector != IA64_SPURIOUS_INT_VECTOR) {
492
		int irq = local_vector_to_irq(vector);
493
		struct irq_desc *desc = irq_to_desc(irq);
494

495 496
		if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
			smp_local_flush_tlb();
497
			kstat_incr_irqs_this_cpu(irq, desc);
498
		} else if (unlikely(IS_RESCHEDULE(vector))) {
499
			kstat_incr_irqs_this_cpu(irq, desc);
500
		} else {
L
Linus Torvalds 已提交
501 502 503
			ia64_setreg(_IA64_REG_CR_TPR, vector);
			ia64_srlz_d();

504 505 506
			if (unlikely(irq < 0)) {
				printk(KERN_ERR "%s: Unexpected interrupt "
				       "vector %d on CPU %d is not mapped "
507
				       "to any IRQ!\n", __func__, vector,
508 509 510
				       smp_processor_id());
			} else
				generic_handle_irq(irq);
L
Linus Torvalds 已提交
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526

			/*
			 * Disable interrupts and send EOI:
			 */
			local_irq_disable();
			ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
		}
		ia64_eoi();
		vector = ia64_get_ivr();
	}
	/*
	 * This must be done *after* the ia64_eoi().  For example, the keyboard softirq
	 * handler needs to be able to wait for further keyboard interrupts, which can't
	 * come through until ia64_eoi() has been done.
	 */
	irq_exit();
527
	set_irq_regs(old_regs);
L
Linus Torvalds 已提交
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
}

#ifdef CONFIG_HOTPLUG_CPU
/*
 * This function emulates a interrupt processing when a cpu is about to be
 * brought down.
 */
void ia64_process_pending_intr(void)
{
	ia64_vector vector;
	unsigned long saved_tpr;
	extern unsigned int vectors_in_migration[NR_IRQS];

	vector = ia64_get_ivr();

543 544 545
	irq_enter();
	saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
	ia64_srlz_d();
L
Linus Torvalds 已提交
546 547 548 549 550

	 /*
	  * Perform normal interrupt style processing
	  */
	while (vector != IA64_SPURIOUS_INT_VECTOR) {
551
		int irq = local_vector_to_irq(vector);
552
		struct irq_desc *desc = irq_to_desc(irq);
553

554 555
		if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
			smp_local_flush_tlb();
556
			kstat_incr_irqs_this_cpu(irq, desc);
557
		} else if (unlikely(IS_RESCHEDULE(vector))) {
558
			kstat_incr_irqs_this_cpu(irq, desc);
559
		} else {
T
Tony Luck 已提交
560 561
			struct pt_regs *old_regs = set_irq_regs(NULL);

L
Linus Torvalds 已提交
562 563 564 565 566 567 568 569 570
			ia64_setreg(_IA64_REG_CR_TPR, vector);
			ia64_srlz_d();

			/*
			 * Now try calling normal ia64_handle_irq as it would have got called
			 * from a real intr handler. Try passing null for pt_regs, hopefully
			 * it will work. I hope it works!.
			 * Probably could shared code.
			 */
571 572 573
			if (unlikely(irq < 0)) {
				printk(KERN_ERR "%s: Unexpected interrupt "
				       "vector %d on CPU %d not being mapped "
574
				       "to any IRQ!!\n", __func__, vector,
575 576 577 578 579
				       smp_processor_id());
			} else {
				vectors_in_migration[irq]=0;
				generic_handle_irq(irq);
			}
T
Tony Luck 已提交
580
			set_irq_regs(old_regs);
L
Linus Torvalds 已提交
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597

			/*
			 * Disable interrupts and send EOI
			 */
			local_irq_disable();
			ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
		}
		ia64_eoi();
		vector = ia64_get_ivr();
	}
	irq_exit();
}
#endif


#ifdef CONFIG_SMP

J
Jack Steiner 已提交
598 599 600 601 602
static irqreturn_t dummy_handler (int irq, void *dev_id)
{
	BUG();
}

L
Linus Torvalds 已提交
603 604
static struct irqaction ipi_irqaction = {
	.handler =	handle_IPI,
605
	.flags =	IRQF_DISABLED,
L
Linus Torvalds 已提交
606 607
	.name =		"IPI"
};
J
Jack Steiner 已提交
608

609 610 611
/*
 * KVM uses this interrupt to force a cpu out of guest mode
 */
J
Jack Steiner 已提交
612 613
static struct irqaction resched_irqaction = {
	.handler =	dummy_handler,
614
	.flags =	IRQF_DISABLED,
J
Jack Steiner 已提交
615 616
	.name =		"resched"
};
617 618 619

static struct irqaction tlb_irqaction = {
	.handler =	dummy_handler,
620
	.flags =	IRQF_DISABLED,
621 622 623
	.name =		"tlb_flush"
};

L
Linus Torvalds 已提交
624 625 626
#endif

void
627
ia64_native_register_percpu_irq (ia64_vector vec, struct irqaction *action)
L
Linus Torvalds 已提交
628 629 630
{
	unsigned int irq;

631
	irq = vec;
632
	BUG_ON(bind_irq_vector(irq, vec, CPU_MASK_ALL));
633
	irq_set_status_flags(irq, IRQ_PER_CPU);
J
Jiri Slaby 已提交
634
	set_irq_chip(irq, &irq_type_ia64_lsapic);
635 636
	if (action)
		setup_irq(irq, action);
637
	set_irq_handler(irq, handle_percpu_irq);
L
Linus Torvalds 已提交
638 639 640
}

void __init
641
ia64_native_register_ipi(void)
L
Linus Torvalds 已提交
642 643 644
{
#ifdef CONFIG_SMP
	register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
J
Jack Steiner 已提交
645
	register_percpu_irq(IA64_IPI_RESCHEDULE, &resched_irqaction);
646
	register_percpu_irq(IA64_IPI_LOCAL_TLB_FLUSH, &tlb_irqaction);
647 648 649 650 651 652
#endif
}

void __init
init_IRQ (void)
{
653 654 655
#ifdef CONFIG_ACPI
	acpi_boot_init();
#endif
656 657 658
	ia64_register_ipi();
	register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
#ifdef CONFIG_SMP
659
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG)
660
	if (vector_domain_type != VECTOR_DOMAIN_NONE)
661 662
		register_percpu_irq(IA64_IRQ_MOVE_VECTOR, &irq_move_irqaction);
#endif
L
Linus Torvalds 已提交
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
#endif
#ifdef CONFIG_PERFMON
	pfm_init_percpu();
#endif
	platform_irq_init();
}

void
ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect)
{
	void __iomem *ipi_addr;
	unsigned long ipi_data;
	unsigned long phys_cpu_id;

	phys_cpu_id = cpu_physical_id(cpu);

	/*
	 * cpu number is in 8bit ID and 8bit EID
	 */

	ipi_data = (delivery_mode << 8) | (vector & 0xff);
	ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));

	writeq(ipi_data, ipi_addr);
}