Skip to content

Commit 073352e

Browse files
smaeulMarc Zyngier
authored andcommitted
genirq: Add and use an irq_data_update_affinity helper
Some architectures and irqchip drivers modify the cpumask returned by irq_data_get_affinity_mask, usually by copying in to it. This is problematic for uniprocessor configurations, where the affinity mask should be constant, as it is known at compile time. Add and use a setter for the affinity mask, following the pattern of irq_data_update_effective_affinity. This allows the getter function to return a const cpumask pointer. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Oleksandr Tyshchenko <[email protected]> # Xen bits Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 961343d commit 073352e

File tree

10 files changed

+21
-14
lines changed

10 files changed

+21
-14
lines changed

arch/alpha/kernel/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int irq_select_affinity(unsigned int irq)
6060
cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
6161
last_cpu = cpu;
6262

63-
cpumask_copy(irq_data_get_affinity_mask(data), cpumask_of(cpu));
63+
irq_data_update_affinity(data, cpumask_of(cpu));
6464
chip->irq_set_affinity(data, cpumask_of(cpu), false);
6565
return 0;
6666
}

arch/ia64/kernel/iosapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ iosapic_unregister_intr (unsigned int gsi)
834834
if (iosapic_intr_info[irq].count == 0) {
835835
#ifdef CONFIG_SMP
836836
/* Clear affinity */
837-
cpumask_setall(irq_get_affinity_mask(irq));
837+
irq_data_update_affinity(irq_get_irq_data(irq), cpu_all_mask);
838838
#endif
839839
/* Clear the interrupt information */
840840
iosapic_intr_info[irq].dest = 0;

arch/ia64/kernel/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
5757
void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
5858
{
5959
if (irq < NR_IRQS) {
60-
cpumask_copy(irq_get_affinity_mask(irq),
61-
cpumask_of(cpu_logical_id(hwid)));
60+
irq_data_update_affinity(irq_get_irq_data(irq),
61+
cpumask_of(cpu_logical_id(hwid)));
6262
irq_redir[irq] = (char) (redir & 0xff);
6363
}
6464
}

arch/ia64/kernel/msi_ia64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int ia64_set_msi_irq_affinity(struct irq_data *idata,
3737
msg.data = data;
3838

3939
pci_write_msi_msg(irq, &msg);
40-
cpumask_copy(irq_data_get_affinity_mask(idata), cpumask_of(cpu));
40+
irq_data_update_affinity(idata, cpumask_of(cpu));
4141

4242
return 0;
4343
}
@@ -132,7 +132,7 @@ static int dmar_msi_set_affinity(struct irq_data *data,
132132
msg.address_lo |= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu));
133133

134134
dmar_msi_write(irq, &msg);
135-
cpumask_copy(irq_data_get_affinity_mask(data), mask);
135+
irq_data_update_affinity(data, mask);
136136

137137
return 0;
138138
}

arch/parisc/kernel/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ unsigned long txn_affinity_addr(unsigned int irq, int cpu)
315315
{
316316
#ifdef CONFIG_SMP
317317
struct irq_data *d = irq_get_irq_data(irq);
318-
cpumask_copy(irq_data_get_affinity_mask(d), cpumask_of(cpu));
318+
irq_data_update_affinity(d, cpumask_of(cpu));
319319
#endif
320320

321321
return per_cpu(cpu_data, cpu).txn_addr;

drivers/irqchip/irq-bcm6345-l1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ static int bcm6345_l1_set_affinity(struct irq_data *d,
216216
enabled = intc->cpus[old_cpu]->enable_cache[word] & mask;
217217
if (enabled)
218218
__bcm6345_l1_mask(d);
219-
cpumask_copy(irq_data_get_affinity_mask(d), dest);
219+
irq_data_update_affinity(d, dest);
220220
if (enabled)
221221
__bcm6345_l1_unmask(d);
222222
} else {
223-
cpumask_copy(irq_data_get_affinity_mask(d), dest);
223+
irq_data_update_affinity(d, dest);
224224
}
225225
raw_spin_unlock_irqrestore(&intc->lock, flags);
226226

drivers/parisc/iosapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static int iosapic_set_affinity_irq(struct irq_data *d,
677677
if (dest_cpu < 0)
678678
return -1;
679679

680-
cpumask_copy(irq_data_get_affinity_mask(d), cpumask_of(dest_cpu));
680+
irq_data_update_affinity(d, cpumask_of(dest_cpu));
681681
vi->txn_addr = txn_affinity_addr(d->irq, dest_cpu);
682682

683683
spin_lock_irqsave(&iosapic_lock, flags);

drivers/sh/intc/chip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int intc_set_affinity(struct irq_data *data,
7272
if (!cpumask_intersects(cpumask, cpu_online_mask))
7373
return -1;
7474

75-
cpumask_copy(irq_data_get_affinity_mask(data), cpumask);
75+
irq_data_update_affinity(data, cpumask);
7676

7777
return IRQ_SET_MASK_OK_NOCOPY;
7878
}

drivers/xen/events/events_base.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,10 @@ static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
528528
BUG_ON(irq == -1);
529529

530530
if (IS_ENABLED(CONFIG_SMP) && force_affinity) {
531-
cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu));
532-
cpumask_copy(irq_get_effective_affinity_mask(irq),
533-
cpumask_of(cpu));
531+
struct irq_data *data = irq_get_irq_data(irq);
532+
533+
irq_data_update_affinity(data, cpumask_of(cpu));
534+
irq_data_update_effective_affinity(data, cpumask_of(cpu));
534535
}
535536

536537
xen_evtchn_port_bind_to_cpu(evtchn, cpu, info->cpu);

include/linux/irq.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@ static inline struct cpumask *irq_data_get_affinity_mask(struct irq_data *d)
884884
return d->common->affinity;
885885
}
886886

887+
static inline void irq_data_update_affinity(struct irq_data *d,
888+
const struct cpumask *m)
889+
{
890+
cpumask_copy(d->common->affinity, m);
891+
}
892+
887893
static inline struct cpumask *irq_get_affinity_mask(int irq)
888894
{
889895
struct irq_data *d = irq_get_irq_data(irq);

0 commit comments

Comments
 (0)