public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Kumar Gala <galak@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Subject: [patch 18/22] powerpc/mpic: Fix regression caused by change of default IRQ affinity
Date: Fri, 14 Nov 2008 21:23:45 -0800	[thread overview]
Message-ID: <20081115052345.GS3710@kroah.com> (raw)
In-Reply-To: <20081115052220.GA3710@kroah.com>

[-- Attachment #1: powerpc-mpic-fix-regression-caused-by-change-of-default-irq-affinity.patch --]
[-- Type: text/plain, Size: 4196 bytes --]

2.6.27-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Kumar Gala <galak@kernel.crashing.org>

commit 3c10c9c45e290022ca7d2aa1ad33a0b6ed767520 upstream.

The Freescale implementation of MPIC only allows a single CPU destination
for non-IPI interrupts.  We add a flag to the mpic_init to distinquish
these variants of MPIC.  We pull in the irq_choose_cpu from sparc64 to
select a single CPU as the destination of the interrupt.

This is to deal with the fact that the default smp affinity was
changed by commit 18404756765c713a0be4eb1082920c04822ce588 ("genirq
Expose default irq affinity mask (take 3)") to be all CPUs.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 arch/powerpc/include/asm/mpic.h          |    2 +
 arch/powerpc/platforms/85xx/mpc85xx_ds.c |    3 +
 arch/powerpc/platforms/86xx/pic.c        |    3 +
 arch/powerpc/sysdev/mpic.c               |   59 ++++++++++++++++++++++++++++---
 4 files changed, 61 insertions(+), 6 deletions(-)

--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -355,6 +355,8 @@ struct mpic
 #define MPIC_NO_BIAS			0x00000400
 /* Ignore NIRQS as reported by FRR */
 #define MPIC_BROKEN_FRR_NIRQS		0x00000800
+/* Destination only supports a single CPU at a time */
+#define MPIC_SINGLE_DEST_CPU		0x00001000
 
 /* MPIC HW modification ID */
 #define MPIC_REGSET_MASK		0xf0000000
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -78,7 +78,8 @@ void __init mpc85xx_ds_pic_init(void)
 
 	mpic = mpic_alloc(np, r.start,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
-			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
+			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
+			  MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	of_node_put(np);
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -44,7 +44,8 @@ void __init mpc86xx_init_irq(void)
 
 	mpic = mpic_alloc(np, res.start,
 			MPIC_PRIMARY | MPIC_WANTS_RESET |
-			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
+			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
+			MPIC_SINGLE_DEST_CPU,
 			0, 256, " MPIC     ");
 	of_node_put(np);
 	BUG_ON(mpic == NULL);
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -563,6 +563,51 @@ static void __init mpic_scan_ht_pics(str
 
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
+#ifdef CONFIG_SMP
+static int irq_choose_cpu(unsigned int virt_irq)
+{
+	cpumask_t mask = irq_desc[virt_irq].affinity;
+	int cpuid;
+
+	if (cpus_equal(mask, CPU_MASK_ALL)) {
+		static int irq_rover;
+		static DEFINE_SPINLOCK(irq_rover_lock);
+		unsigned long flags;
+
+		/* Round-robin distribution... */
+	do_round_robin
+		spin_lock_irqsave(&irq_rover_lock, flags);
+
+		while (!cpu_online(irq_rover)) {
+			if (++irq_rover >= NR_CPUS)
+				irq_rover = 0;
+		}
+		cpuid = irq_rover;
+		do {
+			if (++irq_rover >= NR_CPUS)
+				irq_rover = 0;
+		} while (!cpu_online(irq_rover));
+
+		spin_unlock_irqrestore(&irq_rover_lock, flags);
+	} else {
+		cpumask_t tmp;
+
+		cpus_and(tmp, cpu_online_map, mask);
+
+		if (cpus_empty(tmp))
+			goto do_round_robin;
+
+		cpuid = first_cpu(tmp);
+	}
+
+	return cpuid;
+}
+#else
+static int irq_choose_cpu(unsigned int virt_irq)
+{
+	return hard_smp_processor_id();
+}
+#endif
 
 #define mpic_irq_to_hw(virq)	((unsigned int)irq_map[virq].hwirq)
 
@@ -777,12 +822,18 @@ void mpic_set_affinity(unsigned int irq,
 	struct mpic *mpic = mpic_from_irq(irq);
 	unsigned int src = mpic_irq_to_hw(irq);
 
-	cpumask_t tmp;
+	if (mpic->flags & MPIC_SINGLE_DEST_CPU) {
+		int cpuid = irq_choose_cpu(irq);
+
+		mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
+	} else {
+		cpumask_t tmp;
 
-	cpus_and(tmp, cpumask, cpu_online_map);
+		cpus_and(tmp, cpumask, cpu_online_map);
 
-	mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION),
-		       mpic_physmask(cpus_addr(tmp)[0]));	
+		mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION),
+			       mpic_physmask(cpus_addr(tmp)[0]));
+	}
 }
 
 static unsigned int mpic_type_to_vecpri(struct mpic *mpic, unsigned int type)

