x86: mpparse and cstate need to use 32bit apic id
authorKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 11:52:14 +0000 (11:52 +0000)
committerKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 11:52:14 +0000 (11:52 +0000)
Instead of going with mpc_config_processor struct.
that field ony have 8 bits.

We should not change that struct, because it is shared with mptable.

Also need to increase MAX_APICS.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Rather than using a fixed value of 512, make this scale with NR_CPUS
(which obviously still doesn't cover all theoretically possible
systems, but at least allows some build time control).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/mpparse.c
xen/common/sched_sedf.c
xen/include/asm-x86/mach-generic/mach_apic.h
xen/include/asm-x86/mpspec_def.h
xen/include/xen/kernel.h

index 46febb0e0d36b5f810dbdd453fc344e88487c7d7..d43561ddcc1f8407e171bad84025dc5c0e06ebce 100644 (file)
@@ -866,7 +866,7 @@ static void set_cx(
 int get_cpu_id(u8 acpi_id)
 {
     int i;
-    u8 apic_id;
+    u32 apic_id;
 
     apic_id = x86_acpiid_to_apicid[acpi_id];
     if ( apic_id == 0xff )
index 2a41df85351847984b6ff8d1f78ddca8d342027d..b64f9cc2c7e24b8525d275d957b98de99af56bdb 100644 (file)
@@ -99,7 +99,8 @@ static int mpc_record;
 static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata;
 
 /* Return xen's logical cpu_id of the new added cpu or <0 if error */
-static int __devinit MP_processor_info (struct mpc_config_processor *m)
+static int __devinit MP_processor_info_x(struct mpc_config_processor *m,
+                                        u32 apicidx)
 {
        int ver, apicid, cpu = 0;
        physid_mask_t phys_cpu;
@@ -107,7 +108,7 @@ static int __devinit MP_processor_info (struct mpc_config_processor *m)
        if (!(m->mpc_cpuflag & CPU_ENABLED))
                return -EINVAL;
 
-       apicid = mpc_apic_id(m, translation_table[mpc_record]);
+       apicid = mpc_apic_id(m, apicidx, translation_table[mpc_record]);
 
        if (m->mpc_featureflag&(1<<0))
                Dprintk("    Floating point unit present.\n");
@@ -159,7 +160,7 @@ static int __devinit MP_processor_info (struct mpc_config_processor *m)
 
        if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
                Dprintk("    Bootup CPU\n");
-               boot_cpu_physical_apicid = m->mpc_apicid;
+               boot_cpu_physical_apicid = apicid;
        }
 
        ver = m->mpc_apicver;
@@ -170,10 +171,10 @@ static int __devinit MP_processor_info (struct mpc_config_processor *m)
        if (ver == 0x0) {
                printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! "
                                "fixing up to 0x10. (tell your hw vendor)\n",
-                               m->mpc_apicid);
+                               apicid);
                ver = 0x10;
        }
-       apic_version[m->mpc_apicid] = ver;
+       apic_version[apicid] = ver;
 
        phys_cpu = apicid_to_cpu_present(apicid);
        physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu);
@@ -213,6 +214,11 @@ static int __devinit MP_processor_info (struct mpc_config_processor *m)
        return cpu;
 }
 
+static int __devinit MP_processor_info(struct mpc_config_processor *m)
+{
+       return MP_processor_info_x(m, m->mpc_apicid);
+}
+
 static void __init MP_bus_info (struct mpc_config_bus *m)
 {
        char str[7];
@@ -839,7 +845,7 @@ int __devinit mp_register_lapic (
        struct mpc_config_processor processor;
        int                     boot_cpu = 0;
        
-       if (MAX_APICS - id <= 0) {
+       if (MAX_APICS <= id) {
                printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
                        id, MAX_APICS);
                return -EINVAL;
@@ -859,7 +865,7 @@ int __devinit mp_register_lapic (
        processor.mpc_reserved[0] = 0;
        processor.mpc_reserved[1] = 0;
 
-       return MP_processor_info(&processor);
+       return MP_processor_info_x(&processor, id);
 }
 
 void mp_unregister_lapic(uint32_t apic_id, uint32_t cpu)
index 7dde35b912e6e530d7ce4f5ca05f753e8404e0b7..4d95753a9ec3196dafd9421458dcd275b74639e8 100644 (file)
@@ -127,7 +127,6 @@ struct sedf_cpu_info {
 
 #define PERIOD_BEGIN(inf) ((inf)->deadl_abs - (inf)->period)
 
-#define MIN(x,y)    (((x)<(y))?(x):(y))
 #define DIV_UP(x,y) (((x) + (y) - 1) / y)
 
 #define extra_runs(inf)      ((inf->status) & 6)
index 845f25536bd5bb378143de60a2d6698666852525..83783b35469bc12d7b8df45a94fbb6bb87fa3305 100644 (file)
@@ -28,15 +28,15 @@ static inline void enable_apic_mode(void)
 
 extern u32 bios_cpu_apicid[];
 
-static inline int mpc_apic_id(struct mpc_config_processor *m, 
+static inline int mpc_apic_id(struct mpc_config_processor *m, u32 apicid,
                        struct mpc_config_translation *translation_record)
 {
        printk("Processor #%d %d:%d APIC version %d\n",
-                       m->mpc_apicid,
+                       apicid,
                        (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
                        (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
                        m->mpc_apicver);
-       return (m->mpc_apicid);
+       return apicid;
 }
 
 static inline int multi_timer_check(int apic, int irq)
index d348eb73ad2ff08d339c4c6e70e53b7f98bf0361..b17ec4142667dcf98b107755dca875866c999244 100644 (file)
@@ -14,7 +14,7 @@
 #define SMP_MAGIC_IDENT        (('_'<<24)|('P'<<16)|('M'<<8)|'_')
 
 #define MAX_MPC_ENTRY 1024
-#define MAX_APICS      256
+#define MAX_APICS     MAX(256, 4 * NR_CPUS)
 
 struct intel_mp_floating
 {
index 34e831a39a628ab7d1e4bcd2d01e545d5b46af5a..fd03f74c8ba3dab2c7210689f8fa5b88a6167f20 100644 (file)
 #define max_t(type,x,y) \
         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 
+/*
+ * pre-processor, array size, and bit field width suitable variants;
+ * please don't use in "normal" expressions.
+ */
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
 /**
  * container_of - cast a member of a structure out to the containing structure
  *