public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-mips@linux-mips.org
Cc: ralf@linux-mips.org, cernekee@gmail.com, jaedon.shin@gmail.com,
	justinpopo6@gmail.com, tglx@linutronix.de, marc.zyngier@arm.com,
	jason@lakedaemon.net, linux-kernel@vger.kernel.org,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH 1/2] irqchip/bcm7038-l1: Implement irq_cpu_offline
Date: Mon, 31 Oct 2016 14:17:35 -0700	[thread overview]
Message-ID: <1477948656-12966-2-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1477948656-12966-1-git-send-email-f.fainelli@gmail.com>

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")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 0fea985ef1dc..529968ac38c0 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -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,
-- 
2.7.4

  reply	other threads:[~2016-10-31 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 21:17 [PATCH 0/2] MIPS: BMIPS: Fix interrupt affinity migration Florian Fainelli
2016-10-31 21:17 ` Florian Fainelli [this message]
2016-11-18 14:13   ` [tip:irq/core] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback tip-bot for Florian Fainelli
2016-10-31 21:17 ` [PATCH 2/2] MIPS: BMIPS: Migrate interrupts during bmips_cpu_disable Florian Fainelli
2016-10-31 21:18 ` [PATCH 0/2] MIPS: BMIPS: Fix interrupt affinity migration Florian Fainelli
2016-11-18 14:09 ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2016-10-31 21:16 Florian Fainelli
2016-10-31 21:16 ` [PATCH 1/2] irqchip/bcm7038-l1: Implement irq_cpu_offline Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477948656-12966-2-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=cernekee@gmail.com \
    --cc=jaedon.shin@gmail.com \
    --cc=jason@lakedaemon.net \
    --cc=justinpopo6@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marc.zyngier@arm.com \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox