Skip to contentSkip to conversation

Summit patch for 2.5.34

PATCH In review James Cleverdon 3 participants 6 messages Sep 13, 2002 – Sep 16, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Summit patch for 2.5.34

Patch that allows IBM x440 boxes to on-line all CPUs and interrupt routing for
x360s. Fixed x360 ID bug.

Signature · 3 lines
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
arch/i386/kernel/acpi.c +9 -1
diff -ruN 2.5.34/arch/i386/kernel/acpi.c d34/arch/i386/kernel/acpi.c
@@ -127,6 +127,8 @@
 	printk(KERN_INFO PREFIX "Local APIC address 0x%08x\n",
 		madt->lapic_address);
 
+	acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
+
 	return 0;
 }
 
@@ -361,18 +363,21 @@
 		return result;
 	}
 
+#ifndef CONFIG_ACPI_HT_ONLY
 	result = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi);
 	if (result < 0) {
 		printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
 		return result;
 	}
+#endif /*!CONFIG_ACPI_HT_ONLY*/
 
 	acpi_lapic = 1;
 
 #endif /*CONFIG_X86_LOCAL_APIC*/
 
 #ifdef CONFIG_X86_IO_APIC
+#ifndef CONFIG_ACPI_HT_ONLY
 
 	/* 
 	 * I/O APIC 
@@ -410,11 +415,14 @@
 
 	acpi_ioapic = 1;
 
+#endif /*!CONFIG_ACPI_HT_ONLY*/
 #endif /*CONFIG_X86_IO_APIC*/
 
 #ifdef CONFIG_X86_LOCAL_APIC
-	if (acpi_lapic && acpi_ioapic)
+	if (acpi_lapic && acpi_ioapic) {
 		smp_found_config = 1;
+		smp_cluster_apic_check();
+	}
 #endif
 
 	return 0;
arch/i386/kernel/apic.c +20 -8
diff -ruN 2.5.34/arch/i386/kernel/apic.c d34/arch/i386/kernel/apic.c
@@ -29,6 +29,7 @@
 #include <asm/mtrr.h>
 #include <asm/mpspec.h>
 #include <asm/pgalloc.h>
+#include <asm/smpboot.h>
 
 /* Using APIC to generate smp_local_timer_interrupt? */
 int using_apic_timer = 0;
@@ -272,6 +273,16 @@
 	apic_write_around(APIC_LVT1, value);
 }
 
+static inline unsigned long apic_ldr_value(unsigned long value)
+{
+	if (clustered_apic_numaq)
+		return (value);
+	if (clustered_apic_xapic)
+		return (((value) & ~APIC_LDR_MASK) |
+			SET_APIC_LOGICAL_ID(xapic_physical_to_logical_apicid(hard_smp_processor_id())));
+	return (((value) & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(1UL << smp_processor_id()));
+}
+
 void __init setup_local_APIC (void)
 {
 	unsigned long value, ver, maxlvt;
@@ -304,21 +315,22 @@
 	 * document number 292116).  So here it goes...
 	 */
 
-	if (!clustered_apic_mode) {
+	if (!clustered_apic_numaq) {
 		/*
-		 * In clustered apic mode, the firmware does this for us 
-		 * Put the APIC into flat delivery mode.
-		 * Must be "all ones" explicitly for 82489DX.
+		 * For NUMA-Q, the firmware does this for us.  Otherwise, put the APIC into clustered or flat
+		 *
+		 * delivery mode.  Must be "all ones" explicitly for 82489DX.
 		 */
-		apic_write_around(APIC_DFR, 0xffffffff);
+		if (clustered_apic_mode)
+			apic_write_around(APIC_DFR, APIC_DFR_CLUSTER);
+		else
+			apic_write_around(APIC_DFR, APIC_DFR_FLAT);
 
 		/*
 		 * Set up the logical destination ID.
 		 */
 		value = apic_read(APIC_LDR);
-		value &= ~APIC_LDR_MASK;
-		value |= (1<<(smp_processor_id()+24));
-		apic_write_around(APIC_LDR, value);
+		apic_write_around(APIC_LDR, apic_ldr_value(value));
 	}
 
 	/*
arch/i386/kernel/io_apic.c +42 -90

209 lines not on this page · raw message

arch/i386/kernel/irq.c +2 -0
diff -ruN 2.5.34/arch/i386/kernel/irq.c d34/arch/i386/kernel/irq.c
@@ -331,6 +331,7 @@
 
 	irq_enter();
 	kstat.irqs[cpu][irq]++;
+	apic_adj_tpr(TPR_IRQ);
 	spin_lock(&desc->lock);
 	desc->handler->ack(irq);
 	/*
@@ -389,6 +390,7 @@
 	 */
 	desc->handler->end(irq);
 	spin_unlock(&desc->lock);
+	apic_adj_tpr(-TPR_IRQ);
 
 	irq_exit();
 
arch/i386/kernel/mpparse.c +99 -20

225 lines not on this page · raw message

arch/i386/kernel/process.c +3 -1
diff -ruN 2.5.34/arch/i386/kernel/process.c d34/arch/i386/kernel/process.c
@@ -144,7 +144,9 @@
 		irq_stat[smp_processor_id()].idle_timestamp = jiffies;
 		while (!need_resched())
 			idle();
+		apic_set_tpr(TPR_TASK);
 		schedule();
+		apic_set_tpr(TPR_IDLE);
 	}
 }
 
