]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
c777ac55 | 2 | |
d824e66a | 3 | #include <linux/irq.h> |
57b150cc YL |
4 | #include <linux/interrupt.h> |
5 | ||
6 | #include "internals.h" | |
c777ac55 | 7 | |
cdd16365 TG |
8 | /** |
9 | * irq_fixup_move_pending - Cleanup irq move pending from a dying CPU | |
10 | * @desc: Interrupt descpriptor to clean up | |
11 | * @force_clear: If set clear the move pending bit unconditionally. | |
12 | * If not set, clear it only when the dying CPU is the | |
13 | * last one in the pending mask. | |
14 | * | |
15 | * Returns true if the pending bit was set and the pending mask contains an | |
16 | * online CPU other than the dying CPU. | |
17 | */ | |
18 | bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear) | |
19 | { | |
20 | struct irq_data *data = irq_desc_get_irq_data(desc); | |
21 | ||
22 | if (!irqd_is_setaffinity_pending(data)) | |
23 | return false; | |
24 | ||
25 | /* | |
26 | * The outgoing CPU might be the last online target in a pending | |
27 | * interrupt move. If that's the case clear the pending move bit. | |
28 | */ | |
29 | if (cpumask_any_and(desc->pending_mask, cpu_online_mask) >= nr_cpu_ids) { | |
30 | irqd_clr_move_pending(data); | |
31 | return false; | |
32 | } | |
33 | if (force_clear) | |
34 | irqd_clr_move_pending(data); | |
35 | return true; | |
36 | } | |
37 | ||
a439520f | 38 | void irq_move_masked_irq(struct irq_data *idata) |
c777ac55 | 39 | { |
a439520f | 40 | struct irq_desc *desc = irq_data_to_desc(idata); |
77ed42f1 | 41 | struct irq_chip *chip = desc->irq_data.chip; |
c777ac55 | 42 | |
f230b6d5 | 43 | if (likely(!irqd_is_setaffinity_pending(&desc->irq_data))) |
c777ac55 AM |
44 | return; |
45 | ||
a614a610 TG |
46 | irqd_clr_move_pending(&desc->irq_data); |
47 | ||
501f2499 BH |
48 | /* |
49 | * Paranoia: cpu-local interrupts shouldn't be calling in here anyway. | |
50 | */ | |
a614a610 | 51 | if (irqd_is_per_cpu(&desc->irq_data)) { |
501f2499 BH |
52 | WARN_ON(1); |
53 | return; | |
54 | } | |
55 | ||
7f7ace0c | 56 | if (unlikely(cpumask_empty(desc->pending_mask))) |
c777ac55 AM |
57 | return; |
58 | ||
c96b3b3c | 59 | if (!chip->irq_set_affinity) |
c777ac55 AM |
60 | return; |
61 | ||
239007b8 | 62 | assert_raw_spin_locked(&desc->lock); |
501f2499 | 63 | |
c777ac55 AM |
64 | /* |
65 | * If there was a valid mask to work with, please | |
66 | * do the disable, re-program, enable sequence. | |
67 | * This is *not* particularly important for level triggered | |
68 | * but in a edge trigger case, we might be setting rte | |
25985edc | 69 | * when an active trigger is coming in. This could |
c777ac55 AM |
70 | * cause some ioapics to mal-function. |
71 | * Being paranoid i guess! | |
e7b946e9 EB |
72 | * |
73 | * For correct operation this depends on the caller | |
74 | * masking the irqs. | |
c777ac55 | 75 | */ |
818b0f3b JL |
76 | if (cpumask_any_and(desc->pending_mask, cpu_online_mask) < nr_cpu_ids) |
77 | irq_do_set_affinity(&desc->irq_data, desc->pending_mask, false); | |
57b150cc | 78 | |
7f7ace0c | 79 | cpumask_clear(desc->pending_mask); |
c777ac55 | 80 | } |
e7b946e9 | 81 | |
a439520f | 82 | void irq_move_irq(struct irq_data *idata) |
e7b946e9 | 83 | { |
f1a06390 | 84 | bool masked; |
e7b946e9 | 85 | |
77ed42f1 JL |
86 | /* |
87 | * Get top level irq_data when CONFIG_IRQ_DOMAIN_HIERARCHY is enabled, | |
88 | * and it should be optimized away when CONFIG_IRQ_DOMAIN_HIERARCHY is | |
89 | * disabled. So we avoid an "#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY" here. | |
90 | */ | |
91 | idata = irq_desc_get_irq_data(irq_data_to_desc(idata)); | |
92 | ||
a439520f | 93 | if (likely(!irqd_is_setaffinity_pending(idata))) |
e7b946e9 EB |
94 | return; |
95 | ||
32f4125e | 96 | if (unlikely(irqd_irq_disabled(idata))) |
2a786b45 | 97 | return; |
e7b946e9 | 98 | |
f1a06390 TG |
99 | /* |
100 | * Be careful vs. already masked interrupts. If this is a | |
101 | * threaded interrupt with ONESHOT set, we can end up with an | |
102 | * interrupt storm. | |
103 | */ | |
32f4125e | 104 | masked = irqd_irq_masked(idata); |
f1a06390 | 105 | if (!masked) |
a439520f TG |
106 | idata->chip->irq_mask(idata); |
107 | irq_move_masked_irq(idata); | |
f1a06390 | 108 | if (!masked) |
a439520f TG |
109 | idata->chip->irq_unmask(idata); |
110 | } |