-- 

  parent reply	other threads:[~2008-11-15  5:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081115051732.506914008@mini.kroah.org>
2008-11-15  5:22 ` [patch 00/22] 2.6.27.7-stable review Greg KH
2008-11-15  5:22   ` [patch 01/22] touch_mnt_namespace when the mount flags change Greg KH
2008-11-15  5:22   ` [patch 02/22] iwlagn: avoid sleep in softirq context Greg KH
2008-11-15  5:22   ` [patch 03/22] ath5k: fix suspend-related oops on rmmod Greg KH
2008-11-15  5:22   ` [patch 04/22] ath5k: Fix reset sequence for AR5212 in general and RF5111 in particular Greg KH
2008-11-15  5:22   ` [patch 05/22] bnx2x: Removing the PMF indication when unloading Greg KH
2008-11-15  5:23   ` [patch 06/22] bnx2x: PCI configuration bug on big-endian Greg KH
2008-11-15  5:23   ` [patch 07/22] bnx2x: Calling netif_carrier_off at the end of the probe Greg KH
2008-11-15  5:23   ` [patch 08/22] ARM: 5329/1: Feroceon: fix feroceon_l2_inv_range Greg KH
2008-11-15  5:23   ` [patch 09/22] Fix platform drivers that crash on suspend/resume Greg KH
2008-11-15  5:23   ` [patch 10/22] hostap: pad the skb->cb usage in lieu of a proper fix Greg KH
2008-11-15  5:23   ` [patch 11/22] ACPI: avoid empty file name in sysfs Greg KH
2008-11-15  5:23   ` [patch 12/22] ACPI: EC: make kernel messages more useful when GPE storm is detected Greg KH
2008-11-15  5:23   ` [patch 13/22] hugetlb: make unmap_ref_private multi-size-aware Greg KH
2008-11-15  5:23   ` [patch 14/22] rtl8187: Add Abocom USB ID Greg KH
2008-11-15  5:23   ` [patch 15/22] rtl8187 : support for Sitecom WL-168 0001 v4 Greg KH
2008-11-15  5:23   ` [patch 16/22] kbuild: Fixup deb-pkg target to generate separate firmware deb Greg KH
2008-11-15  5:23   ` [patch 17/22] block: fix nr_phys_segments miscalculation bug Greg KH
2008-11-15  5:23   ` Greg KH [this message]
2008-11-15  5:23   ` [patch 19/22] Input: ALPS - add signature for DualPoint found in Dell Latitude E6500 Greg KH
2008-11-15  5:23   ` [patch 20/22] memory hotplug: fix page_zone() calculation in test_pages_isolated() Greg KH
2008-11-15  5:23   ` [patch 21/22] r8169: select MII in Kconfig Greg KH
2008-11-15  5:24   ` [patch 22/22] sony-laptop: ignore missing _DIS method on pic device Greg KH
2008-11-16 10:38   ` [patch 00/22] 2.6.27.7-stable review François Valenduc

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=20081115052345.GS3710@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=eteo@redhat.com \
    --cc=galak@kernel.crashing.org \
    --cc=jake@lwn.net \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkrufky@linuxtv.org \
    --cc=paulus@samba.org \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --cc=zwane@arm.linux.org.uk \
    /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