@@ -196,7 +198,7 @@
 			}
 				/* we will leave sorting out the final value 
 				when we are ready to reboot, since we might not
- 				have set up boot_cpu_id or smp_num_cpu */
+ 				have set up boot_cpu_physical_apicid or smp_num_cpu */
 			break;
 #endif
 		}
arch/i386/kernel/smpboot.c +65 -76

268 lines not on this page · raw message

arch/i386/kernel/trampoline.S +0 -2
diff -ruN 2.5.34/arch/i386/kernel/trampoline.S d34/arch/i386/kernel/trampoline.S
@@ -36,9 +36,7 @@
 
 ENTRY(trampoline_data)
 r_base = .
-#ifdef CONFIG_MULTIQUAD
 	wbinvd
-#endif /* CONFIG_MULTIQUAD */
 	mov	%cs, %ax	# Code and data in the same place
 	mov	%ax, %ds
 
include/asm-i386/acpi.h +3 -0
diff -ruN 2.5.34/include/asm-i386/acpi.h d34/include/asm-i386/acpi.h
@@ -138,6 +138,9 @@
 /* early initialization routine */
 extern void acpi_reserve_bootmem(void);
 
+/* Check for special HW using OEM name lists */
+extern void acpi_madt_oem_check(char *oem_id, char *oem_table_id);
+
 #endif /*CONFIG_ACPI_SLEEP*/
 
 #endif /*__KERNEL__*/
include/asm-i386/apic.h +25 -0
diff -ruN 2.5.34/include/asm-i386/apic.h d34/include/asm-i386/apic.h
@@ -64,6 +64,22 @@
 	apic_write_around(APIC_EOI, 0);
 }
 
+static inline void apic_set_tpr(unsigned long val)
+{
+	unsigned long value;
+
+	value = apic_read(APIC_TASKPRI);
+	apic_write_around(APIC_TASKPRI, (value & ~APIC_TPRI_MASK) + val);
+}
+
+static inline void apic_adj_tpr(long adj)
+{
+	unsigned long value;
+
+	value = apic_read(APIC_TASKPRI);
+	apic_write_around(APIC_TASKPRI, value + adj);
+}
+
 extern int get_maxlvt(void);
 extern void clear_local_APIC(void);
 extern void connect_bsp_APIC (void);
@@ -96,6 +112,15 @@
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
 
+#else /* CONFIG_X86_LOCAL_APIC */
+#define apic_set_tpr(val)
+#define apic_adj_tpr(adj)
 #endif /* CONFIG_X86_LOCAL_APIC */
 
+/* Priority values for apic_adj_tpr() and apic_set_tpr() */
+/* xAPICs only do priority comparisons on the upper nibble. */
+#define TPR_IDLE	(0x00L)
+#define TPR_TASK	(0x10L)
+#define TPR_IRQ		(0x10L)
+
 #endif /* __ASM_APIC_H */
