migration.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (!chip->irq_set_affinity(&desc->irq_data,
  38. desc->pending_mask, false)) {
  39. cpumask_copy(desc->irq_data.affinity, desc->pending_mask);
  40. irq_set_thread_affinity(desc);
  41. }
  42. cpumask_clear(desc->pending_mask);
  43. }
  44. void irq_move_irq(struct irq_data *idata)
  45. {
  46. bool masked;
  47. if (likely(!irqd_is_setaffinity_pending(idata)))
  48. return;
  49. if (unlikely(irqd_irq_disabled(idata)))
  50. return;
  51. /*
  52. * Be careful vs. already masked interrupts. If this is a
  53. * threaded interrupt with ONESHOT set, we can end up with an
  54. * interrupt storm.
  55. */
  56. masked = irqd_irq_masked(idata);
  57. if (!masked)
  58. idata->chip->irq_mask(idata);
  59. irq_move_masked_irq(idata);
  60. if (!masked)
  61. idata->chip->irq_unmask(idata);
  62. }