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