Skip to contentSkip to conversation

sparc32 smp patch

PATCH Bob Breuer 2 participants 2 messages Jan 25, 2006 – Mar 24, 2006 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Bob Breuer

author
#0 lore raw

Here's the latest update of the SMP patch (see [1] for a previous incarnation).

It may not be ready for upstream merging yet, but it would be helpful to get some review and testing of it.

Todo items:
- IRQ_INPROGRESS flag - use sparc64 irq buckets, or generic irq_desc?
- sun4d
- re-indent large chunks of sun4m_smp.c
- some places assume sequential cpu numbering (i.e. 0,1 instead of 0,2)

Last I checked (with 2.6.14), random programs segfault with dual HyperSPARC. And with SuperSPARC II's, it seems stable but will eventually die from a write lock error (wrong lock owner or something).

I haven't tried the HyperSPARC + highmem combination recently, so that may still be a problem.

Bob

[1] http://marc.theaimsgroup.com/?l=linux-sparc&m=110828111116713&w=2

arch/sparc/Kconfig +0 -1
diff -urp -X dontdiff linux-2.6.14-clean/arch/sparc/Kconfig linux-2.6.14smp/arch/sparc/Kconfig
@@ -27,7 +27,6 @@ menu "General machine setup"
 
 config SMP
 	bool "Symmetric multi-processing support (does not work on sun4/sun4c)"
-	depends on BROKEN
 	---help---
 	  This enables support for systems with more than one CPU. If you have
 	  a system with only one CPU, say N. If you have a system with more
arch/sparc/kernel/irq.c +34 -32

175 lines not on this page · raw message

arch/sparc/kernel/smp.c +63 -21

123 lines not on this page · raw message

arch/sparc/kernel/sparc_ksyms.c +0 -4
diff -urp -X dontdiff linux-2.6.14-clean/arch/sparc/kernel/sparc_ksyms.c linux-2.6.14smp/arch/sparc/kernel/sparc_ksyms.c
@@ -139,10 +139,6 @@ EXPORT_PER_CPU_SYMBOL(__cpu_data);
 /* IRQ implementation. */
 EXPORT_SYMBOL(synchronize_irq);
 
-/* Misc SMP information */
-EXPORT_SYMBOL(__cpu_number_map);
-EXPORT_SYMBOL(__cpu_logical_map);
-
 /* CPU online map and active count. */
 EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(phys_cpu_present_map);
arch/sparc/kernel/sun4d_irq.c +1 -1
diff -urp -X dontdiff linux-2.6.14-clean/arch/sparc/kernel/sun4d_irq.c linux-2.6.14smp/arch/sparc/kernel/sun4d_irq.c
@@ -54,7 +54,7 @@ unsigned char cpu_leds[32];
 unsigned char sbus_tid[32];
 #endif
 
