Skip to contentSkip to conversation

MIPS: BMIPS: Fix interrupt affinity migration

PATCH In review Florian Fainelli 3 participants 6 messages Oct 31, 2016 – Nov 18, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover MIPS: BMIPS: Fix interrupt affinity migration

Hi,

These two patches are against Thomas' irq/core branch as of today:

4cd13c21b207e80ddb1144c576500098f2d5f882 ("softirq: Let ksoftirqd do its job")

Patches can be taken indepdently or together, your call.

Florian Fainelli (2):
irqchip/bcm7038-l1: Implement irq_cpu_offline
MIPS: BMIPS: Migrate interrupts during bmips_cpu_disable

 arch/mips/kernel/smp-bmips.c     |  2 ++
 drivers/irqchip/irq-bcm7038-l1.c | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 irqchip/bcm7038-l1: Implement irq_cpu_offline

We did not implement an irq_cpu_offline callback for our irqchip, yet we support setting a given IRQ's affinity. This resulted in interrupts whose affinity mask included CPUs being taken offline not to work correctly once the CPU had been put offline.

Fixes 5f7f0317ed28 ("IRQCHIP: Add new driver for BCM7038-style level 1 interrupt controllers")
---
 drivers/irqchip/irq-bcm7038-l1.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/irqchip/irq-bcm7038-l1.c +25 -0
index 0fea985ef1dc..529968ac38c0 100644
@@ -216,6 +216,30 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 	return 0;
 }
 
+static void bcm7038_l1_cpu_offline(struct irq_data *d)
+{
+	struct cpumask *mask = irq_data_get_affinity_mask(d);
+	int cpu = smp_processor_id();
+	cpumask_t new_affinity;
+
+	/* This CPU was not on the affinity mask */
+	if (!cpumask_test_cpu(cpu, mask))
+		return;
+
+	if (cpumask_weight(mask) > 1) {
+		/* Multiple CPU affinity, remove this CPU from the affinity
+		 * mask
+		 */
+		cpumask_copy(&new_affinity, mask);
+		cpumask_clear_cpu(cpu, &new_affinity);
+	} else {
+		/* Only CPU, put on the lowest online CPU */
+		cpumask_clear(&new_affinity);
+		cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
+	}
+	irq_set_affinity_locked(d, &new_affinity, false);
+}
+
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
 				      struct bcm7038_l1_chip *intc)
@@ -267,6 +291,7 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
+	.irq_cpu_offline	= bcm7038_l1_cpu_offline,
 };
 
 static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/2 MIPS: BMIPS: Migrate interrupts during bmips_cpu_disable

In reply to Florian Fainelli

While we properly disabled the per-CPU timer interrupt, we also need to make sure that all interrupts that can possibly have this CPU in their smp_affinity mask also have a chance to see this interrupt migrated to a CPU not being taken offline.

Fixes 230b6ff57552 ("MIPS: BMIPS: Mask off timer IRQs when hot-unplugging a CPU")
---
 arch/mips/kernel/smp-bmips.c | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/kernel/smp-bmips.c +2 -0
index 6d0f1321e084..37dffda8f16b 100644
@@ -365,6 +365,8 @@ static int bmips_cpu_disable(void)
 	set_cpu_online(cpu, false);
 	calculate_cpu_foreign_map();
 	cpumask_clear_cpu(cpu, &cpu_callin_map);
+
+	irq_cpu_offline();
 	clear_c0_status(IE_IRQ5);
 
 	local_flush_tlb_all();
Signature · 1 line
2.7.4
#4 lore raw
In reply to Florian Fainelli
Quoted 7 lines · Florian Fainelli

Hi,

These two patches are against Thomas' irq/core branch as of today:

4cd13c21b207e80ddb1144c576500098f2d5f882 ("softirq: Let ksoftirqd do its job")

Patches can be taken indepdently or together, your call.

Resending since I goofed on Thomas' address the first time..

Quoted 9 lines

Florian Fainelli (2):
irqchip/bcm7038-l1: Implement irq_cpu_offline
MIPS: BMIPS: Migrate interrupts during bmips_cpu_disable

 arch/mips/kernel/smp-bmips.c     |  2 ++
 drivers/irqchip/irq-bcm7038-l1.c | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Signature · 1 line
Florian
#5 lore raw
In reply to Florian Fainelli
Quoted 10 lines · Florian Fainelli

Hi,

These two patches are against Thomas' irq/core branch as of today:

4cd13c21b207e80ddb1144c576500098f2d5f882 ("softirq: Let ksoftirqd do its job")

Patches can be taken indepdently or together, your call.

Florian Fainelli (2):
irqchip/bcm7038-l1: Implement irq_cpu_offline

I took that one through tip

Quoted 1 line

MIPS: BMIPS: Migrate interrupts during bmips_cpu_disable

This one should probably go through MIPS

Thanks,

tglx

#2 lore raw

[tip:irq/core] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback

In reply to Florian Fainelli
irqchip/bcm7038-l1: Implement irq_cpu_offline() callback
Commit-ID:  34c535793bcbf9263cf22f8a52101f796cdfab8e
Gitweb:     http://git.kernel.org/tip/34c535793bcbf9263cf22f8a52101f796cdfab8e
Author:     Florian Fainelli <[email protected]>
AuthorDate: Mon, 31 Oct 2016 14:17:35 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 18 Nov 2016 14:17:22 +0100

irqchip/bcm7038-l1: Implement irq_cpu_offline() callback

We did not implement an irq_cpu_offline callback for our irqchip, yet we support setting a given IRQ's affinity. This resulted in interrupts whose affinity mask included CPUs being taken offline not to work correctly once the CPU had been put offline.

---
 drivers/irqchip/irq-bcm7038-l1.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/irqchip/irq-bcm7038-l1.c +26 -0
index 353c549..c2662a1 100644
@@ -215,6 +215,31 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 	return 0;
 }
 
+static void bcm7038_l1_cpu_offline(struct irq_data *d)
+{
+	struct cpumask *mask = irq_data_get_affinity_mask(d);
+	int cpu = smp_processor_id();
+	cpumask_t new_affinity;
+
+	/* This CPU was not on the affinity mask */
+	if (!cpumask_test_cpu(cpu, mask))
+		return;
+
+	if (cpumask_weight(mask) > 1) {
+		/*
+		 * Multiple CPU affinity, remove this CPU from the affinity
+		 * mask
+		 */
+		cpumask_copy(&new_affinity, mask);
+		cpumask_clear_cpu(cpu, &new_affinity);
+	} else {
+		/* Only CPU, put on the lowest online CPU */
+		cpumask_clear(&new_affinity);
+		cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
+	}
+	irq_set_affinity_locked(d, &new_affinity, false);
+}
+
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
 				      struct bcm7038_l1_chip *intc)
@@ -266,6 +291,7 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
+	.irq_cpu_offline	= bcm7038_l1_cpu_offline,
 };
 
 static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,