summaryrefslogtreecommitdiff
path: root/arch/ppc/kernel/smp-tbsync.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-06-09 04:01:46 (GMT)
committerPaul Mackerras <paulus@samba.org>2008-06-10 11:40:22 (GMT)
commit917f0af9e5a9ceecf9e72537fabb501254ba321d (patch)
tree1ef207755c6d83ce4af93ef2b5e4645eebd65886 /arch/ppc/kernel/smp-tbsync.c
parent0f3d6bcd391b058c619fc30e8022e8a29fbf4bef (diff)
downloadlinux-fsl-qoriq-917f0af9e5a9ceecf9e72537fabb501254ba321d.tar.xz
powerpc: Remove arch/ppc and include/asm-ppc
All the maintained platforms are now in arch/powerpc, so the old arch/ppc stuff can now go away. Acked-by: Adrian Bunk <bunk@kernel.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Becky Bruce <becky.bruce@freescale.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Jochen Friedrich <jochen@scram.de> Acked-by: John Linn <john.linn@xilinx.com> Acked-by: Jon Loeliger <jdl@freescale.com> Acked-by: Josh Boyer <jwboyer@linux.vnet.ibm.com> Acked-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Olof Johansson <olof@lixom.net> Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Acked-by: Scott Wood <scottwood@freescale.com> Acked-by: Sean MacLennan <smaclennan@pikatech.com> Acked-by: Segher Boessenkool <segher@kernel.crashing.org> Acked-by: Stefan Roese <sr@denx.de> Acked-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com> Acked-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc/kernel/smp-tbsync.c')
-rw-r--r--arch/ppc/kernel/smp-tbsync.c180
1 files changed, 0 insertions, 180 deletions
diff --git a/arch/ppc/kernel/smp-tbsync.c b/arch/ppc/kernel/smp-tbsync.c
deleted file mode 100644
index d0cf3f8..0000000
--- a/arch/ppc/kernel/smp-tbsync.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Smp timebase synchronization for ppc.
- *
- * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se)
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/unistd.h>
-#include <linux/init.h>
-#include <asm/atomic.h>
-#include <asm/smp.h>
-#include <asm/time.h>
-
-#define NUM_ITER 300
-
-enum {
- kExit=0, kSetAndTest, kTest
-};
-
-static struct {
- volatile int tbu;
- volatile int tbl;
- volatile int mark;
- volatile int cmd;
- volatile int handshake;
- int filler[3];
-
- volatile int ack;
- int filler2[7];
-
- volatile int race_result;
-} *tbsync;
-
-static volatile int running;
-
-static void __devinit
-enter_contest( int mark, int add )
-{
- while( (int)(get_tbl() - mark) < 0 )
- tbsync->race_result = add;
-}
-
-void __devinit
-smp_generic_take_timebase( void )
-{
- int cmd, tbl, tbu;
- unsigned long flags;
-
- local_irq_save(flags);
- while( !running )
- ;
- rmb();
-
- for( ;; ) {
- tbsync->ack = 1;
- while( !tbsync->handshake )
- ;
- rmb();
-
- cmd = tbsync->cmd;
- tbl = tbsync->tbl;
- tbu = tbsync->tbu;
- tbsync->ack = 0;
- if( cmd == kExit )
- break;
-
- if( cmd == kSetAndTest ) {
- while( tbsync->handshake )
- ;
- asm volatile ("mttbl %0" :: "r" (tbl) );
- asm volatile ("mttbu %0" :: "r" (tbu) );
- } else {
- while( tbsync->handshake )
- ;
- }
- enter_contest( tbsync->mark, -1 );
- }
- local_irq_restore(flags);
-}
-
-static int __devinit
-start_contest( int cmd, int offset, int num )
-{
- int i, tbu, tbl, mark, score=0;
-
- tbsync->cmd = cmd;
-
- local_irq_disable();
- for( i=-3; i<num; ) {
- tbl = get_tbl() + 400;
- tbsync->tbu = tbu = get_tbu();
- tbsync->tbl = tbl + offset;
- tbsync->mark = mark = tbl + 400;
-
- wmb();
-
- tbsync->handshake = 1;
- while( tbsync->ack )
- ;
-
- while( (int)(get_tbl() - tbl) <= 0 )
- ;
- tbsync->handshake = 0;
- enter_contest( mark, 1 );
-
- while( !tbsync->ack )
- ;
-
- if( tbsync->tbu != get_tbu() || ((tbsync->tbl ^ get_tbl()) & 0x80000000) )
- continue;
- if( i++ > 0 )
- score += tbsync->race_result;
- }
- local_irq_enable();
- return score;
-}
-
-void __devinit
-smp_generic_give_timebase( void )
-{
- int i, score, score2, old, min=0, max=5000, offset=1000;
-
- printk("Synchronizing timebase\n");
-
- /* if this fails then this kernel won't work anyway... */
- tbsync = kzalloc( sizeof(*tbsync), GFP_KERNEL );
- mb();
- running = 1;
-
- while( !tbsync->ack )
- ;
-
- /* binary search */
- for( old=-1 ; old != offset ; offset=(min+max)/2 ) {
- score = start_contest( kSetAndTest, offset, NUM_ITER );
-
- printk("score %d, offset %d\n", score, offset );
-
- if( score > 0 )
- max = offset;
- else
- min = offset;
- old = offset;
- }
- score = start_contest( kSetAndTest, min, NUM_ITER );
- score2 = start_contest( kSetAndTest, max, NUM_ITER );
-
- printk( "Min %d (score %d), Max %d (score %d)\n", min, score, max, score2 );
- score = abs( score );
- score2 = abs( score2 );
- offset = (score < score2) ? min : max;
-
- /* guard against inaccurate mttb */
- for( i=0; i<10; i++ ) {
- start_contest( kSetAndTest, offset, NUM_ITER/10 );
-
- if( (score2=start_contest(kTest, offset, NUM_ITER)) < 0 )
- score2 = -score2;
- if( score2 <= score || score2 < 20 )
- break;
- }
- printk("Final offset: %d (%d/%d)\n", offset, score2, NUM_ITER );
-
- /* exiting */
- tbsync->cmd = kExit;
- wmb();
- tbsync->handshake = 1;
- while( tbsync->ack )
- ;
- tbsync->handshake = 0;
- kfree( tbsync );
- tbsync = NULL;
- running = 0;
-
- /* all done */
- smp_tb_synchronized = 1;
-}