irq_ia64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * linux/arch/ia64/kernel/irq_ia64.c
  3. *
  4. * Copyright (C) 1998-2001 Hewlett-Packard Co
  5. * Stephane Eranian <eranian@hpl.hp.com>
  6. * David Mosberger-Tang <davidm@hpl.hp.com>
  7. *
  8. * 6/10/99: Updated to bring in sync with x86 version to facilitate
  9. * support for SMP and different interrupt controllers.
  10. *
  11. * 09/15/00 Goutham Rao <goutham.rao@intel.com> Implemented pci_irq_to_vector
  12. * PCI to vector allocation routine.
  13. * 04/14/2004 Ashok Raj <ashok.raj@intel.com>
  14. * Added CPU Hotplug handling for IPF.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/jiffies.h>
  18. #include <linux/errno.h>
  19. #include <linux/init.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/ioport.h>
  22. #include <linux/kernel_stat.h>
  23. #include <linux/ptrace.h>
  24. #include <linux/random.h> /* for rand_initialize_irq() */
  25. #include <linux/signal.h>
  26. #include <linux/smp.h>
  27. #include <linux/threads.h>
  28. #include <linux/bitops.h>
  29. #include <linux/irq.h>
  30. #include <linux/ratelimit.h>
  31. #include <linux/acpi.h>
  32. #include <linux/sched.h>
  33. #include <asm/delay.h>
  34. #include <asm/intrinsics.h>
  35. #include <asm/io.h>
  36. #include <asm/hw_irq.h>
  37. #include <asm/machvec.h>
  38. #include <asm/pgtable.h>
  39. #include <asm/system.h>
  40. #include <asm/tlbflush.h>
  41. #ifdef CONFIG_PERFMON
  42. # include <asm/perfmon.h>
  43. #endif
  44. #define IRQ_DEBUG 0
  45. #define IRQ_VECTOR_UNASSIGNED (0)
  46. #define IRQ_UNUSED (0)
  47. #define IRQ_USED (1)
  48. #define IRQ_RSVD (2)
  49. /* These can be overridden in platform_irq_init */
  50. int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
  51. int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;
  52. /* default base addr of IPI table */
  53. void __iomem *ipi_base_addr = ((void __iomem *)
  54. (__IA64_UNCACHED_OFFSET | IA64_IPI_DEFAULT_BASE_ADDR));
  55. static cpumask_t vector_allocation_domain(int cpu);
  56. /*
  57. * Legacy IRQ to IA-64 vector translation table.
  58. */
  59. __u8 isa_irq_to_vector_map[16] = {
  60. /* 8259 IRQ translation, first 16 entries */
  61. 0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
  62. 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
  63. };
  64. EXPORT_SYMBOL(isa_irq_to_vector_map);
  65. DEFINE_SPINLOCK(vector_lock);
  66. struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
  67. [0 ... NR_IRQS - 1] = {
  68. .vector = IRQ_VECTOR_UNASSIGNED,
  69. .domain = CPU_MASK_NONE
  70. }
  71. };
  72. DEFINE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq) = {
  73. [0 ... IA64_NUM_VECTORS - 1] = -1
  74. };
  75. static cpumask_t vector_table[IA64_NUM_VECTORS] = {
  76. [0 ... IA64_NUM_VECTORS - 1] = CPU_MASK_NONE
  77. };
  78. static int irq_status[NR_IRQS] = {
  79. [0 ... NR_IRQS -1] = IRQ_UNUSED
  80. };
  81. int check_irq_used(int irq)
  82. {
  83. if (irq_status[irq] == IRQ_USED)
  84. return 1;
  85. return -1;
  86. }
  87. static inline int find_unassigned_irq(void)
  88. {
  89. int irq;
  90. for (irq = IA64_FIRST_DEVICE_VECTOR; irq < NR_IRQS; irq++)
  91. if (irq_status[irq] == IRQ_UNUSED)
  92. return irq;
  93. return -ENOSPC;
  94. }
  95. static inline int find_unassigned_vector(cpumask_t domain)
  96. {
  97. cpumask_t mask;
  98. int pos, vector;
  99. cpus_and(mask, domain, cpu_online_map);
  100. if (cpus_empty(mask))
  101. return -EINVAL;
  102. for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) {
  103. vector = IA64_FIRST_DEVICE_VECTOR + pos;
  104. cpus_and(mask, domain, vector_table[vector]);
  105. if (!cpus_empty(mask))
  106. continue;
  107. return vector;
  108. }
  109. return -ENOSPC;
  110. }
  111. static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
  112. {
  113. cpumask_t mask;
  114. int cpu;
  115. struct irq_cfg *cfg = &irq_cfg[irq];
  116. BUG_ON((unsigned)irq >= NR_IRQS);
  117. BUG_ON((unsigned)vector >= IA64_NUM_VECTORS);
  118. cpus_and(mask, domain, cpu_online_map);
  119. if (cpus_empty(mask))
  120. return -EINVAL;
  121. if ((cfg->vector == vector) && cpus_equal(cfg->domain, domain))
  122. return 0;
  123. if (cfg->vector != IRQ_VECTOR_UNASSIGNED)
  124. return -EBUSY;
  125. for_each_cpu_mask(cpu, mask)
  126. per_cpu(vector_irq, cpu)[vector] = irq;
  127. cfg->vector = vector;
  128. cfg->domain = domain;
  129. irq_status[irq] = IRQ_USED;
  130. cpus_or(vector_table[vector], vector_table[vector], domain);
  131. return 0;
  132. }
  133. int bind_irq_vector(int irq, int vector, cpumask_t domain)
  134. {
  135. unsigned long flags;
  136. int ret;
  137. spin_lock_irqsave(&vector_lock, flags);
  138. ret = __bind_irq_vector(irq, vector, domain);
  139. spin_unlock_irqrestore(&vector_lock, flags);
  140. return ret;
  141. }
  142. static void __clear_irq_vector(int irq)
  143. {
  144. int vector, cpu;
  145. cpumask_t mask;
  146. cpumask_t domain;
  147. struct irq_cfg *cfg = &irq_cfg[irq];
  148. BUG_ON((unsigned)irq >= NR_IRQS);
  149. BUG_ON(cfg->vector == IRQ_VECTOR_UNASSIGNED);
  150. vector = cfg->vector;
  151. domain = cfg->domain;
  152. cpus_and(mask, cfg->domain, cpu_online_map);
  153. for_each_cpu_mask(cpu, mask)
  154. per_cpu(vector_irq, cpu)[vector] = -1;
  155. cfg->vector = IRQ_VECTOR_UNASSIGNED;
  156. cfg->domain = CPU_MASK_NONE;
  157. irq_status[irq] = IRQ_UNUSED;
  158. cpus_andnot(vector_table[vector], vector_table[vector], domain);
  159. }
  160. static void clear_irq_vector(int irq)
  161. {
  162. unsigned long flags;
  163. spin_lock_irqsave(&vector_lock, flags);
  164. __clear_irq_vector(irq);
  165. spin_unlock_irqrestore(&vector_lock, flags);
  166. }
  167. int
  168. ia64_native_assign_irq_vector (int irq)
  169. {
  170. unsigned long flags;
  171. int vector, cpu;
  172. cpumask_t domain = CPU_MASK_NONE;
  173. vector = -ENOSPC;
  174. spin_lock_irqsave(&vector_lock, flags);
  175. for_each_online_cpu(cpu) {
  176. domain = vector_allocation_domain(cpu);
  177. vector = find_unassigned_vector(domain);
  178. if (vector >= 0)
  179. break;
  180. }
  181. if (vector < 0)
  182. goto out;
  183. if (irq == AUTO_ASSIGN)
  184. irq = vector;
  185. BUG_ON(__bind_irq_vector(irq, vector, domain));
  186. out:
  187. spin_unlock_irqrestore(&vector_lock, flags);
  188. return vector;
  189. }
  190. void
  191. ia64_native_free_irq_vector (int vector)
  192. {
  193. if (vector < IA64_FIRST_DEVICE_VECTOR ||
  194. vector > IA64_LAST_DEVICE_VECTOR)
  195. return;
  196. clear_irq_vector(vector);
  197. }
  198. int
  199. reserve_irq_vector (int vector)
  200. {
  201. if (vector < IA64_FIRST_DEVICE_VECTOR ||
  202. vector > IA64_LAST_DEVICE_VECTOR)
  203. return -EINVAL;
  204. return !!bind_irq_vector(vector, vector, CPU_MASK_ALL);
  205. }
  206. /*
  207. * Initialize vector_irq on a new cpu. This function must be called
  208. * with vector_lock held.
  209. */
  210. void __setup_vector_irq(int cpu)
  211. {
  212. int irq, vector;
  213. /* Clear vector_irq */
  214. for (vector = 0; vector < IA64_NUM_VECTORS; ++vector)
  215. per_cpu(vector_irq, cpu)[vector] = -1;
  216. /* Mark the inuse vectors */
  217. for (irq = 0; irq < NR_IRQS; ++irq) {
  218. if (!cpu_isset(cpu, irq_cfg[irq].domain))
  219. continue;
  220. vector = irq_to_vector(irq);
  221. per_cpu(vector_irq, cpu)[vector] = irq;
  222. }
  223. }
  224. #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
  225. static enum vector_domain_type {
  226. VECTOR_DOMAIN_NONE,
  227. VECTOR_DOMAIN_PERCPU
  228. } vector_domain_type = VECTOR_DOMAIN_NONE;
  229. static cpumask_t vector_allocation_domain(int cpu)
  230. {
  231. if (vector_domain_type == VECTOR_DOMAIN_PERCPU)
  232. return cpumask_of_cpu(cpu);
  233. return CPU_MASK_ALL;
  234. }
  235. static int __irq_prepare_move(int irq, int cpu)
  236. {
  237. struct irq_cfg *cfg = &irq_cfg[irq];
  238. int vector;
  239. cpumask_t domain;
  240. if (cfg->move_in_progress || cfg->move_cleanup_count)
  241. return -EBUSY;
  242. if (cfg->vector == IRQ_VECTOR_UNASSIGNED || !cpu_online(cpu))
  243. return -EINVAL;
  244. if (cpu_isset(cpu, cfg->domain))
  245. return 0;
  246. domain = vector_allocation_domain(cpu);
  247. vector = find_unassigned_vector(domain);
  248. if (vector < 0)
  249. return -ENOSPC;
  250. cfg->move_in_progress = 1;
  251. cfg->old_domain = cfg->domain;
  252. cfg->vector = IRQ_VECTOR_UNASSIGNED;
  253. cfg->domain = CPU_MASK_NONE;
  254. BUG_ON(__bind_irq_vector(irq, vector, domain));
  255. return 0;
  256. }
  257. int irq_prepare_move(int irq, int cpu)
  258. {
  259. unsigned long flags;
  260. int ret;
  261. spin_lock_irqsave(&vector_lock, flags);
  262. ret = __irq_prepare_move(irq, cpu);
  263. spin_unlock_irqrestore(&vector_lock, flags);
  264. return ret;
  265. }
  266. void irq_complete_move(unsigned irq)
  267. {
  268. struct irq_cfg *cfg = &irq_cfg[irq];
  269. cpumask_t cleanup_mask;
  270. int i;
  271. if (likely(!cfg->move_in_progress))
  272. return;
  273. if (unlikely(cpu_isset(smp_processor_id(), cfg->old_domain)))
  274. return;
  275. cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
  276. cfg->move_cleanup_count = cpus_weight(cleanup_mask);
  277. for_each_cpu_mask(i, cleanup_mask)
  278. platform_send_ipi(i, IA64_IRQ_MOVE_VECTOR, IA64_IPI_DM_INT, 0);
  279. cfg->move_in_progress = 0;
  280. }
  281. static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
  282. {
  283. int me = smp_processor_id();
  284. ia64_vector vector;
  285. unsigned long flags;
  286. for (vector = IA64_FIRST_DEVICE_VECTOR;
  287. vector < IA64_LAST_DEVICE_VECTOR; vector++) {
  288. int irq;
  289. struct irq_desc *desc;
  290. struct irq_cfg *cfg;
  291. irq = __get_cpu_var(vector_irq)[vector];
  292. if (irq < 0)
  293. continue;
  294. desc = irq_to_desc(irq);
  295. cfg = irq_cfg + irq;
  296. raw_spin_lock(&desc->lock);
  297. if (!cfg->move_cleanup_count)
  298. goto unlock;
  299. if (!cpu_isset(me, cfg->old_domain))
  300. goto unlock;
  301. spin_lock_irqsave(&vector_lock, flags);
  302. __get_cpu_var(vector_irq)[vector] = -1;
  303. cpu_clear(me, vector_table[vector]);
  304. spin_unlock_irqrestore(&vector_lock, flags);
  305. cfg->move_cleanup_count--;
  306. unlock:
  307. raw_spin_unlock(&desc->lock);
  308. }
  309. return IRQ_HANDLED;
  310. }
  311. static struct irqaction irq_move_irqaction = {
  312. .handler = smp_irq_move_cleanup_interrupt,
  313. .flags = IRQF_DISABLED,
  314. .name = "irq_move"
  315. };
  316. static int __init parse_vector_domain(char *arg)
  317. {
  318. if (!arg)
  319. return -EINVAL;
  320. if (!strcmp(arg, "percpu")) {
  321. vector_domain_type = VECTOR_DOMAIN_PERCPU;
  322. no_int_routing = 1;
  323. }
  324. return 0;
  325. }
  326. early_param("vector", parse_vector_domain);
  327. #else
  328. static cpumask_t vector_allocation_domain(int cpu)
  329. {
  330. return CPU_MASK_ALL;
  331. }
  332. #endif
  333. void destroy_and_reserve_irq(unsigned int irq)
  334. {
  335. unsigned long flags;
  336. dynamic_irq_cleanup(irq);
  337. spin_lock_irqsave(&vector_lock, flags);
  338. __clear_irq_vector(irq);
  339. irq_status[irq] = IRQ_RSVD;
  340. spin_unlock_irqrestore(&vector_lock, flags);
  341. }
  342. /*
  343. * Dynamic irq allocate and deallocation for MSI
  344. */
  345. int create_irq(void)
  346. {
  347. unsigned long flags;
  348. int irq, vector, cpu;
  349. cpumask_t domain = CPU_MASK_NONE;
  350. irq = vector = -ENOSPC;
  351. spin_lock_irqsave(&vector_lock, flags);
  352. for_each_online_cpu(cpu) {
  353. domain = vector_allocation_domain(cpu);
  354. vector = find_unassigned_vector(domain);
  355. if (vector >= 0)
  356. break;
  357. }
  358. if (vector < 0)
  359. goto out;
  360. irq = find_unassigned_irq();
  361. if (irq < 0)
  362. goto out;
  363. BUG_ON(__bind_irq_vector(irq, vector, domain));
  364. out:
  365. spin_unlock_irqrestore(&vector_lock, flags);
  366. if (irq >= 0)
  367. dynamic_irq_init(irq);
  368. return irq;
  369. }
  370. void destroy_irq(unsigned int irq)
  371. {
  372. dynamic_irq_cleanup(irq);
  373. clear_irq_vector(irq);
  374. }
  375. #ifdef CONFIG_SMP
  376. # define IS_RESCHEDULE(vec) (vec == IA64_IPI_RESCHEDULE)
  377. # define IS_LOCAL_TLB_FLUSH(vec) (vec == IA64_IPI_LOCAL_TLB_FLUSH)
  378. #else
  379. # define IS_RESCHEDULE(vec) (0)
  380. # define IS_LOCAL_TLB_FLUSH(vec) (0)
  381. #endif
  382. /*
  383. * That's where the IVT branches when we get an external
  384. * interrupt. This branches to the correct hardware IRQ handler via
  385. * function ptr.
  386. */
  387. void
  388. ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
  389. {
  390. struct pt_regs *old_regs = set_irq_regs(regs);
  391. unsigned long saved_tpr;
  392. #if IRQ_DEBUG
  393. {
  394. unsigned long bsp, sp;
  395. /*
  396. * Note: if the interrupt happened while executing in
  397. * the context switch routine (ia64_switch_to), we may
  398. * get a spurious stack overflow here. This is
  399. * because the register and the memory stack are not
  400. * switched atomically.
  401. */
  402. bsp = ia64_getreg(_IA64_REG_AR_BSP);
  403. sp = ia64_getreg(_IA64_REG_SP);
  404. if ((sp - bsp) < 1024) {
  405. static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
  406. if (__ratelimit(&ratelimit)) {
  407. printk("ia64_handle_irq: DANGER: less than "
  408. "1KB of free stack space!!\n"
  409. "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
  410. }
  411. }
  412. }
  413. #endif /* IRQ_DEBUG */
  414. /*
  415. * Always set TPR to limit maximum interrupt nesting depth to
  416. * 16 (without this, it would be ~240, which could easily lead
  417. * to kernel stack overflows).
  418. */
  419. irq_enter();
  420. saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
  421. ia64_srlz_d();
  422. while (vector != IA64_SPURIOUS_INT_VECTOR) {
  423. int irq = local_vector_to_irq(vector);
  424. struct irq_desc *desc = irq_to_desc(irq);
  425. if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
  426. smp_local_flush_tlb();
  427. kstat_incr_irqs_this_cpu(irq, desc);
  428. } else if (unlikely(IS_RESCHEDULE(vector))) {
  429. scheduler_ipi();
  430. kstat_incr_irqs_this_cpu(irq, desc);
  431. } else {
  432. ia64_setreg(_IA64_REG_CR_TPR, vector);
  433. ia64_srlz_d();
  434. if (unlikely(irq < 0)) {
  435. printk(KERN_ERR "%s: Unexpected interrupt "
  436. "vector %d on CPU %d is not mapped "
  437. "to any IRQ!\n", __func__, vector,
  438. smp_processor_id());
  439. } else
  440. generic_handle_irq(irq);
  441. /*
  442. * Disable interrupts and send EOI:
  443. */
  444. local_irq_disable();
  445. ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
  446. }
  447. ia64_eoi();
  448. vector = ia64_get_ivr();
  449. }
  450. /*
  451. * This must be done *after* the ia64_eoi(). For example, the keyboard softirq
  452. * handler needs to be able to wait for further keyboard interrupts, which can't
  453. * come through until ia64_eoi() has been done.
  454. */
  455. irq_exit();
  456. set_irq_regs(old_regs);
  457. }
  458. #ifdef CONFIG_HOTPLUG_CPU
  459. /*
  460. * This function emulates a interrupt processing when a cpu is about to be
  461. * brought down.
  462. */
  463. void ia64_process_pending_intr(void)
  464. {
  465. ia64_vector vector;
  466. unsigned long saved_tpr;
  467. extern unsigned int vectors_in_migration[NR_IRQS];
  468. vector = ia64_get_ivr();
  469. irq_enter();
  470. saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
  471. ia64_srlz_d();
  472. /*
  473. * Perform normal interrupt style processing
  474. */
  475. while (vector != IA64_SPURIOUS_INT_VECTOR) {
  476. int irq = local_vector_to_irq(vector);
  477. struct irq_desc *desc = irq_to_desc(irq);
  478. if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
  479. smp_local_flush_tlb();
  480. kstat_incr_irqs_this_cpu(irq, desc);
  481. } else if (unlikely(IS_RESCHEDULE(vector))) {
  482. kstat_incr_irqs_this_cpu(irq, desc);
  483. } else {
  484. struct pt_regs *old_regs = set_irq_regs(NULL);
  485. ia64_setreg(_IA64_REG_CR_TPR, vector);
  486. ia64_srlz_d();
  487. /*
  488. * Now try calling normal ia64_handle_irq as it would have got called
  489. * from a real intr handler. Try passing null for pt_regs, hopefully
  490. * it will work. I hope it works!.
  491. * Probably could shared code.
  492. */
  493. if (unlikely(irq < 0)) {
  494. printk(KERN_ERR "%s: Unexpected interrupt "
  495. "vector %d on CPU %d not being mapped "
  496. "to any IRQ!!\n", __func__, vector,
  497. smp_processor_id());
  498. } else {
  499. vectors_in_migration[irq]=0;
  500. generic_handle_irq(irq);
  501. }
  502. set_irq_regs(old_regs);
  503. /*
  504. * Disable interrupts and send EOI
  505. */
  506. local_irq_disable();
  507. ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
  508. }
  509. ia64_eoi();
  510. vector = ia64_get_ivr();
  511. }
  512. irq_exit();
  513. }
  514. #endif
  515. #ifdef CONFIG_SMP
  516. static irqreturn_t dummy_handler (int irq, void *dev_id)
  517. {
  518. BUG();
  519. }
  520. static struct irqaction ipi_irqaction = {
  521. .handler = handle_IPI,
  522. .flags = IRQF_DISABLED,
  523. .name = "IPI"
  524. };
  525. /*
  526. * KVM uses this interrupt to force a cpu out of guest mode
  527. */
  528. static struct irqaction resched_irqaction = {
  529. .handler = dummy_handler,
  530. .flags = IRQF_DISABLED,
  531. .name = "resched"
  532. };
  533. static struct irqaction tlb_irqaction = {
  534. .handler = dummy_handler,
  535. .flags = IRQF_DISABLED,
  536. .name = "tlb_flush"
  537. };
  538. #endif
  539. void
  540. ia64_native_register_percpu_irq (ia64_vector vec, struct irqaction *action)
  541. {
  542. unsigned int irq;
  543. irq = vec;
  544. BUG_ON(bind_irq_vector(irq, vec, CPU_MASK_ALL));
  545. irq_set_status_flags(irq, IRQ_PER_CPU);
  546. irq_set_chip(irq, &irq_type_ia64_lsapic);
  547. if (action)
  548. setup_irq(irq, action);
  549. irq_set_handler(irq, handle_percpu_irq);
  550. }
  551. void __init
  552. ia64_native_register_ipi(void)
  553. {
  554. #ifdef CONFIG_SMP
  555. register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
  556. register_percpu_irq(IA64_IPI_RESCHEDULE, &resched_irqaction);
  557. register_percpu_irq(IA64_IPI_LOCAL_TLB_FLUSH, &tlb_irqaction);
  558. #endif
  559. }
  560. void __init
  561. init_IRQ (void)
  562. {
  563. #ifdef CONFIG_ACPI
  564. acpi_boot_init();
  565. #endif
  566. ia64_register_ipi();
  567. register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
  568. #ifdef CONFIG_SMP
  569. #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG)
  570. if (vector_domain_type != VECTOR_DOMAIN_NONE)
  571. register_percpu_irq(IA64_IRQ_MOVE_VECTOR, &irq_move_irqaction);
  572. #endif
  573. #endif
  574. #ifdef CONFIG_PERFMON
  575. pfm_init_percpu();
  576. #endif
  577. platform_irq_init();
  578. }
  579. void
  580. ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect)
  581. {
  582. void __iomem *ipi_addr;
  583. unsigned long ipi_data;
  584. unsigned long phys_cpu_id;
  585. phys_cpu_id = cpu_physical_id(cpu);
  586. /*
  587. * cpu number is in 8bit ID and 8bit EID
  588. */
  589. ipi_data = (delivery_mode << 8) | (vector & 0xff);
  590. ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
  591. writeq(ipi_data, ipi_addr);
  592. }