Skip to contentSkip to conversation

powerpc 2.6.20-rt8: fix build breakage for PowerPC(ppc64)

PATCH Applied Tsutomu OWA 2 participants 9 messages Mar 7, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover powerpc 2.6.20-rt8: fix build breakage for PowerPC(ppc64)

Hi Ingo,

Please apply.

This series of patches fixes build breakage on arch/powerpc with realtime
preempt patch. This applies on top of linux-2.6.20 and patch-2.6.20-rt8.

Although there has been some efforts to port realtime-preempt patch to
powerpc, build breakage still exists for powerpc (esp. 64bit architecture).

I'll also post these pathes later at CE Linux Forum's wiki page at;
http://tree.celinuxforum.org/CelfPubWiki/RTPatchForPowerPC

Comments and suggestions are welcome.

Thanks in advance.
-- owa
TOSHIBA, Software Engineering Center.

#1 lore raw

PATCH 1/7 powerpc 2.6.20-rt8: fix compile error in bug.h

To fix the following compile error by enclosing it in ifndef __ASSEMBLY__/endif.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/asm-generic/bug.h
include/asm-generic/bug.h: Assembler messages:
include/asm-generic/bug.h:7: Error: Unrecognized opcode: `extern'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-- owa

include/asm-generic/bug.h +2 -0
diff -rup linux-rt8/include/asm-generic/bug.h rt/include/asm-generic/bug.h
@@ -3,7 +3,9 @@
 
 #include <linux/compiler.h>
 
+#ifndef __ASSEMBLY__
 extern void __WARN_ON(const char *func, const char *file, const int line);
+#endif /* __ASSEMBLY__ */
 
 #ifdef CONFIG_BUG
 
#2 lore raw

PATCH 2/7 powerpc 2.6.20-rt8: fix compile error (time.c)

In reply to Tsutomu OWA

To fix the following compile error by replacing the deleted structure member "is_continuous" with "flags".

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - arch/powerpc/kernel/time.c
arch/powerpc/kernel/time.c:938: error: unknown field 'is_continuous' specified in initializer
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-- owa

arch/powerpc/kernel/time.c +1 -1
diff -rup linux-rt8/arch/powerpc/kernel/time.c rt/arch/powerpc/kernel/time.c
@@ -935,7 +935,7 @@ struct clocksource clocksource_timebase 
 	.mask		= (cycle_t)-1,
 	.mult		= 0,
 	.shift		= 22,
-	.is_continuous	= 1,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
 
#3 lore raw

PATCH 3/7 powerpc 2.6.20-rt8: fix compile error (manage.c)

In reply to Tsutomu OWA

To fix the following compile error.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - kernel/irq/manage.c: In function 'irq_set_affinity':
kernel/irq/manage.c:81: error: invalid type argument of '->' kernel/irq/manage.c:82: error: invalid type argument of '->'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-- owa

kernel/irq/manage.c +2 -2
diff -rup linux-rt8/kernel/irq/manage.c rt/kernel/irq/manage.c
@@ -78,8 +78,8 @@ int irq_set_affinity(unsigned int irq, c
 #ifdef CONFIG_GENERIC_PENDING_IRQ
 	set_pending_irq(irq, cpumask);
 #else
-	irq_desc[irq]->affinity = cpumask;
-	irq_desc[irq]->chip->set_affinity(irq, cpumask);
+	desc->affinity = cpumask;
+	desc->chip->set_affinity(irq, cpumask);
 #endif
 	return 0;
 }
#4 lore raw

PATCH 4/7 powerpc 2.6.20-rt8: fix compile error (futex.h)

In reply to Tsutomu OWA

To fix the following compile error by adding dummy functions for now.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/asm-powerpc/futex.h
kernel/built-in.o: In function `fixup_pi_state_owner64':
kernel/futex.c:2380: undefined reference to .futex_atomic_cmpxchg_inatomic64' kernel/built-in.o: In function futex_lock_pi64':
kernel/futex.c:3228: undefined reference to .futex_atomic_cmpxchg_inatomic64' kernel/futex.c:3273: undefined reference to .futex_atomic_cmpxchg_inatomic64' kernel/futex.c:3310: undefined reference to .futex_atomic_cmpxchg_inatomic64' kernel/built-in.o: In function futex_requeue_pi64':
kernel/futex.c:2756: undefined reference to .futex_atomic_cmpxchg_inatomic64' kernel/built-in.o: In function do_futex64':
kernel/futex.c:2547: undefined reference to .futex_atomic_op_inuser64' kernel/futex.c:3446: undefined reference to .futex_atomic_cmpxchg_inatomic64'

	:

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

-- owa

include/asm-powerpc/futex.h +20 -0
diff -rup linux-rt8/include/asm-powerpc/futex.h rt/include/asm-powerpc/futex.h
@@ -113,5 +113,25 @@ futex_atomic_cmpxchg_inatomic(int __user
         return prev;
 }
 
+static inline int
+futex_atomic_op_inuser64 (int encoded_op, u64 __user *uaddr)
+{
+       /* FIXME: implement this at some point! */
+	printk("futex_atomic_op_inuser64: not yet.\n");
+       BUG();
+
+       return 0;
+}
+
+static inline u64
+futex_atomic_cmpxchg_inatomic64(u64 __user *uaddr, u64 oldval, u64 newval)
+{
+       /* FIXME: implement this at some point! */
+	printk("futex_atomic_cmpxchg_inatomic64: not yet.\n");
+       BUG();
+
+       return 0;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_FUTEX_H */
#5 lore raw

PATCH 5/7 powerpc 2.6.20-rt8: fix compile error (spinlock.h)

In reply to Tsutomu OWA

To fix the following compile error by changing names from
__{read,write}_trylock to ___raw_{read,write}_trylock in asm-powerpc/spinlock.h

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/asm-powerpc/spinlock.h
include/linux/spinlock_api_smp.h:49: error: conflicting types for '__read_trylock' include/asm/spinlock.h:183: error: previous definition of '__read_trylock' was here include/linux/spinlock_api_smp.h:50: error: conflicting types for '__write_trylock' include/asm/spinlock.h:207: error: previous definition of '__write_trylock' was here
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-- owa

include/asm-powerpc/spinlock.h +6 -6
diff -rup linux-rt8/include/asm-powerpc/spinlock.h rt/include/asm-powerpc/spinlock.h
@@ -179,7 +179,7 @@ extern void __raw_spin_unlock_wait(__raw
  * This returns the old value in the lock + 1,
  * so we got a read lock if the return value is > 0.
  */
-static long __inline__ __read_trylock(__raw_rwlock_t *rw)
+static long __inline__ ___raw_read_trylock(__raw_rwlock_t *rw)
 {
 	long tmp;
 
@@ -203,7 +203,7 @@ static long __inline__ __read_trylock(__
  * This returns the old value in the lock,
  * so we got the write lock if the return value is 0.
  */
-static __inline__ long __write_trylock(__raw_rwlock_t *rw)
+static __inline__ long ___raw_write_trylock(__raw_rwlock_t *rw)
 {
 	long tmp, token;
 
@@ -226,7 +226,7 @@ static __inline__ long __write_trylock(_
 static void __inline__ __raw_read_lock(__raw_rwlock_t *rw)
 {
 	while (1) {
-		if (likely(__read_trylock(rw) > 0))
+		if (likely(___raw_read_trylock(rw) > 0))
 			break;
 		do {
 			HMT_low();
@@ -240,7 +240,7 @@ static void __inline__ __raw_read_lock(_
 static void __inline__ __raw_write_lock(__raw_rwlock_t *rw)
 {
 	while (1) {
-		if (likely(__write_trylock(rw) == 0))
+		if (likely(___raw_write_trylock(rw) == 0))
 			break;
 		do {
 			HMT_low();
@@ -253,12 +253,12 @@ static void __inline__ __raw_write_lock(
 
 static int __inline__ __raw_read_trylock(__raw_rwlock_t *rw)
 {
-	return __read_trylock(rw) > 0;
+	return ___raw_read_trylock(rw) > 0;
 }
 
 static int __inline__ __raw_write_trylock(__raw_rwlock_t *rw)
 {
-	return __write_trylock(rw) == 0;
+	return ___raw_write_trylock(rw) == 0;
 }
 
 static void __inline__ __raw_read_unlock(__raw_rwlock_t *rw)
#6 lore raw

PATCH 6/7 powerpc 2.6.20-rt8: fix compile error (percpu.h)

In reply to Tsutomu OWA

To fix the following compile error by adding necessary macro definitions
(mostly taken from asm-generic/percpu.h).

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/asm-powerpc/percpu.h
In file included from include/asm/tlb.h:52,

		 from arch/powerpc/mm/mem.c:44:

include/asm-generic/tlb.h:49: error: expected declaration specifiers or '...' before 'mmu_gathers' include/asm-generic/tlb.h:49: warning: data definition has no type or storage class include/asm-generic/tlb.h:49: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU_LOCKED' include/asm-generic/tlb.h: In function 'tlb_gather_mmu':
include/asm-generic/tlb.h:58: warning: implicit declaration of function '__get_cpu_lock' include/asm-generic/tlb.h:58: error: 'mmu_gathers' undeclared (first use in this function) include/asm-generic/tlb.h:58: error: (Each undeclared identifier is reported only once include/asm-generic/tlb.h:58: error: for each function it appears in.)

	:

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

-- owa

include/asm-powerpc/percpu.h +22 -0
diff -rup linux-rt8/include/asm-powerpc/percpu.h rt/include/asm-powerpc/percpu.h
@@ -19,12 +19,24 @@
 /* Separate out the type, so (int[3], foo) works. */
 #define DEFINE_PER_CPU(type, name) \
     __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
+#define DEFINE_PER_CPU_LOCKED(type, name) \
+    __attribute__((__section__(".data.percpu"))) __DEFINE_SPINLOCK(per_cpu_lock__##name##_locked); \
+    __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name##_locked
 
 /* var is in discarded region: offset to particular copy we want */
 #define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
 
+#define per_cpu_lock(var, cpu) \
+    (*RELOC_HIDE(&per_cpu_lock__##var##_locked, __per_cpu_offset(cpu)))
+#define per_cpu_var_locked(var, cpu) \
+    (*RELOC_HIDE(&per_cpu__##var##_locked, __per_cpu_offset(cpu)))
+#define __get_cpu_lock(var, cpu) \
+    per_cpu_lock(var, cpu)
+#define __get_cpu_var_locked(var, cpu) \
+    per_cpu_var_locked(var, cpu)
+
 /* A macro to avoid #include hell... */
 #define percpu_modcopy(pcpudst, src, size)			\
 do {								\
@@ -40,17 +52,27 @@ extern void setup_per_cpu_areas(void);
 
 #define DEFINE_PER_CPU(type, name) \
     __typeof__(type) per_cpu__##name
+#define DEFINE_PER_CPU_LOCKED(type, name) \
+    __DEFINE_SPINLOCK(per_cpu_lock__##name##_locked); \
+    __typeof__(type) per_cpu__##name##_locked
 
 #define per_cpu(var, cpu)			(*((void)(cpu), &per_cpu__##var))
+#define per_cpu_var_locked(var, cpu)		(*((void)(cpu), &per_cpu__##var##_locked))
+
 #define __get_cpu_var(var)			per_cpu__##var
 #define __raw_get_cpu_var(var)			per_cpu__##var
 
 #endif	/* SMP */
 
 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+#define DECLARE_PER_CPU_LOCKED(type, name) \
+    extern spinlock_t per_cpu_lock__##name##_locked; \
+    extern __typeof__(type) per_cpu__##name##_locked
 
 #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
 #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
+#define EXPORT_PER_CPU_LOCKED_SYMBOL(var) EXPORT_SYMBOL(per_cpu_lock__##var##_locked); EXPORT_SYMBOL(per_cpu__##var##_locked)
+#define EXPORT_PER_CPU_LOCKED_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu_lock__##var##_locked); EXPORT_SYMBOL_GPL(per_cpu__##var##_locked)
 
 #else
 #include <asm-generic/percpu.h>
#7 lore raw

PATCH 7/7 powerpc 2.6.20-rt8: fix compile error (hw_irq.h)

In reply to Tsutomu OWA

To fix the following compile error by changing local_irq_restore()
to raw_local_irq_restore().

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/asm-powerpc/hw_irq.h
In file included from include/asm/system.h:9,
from include/linux/list.h:9,
from include/linux/signal.h:8,
from arch/powerpc/kernel/asm-offsets.c:16:
include/asm/hw_irq.h: In function 'local_get_flags':
include/asm/hw_irq.h:23: error: expected expression before '<<' token include/asm/hw_irq.h:24: error: expected expression before '<<' token include/asm/hw_irq.h:25: error: expected expression before ':' token include/asm/hw_irq.h:25: error: expected statement before ')' token
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-- owa

include/asm-powerpc/hw_irq.h +11 -15
diff -rup linux-rt8/include/asm-powerpc/hw_irq.h rt/include/asm-powerpc/hw_irq.h
@@ -16,18 +16,18 @@ extern void timer_interrupt(struct pt_re
 #ifdef CONFIG_PPC64
 #include <asm/paca.h>
 
-static inline unsigned long local_get_flags(void)
+static inline unsigned long raw_local_get_flags(void)
 {
 	unsigned long flags;
 
-<<<<<<< delete extern unsigned long local_get_flags(void);
-<<<<<<< delete extern unsigned long local_irq_disable(void);
+	__asm__ __volatile__("lbz %0,%1(13)"
+	: "=r" (flags)
 	: "i" (offsetof(struct paca_struct, soft_enabled)));
 
 	return flags;
 }
 
-static inline unsigned long local_irq_disable(void)
+static inline unsigned long raw_local_irq_disable(void)
 {
 	unsigned long flags, zero;
 
@@ -39,32 +39,28 @@ static inline unsigned long local_irq_di
 	return flags;
 }
 
-extern void iseries_handle_interrupts(void);
-extern unsigned long raw_local_get_flags(void);
-extern unsigned long raw_local_irq_disable(void);
 extern void raw_local_irq_restore(unsigned long);
+extern void iseries_handle_interrupts(void);
 
-#define raw_local_irq_enable()	raw_local_irq_restore(1)
+#define raw_local_irq_enable()		raw_local_irq_restore(1)
 #define raw_local_save_flags(flags)	((flags) = raw_local_get_flags())
 #define raw_local_irq_save(flags)	((flags) = raw_local_irq_disable())
 
-#define raw_irqs_disabled()			(raw_local_get_flags() == 0)
+#define raw_irqs_disabled()		(raw_local_get_flags() == 0)
 #define raw_irqs_disabled_flags(flags)	((flags) == 0)
 
-#define hard_irq_enable()	__mtmsrd(mfmsr() | MSR_EE, 1)
-#define hard_irq_disable()	__mtmsrd(mfmsr() & ~MSR_EE, 1)
+#define hard_irq_enable()		__mtmsrd(mfmsr() | MSR_EE, 1)
+#define hard_irq_disable()		__mtmsrd(mfmsr() & ~MSR_EE, 1)
 
-#else
+#else /* CONFIG_PPC64 */
 
 #if defined(CONFIG_BOOKE)
 #define SET_MSR_EE(x)	mtmsr(x)
 #define raw_local_irq_restore(flags)	__asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
-<<<<<<< delete #define local_irq_restore(flags) do { \
-#define raw_local_irq_restore(flags) do { \
 #else
 #define SET_MSR_EE(x)	mtmsr(x)
 #define raw_local_irq_restore(flags)	mtmsr(flags)
-#endif
+#endif /* CONFIG_BOOKE */
 
 static inline void raw_local_irq_disable(void)
 {
arch/powerpc/kernel/irq.c +1 -1
diff -rup linux-rt8/arch/powerpc/kernel/irq.c rt/arch/powerpc/kernel/irq.c
@@ -111,7 +111,7 @@ static inline void set_soft_enabled(unsi
 	: : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled)));
 }
 
-void local_irq_restore(unsigned long en)
+void raw_local_irq_restore(unsigned long en)
 {
 	/*
 	 * get_paca()->soft_enabled = en;
arch/powerpc/kernel/head_64.S +1 -1
diff -rup linux-rt8/arch/powerpc/kernel/head_64.S rt/arch/powerpc/kernel/head_64.S
@@ -1385,7 +1385,7 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	 * handles any interrupts pending at this point.
 	 */
 	ld	r3,SOFTE(r1)
-	bl	.local_irq_restore
+	bl	.raw_local_irq_restore
 	b	11f
 
 /* Here we have a page fault that hash_page can't handle. */
arch/powerpc/kernel/ppc_ksyms.c +1 -1
diff -rup linux-rt8/arch/powerpc/kernel/ppc_ksyms.c rt/arch/powerpc/kernel/ppc_ksyms.c
@@ -49,7 +49,7 @@
 #endif
 
 #ifdef CONFIG_PPC64
-EXPORT_SYMBOL(local_irq_restore);
+EXPORT_SYMBOL(raw_local_irq_restore);
 #endif
 
 #ifdef CONFIG_PPC32
Applied
#8 lore raw
In reply to Tsutomu OWA
Quoted 8 lines · Tsutomu OWA

Hi Ingo,

Please apply.

This series of patches fixes build breakage on arch/powerpc with
realtime preempt patch. This applies on top of linux-2.6.20 and patch-2.6.20-rt8.

thanks, applied - these fixes all look straightforward and clean.

Ingo