migration.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <linux/irq.h>
  2. #include <linux/interrupt.h>
  3. #include "internals.h"
  4. void irq_move_masked_irq(struct irq_data *idata)
  5. {
  6. struct irq_desc *desc = irq_data_to_desc(idata);
  7. struct irq_chip *chip = idata->chip;
  8. if (likely(!irqd_is_setaffinity_pending(&desc->irq_data)))
  9. return;
  10. /*
  11. * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
  12. */
  13. if (!irqd_can_balance(&desc->irq_data)) {
  14. WARN_ON(1);
  15. return;
  16. }
  17. irqd_clr_move_pending(&desc->irq_data);
  18. if (unlikely(cpumask_empty(desc->pending_mask)))
  19. return;
  20. if (!chip->irq_set_affinity)
  21. return;
  22. assert_raw_spin_locked(&desc->lock);
  23. /*
  24. * If there was a valid mask to work with, please
  25. * do the disable, re-program, enable sequence.
  26. * This is *not* particularly important for level triggered
  27. * but in a edge trigger case, we might be setting rte
  28. * when an active trigger is coming in. This could
  29. * cause some ioapics to mal-function.
  30. * Being paranoid i guess!
  31. *
  32. * For correct operation this depends on the caller
  33. * masking the irqs.
  34. */
  35. if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
  36. < nr_cpu_ids)) {
  37. int ret = chip->irq_set_affinity(&desc->irq_data,
  38. desc->pending_mask, false);
  39. switch (ret) {
  40. case IRQ_SET_MASK_OK:
  41. cpumask_copy(desc->irq_data.affinity, desc->pending_mask);
  42. case IRQ_SET_MASK_OK_NOCOPY:
  43. irq_set_thread_affinity(desc);
  44. }
  45. }
  46. cpumask_clear(desc->pending_mask);
  47. }
  48. void irq_move_irq(struct irq_data *idata)
  49. {
  50. bool masked;
  51. if (likely(!irqd_is_setaffinity_pending(idata)))
  52. return;
  53. if (unlikely(irqd_irq_disabled(idata)))
  54. return;
  55. /*
  56. * Be careful vs. already masked interrupts. If this is a
  57. * threaded interrupt with ONESHOT set, we can end up with an
  58. * interrupt storm.
  59. */
  60. masked = irqd_irq_masked(idata);
  61. if (!masked)
  62. idata->chip->irq_mask(idata);
  63. irq_move_masked_irq(idata);
  64. if (!masked)
  65. idata->chip->irq_unmask(idata);
  66. }