[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XenPPC] [PATCH/RFC] Handshake with secondary processors
This is a rough first cut at handshaking with the secondary processors. Once we get this right, they will wait on a shared variable, build a stack, and start running C code proper. I am posting this now because I want to make sure we get the register flushes and memory barriers correct. Any comments? The code prints output like this on a JS21: spinning up secondary processor #1: ping = 0: pong = 1 spinning up secondary processor #2: ping = 0: pong = 2 spinning up secondary processor #3: ping = 0: pong = 3 --- boot_of.c | 33 ++++++++++++++++++++++++++++++++- powerpc64/exceptions.S | 23 +++++++++++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-) diff -r 058f2e27476d xen/arch/powerpc/boot_of.c --- a/xen/arch/powerpc/boot_of.c Mon Aug 07 17:49:16 2006 -0500 +++ b/xen/arch/powerpc/boot_of.c Wed Aug 09 23:08:03 2006 -0400 @@ -42,6 +42,7 @@ static char builtin_cmdline[COMMAND_LINE __attribute__((section("__builtin_cmdline"))) = CMDLINE; extern struct ns16550_defaults ns16550; +extern unsigned long __spin_ack; #undef OF_DEBUG @@ -956,7 +957,37 @@ static int __init boot_of_cpus(void) /* FIXME: should not depend on the boot CPU bring the first child */ cpu = of_getpeer(cpu); while (cpu > 0) { - of_start_cpu(cpu, (ulong)spin_start, 0); + unsigned int cpuid; + unsigned long ping, pong, now, then, timeout; + unsigned long *ack = (unsigned long *)&__spin_ack; + + result = of_getprop(cpu, "reg", &cpuid, sizeof(cpuid)); + if (result == OF_FAILURE) of_panic("cpuid lookup failed\n"); + + of_printf("spinning up secondary processor #%d: ", cpuid); + + *ack = 0x0; + ping = *ack; + of_printf("ping = %lx: ", ping); + + mb(); + of_start_cpu(cpu, (ulong)spin_start, cpuid); + + then = mftb(); + timeout = then + 1024; + do { + now = mftb(); + if (now >= timeout) { + of_printf("SKIPPING: "); + pong = ~0x0; + break; + } + + mb(); + pong = *ack; + } while (pong == ping); + of_printf("pong = %lx\n", pong); + cpu = of_getpeer(cpu); } return 1; diff -r 058f2e27476d xen/arch/powerpc/powerpc64/exceptions.S --- a/xen/arch/powerpc/powerpc64/exceptions.S Mon Aug 07 17:49:16 2006 -0500 +++ b/xen/arch/powerpc/powerpc64/exceptions.S Wed Aug 09 21:41:16 2006 -0400 @@ -178,6 +178,25 @@ zero: li r0, 0x0 /* exception vector for GDB stub */ bctr +/* Begin secondary processor spin and ack logic. */ + .globl __spin_ack +__spin_ack: + .llong 0x0 + + .globl spin_start +spin_start: + /* Our physical cpu number is passed in r3. */ + mr r24, r3 + lis r25, __spin_ack@highest + ori r25, r25, __spin_ack@higher + rldicr r25, r25, 32, 31 + oris r25, r25, __spin_ack@h + ori r25, r25, __spin_ack@l + stdu r24, 0(r25) + sync + b . + +/* Begin exception handlers. */ . = 0x100 # System Reset ex_reset: /* XXX thread initialization */ @@ -513,7 +532,3 @@ _GLOBAL(sleep) isync mtmsrd r3 blr - - .globl spin_start -spin_start: - b . _______________________________________________ Xen-ppc-devel mailing list Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ppc-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |