irq_ia64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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 <asm/delay.h>
  31. #include <asm/intrinsics.h>
  32. #include <asm/io.h>
  33. #include <asm/hw_irq.h>
  34. #include <asm/machvec.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/system.h>
  37. #include <asm/tlbflush.h>
  38. #ifdef CONFIG_PERFMON
  39. # include <asm/perfmon.h>
  40. #endif
  41. #define IRQ_DEBUG 0
  42. #define IRQ_VECTOR_UNASSIGNED (0)
  43. #define IRQ_UNUSED (0)
  44. #define IRQ_USED (1)
  45. #define IRQ_RSVD (2)
  46. /* These can be overridden in platform_irq_init */
  47. int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
  48. int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;
  49. /* default base addr of IPI table */
  50. void __iomem *ipi_base_addr = ((void __iomem *)
  51. (__IA64_UNCACHED_OFFSET | IA64_IPI_DEFAULT_BASE_ADDR));
  52. static cpumask_t vector_allocation_domain(int cpu);
  53. /*
  54. * Legacy IRQ to IA-64 vector translation table.
  55. */
  56. __u8 isa_irq_to_vector_map[16] = {
  57. /* 8259 IRQ translation, first 16 entries */
  58. 0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
  59. 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
  60. };
  61. EXPORT_SYMBOL(isa_irq_to_vector_map);
  62. DEFINE_SPINLOCK(vector_lock);
  63. struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
  64. [0 ... NR_IRQS - 1] = {
  65. .vector = IRQ_VECTOR_UNASSIGNED,
  66. .domain = CPU_MASK_NONE
  67. }
  68. };
  69. DEFINE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq) = {
  70. [0 ... IA64_NUM_VECTORS - 1] = -1
  71. };
  72. static cpumask_t vector_table[IA64_NUM_VECTORS] = {
  73. [0 ... IA64_NUM_VECTORS - 1] = CPU_MASK_NONE
  74. };
  75. static int irq_status[NR_IRQS] = {
  76. [0 ... NR_IRQS -1] = IRQ_UNUSED
  77. };
  78. int check_irq_used(int irq)
  79. {
  80. if (irq_status[irq] == IRQ_USED)
  81. return 1;
  82. return -1;
  83. }
  84. static inline int find_unassigned_irq(void)
  85. {
  86. int irq;
  87. for (irq = IA64_FIRST_DEVICE_VECTOR; irq < NR_IRQS; irq++)
  88. if (irq_status[irq] == IRQ_UNUSED)
  89. return irq;
  90. return -ENOSPC;
  91. }
  92. static inline int find_unassigned_vector(cpumask_t domain)
  93. {
  94. cpumask_t mask;
  95. int pos, vector;
  96. cpus_and(mask, domain, cpu_online_map);
  97. if (cpus_empty(mask))
  98. return -EINVAL;
  99. for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) {
  100. vector = IA64_FIRST_DEVICE_VECTOR + pos;
  101. cpus_and(mask, domain, vector_table[vector]);
  102. if (!cpus_empty(mask))
  103. continue;
  104. return vector;
  105. }
  106. return -ENOSPC;
  107. }
  108. static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
  109. {
  110. cpumask_t mask;
  111. int cpu;
  112. struct irq_cfg *cfg = &irq_cfg[irq];
  113. BUG_ON((unsigned)irq >= NR_IRQS);
  114. BUG_ON((unsigned)vector >= IA64_NUM_VECTORS);
  115. cpus_and(mask, domain, cpu_online_map);
  116. if (cpus_empty(mask))
  117. return -EINVAL;
  118. if ((cfg->vector == vector) && cpus_equal(cfg->domain, domain))
  119. return 0;
  120. if (cfg->vector != IRQ_VECTOR_UNASSIGNED)
  121. return -EBUSY;
  122. for_each_cpu_mask(cpu, mask)
  123. per_cpu(vector_irq, cpu)[vector] = irq;
  124. cfg->vector = vector;
  125. cfg->domain = domain;
  126. irq_status[irq] = IRQ_USED;
  127. cpus_or(vector_table[vector], vector_table[vector], domain);
  128. return 0;
  129. }
  130. int bind_irq_vector(int irq, int vector, cpumask_t domain)
  131. {
  132. unsigned long flags;
  133. int ret;
  134. spin_lock_irqsave(&vector_lock, flags);
  135. ret = __bind_irq_vector(irq, vector, domain);
  136. spin_unlock_irqrestore(&vector_lock, flags);
  137. return ret;
  138. }
  139. static void __clear_irq_vector(int irq)
  140. {
  141. int vector, cpu;
  142. cpumask_t mask;
  143. cpumask_t domain;
  144. struct irq_cfg *cfg = &irq_cfg[irq];
  145. BUG_ON((unsigned)irq >= NR_IRQS);
  146. BUG_ON(cfg->vector == IRQ_VECTOR_UNASSIGNED);
  147. vector = cfg->vector;
  148. domain = cfg->domain;
  149. cpus_and(mask, cfg->domain, cpu_online_map);
  150. for_each_cpu_mask(cpu, mask)
  151. per_cpu(vector_irq, cpu)[vector] = -1;
  152. cfg->vector = IRQ_VECTOR_UNASSIGNED;
  153. cfg->domain = CPU_MASK_NONE;
  154. irq_status[irq] = IRQ_UNUSED;
  155. cpus_andnot(vector_table[vector], vector_table[vector], domain);
  156. }
  157. static void clear_irq_vector(int irq)
  158. {
  159. unsigned long flags;
  160. spin_lock_irqsave(&vector_lock, flags);
  161. __clear_irq_vector(irq);
  162. spin_unlock_irqrestore(&vector_lock, flags);
  163. }
  164. int
  165. ia64_native_assign_irq_vector (int irq)
  166. {
  167. unsigned long flags;
  168. int vector, cpu;
  169. cpumask_t domain = CPU_MASK_NONE;
  170. vector = -ENOSPC;
  171. spin_lock_irqsave(&vector_lock, flags);
  172. for_each_online_cpu(cpu) {
  173. domain = vector_allocation_domain(cpu);
  174. vector = find_unassigned_vector(domain);
  175. if (vector >= 0)
  176. break;
  177. }
  178. if (vector < 0)
  179. goto out;
  180. if (irq == AUTO_ASSIGN)
  181. irq = vector;
  182. BUG_ON(__bind_irq_vector(irq, vector, domain));
  183. out:
  184. spin_unlock_irqrestore(&vector_lock, flags);
  185. return vector;
  186. }
  187. void
  188. ia64_native_free_irq_vector (int vector)
  189. {
  190. if (vector < IA64_FIRST_DEVICE_VECTOR ||
  191. vector > IA64_LAST_DEVICE_VECTOR)
  192. return;
  193. clear_irq_vector(vector);
  194. }
  195. int
  196. reserve_irq_vector (int vector)
  197. {
  198. if (vector < IA64_FIRST_DEVICE_VECTOR ||
  199. vector > IA64_LAST_DEVICE_VECTOR)
  200. return -EINVAL;
  201. return !!bind_irq_vector(vector, vector, CPU_MASK_ALL);
  202. }
  203. /*
  204. * Initialize vector_irq on a new cpu. This function must be called
  205. * with vector_lock held.
  206. */
  207. void __setup_vector_irq(int cpu)
  208. {
  209. int irq, vector;
  210. /* Clear vector_irq */
  211. for (vector = 0; vector < IA64_NUM_VECTORS; ++vector)
  212. per_cpu(vector_irq, cpu)[vector] = -1;
  213. /* Mark the inuse vectors */
  214. for (irq = 0; irq < NR_IRQS; ++irq) {
  215. if (!cpu_isset(cpu, irq_cfg[irq].domain))
  216. continue;
  217. vector = irq_to_vector(irq);
  218. per_cpu(vector_irq, cpu)[vector] = irq;
  219. }
  220. }
  221. #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
  222. static enum vector_domain_type {
  223. VECTOR_DOMAIN_NONE,
  224. VECTOR_DOMAIN_PERCPU
  225. } vector_domain_type = VECTOR_DOMAIN_NONE;
  226. static cpumask_t vector_allocation_domain(int cpu)
  227. {
  228. if (vector_domain_type == VECTOR_DOMAIN_PERCPU)
  229. return cpumask_of_cpu(cpu);
  230. return CPU_MASK_ALL;
  231. }
  232. static int __irq_prepare_move(int irq, int cpu)
  233. {
  234. struct irq_cfg *cfg = &irq_cfg[irq];
  235. int vector;
  236. cpumask_t domain;
  237. if (cfg->move_in_progress || cfg->move_cleanup_count)
  238. return -EBUSY;
  239. if (cfg->vector == IRQ_VECTOR_UNASSIGNED || !cpu_online(cpu))
  240. return -EINVAL;
  241. if (cpu_isset(cpu, cfg->domain))
  242. return 0;
  243. domain = vector_allocation_domain(cpu);
  244. vector = find_unassigned_vector(domain);
  245. if (vector < 0)
  246. return -ENOSPC;
  247. cfg->move_in_progress = 1;
  248. cfg->old_domain = cfg->domain;
  249. cfg->vector = IRQ_VECTOR_UNASSIGNED;
  250. cfg->domain = CPU_MASK_NONE;
  251. BUG_ON(__bind_irq_vector(irq, vector, domain));
  252. return 0;
  253. }
  254. int irq_prepare_move(int irq, int cpu)
  255. {
  256. unsigned long flags;
  257. int ret;
  258. spin_lock_irqsave(&vector_lock, flags);
  259. ret = __irq_prepare_move(irq, cpu);
  260. spin_unlock_irqrestore(&vector_lock, flags);
  261. return ret;
  262. }
  263. void irq_complete_move(unsigned irq)
  264. {
  265. struct irq_cfg *cfg = &irq_cfg[irq];
  266. cpumask_t cleanup_mask;
  267. int i;
  268. if (likely(!cfg->move_in_progress))
  269. return;
  270. if (unlikely(cpu_isset(smp_processor_id(), cfg->old_domain)))
  271. return;
  272. cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
  273. cfg->move_cleanup_count = cpus_weight(cleanup_mask);
  274. for_each_cpu_mask(i, cleanup_mask)
  275. platform_send_ipi(i, IA64_IRQ_MOVE_VECTOR, IA64_IPI_DM_INT, 0);
  276. cfg->move_in_progress = 0;
  277. }
  278. static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
  279. {
  280. int me = smp_processor_id();
  281. ia64_vector vector;
  282. unsigned long flags;
  283. for (vector = IA64_FIRST_DEVICE_VECTOR;
  284. vector < IA64_LAST_DEVICE_VECTOR; vector++) {
  285. int irq;
  286. struct irq_desc *desc;
  287. struct irq_cfg *cfg;
  288. irq = __get_cpu_var(vector_irq)[vector];
  289. if (irq < 0)
  290. continue;
  291. desc = irq_desc + irq;
  292. cfg = irq_cfg + irq;
  293. raw_spin_lock(&desc->lock);
  294. if (!cfg->move_cleanup_count)
  295. goto unlock;
  296. if (!cpu_isset(me, cfg->old_domain))
  297. goto unlock;
  298. spin_lock_irqsave(&vector_lock, flags);
  299. __get_cpu_var(vector_irq)[vector] = -1;
  300. cpu_clear(me, vector_table[vector]);
  301. spin_unlock_irqrestore(&vector_lock, flags);
  302. cfg->move_cleanup_count--;
  303. unlock:
  304. raw_spin_unlock(&desc->lock);
  305. }
  306. return IRQ_HANDLED;
  307. }
  308. static struct irqaction irq_move_irqaction = {
  309. .handler = smp_irq_move_cleanup_interrupt,
  310. .flags = IRQF_DISABLED,
  311. .name = "irq_move"
  312. };
  313. static int __init parse_vector_domain(char *arg)
  314. {
  315. if (!arg)
  316. return -EINVAL;
  317. if (!strcmp(arg, "percpu")) {
  318. vector_domain_type = VECTOR_DOMAIN_PERCPU;
  319. no_int_routing = 1;
  320. }
  321. return 0;
  322. }
  323. early_param("vector", parse_vector_domain);
  324. #else
  325. static cpumask_t vector_allocation_domain(int cpu)
  326. {
  327. return CPU_MASK_ALL;
  328. }
  329. #endif
  330. void destroy_and_reserve_irq(unsigned int irq)
  331. {
  332. unsigned long flags;
  333. dynamic_irq_cleanup(irq);
  334. spin_lock_irqsave(&vector_lock, flags);
  335. __clear_irq_vector(irq);
  336. irq_status[irq] = IRQ_RSVD;
  337. spin_unlock_irqrestore(&vector_lock, flags);
  338. }
  339. /*
  340. * Dynamic irq allocate and deallocation for MSI
  341. */
  342. int create_irq(void)
  343. {
  344. unsigned long flags;
  345. int irq, vector, cpu;
  346. cpumask_t domain = CPU_MASK_NONE;
  347. irq = vector = -ENOSPC;
  348. spin_lock_irqsave(&vector_lock, flags);
  349. for_each_online_cpu(cpu) {
  350. domain = vector_allocation_domain(cpu);
  351. vector = find_unassigned_vector(domain);
  352. if (vector >= 0)
  353. break;
  354. }
  355. if (vector < 0)
  356. goto out;
  357. irq = find_unassigned_irq();
  358. if (irq < 0)
  359. goto out;
  360. BUG_ON(__bind_irq_vector(irq, vector, domain));
  361. out:
  362. spin_unlock_irqrestore(&vector_lock, flags);
  363. if (irq >= 0)
  364. dynamic_irq_init(irq);
  365. return irq;
  366. }
  367. void destroy_irq(unsigned int irq)
  368. {
  369. dynamic_irq_cleanup(irq);
  370. clear_irq_vector(irq);
  371. }
  372. #ifdef CONFIG_SMP
  373. # define IS_RESCHEDULE(vec) (vec == IA64_IPI_RESCHEDULE)
  374. # define IS_LOCAL_TLB_FLUSH(vec) (vec == IA64_IPI_LOCAL_TLB_FLUSH)
  375. #else
  376. # define IS_RESCHEDULE(vec) (0)
  377. # define IS_LOCAL_TLB_FLUSH(vec) (0)
  378. #endif
  379. /*
  380. * That's where the IVT branches when we get an external
  381. * interrupt. This branches to the correct hardware IRQ handler via
  382. * function ptr.
  383. */
  384. void
  385. ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
  386. {
  387. struct pt_regs *old_regs = set_irq_regs(regs);
  388. unsigned long saved_tpr;
  389. #if IRQ_DEBUG
  390. {
  391. unsigned long bsp, sp;
  392. /*
  393. * Note: if the interrupt happened while executing in
  394. * the context switch routine (ia64_switch_to), we may
  395. * get a spurious stack overflow here. This is
  396. * because the register and the memory stack are not
  397. * switched atomically.
  398. */
  399. bsp = ia64_getreg(_IA64_REG_AR_BSP);
  400. sp = ia64_getreg(_IA64_REG_SP);
  401. if ((sp - bsp) < 1024) {
  402. static unsigned char count;
  403. static long last_time;
  404. if (time_after(jiffies, last_time + 5 * HZ))
  405. count = 0;
  406. if (++count < 5) {
  407. last_time = jiffies;
  408. printk("ia64_handle_irq: DANGER: less than "
  409. "1KB of free stack space!!\n"
  410. "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
  411. }
  412. }
  413. }
  414. #endif /* IRQ_DEBUG */
  415. /*
  416. * Always set TPR to limit maximum interrupt nesting depth to
  417. * 16 (without this, it would be ~240, which could easily lead
  418. * to kernel stack overflows).
  419. */
  420. irq_enter();
  421. saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
  422. ia64_srlz_d();
  423. while (vector != IA64_SPURIOUS_INT_VECTOR) {
  424. int irq = local_vector_to_irq(vector);
  425. struct irq_desc *desc = irq_to_desc(irq);
  426. if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
  427. smp_local_flush_tlb();
  428. kstat_incr_irqs_this_cpu(irq, desc);
  429. } else if (unlikely(IS_RESCHEDULE(vector))) {
  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. struct irq_desc *desc;
  543. unsigned int irq;
  544. irq = vec;
  545. BUG_ON(bind_irq_vector(irq, vec, CPU_MASK_ALL));
  546. desc = irq_desc + irq;
  547. desc->status |= IRQ_PER_CPU;
  548. desc->chip = &irq_type_ia64_lsapic;
  549. if (action)
  550. setup_irq(irq, action);
  551. }
  552. void __init
  553. ia64_native_register_ipi(void)
  554. {
  555. #ifdef CONFIG_SMP
  556. register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
  557. register_percpu_irq(IA64_IPI_RESCHEDULE, &resched_irqaction);
  558. register_percpu_irq(IA64_IPI_LOCAL_TLB_FLUSH, &tlb_irqaction);
  559. #endif
  560. }
  561. void __init
  562. init_IRQ (void)
  563. {
  564. ia64_register_ipi();
  565. register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
  566. #ifdef CONFIG_SMP
  567. #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG)
  568. if (vector_domain_type != VECTOR_DOMAIN_NONE)
  569. register_percpu_irq(IA64_IRQ_MOVE_VECTOR, &irq_move_irqaction);
  570. #endif
  571. #endif
  572. #ifdef CONFIG_PERFMON
  573. pfm_init_percpu();
  574. #endif
  575. platform_irq_init();
  576. }
  577. void
  578. ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect)
  579. {
  580. void __iomem *ipi_addr;
  581. unsigned long ipi_data;
  582. unsigned long phys_cpu_id;
  583. phys_cpu_id = cpu_physical_id(cpu);
  584. /*
  585. * cpu number is in 8bit ID and 8bit EID
  586. */
  587. ipi_data = (delivery_mode << 8) | (vector & 0xff);
  588. ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
  589. writeq(ipi_data, ipi_addr);
  590. }