-extern struct irqaction *irq_action[];
+static struct irqaction *irq_action[NR_IRQS];
 extern spinlock_t irq_action_lock;
 
 struct sbus_action {
arch/sparc/kernel/sun4d_smp.c +4 -2
diff -urp -X dontdiff linux-2.6.14-clean/arch/sparc/kernel/sun4d_smp.c linux-2.6.14smp/arch/sparc/kernel/sun4d_smp.c
@@ -53,7 +53,9 @@ extern volatile int __cpu_number_map[NR_
 extern volatile int __cpu_logical_map[NR_CPUS];
 extern volatile unsigned long ipi_count;
 extern volatile int smp_process_available;
-extern volatile int smp_commenced;
+
+extern cpumask_t smp_commenced_mask;
+
 extern int __smp4d_processor_id(void);
 
 /* #define SMP_DEBUG */
@@ -136,7 +138,7 @@ void __init smp4d_callin(void)
 	
 	local_irq_enable();	/* We don't allow PIL 14 yet */
 	
-	while(!smp_commenced)
+	while (!cpu_isset(cpuid, smp_commenced_mask))
 		barrier();
 
 	spin_lock_irqsave(&sun4d_imsk_lock, flags);
arch/sparc/kernel/sun4m_smp.c +47 -81

226 lines not on this page · raw message

Only in linux-2.6.14smp/arch/sparc/kernel: vmlinux.lds

arch/sparc/mm/srmmu.c +6 -0
diff -urp -X dontdiff linux-2.6.14-clean/arch/sparc/mm/srmmu.c linux-2.6.14smp/arch/sparc/mm/srmmu.c
@@ -1302,7 +1302,12 @@ void __init srmmu_paging_init(void)
 
 	flush_cache_all();
 	srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys);
+#ifdef CONFIG_SMP
+	/* Stop from hanging here... */
+	local_flush_tlb_all();
+#else
 	flush_tlb_all();
+#endif
 	poke_srmmu();
 
 #ifdef CONFIG_SUN_IO
@@ -1419,6 +1424,7 @@ static void __init init_vac_layout(void)
 				max_size = vac_cache_size;
 			if(vac_line_size < min_line_size)
 				min_line_size = vac_line_size;
+			//FIXME: cpus not contiguous!!
 			cpu++;
 			if (cpu >= NR_CPUS || !cpu_online(cpu))
 				break;
include/asm-sparc/cpudata.h +1 -0
diff -urp -X dontdiff linux-2.6.14-clean/include/asm-sparc/cpudata.h linux-2.6.14smp/include/asm-sparc/cpudata.h
@@ -18,6 +18,7 @@ typedef struct {
 	unsigned int counter;
 	int prom_node;
 	int mid;
+	int next;
 } cpuinfo_sparc;
 
 DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
include/asm-sparc/smp.h +1 -8
diff -urp -X dontdiff linux-2.6.14-clean/include/asm-sparc/smp.h linux-2.6.14smp/include/asm-sparc/smp.h
@@ -81,16 +81,9 @@ static inline int smp_call_function(void
 	return 0;
 }
 
-extern __volatile__ int __cpu_number_map[NR_CPUS];
-extern __volatile__ int __cpu_logical_map[NR_CPUS];
-
 static inline int cpu_logical_map(int cpu)
 {
-	return __cpu_logical_map[cpu];
-}
-static inline int cpu_number_map(int cpu)
-{
-	return __cpu_number_map[cpu];
+	return cpu;
 }
 
 static inline int hard_smp4m_processor_id(void)
include/asm-sparc/spinlock.h +22 -3
diff -urp -X dontdiff linux-2.6.14-clean/include/asm-sparc/spinlock.h linux-2.6.14smp/include/asm-sparc/spinlock.h
@@ -94,7 +94,7 @@ static inline void __read_lock(raw_rwloc
 #define __raw_read_lock(lock) \
 do {	unsigned long flags; \
 	local_irq_save(flags); \
-	__raw_read_lock(lock); \
+	__read_lock(lock); \
 	local_irq_restore(flags); \
 } while(0)
 
@@ -114,11 +114,11 @@ static inline void __read_unlock(raw_rwl
 #define __raw_read_unlock(lock) \
 do {	unsigned long flags; \
 	local_irq_save(flags); \
-	__raw_read_unlock(lock); \
+	__read_unlock(lock); \
 	local_irq_restore(flags); \
 } while(0)
 
-extern __inline__ void __raw_write_lock(raw_rwlock_t *rw)
+static inline void __raw_write_lock(raw_rwlock_t *rw)
 {
 	register raw_rwlock_t *lp asm("g1");
 	lp = rw;
@@ -131,9 +131,28 @@ extern __inline__ void __raw_write_lock(
 	: "g2", "g4", "memory", "cc");
 }
 
+static inline int __raw_write_trylock(raw_rwlock_t *rw)
+{
+	unsigned int val;
+
+	__asm__ __volatile__("ldstub [%1 + 3], %0"
+			     : "=r" (val)
+			     : "r" (&rw->lock)
+			     : "memory");
+
+	if (val == 0) {
+		val = rw->lock & ~0xff;
+		if (val)
+			((volatile u8*)&rw->lock)[3] = 0;
+	}
+
+	return (val == 0);
+}
+
 #define __raw_write_unlock(rw)	do { (rw)->lock = 0; } while(0)
 
 #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
+#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
 
 #endif /* !(__ASSEMBLY__) */
 
maintainer
#1 lore raw

From: Bob Breuer <[email protected]>
Date: Wed, 25 Jan 2006 16:20:37 -0600

Quoted 9 lines

It may not be ready for upstream merging yet, but it would be helpful to get some review and testing of it.

Todo items:
- IRQ_INPROGRESS flag - use sparc64 irq buckets, or generic irq_desc?
- sun4d
- re-indent large chunks of sun4m_smp.c
- some places assume sequential cpu numbering (i.e. 0,1 instead of 0,2)

Quoted 6 lines

Last I checked (with 2.6.14), random programs segfault with dual HyperSPARC. And with SuperSPARC II's, it seems stable but will eventually die from a write lock error (wrong lock owner or something).

I haven't tried the HyperSPARC + highmem combination recently, so that may still be a problem.

I think this is better than no progress at all, so I'm going to put this patch into 2.6.17

Thanks Bob, and please provide "Signed-off-by: " lines in the future.