From: Ashok Raj <ashok.raj@intel.com>

- Extend zwane's fixes for set_ioapic_affinity to x86_64 as well.
- Put correct fix requested by Adrian, for include/linux/irq.h when
  CONFIG_GENERIC_PENDING_IRQ is not defined.

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 arch/x86_64/kernel/io_apic.c |   15 +++++++++------
 include/linux/irq.h          |   27 +++++++++++++++++++++++----
 kernel/irq/manage.c          |    6 +-----
 3 files changed, 33 insertions(+), 15 deletions(-)

diff -puN arch/x86_64/kernel/io_apic.c~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4 arch/x86_64/kernel/io_apic.c
--- 25/arch/x86_64/kernel/io_apic.c~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4	2005-05-31 02:44:03.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/io_apic.c	2005-05-31 02:44:03.000000000 -0700
@@ -124,11 +124,6 @@ static void set_ioapic_affinity_irq(unsi
 	set_irq_info(irq, mask);
 	spin_unlock_irqrestore(&ioapic_lock, flags);
 }
-#else
-static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
-{
-	return;
-}
 #endif
 
 /*
@@ -1396,6 +1391,7 @@ static void unmask_IO_APIC_vector (unsig
 	unmask_IO_APIC_irq(irq);
 }
 
+#ifdef CONFIG_SMP
 static void set_ioapic_affinity_vector (unsigned int vector,
 					cpumask_t cpu_mask)
 {
@@ -1404,7 +1400,8 @@ static void set_ioapic_affinity_vector (
 	set_native_irq_info(vector, cpu_mask);
 	set_ioapic_affinity_irq(irq, cpu_mask);
 }
-#endif
+#endif // CONFIG_SMP
+#endif // CONFIG_PCI_MSI
 
 /*
  * Level and edge triggered IO-APIC interrupts need different handling,
@@ -1423,7 +1420,9 @@ static struct hw_interrupt_type ioapic_e
 	.disable 	= disable_edge_ioapic,
 	.ack 		= ack_edge_ioapic,
 	.end 		= end_edge_ioapic,
+#ifdef CONFIG_SMP
 	.set_affinity = set_ioapic_affinity,
+#endif
 };
 
 static struct hw_interrupt_type ioapic_level_type = {
@@ -1434,7 +1433,9 @@ static struct hw_interrupt_type ioapic_l
 	.disable 	= disable_level_ioapic,
 	.ack 		= mask_and_ack_level_ioapic,
 	.end 		= end_level_ioapic,
+#ifdef CONFIG_SMP
 	.set_affinity = set_ioapic_affinity,
+#endif
 };
 
 static inline void init_IO_APIC_traps(void)
@@ -1923,6 +1924,7 @@ int io_apic_set_pci_routing (int ioapic,
  * we need to reprogram the ioredtbls to cater for the cpus which have come online
  * so mask in all cases should simply be TARGET_CPUS
  */
+#ifdef CONFIG_SMP
 void __init setup_ioapic_dest(void)
 {
 	int pin, ioapic, irq, irq_entry;
@@ -1941,3 +1943,4 @@ void __init setup_ioapic_dest(void)
 
 	}
 }
+#endif
diff -puN include/linux/irq.h~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4 include/linux/irq.h
--- 25/include/linux/irq.h~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4	2005-05-31 02:44:03.000000000 -0700
+++ 25-akpm/include/linux/irq.h	2005-05-31 02:44:03.000000000 -0700
@@ -97,9 +97,13 @@ static inline void set_native_irq_info(i
 }
 #endif
 
-#ifdef CONFIG_GENERIC_PENDING_IRQ
+#ifdef CONFIG_SMP
+
+#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
 extern cpumask_t pending_irq_cpumask[NR_IRQS];
+#endif
 
+#ifdef CONFIG_GENERIC_PENDING_IRQ
 static inline void
 move_native_irq(int irq)
 {
@@ -147,7 +151,9 @@ static inline void move_irq(int irq)
 static inline void set_irq_info(int irq, cpumask_t mask)
 {
 }
-#else
+
+#else // CONFIG_PCI_MSI
+
 static inline void move_irq(int irq)
 {
 	move_native_irq(irq);
@@ -158,12 +164,25 @@ static inline void set_irq_info(int irq,
 	set_native_irq_info(irq, mask);
 }
 #endif // CONFIG_PCI_MSI
-#else
+
+#else	// CONFIG_GENERIC_PENDING_IRQ
+
 #define move_irq(x)
 #define move_native_irq(x)
-extern void set_irq_info(unsigned int irq, cpumask_t mask);
+static inline void set_irq_info(int irq, cpumask_t mask)
+{
+	set_native_irq_info(irq, mask);
+}
+
 #endif // CONFIG_GENERIC_PENDING_IRQ
 
+#else // CONFIG_SMP
+
+#define move_irq(x)
+#define move_native_irq(x)
+
+#endif // CONFIG_SMP
+
 extern int no_irq_affinity;
 extern int noirqdebug_setup(char *str);
 
diff -puN kernel/irq/manage.c~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4 kernel/irq/manage.c
--- 25/kernel/irq/manage.c~x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree-fix-4	2005-05-31 02:44:03.000000000 -0700
+++ 25-akpm/kernel/irq/manage.c	2005-05-31 02:44:03.000000000 -0700
@@ -17,7 +17,7 @@
 
 cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
 
-#ifdef CONFIG_GENERIC_PENDING_IRQ
+#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
 cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS];
 #endif
 
@@ -40,10 +40,6 @@ void synchronize_irq(unsigned int irq)
 
 EXPORT_SYMBOL(synchronize_irq);
 
-#else
-void set_irq_info(unsigned int irq, cpumask_t mask)
-{
-}
 #endif
 
 /**
_