direct-io.hg

changeset 11526:ce9c34c049c5

[POWERPC][XEN] Track the Hard CPUID as configured by the FW

This patch correctly implements and supports hard_smp_processor_id().

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Mon Sep 18 09:23:51 2006 -0400 (2006-09-18)
parents a3762039dc23
children 0bdd578c417f
files xen/arch/powerpc/boot_of.c xen/arch/powerpc/powerpc64/ppc970.c xen/arch/powerpc/setup.c xen/include/asm-powerpc/powerpc64/procarea.h xen/include/asm-powerpc/processor.h xen/include/asm-powerpc/smp.h
line diff
     1.1 --- a/xen/arch/powerpc/boot_of.c	Mon Sep 18 08:14:46 2006 -0400
     1.2 +++ b/xen/arch/powerpc/boot_of.c	Mon Sep 18 09:23:51 2006 -0400
     1.3 @@ -957,21 +957,31 @@ static void boot_of_module(ulong r3, ulo
     1.4  
     1.5  static int __init boot_of_cpus(void)
     1.6  {
     1.7 -    int cpus;
     1.8 -    int cpu, bootcpu, logical;
     1.9 +    int cpus_node;
    1.10 +    int cpu_node, bootcpu_node, logical;
    1.11      int result;
    1.12 +    s32 cpuid;
    1.13      u32 cpu_clock[2];
    1.14 +    extern uint cpu_hard_id[NR_CPUS];
    1.15  
    1.16 -    cpus = of_finddevice("/cpus");
    1.17 -    cpu = of_getchild(cpus);
    1.18 -    result = of_getprop(cpu, "timebase-frequency", &timebase_freq,
    1.19 +    /* Look up which CPU we are running on right now and get all info
    1.20 +     * from there */
    1.21 +    result = of_getprop(bof_chosen, "cpu",
    1.22 +                        &bootcpu_node, sizeof (bootcpu_node));
    1.23 +    if (result == OF_FAILURE)
    1.24 +        of_panic("Failed to look up boot cpu\n");
    1.25 +
    1.26 +    cpu_node = bootcpu_node;
    1.27 +
    1.28 +    result = of_getprop(cpu_node, "timebase-frequency", &timebase_freq,
    1.29              sizeof(timebase_freq));
    1.30      if (result == OF_FAILURE) {
    1.31          of_panic("Couldn't get timebase frequency!\n");
    1.32      }
    1.33      of_printf("OF: timebase-frequency = %d Hz\n", timebase_freq);
    1.34  
    1.35 -    result = of_getprop(cpu, "clock-frequency", &cpu_clock, sizeof(cpu_clock));
    1.36 +    result = of_getprop(cpu_node, "clock-frequency",
    1.37 +                        &cpu_clock, sizeof(cpu_clock));
    1.38      if (result == OF_FAILURE || (result !=4 && result != 8)) {
    1.39          of_panic("Couldn't get clock frequency!\n");
    1.40      }
    1.41 @@ -983,69 +993,79 @@ static int __init boot_of_cpus(void)
    1.42      cpu_khz /= 1000;
    1.43      of_printf("OF: clock-frequency = %ld KHz\n", cpu_khz);
    1.44  
    1.45 -    /* Look up which CPU we are running on right now.  */
    1.46 -    result = of_getprop(bof_chosen, "cpu", &bootcpu, sizeof (bootcpu));
    1.47 -    if (result == OF_FAILURE)
    1.48 -        of_panic("Failed to look up boot cpu\n");
    1.49 -
    1.50 -    cpu = of_getpeer(cpu);
    1.51 -
    1.52 -    /* We want a continuous logical cpu number space.  */
    1.53 +    /* We want a continuous logical cpu number space and we'll make
    1.54 +     * the booting CPU logical 0.  */
    1.55      cpu_set(0, cpu_present_map);
    1.56      cpu_set(0, cpu_online_map);
    1.57      cpu_set(0, cpu_possible_map);
    1.58  
    1.59 -    /* Spin up all CPUS, even if there are more than NR_CPUS, because
    1.60 -     * Open Firmware has them spinning on cache lines which will
    1.61 -     * eventually be scrubbed, which could lead to random CPU activation.
    1.62 +    result = of_getprop(cpu_node, "reg", &cpuid, sizeof(cpuid));
    1.63 +    cpu_hard_id[0] = cpuid;
    1.64 +
    1.65 +    /* Spin up all CPUS, even if there are more than NR_CPUS or we are
    1.66 +     * runnign nosmp, because Open Firmware has them spinning on cache
    1.67 +     * lines which will eventually be scrubbed, which could lead to
    1.68 +     * random CPU activation.
    1.69       */
    1.70 -    for (logical = 1; cpu > 0; logical++) {
    1.71 -        unsigned int cpuid, ping, pong;
    1.72 -        unsigned long now, then, timeout;
    1.73  
    1.74 -        if (cpu == bootcpu) {
    1.75 -            of_printf("skipping boot cpu!\n");
    1.76 -            continue;
    1.77 -        }
    1.78 -
    1.79 -        result = of_getprop(cpu, "reg", &cpuid, sizeof(cpuid));
    1.80 -        if (result == OF_FAILURE)
    1.81 -            of_panic("cpuid lookup failed\n");
    1.82 -
    1.83 -        of_printf("spinning up secondary processor #%d: ", logical);
    1.84 +    /* Find the base of the multi-CPU package node */
    1.85 +    cpus_node = of_finddevice("/cpus");
    1.86 +    if (cpus_node <= 0) {
    1.87 +        of_printf("Single Processor System\n");
    1.88 +        return 1;
    1.89 +    }
    1.90 +    /* Start with the first child */
    1.91 +    cpu_node = of_getchild(cpus_node);
    1.92  
    1.93 -        __spin_ack = ~0x0;
    1.94 -        ping = __spin_ack;
    1.95 -        pong = __spin_ack;
    1.96 -        of_printf("ping = 0x%x: ", ping);
    1.97 -
    1.98 -        mb();
    1.99 -        result = of_start_cpu(cpu, (ulong)spin_start, logical);
   1.100 -        if (result == OF_FAILURE)
   1.101 -            of_panic("start cpu failed\n");
   1.102 +    for (logical = 1; cpu_node > 0; logical++) {
   1.103 +        unsigned int ping, pong;
   1.104 +        unsigned long now, then, timeout;
   1.105 +        
   1.106 +        if (cpu_node == bootcpu_node) {
   1.107 +            /* same CPU as boot CPU shich we have already made 0 so
   1.108 +             * reduce the logical count */
   1.109 +            --logical;
   1.110 +        } else {
   1.111 +            result = of_getprop(cpu_node, "reg", &cpuid, sizeof(cpuid));
   1.112 +            if (result == OF_FAILURE)
   1.113 +                of_panic("cpuid lookup failed\n");
   1.114  
   1.115 -        /* We will give the secondary processor five seconds to reply.  */
   1.116 -        then = mftb();
   1.117 -        timeout = then + (5 * timebase_freq);
   1.118 +            cpu_hard_id[logical] = cpuid;
   1.119 +
   1.120 +            of_printf("spinning up secondary processor #%d: ", logical);
   1.121  
   1.122 -        do {
   1.123 -            now = mftb();
   1.124 -            if (now >= timeout) {
   1.125 -                of_printf("BROKEN: ");
   1.126 -                break;
   1.127 -            }
   1.128 +            __spin_ack = ~0x0;
   1.129 +            ping = __spin_ack;
   1.130 +            pong = __spin_ack;
   1.131 +            of_printf("ping = 0x%x: ", ping);
   1.132  
   1.133              mb();
   1.134 -            pong = __spin_ack;
   1.135 -        } while (pong == ping);
   1.136 -        of_printf("pong = 0x%x\n", pong);
   1.137 +            result = of_start_cpu(cpu_node, (ulong)spin_start, logical);
   1.138 +            if (result == OF_FAILURE)
   1.139 +                of_panic("start cpu failed\n");
   1.140 +
   1.141 +            /* We will give the secondary processor five seconds to reply.  */
   1.142 +            then = mftb();
   1.143 +            timeout = then + (5 * timebase_freq);
   1.144  
   1.145 -        if (pong != ping) {
   1.146 -            cpu_set(logical, cpu_present_map);
   1.147 -            cpu_set(logical, cpu_possible_map);
   1.148 +            do {
   1.149 +                now = mftb();
   1.150 +                if (now >= timeout) {
   1.151 +                    of_printf("BROKEN: ");
   1.152 +                    break;
   1.153 +                }
   1.154 +
   1.155 +                mb();
   1.156 +                pong = __spin_ack;
   1.157 +            } while (pong == ping);
   1.158 +            of_printf("pong = 0x%x\n", pong);
   1.159 +
   1.160 +            if (pong != ping) {
   1.161 +                cpu_set(logical, cpu_present_map);
   1.162 +                cpu_set(logical, cpu_possible_map);
   1.163 +            }
   1.164          }
   1.165 -
   1.166 -        cpu = of_getpeer(cpu);
   1.167 +        cpu_node = of_getpeer(cpu_node);
   1.168      }
   1.169      return 1;
   1.170  }
     2.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Mon Sep 18 08:14:46 2006 -0400
     2.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Mon Sep 18 09:23:51 2006 -0400
     2.3 @@ -145,7 +145,7 @@ void cpu_initialize(int cpuid)
     2.4      mthsprg0((ulong)parea); /* now ready for exceptions */
     2.5  
     2.6      printk("CPU[PIR:%u IPI:%u Logical:%u] Hello World!\n",
     2.7 -           mfpir(), raw_smp_processor_id(), smp_processor_id());
     2.8 +           mfpir(), hard_smp_processor_id(), smp_processor_id());
     2.9  
    2.10  #ifdef DEBUG
    2.11      {
     3.1 --- a/xen/arch/powerpc/setup.c	Mon Sep 18 08:14:46 2006 -0400
     3.2 +++ b/xen/arch/powerpc/setup.c	Mon Sep 18 09:23:51 2006 -0400
     3.3 @@ -74,6 +74,7 @@ ulong oftree;
     3.4  ulong oftree_len;
     3.5  ulong oftree_end;
     3.6  
     3.7 +uint cpu_hard_id[NR_CPUS] __initdata;
     3.8  cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
     3.9  cpumask_t cpu_online_map; /* missing ifdef in schedule.c */
    3.10  cpumask_t cpu_present_map;
    3.11 @@ -227,6 +228,7 @@ static void init_parea(int cpuid)
    3.12                __func__, STACK_ORDER, cpuid);
    3.13  
    3.14      pa->whoami = cpuid;
    3.15 +    pa->hard_id = cpu_hard_id[cpuid];
    3.16      pa->hyp_stack_base = (void *)((ulong)stack + STACK_SIZE);
    3.17  
    3.18      /* This store has the effect of invoking secondary_cpu_init.  */
     4.1 --- a/xen/include/asm-powerpc/powerpc64/procarea.h	Mon Sep 18 08:14:46 2006 -0400
     4.2 +++ b/xen/include/asm-powerpc/powerpc64/procarea.h	Mon Sep 18 09:23:51 2006 -0400
     4.3 @@ -29,6 +29,7 @@ struct gdb_state;
     4.4  struct processor_area
     4.5  {
     4.6      unsigned int whoami;
     4.7 +    unsigned int hard_id;
     4.8      struct vcpu *cur_vcpu;
     4.9      void *hyp_stack_base;
    4.10      ulong saved_regs[2];
     5.1 --- a/xen/include/asm-powerpc/processor.h	Mon Sep 18 08:14:46 2006 -0400
     5.2 +++ b/xen/include/asm-powerpc/processor.h	Mon Sep 18 09:23:51 2006 -0400
     5.3 @@ -38,7 +38,7 @@ struct domain;
     5.4  struct vcpu;
     5.5  struct cpu_user_regs;
     5.6  extern int cpu_machinecheck(struct cpu_user_regs *);
     5.7 -extern int cpu_scom_init(void);
     5.8 +extern void cpu_scom_init(void);
     5.9  extern void show_registers(struct cpu_user_regs *);
    5.10  extern void show_execution_state(struct cpu_user_regs *);
    5.11  extern void show_backtrace(ulong sp, ulong lr, ulong pc);
     6.1 --- a/xen/include/asm-powerpc/smp.h	Mon Sep 18 08:14:46 2006 -0400
     6.2 +++ b/xen/include/asm-powerpc/smp.h	Mon Sep 18 09:23:51 2006 -0400
     6.3 @@ -28,9 +28,9 @@
     6.4  extern int smp_num_siblings;
     6.5  
     6.6  /* revisit when we support SMP */
     6.7 -#define get_hard_smp_processor_id(i) (global_cpu_table[i]->whoami)
     6.8  #define raw_smp_processor_id() (parea->whoami)
     6.9 -#define hard_smp_processor_id() raw_smp_processor_id()
    6.10 +#define get_hard_smp_processor_id(i) (global_cpu_table[i]->hard_id)
    6.11 +#define hard_smp_processor_id() (parea->hard_id)
    6.12  extern cpumask_t cpu_sibling_map[];
    6.13  extern cpumask_t cpu_core_map[];
    6.14  extern void __devinit smp_generic_take_timebase(void);