include/asm-i386/apicdef.h +14 -3
diff -ruN 2.5.34/include/asm-i386/apicdef.h d34/include/asm-i386/apicdef.h
@@ -11,8 +11,10 @@
 #define		APIC_DEFAULT_PHYS_BASE	0xfee00000
  
 #define		APIC_ID		0x20
-#define			APIC_ID_MASK		(0x0F<<24)
-#define			GET_APIC_ID(x)		(((x)>>24)&0x0F)
+#define			APIC_ID_MASK		(0xFF<<24)
+#define			GET_APIC_ID(x)		(((x)>>24)&0xFF)
+#define				XAPIC_VER_LOW	0x14	/* Version num range */
+#define				XAPIC_VER_HIGH	0x1F
 #define		APIC_LVR	0x30
 #define			APIC_LVR_MASK		0xFF00FF
 #define			GET_APIC_VERSION(x)	((x)&0xFF)
@@ -32,6 +34,8 @@
 #define			SET_APIC_LOGICAL_ID(x)	(((x)<<24))
 #define			APIC_ALL_CPUS		0xFF
 #define		APIC_DFR	0xE0
+#define			APIC_DFR_CLUSTER	0x0FFFFFFFul	/* Clustered */
+#define			APIC_DFR_FLAT		0xFFFFFFFFul	/* Flat mode */
 #define		APIC_SPIV	0xF0
 #define			APIC_SPIV_FOCUS_DISABLED	(1<<9)
 #define			APIC_SPIV_APIC_ENABLED		(1<<8)
@@ -58,6 +62,7 @@
 #define			APIC_INT_ASSERT		0x04000
 #define			APIC_ICR_BUSY		0x01000
 #define			APIC_DEST_LOGICAL	0x00800
+#define				APIC_DEST_PHYSICAL	0x0	/* For symmetry */
 #define			APIC_DM_FIXED		0x00000
 #define			APIC_DM_LOWEST		0x00100
 #define			APIC_DM_SMI		0x00200
@@ -108,7 +113,13 @@
 
 #define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
 
-#define MAX_IO_APICS 8
+#define MAX_IO_APICS 32	/* Summit boxes can have 4*(2+3*2) I/O APICs */
+
+/*
+ * The intr broadcast ID is 0xF for old APICs and 0xFF for xAPICs.
+ */
+#define APIC_BROADCAST_ID_XAPIC	0xFF
+#define APIC_BROADCAST_ID_APIC	0x0F
 
 /*
  * the local APIC register structure, memory mapped. Not terribly well
include/asm-i386/mpspec.h +3 -5
diff -ruN 2.5.34/include/asm-i386/mpspec.h d34/include/asm-i386/mpspec.h
@@ -14,13 +14,10 @@
 #define SMP_MAGIC_IDENT	(('_'<<24)|('P'<<16)|('M'<<8)|'_')
 
 /*
- * a maximum of 16 APICs with the current APIC ID architecture.
+ * A maximum of 16 APICs with the classic APIC ID architecture.
+ * xAPICs can have up to 256.
  */
-#ifdef CONFIG_MULTIQUAD
 #define MAX_APICS 256
-#else /* !CONFIG_MULTIQUAD */
-#define MAX_APICS 16
-#endif /* CONFIG_MULTIQUAD */
 
 #define MAX_MPC_ENTRY 1024
 
@@ -204,6 +201,7 @@
 extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
 
 extern unsigned int boot_cpu_physical_apicid;
+extern unsigned int boot_cpu_logical_apicid;
 extern unsigned long phys_cpu_present_map;
 extern int smp_found_config;
 extern void find_smp_config (void);
include/asm-i386/smp.h +50 -37

113 lines not on this page · raw message

include/asm-i386/smpboot.h +29 -49

91 lines not on this page · raw message

#1 lore raw
Quoted 2 lines · James Cleverdon

Patch that allows IBM x440 boxes to on-line all CPUs and interrupt routing for
x360s. Fixed x360 ID bug.

Couple questions/comments.

- Is this the same summit code as is in 2.4-ac ?
(Ie, the one that boots on non summit systems too)
- I believe the way forward here is to work with James Bottomley, who has a nice abstraction of the areas your patch touches for his Voyager sub-architecture.
Linus has however been completley silent on the x86-subarch idea despite heavyweights like Alan and Ingo adding their support... If you go this route, James' base needs to go in first (converting just the in-kernel visws support). After which, adding support for Voyager, Summit and any other wacky x86esque hardware is a simple non-intrusive patch that touches subarch specific areas.
- Some of the code you've added looks along the lines of..

   if (numaq)
      foo();
   else if (summit)
      foo2();
   else 
      foo3();

Would it be over-abstracting to have some form of APIC struct, defining pointers to various routines instead of lots of ugly if's/switches/fall-through's.

However, the last point may be completley pointless after adapting to use what James B has come up with..

Dave

Signature · 2 lines
| Dave Jones.        http://www.codemonkey.org.uk
| SuSE Labs
#2 lore raw
Quoted 2 lines

- Is this the same summit code as is in 2.4-ac ? (Ie, the one that boots on non summit systems too)

Yes

Quoted 3 lines

- I believe the way forward here is to work with James Bottomley, who has a nice abstraction of the areas your patch touches for his Voyager sub-architecture.

For 2.5 maybe not for 2.4. Until Linus takes the subarch stuff the if if if bits will just get uglier. As well as voyager there are at least two more pending NUMA x86 platforms other than IBM summit

#3 lore raw
Quoted 2 lines · Alan Cox
Quoted 1 line

- I believe the way forward here is to work with James Bottomley,

For 2.5 maybe not for 2.4.

Oh, absolutely. subarch support is way too intrusive a change for 2.4.

Quoted 3 lines

Until Linus takes the subarch stuff the
if if if bits will just get uglier. As well as voyager there are at least two more pending NUMA x86 platforms other than IBM summit

Indeed. And who knows how many more to come...

Dave

Signature · 2 lines
| Dave Jones.        http://www.codemonkey.org.uk
| SuSE Labs
#4 lore raw
In reply to Alan Cox
Quoted 4 lines · Alan Cox
Quoted 2 lines

- Is this the same summit code as is in 2.4-ac ? (Ie, the one that boots on non summit systems too)

Yes

It's the same, save for a few lines of code that use the local APIC's task priority HW to try for some better dynamic interrupt balancing.

Quoted 8 lines
Quoted 3 lines

- I believe the way forward here is to work with James Bottomley, who has a nice abstraction of the areas your patch touches for his Voyager sub-architecture.

For 2.5 maybe not for 2.4. Until Linus takes the subarch stuff the if if if bits will just get uglier. As well as voyager there are at least two more pending NUMA x86 platforms other than IBM summit
-

I'll have to read up on James Bottomley's x86 subarch code.

Signature · 3 lines
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
#5 lore raw
In reply to Dave Jones
Quoted 8 lines · Dave Jones
Quoted 2 lines · James Cleverdon

Patch that allows IBM x440 boxes to on-line all CPUs and interrupt
routing for x360s. Fixed x360 ID bug.

Couple questions/comments.

- Is this the same summit code as is in 2.4-ac ? (Ie, the one that boots on non summit systems too)

Yes, save for the dynamic TPR enhancement. (Already addressed by Alan, etc, in other postings.)

Quoted 18 lines

- I believe the way forward here is to work with James Bottomley, who has a nice abstraction of the areas your patch touches for his Voyager sub-architecture.
Linus has however been completley silent on the x86-subarch idea despite heavyweights like Alan and Ingo adding their support... If you go this route, James' base needs to go in first (converting just the in-kernel visws support). After which, adding support for Voyager, Summit and any other wacky x86esque hardware is a simple non-intrusive patch that touches subarch specific areas.
- Some of the code you've added looks along the lines of..

   if (numaq)
      foo();
   else if (summit)
      foo2();
   else
      foo3();
Quoted 8 lines

Would it be over-abstracting to have some form of APIC struct, defining pointers to various routines instead of lots of ugly if's/switches/fall-through's.

However, the last point may be completley pointless after adapting to use what James B has come up with..

Dave

All the if/else chains are in init code, where a few more microseconds for some extra branches isn't important. However, a nice sub-arch abstraction would be welcome.

Thanks!

Signature · 3 lines
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com