ia64/xen-unstable

changeset 9582:887ff2d1e382

Simplify the Xen genapic code. Many genapic hooks have been
replaced with unconditional static 'sane' implementations.
Functions relating to interrupt/IPI delivery have been
grouped into two sets: physical delivery and logical-flat
delivery. All subarchitectures use physical delivery except
the basic default subarchitecture.

The main behavioural changes are:
1. Summit no longer uses logical-clustered delivery mode
2. Physical mode no longer makes any pretence to set the
LDR sanely. We never deliver interrupts in logical mode
so this really should not matter.
3. Sanity checking of phys_cpu_present_map is enabled
for all subarchitectures. Really we should have a sane
set of APIC IDs in the system, as we rely on them for
physical delivery mode.
4. We enable 'bigsmp' mode on any system with more than
eight CPUs. The previous xAPIC check was unnecessary,
since our bigsmp mode uses physical delivery, not
logical-clustered.

This all obviously needs testing on some big systems.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Apr 04 15:00:41 2006 +0100 (2006-04-04)
parents 9ae1f9349b76
children 8d08ad8256df
files xen/arch/x86/apic.c xen/arch/x86/cpu/common.c xen/arch/x86/genapic/Makefile xen/arch/x86/genapic/bigsmp.c xen/arch/x86/genapic/default.c xen/arch/x86/genapic/delivery.c xen/arch/x86/genapic/es7000.c xen/arch/x86/genapic/summit.c xen/arch/x86/io_apic.c xen/arch/x86/mpparse.c xen/arch/x86/nmi.c xen/arch/x86/smp.c xen/arch/x86/smpboot.c xen/arch/x86/x86_32/entry.S xen/include/asm-x86/apicdef.h xen/include/asm-x86/genapic.h xen/include/asm-x86/ipi.h xen/include/asm-x86/mach-generic/mach_apic.h xen/include/asm-x86/mach-summit/mach_mpparse.h
line diff
     1.1 --- a/xen/arch/x86/apic.c	Tue Apr 04 14:04:32 2006 +0100
     1.2 +++ b/xen/arch/x86/apic.c	Tue Apr 04 15:00:41 2006 +0100
     1.3 @@ -657,9 +657,10 @@ void __init init_apic_mappings(void)
     1.4       * zeroes page to simulate the local APIC and another
     1.5       * one for the IO-APIC.
     1.6       */
     1.7 -    if (!smp_found_config && detect_init_APIC())
     1.8 +    if (!smp_found_config && detect_init_APIC()) {
     1.9          apic_phys = __pa(alloc_xenheap_page());
    1.10 -    else
    1.11 +        memset(__va(apic_phys), 0, PAGE_SIZE);
    1.12 +    } else
    1.13          apic_phys = mp_lapic_addr;
    1.14  
    1.15      set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
    1.16 @@ -693,6 +694,7 @@ void __init init_apic_mappings(void)
    1.17              } else {
    1.18  fake_ioapic_page:
    1.19                  ioapic_phys = __pa(alloc_xenheap_page());
    1.20 +                memset(__va(ioapic_phys), 0, PAGE_SIZE);
    1.21              }
    1.22              set_fixmap_nocache(idx, ioapic_phys);
    1.23              apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n",
     2.1 --- a/xen/arch/x86/cpu/common.c	Tue Apr 04 14:04:32 2006 +0100
     2.2 +++ b/xen/arch/x86/cpu/common.c	Tue Apr 04 15:00:41 2006 +0100
     2.3 @@ -427,6 +427,17 @@ void __devinit identify_cpu(struct cpuin
     2.4  }
     2.5  
     2.6  #ifdef CONFIG_X86_HT
     2.7 +/* cpuid returns the value latched in the HW at reset, not the APIC ID
     2.8 + * register's value.  For any box whose BIOS changes APIC IDs, like
     2.9 + * clustered APIC systems, we must use hard_smp_processor_id.
    2.10 + *
    2.11 + * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
    2.12 + */
    2.13 +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
    2.14 +{
    2.15 +	return hard_smp_processor_id() >> index_msb;
    2.16 +}
    2.17 +
    2.18  void __devinit detect_ht(struct cpuinfo_x86 *c)
    2.19  {
    2.20  	u32 	eax, ebx, ecx, edx;
     3.1 --- a/xen/arch/x86/genapic/Makefile	Tue Apr 04 14:04:32 2006 +0100
     3.2 +++ b/xen/arch/x86/genapic/Makefile	Tue Apr 04 15:00:41 2006 +0100
     3.3 @@ -2,6 +2,7 @@ include $(BASEDIR)/Rules.mk
     3.4  
     3.5  obj-y += bigsmp.o
     3.6  obj-y += default.o
     3.7 +obj-y += delivery.o
     3.8  obj-y += es7000.o
     3.9  obj-y += es7000plat.o
    3.10  obj-y += probe.o
     4.1 --- a/xen/arch/x86/genapic/bigsmp.c	Tue Apr 04 14:04:32 2006 +0100
     4.2 +++ b/xen/arch/x86/genapic/bigsmp.c	Tue Apr 04 15:00:41 2006 +0100
     4.3 @@ -1,7 +1,3 @@
     4.4 -/* 
     4.5 - * APIC driver for "bigsmp" XAPIC machines with more than 8 virtual CPUs.
     4.6 - * Drives the local APIC in "clustered mode".
     4.7 - */
     4.8  #include <xen/config.h>
     4.9  #include <xen/cpumask.h>
    4.10  #include <asm/current.h>
    4.11 @@ -13,8 +9,6 @@
    4.12  #include <xen/smp.h>
    4.13  #include <xen/init.h>
    4.14  #include <xen/dmi.h>
    4.15 -#include <asm/mach_ipi.h>
    4.16 -#include <asm/mach-bigsmp/mach_apic.h>
    4.17  #include <asm/mach-default/mach_mpparse.h>
    4.18  
    4.19  static int dmi_bigsmp; /* can be set by dmi scanners */
    4.20 @@ -52,5 +46,5 @@ static __init int probe_bigsmp(void)
    4.21  
    4.22  struct genapic apic_bigsmp = {
    4.23  	APIC_INIT("bigsmp", probe_bigsmp),
    4.24 -	.send_ipi_mask = send_IPI_mask_sequence
    4.25 +	GENAPIC_PHYS
    4.26  };
     5.1 --- a/xen/arch/x86/genapic/default.c	Tue Apr 04 14:04:32 2006 +0100
     5.2 +++ b/xen/arch/x86/genapic/default.c	Tue Apr 04 15:00:41 2006 +0100
     5.3 @@ -12,8 +12,6 @@
     5.4  #include <xen/string.h>
     5.5  #include <xen/smp.h>
     5.6  #include <xen/init.h>
     5.7 -#include <asm/mach_ipi.h>
     5.8 -#include <asm/mach-default/mach_apic.h>
     5.9  #include <asm/mach-default/mach_mpparse.h>
    5.10  
    5.11  /* should be called last. */
    5.12 @@ -24,5 +22,5 @@ static __init int probe_default(void)
    5.13  
    5.14  struct genapic apic_default = {
    5.15  	APIC_INIT("default", probe_default),
    5.16 -	.send_ipi_mask = send_IPI_mask_bitmask
    5.17 +	GENAPIC_FLAT
    5.18  };
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/xen/arch/x86/genapic/delivery.c	Tue Apr 04 15:00:41 2006 +0100
     6.3 @@ -0,0 +1,68 @@
     6.4 +#include <xen/config.h>
     6.5 +#include <xen/irq.h>
     6.6 +#include <xen/sched.h>
     6.7 +#include <asm/current.h>
     6.8 +#include <asm/smp.h>
     6.9 +#include <asm/hardirq.h>
    6.10 +#include <mach_apic.h>
    6.11 +
    6.12 +
    6.13 +/*
    6.14 + * LOGICAL FLAT DELIVERY MODE (multicast via bitmask to <= 8 logical APIC IDs).
    6.15 + */
    6.16 +
    6.17 +void init_apic_ldr_flat(void)
    6.18 +{
    6.19 +	unsigned long val;
    6.20 +
    6.21 +	apic_write_around(APIC_DFR, APIC_DFR_FLAT);
    6.22 +	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
    6.23 +	val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
    6.24 +	apic_write_around(APIC_LDR, val);
    6.25 +}
    6.26 +
    6.27 +void clustered_apic_check_flat(void)
    6.28 +{
    6.29 +	printk("Enabling APIC mode:  Flat.  Using %d I/O APICs\n", nr_ioapics);
    6.30 +}
    6.31 +
    6.32 +cpumask_t target_cpus_flat(void)
    6.33 +{
    6.34 +	return cpu_online_map;
    6.35 +} 
    6.36 +
    6.37 +unsigned int cpu_mask_to_apicid_flat(cpumask_t cpumask)
    6.38 +{
    6.39 +	return cpus_addr(cpumask)[0];
    6.40 +}
    6.41 +
    6.42 +
    6.43 +/*
    6.44 + * PHYSICAL DELIVERY MODE (unicast to physical APIC IDs).
    6.45 + */
    6.46 +
    6.47 +void init_apic_ldr_phys(void)
    6.48 +{
    6.49 +	unsigned long val;
    6.50 +	apic_write_around(APIC_DFR, APIC_DFR_FLAT);
    6.51 +	/* A dummy logical ID should be fine. We only deliver in phys mode. */
    6.52 +	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
    6.53 +	apic_write_around(APIC_LDR, val);
    6.54 +}
    6.55 +
    6.56 +void clustered_apic_check_phys(void)
    6.57 +{
    6.58 +	printk("Enabling APIC mode:  Phys.  Using %d I/O APICs\n", nr_ioapics);
    6.59 +}
    6.60 +
    6.61 +cpumask_t target_cpus_phys(void)
    6.62 +{
    6.63 +	/* IRQs will get bound more accurately later. */
    6.64 +	return cpumask_of_cpu(0);
    6.65 +}
    6.66 +
    6.67 +unsigned int cpu_mask_to_apicid_phys(cpumask_t cpumask)
    6.68 +{
    6.69 +	/* As we are using single CPU as destination, pick only one CPU here */
    6.70 +	return cpu_physical_id(first_cpu(cpumask));
    6.71 +}
     7.1 --- a/xen/arch/x86/genapic/es7000.c	Tue Apr 04 14:04:32 2006 +0100
     7.2 +++ b/xen/arch/x86/genapic/es7000.c	Tue Apr 04 15:00:41 2006 +0100
     7.3 @@ -13,8 +13,6 @@
     7.4  #include <xen/string.h>
     7.5  #include <xen/smp.h>
     7.6  #include <xen/init.h>
     7.7 -#include <asm/mach_ipi.h>
     7.8 -#include <asm/mach-es7000/mach_apic.h>
     7.9  #include <asm/mach-es7000/mach_mpparse.h>
    7.10  
    7.11  static __init int probe_es7000(void)
    7.12 @@ -25,5 +23,5 @@ static __init int probe_es7000(void)
    7.13  
    7.14  struct genapic apic_es7000 = {
    7.15  	APIC_INIT("es7000", probe_es7000),
    7.16 -	.send_ipi_mask = send_IPI_mask_sequence
    7.17 +	GENAPIC_PHYS
    7.18  };
     8.1 --- a/xen/arch/x86/genapic/summit.c	Tue Apr 04 14:04:32 2006 +0100
     8.2 +++ b/xen/arch/x86/genapic/summit.c	Tue Apr 04 15:00:41 2006 +0100
     8.3 @@ -12,8 +12,6 @@
     8.4  #include <xen/string.h>
     8.5  #include <xen/smp.h>
     8.6  #include <xen/init.h>
     8.7 -#include <asm/mach_ipi.h>
     8.8 -#include <asm/mach-summit/mach_apic.h>
     8.9  #include <asm/mach-summit/mach_mpparse.h>
    8.10  
    8.11  static __init int probe_summit(void)
    8.12 @@ -24,5 +22,5 @@ static __init int probe_summit(void)
    8.13  
    8.14  struct genapic apic_summit = {
    8.15  	APIC_INIT("summit", probe_summit),
    8.16 -	.send_ipi_mask = send_IPI_mask_sequence
    8.17 +	GENAPIC_PHYS
    8.18  };
     9.1 --- a/xen/arch/x86/io_apic.c	Tue Apr 04 14:04:32 2006 +0100
     9.2 +++ b/xen/arch/x86/io_apic.c	Tue Apr 04 15:00:41 2006 +0100
     9.3 @@ -1736,8 +1736,10 @@ int __init io_apic_get_unique_id (int io
     9.4          spin_unlock_irqrestore(&ioapic_lock, flags);
     9.5  
     9.6          /* Sanity check */
     9.7 -        if (reg_00.bits.ID != apic_id)
     9.8 -            panic("IOAPIC[%d]: Unable change apic_id!\n", ioapic);
     9.9 +        if (reg_00.bits.ID != apic_id) {
    9.10 +            printk("IOAPIC[%d]: Unable to change apic_id!\n", ioapic);
    9.11 +            return -1;
    9.12 +        }
    9.13      }
    9.14  
    9.15      apic_printk(APIC_VERBOSE, KERN_INFO
    10.1 --- a/xen/arch/x86/mpparse.c	Tue Apr 04 14:04:32 2006 +0100
    10.2 +++ b/xen/arch/x86/mpparse.c	Tue Apr 04 15:00:41 2006 +0100
    10.3 @@ -35,7 +35,7 @@
    10.4  
    10.5  /* Have we found an MP table */
    10.6  int smp_found_config;
    10.7 -unsigned int __initdata maxcpus = NR_CPUS;
    10.8 +unsigned int __devinitdata maxcpus = NR_CPUS;
    10.9  
   10.10  #ifdef CONFIG_HOTPLUG_CPU
   10.11  #define CPU_HOTPLUG_ENABLED	(1)
   10.12 @@ -226,16 +226,11 @@ static void __devinit MP_processor_info 
   10.13  	num_processors++;
   10.14  
   10.15  	if (CPU_HOTPLUG_ENABLED || (num_processors > 8)) {
   10.16 -		switch (boot_cpu_data.x86_vendor) {
   10.17 -		case X86_VENDOR_INTEL:
   10.18 -			if (!APIC_XAPIC(ver)) {
   10.19 -				def_to_bigsmp = 0;
   10.20 -				break;
   10.21 -			}
   10.22 -			/* If P4 and above fall through */
   10.23 -		case X86_VENDOR_AMD:
   10.24 -			def_to_bigsmp = 1;
   10.25 -		}
   10.26 +		/*
   10.27 +		 * No need for processor or APIC checks: physical delivery
   10.28 +		 * (bigsmp) mode should always work.
   10.29 +		 */
   10.30 +		def_to_bigsmp = 1;
   10.31  	}
   10.32  	bios_cpu_apicid[num_processors - 1] = m->mpc_apicid;
   10.33  }
   10.34 @@ -916,6 +911,7 @@ void __init mp_register_ioapic (
   10.35  	u32			gsi_base)
   10.36  {
   10.37  	int			idx = 0;
   10.38 +	int			tmpid;
   10.39  
   10.40  	if (nr_ioapics >= MAX_IO_APICS) {
   10.41  		printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
   10.42 @@ -936,9 +932,14 @@ void __init mp_register_ioapic (
   10.43  
   10.44  	set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
   10.45  	if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15))
   10.46 -		mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id);
   10.47 +		tmpid = io_apic_get_unique_id(idx, id);
   10.48  	else
   10.49 -		mp_ioapics[idx].mpc_apicid = id;
   10.50 +		tmpid = id;
   10.51 +	if (tmpid == -1) {
   10.52 +		nr_ioapics--;
   10.53 +		return;
   10.54 +	}
   10.55 +	mp_ioapics[idx].mpc_apicid = tmpid;
   10.56  	mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
   10.57  	
   10.58  	/* 
    11.1 --- a/xen/arch/x86/nmi.c	Tue Apr 04 14:04:32 2006 +0100
    11.2 +++ b/xen/arch/x86/nmi.c	Tue Apr 04 15:00:41 2006 +0100
    11.3 @@ -431,14 +431,14 @@ void nmi_watchdog_tick(struct cpu_user_r
    11.4   */
    11.5  static void do_nmi_trigger(unsigned char key)
    11.6  {
    11.7 -    u32 id = apic_read(APIC_ID);
    11.8 +    u32 id = GET_APIC_ID(apic_read(APIC_ID));
    11.9  
   11.10      printk("Triggering NMI on APIC ID %x\n", id);
   11.11  
   11.12      local_irq_disable();
   11.13      apic_wait_icr_idle();
   11.14      apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(id));
   11.15 -    apic_write_around(APIC_ICR, APIC_DM_NMI | APIC_INT_ASSERT);
   11.16 +    apic_write_around(APIC_ICR, APIC_DM_NMI | APIC_DEST_PHYSICAL);
   11.17      local_irq_enable();
   11.18  }
   11.19  
    12.1 --- a/xen/arch/x86/smp.c	Tue Apr 04 14:04:32 2006 +0100
    12.2 +++ b/xen/arch/x86/smp.c	Tue Apr 04 15:00:41 2006 +0100
    12.3 @@ -20,7 +20,7 @@
    12.4  #include <asm/flushtlb.h>
    12.5  #include <asm/smpboot.h>
    12.6  #include <asm/hardirq.h>
    12.7 -#include <asm/mach_ipi.h>
    12.8 +#include <asm/ipi.h>
    12.9  #include <mach_apic.h>
   12.10  
   12.11  /*
   12.12 @@ -67,7 +67,7 @@
   12.13  
   12.14  static inline int __prepare_ICR (unsigned int shortcut, int vector)
   12.15  {
   12.16 -    return APIC_DM_FIXED | shortcut | vector | APIC_DEST_LOGICAL;
   12.17 +    return APIC_DM_FIXED | shortcut | vector;
   12.18  }
   12.19  
   12.20  static inline int __prepare_ICR2 (unsigned int mask)
   12.21 @@ -85,7 +85,7 @@ static inline void check_IPI_mask(cpumas
   12.22      ASSERT(!cpus_empty(cpumask));
   12.23  }
   12.24  
   12.25 -void send_IPI_mask_bitmask(cpumask_t cpumask, int vector)
   12.26 +void send_IPI_mask_flat(cpumask_t cpumask, int vector)
   12.27  {
   12.28      unsigned long mask = cpus_addr(cpumask)[0];
   12.29      unsigned long cfg;
   12.30 @@ -99,18 +99,18 @@ void send_IPI_mask_bitmask(cpumask_t cpu
   12.31       * Wait for idle.
   12.32       */
   12.33      apic_wait_icr_idle();
   12.34 -		
   12.35 +
   12.36      /*
   12.37       * prepare target chip field
   12.38       */
   12.39      cfg = __prepare_ICR2(mask);
   12.40      apic_write_around(APIC_ICR2, cfg);
   12.41 -		
   12.42 +
   12.43      /*
   12.44       * program the ICR
   12.45       */
   12.46 -    cfg = __prepare_ICR(0, vector);
   12.47 -			
   12.48 +    cfg = __prepare_ICR(0, vector) | APIC_DEST_LOGICAL;
   12.49 +
   12.50      /*
   12.51       * Send the IPI. The write to APIC_ICR fires this off.
   12.52       */
   12.53 @@ -119,7 +119,7 @@ void send_IPI_mask_bitmask(cpumask_t cpu
   12.54      local_irq_restore(flags);
   12.55  }
   12.56  
   12.57 -void send_IPI_mask_sequence(cpumask_t mask, int vector)
   12.58 +void send_IPI_mask_phys(cpumask_t mask, int vector)
   12.59  {
   12.60      unsigned long cfg, flags;
   12.61      unsigned int query_cpu;
   12.62 @@ -140,18 +140,18 @@ void send_IPI_mask_sequence(cpumask_t ma
   12.63           * Wait for idle.
   12.64           */
   12.65          apic_wait_icr_idle();
   12.66 -		
   12.67 +
   12.68          /*
   12.69           * prepare target chip field
   12.70           */
   12.71 -        cfg = __prepare_ICR2(cpu_to_logical_apicid(query_cpu));
   12.72 +        cfg = __prepare_ICR2(cpu_physical_id(query_cpu));
   12.73          apic_write_around(APIC_ICR2, cfg);
   12.74 -		
   12.75 +
   12.76          /*
   12.77           * program the ICR
   12.78           */
   12.79 -        cfg = __prepare_ICR(0, vector);
   12.80 -			
   12.81 +        cfg = __prepare_ICR(0, vector) | APIC_DEST_PHYSICAL;
   12.82 +
   12.83          /*
   12.84           * Send the IPI. The write to APIC_ICR fires this off.
   12.85           */
    13.1 --- a/xen/arch/x86/smpboot.c	Tue Apr 04 14:04:32 2006 +0100
    13.2 +++ b/xen/arch/x86/smpboot.c	Tue Apr 04 15:00:41 2006 +0100
    13.3 @@ -1094,7 +1094,7 @@ static void __init smp_boot_cpus(unsigne
    13.4  		if ((apicid == boot_cpu_apicid) || (apicid == BAD_APICID))
    13.5  			continue;
    13.6  
    13.7 -		if (!check_apicid_present(bit))
    13.8 +		if (!check_apicid_present(apicid))
    13.9  			continue;
   13.10  		if (max_cpus <= cpucount+1)
   13.11  			continue;
    14.1 --- a/xen/arch/x86/x86_32/entry.S	Tue Apr 04 14:04:32 2006 +0100
    14.2 +++ b/xen/arch/x86/x86_32/entry.S	Tue Apr 04 15:00:41 2006 +0100
    14.3 @@ -561,7 +561,7 @@ 1:      movl  %ss:APIC_ICR(%eax),%ebx
    14.4          testl $APIC_ICR_BUSY,%ebx
    14.5          jnz   1b
    14.6          # __send_IPI_shortcut(APIC_DEST_SELF, TRAP_deferred_nmi)
    14.7 -        movl  $(APIC_DM_FIXED | APIC_DEST_SELF | APIC_DEST_LOGICAL | \
    14.8 +        movl  $(APIC_DM_FIXED | APIC_DEST_SELF | APIC_DEST_PHYSICAL | \
    14.9                  TRAP_deferred_nmi),%ss:APIC_ICR(%eax)
   14.10          jmp   restore_all_xen
   14.11  #endif /* !CONFIG_X86_SUPERVISOR_MODE_KERNEL */
    15.1 --- a/xen/include/asm-x86/apicdef.h	Tue Apr 04 14:04:32 2006 +0100
    15.2 +++ b/xen/include/asm-x86/apicdef.h	Tue Apr 04 15:00:41 2006 +0100
    15.3 @@ -62,6 +62,7 @@
    15.4  #define			APIC_INT_ASSERT		0x04000
    15.5  #define			APIC_ICR_BUSY		0x01000
    15.6  #define			APIC_DEST_LOGICAL	0x00800
    15.7 +#define			APIC_DEST_PHYSICAL	0x00000
    15.8  #define			APIC_DM_FIXED		0x00000
    15.9  #define			APIC_DM_LOWEST		0x00100
   15.10  #define			APIC_DM_SMI		0x00200
    16.1 --- a/xen/include/asm-x86/genapic.h	Tue Apr 04 14:04:32 2006 +0100
    16.2 +++ b/xen/include/asm-x86/genapic.h	Tue Apr 04 15:00:41 2006 +0100
    16.3 @@ -21,27 +21,6 @@ struct genapic {
    16.4  	char *name; 
    16.5  	int (*probe)(void); 
    16.6  
    16.7 -	int (*apic_id_registered)(void);
    16.8 -	cpumask_t (*target_cpus)(void);
    16.9 -	int int_delivery_mode;
   16.10 -	int int_dest_mode; 
   16.11 -	int ESR_DISABLE;
   16.12 -	int apic_destination_logical;
   16.13 -	unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
   16.14 -	unsigned long (*check_apicid_present)(int apicid); 
   16.15 -	int no_balance_irq;
   16.16 -	void (*init_apic_ldr)(void);
   16.17 -	physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
   16.18 -
   16.19 -	void (*clustered_apic_check)(void);
   16.20 -	int (*apicid_to_node)(int logical_apicid); 
   16.21 -	int (*cpu_to_logical_apicid)(int cpu);
   16.22 -	int (*cpu_present_to_apicid)(int mps_cpu);
   16.23 -	physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
   16.24 -	int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
   16.25 -	void (*enable_apic_mode)(void);
   16.26 -	u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
   16.27 -
   16.28  	/* When one of the next two hooks returns 1 the genapic
   16.29  	   is switched to this. Essentially they are additional probe 
   16.30  	   functions. */
   16.31 @@ -49,10 +28,14 @@ struct genapic {
   16.32  			      char *productid);
   16.33  	int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
   16.34  
   16.35 +	/* Interrupt delivery parameters ('physical' vs. 'logical flat'). */
   16.36 +	int int_delivery_mode;
   16.37 +	int int_dest_mode; 
   16.38 +	void (*init_apic_ldr)(void);
   16.39 +	void (*clustered_apic_check)(void);
   16.40 +	cpumask_t (*target_cpus)(void);
   16.41  	unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
   16.42 -	
   16.43 -	/* ipi */
   16.44 -	void (*send_ipi_mask)(cpumask_t mask, int vector);
   16.45 +	void (*send_IPI_mask)(cpumask_t mask, int vector);
   16.46  }; 
   16.47  
   16.48  #define APICFUNC(x) .x = x
   16.49 @@ -60,29 +43,37 @@ struct genapic {
   16.50  #define APIC_INIT(aname, aprobe) \
   16.51  	.name = aname, \
   16.52  	.probe = aprobe, \
   16.53 -	.int_delivery_mode = INT_DELIVERY_MODE, \
   16.54 -	.int_dest_mode = INT_DEST_MODE, \
   16.55 -	.no_balance_irq = NO_BALANCE_IRQ, \
   16.56 -	.ESR_DISABLE = esr_disable, \
   16.57 -	.apic_destination_logical = APIC_DEST_LOGICAL, \
   16.58 -	APICFUNC(apic_id_registered), \
   16.59 -	APICFUNC(target_cpus), \
   16.60 -	APICFUNC(check_apicid_used), \
   16.61 -	APICFUNC(check_apicid_present), \
   16.62 -	APICFUNC(init_apic_ldr), \
   16.63 -	APICFUNC(ioapic_phys_id_map), \
   16.64 -	APICFUNC(clustered_apic_check), \
   16.65 -	APICFUNC(apicid_to_node), \
   16.66 -	APICFUNC(cpu_to_logical_apicid), \
   16.67 -	APICFUNC(cpu_present_to_apicid), \
   16.68 -	APICFUNC(apicid_to_cpu_present), \
   16.69 -	APICFUNC(check_phys_apicid_present), \
   16.70  	APICFUNC(mps_oem_check), \
   16.71 -	APICFUNC(cpu_mask_to_apicid), \
   16.72 -	APICFUNC(acpi_madt_oem_check), \
   16.73 -	APICFUNC(enable_apic_mode), \
   16.74 -	APICFUNC(phys_pkg_id)
   16.75 +	APICFUNC(acpi_madt_oem_check)
   16.76  
   16.77  extern struct genapic *genapic;
   16.78  
   16.79 +void init_apic_ldr_flat(void);
   16.80 +void clustered_apic_check_flat(void);
   16.81 +cpumask_t target_cpus_flat(void);
   16.82 +unsigned int cpu_mask_to_apicid_flat(cpumask_t cpumask);
   16.83 +void send_IPI_mask_flat(cpumask_t mask, int vector);
   16.84 +#define GENAPIC_FLAT \
   16.85 +	.int_delivery_mode = dest_LowestPrio, \
   16.86 +	.int_dest_mode = 1 /* logical delivery */, \
   16.87 +	.init_apic_ldr = init_apic_ldr_flat, \
   16.88 +	.clustered_apic_check = clustered_apic_check_flat, \
   16.89 +	.target_cpus = target_cpus_flat, \
   16.90 +	.cpu_mask_to_apicid = cpu_mask_to_apicid_flat, \
   16.91 +	.send_IPI_mask = send_IPI_mask_flat
   16.92 +
   16.93 +void init_apic_ldr_phys(void);
   16.94 +void clustered_apic_check_phys(void);
   16.95 +cpumask_t target_cpus_phys(void);
   16.96 +unsigned int cpu_mask_to_apicid_phys(cpumask_t cpumask);
   16.97 +void send_IPI_mask_phys(cpumask_t mask, int vector);
   16.98 +#define GENAPIC_PHYS \
   16.99 +	.int_delivery_mode = dest_Fixed, \
  16.100 +	.int_dest_mode = 0 /* physical delivery */, \
  16.101 +	.init_apic_ldr = init_apic_ldr_phys, \
  16.102 +	.clustered_apic_check = clustered_apic_check_phys, \
  16.103 +	.target_cpus = target_cpus_phys, \
  16.104 +	.cpu_mask_to_apicid = cpu_mask_to_apicid_phys, \
  16.105 +	.send_IPI_mask = send_IPI_mask_phys
  16.106 +
  16.107  #endif
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/xen/include/asm-x86/ipi.h	Tue Apr 04 15:00:41 2006 +0100
    17.3 @@ -0,0 +1,8 @@
    17.4 +#ifndef __ASM_IPI_H
    17.5 +#define __ASM_IPI_H
    17.6 +
    17.7 +#include <asm/genapic.h>
    17.8 +
    17.9 +#define send_IPI_mask (genapic->send_IPI_mask)
   17.10 +
   17.11 +#endif /* __ASM_IPI_H */
    18.1 --- a/xen/include/asm-x86/mach-bigsmp/mach_apic.h	Tue Apr 04 14:04:32 2006 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,138 +0,0 @@
    18.4 -#ifndef __ASM_MACH_APIC_H
    18.5 -#define __ASM_MACH_APIC_H
    18.6 -
    18.7 -
    18.8 -extern u8 bios_cpu_apicid[];
    18.9 -
   18.10 -#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
   18.11 -#define esr_disable (1)
   18.12 -
   18.13 -static inline int apic_id_registered(void)
   18.14 -{
   18.15 -	return (1);
   18.16 -}
   18.17 -
   18.18 -/* Round robin the irqs amoung the online cpus */
   18.19 -static inline cpumask_t target_cpus(void)
   18.20 -{ 
   18.21 -	static unsigned long cpu = NR_CPUS;
   18.22 -	do {
   18.23 -		if (cpu >= NR_CPUS)
   18.24 -			cpu = first_cpu(cpu_online_map);
   18.25 -		else
   18.26 -			cpu = next_cpu(cpu, cpu_online_map);
   18.27 -	} while (cpu >= NR_CPUS);
   18.28 -	return cpumask_of_cpu(cpu);
   18.29 -}
   18.30 -
   18.31 -#undef APIC_DEST_LOGICAL
   18.32 -#define APIC_DEST_LOGICAL 	0
   18.33 -#define TARGET_CPUS		(target_cpus())
   18.34 -#define APIC_DFR_VALUE		(APIC_DFR_FLAT)
   18.35 -#define INT_DELIVERY_MODE	(dest_Fixed)
   18.36 -#define INT_DEST_MODE		(0)    /* phys delivery to target proc */
   18.37 -#define NO_BALANCE_IRQ		(0)
   18.38 -#define WAKE_SECONDARY_VIA_INIT
   18.39 -
   18.40 -
   18.41 -static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
   18.42 -{
   18.43 -	return (0);
   18.44 -}
   18.45 -
   18.46 -static inline unsigned long check_apicid_present(int bit)
   18.47 -{
   18.48 -	return (1);
   18.49 -}
   18.50 -
   18.51 -static inline unsigned long calculate_ldr(int cpu)
   18.52 -{
   18.53 -	unsigned long val, id;
   18.54 -	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
   18.55 -	id = xapic_phys_to_log_apicid(cpu);
   18.56 -	val |= SET_APIC_LOGICAL_ID(id);
   18.57 -	return val;
   18.58 -}
   18.59 -
   18.60 -/*
   18.61 - * Set up the logical destination ID.
   18.62 - *
   18.63 - * Intel recommends to set DFR, LDR and TPR before enabling
   18.64 - * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
   18.65 - * document number 292116).  So here it goes...
   18.66 - */
   18.67 -static inline void init_apic_ldr(void)
   18.68 -{
   18.69 -	unsigned long val;
   18.70 -	int cpu = smp_processor_id();
   18.71 -
   18.72 -	apic_write_around(APIC_DFR, APIC_DFR_VALUE);
   18.73 -	val = calculate_ldr(cpu);
   18.74 -	apic_write_around(APIC_LDR, val);
   18.75 -}
   18.76 -
   18.77 -static inline void clustered_apic_check(void)
   18.78 -{
   18.79 -	printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
   18.80 -		"Physflat", nr_ioapics);
   18.81 -}
   18.82 -
   18.83 -static inline int apicid_to_node(int logical_apicid)
   18.84 -{
   18.85 -	return (0);
   18.86 -}
   18.87 -
   18.88 -static inline int cpu_present_to_apicid(int mps_cpu)
   18.89 -{
   18.90 -	if (mps_cpu < NR_CPUS)
   18.91 -		return (int) bios_cpu_apicid[mps_cpu];
   18.92 -
   18.93 -	return BAD_APICID;
   18.94 -}
   18.95 -
   18.96 -static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
   18.97 -{
   18.98 -	return physid_mask_of_physid(phys_apicid);
   18.99 -}
  18.100 -
  18.101 -extern u8 cpu_2_logical_apicid[];
  18.102 -/* Mapping from cpu number to logical apicid */
  18.103 -static inline int cpu_to_logical_apicid(int cpu)
  18.104 -{
  18.105 -	if (cpu >= NR_CPUS)
  18.106 -		return BAD_APICID;
  18.107 -	return cpu_physical_id(cpu);
  18.108 -}
  18.109 -
  18.110 -static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  18.111 -{
  18.112 -	/* For clustered we don't have a good way to do this yet - hack */
  18.113 -	return physids_promote(0xFFL);
  18.114 -}
  18.115 -
  18.116 -static inline void enable_apic_mode(void)
  18.117 -{
  18.118 -}
  18.119 -
  18.120 -static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  18.121 -{
  18.122 -	return (1);
  18.123 -}
  18.124 -
  18.125 -/* As we are using single CPU as destination, pick only one CPU here */
  18.126 -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  18.127 -{
  18.128 -	int cpu;
  18.129 -	int apicid;	
  18.130 -
  18.131 -	cpu = first_cpu(cpumask);
  18.132 -	apicid = cpu_to_logical_apicid(cpu);
  18.133 -	return apicid;
  18.134 -}
  18.135 -
  18.136 -static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  18.137 -{
  18.138 -	return cpuid_apic >> index_msb;
  18.139 -}
  18.140 -
  18.141 -#endif /* __ASM_MACH_APIC_H */
    19.1 --- a/xen/include/asm-x86/mach-default/mach_apic.h	Tue Apr 04 14:04:32 2006 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,110 +0,0 @@
    19.4 -#ifndef __ASM_MACH_APIC_H
    19.5 -#define __ASM_MACH_APIC_H
    19.6 -
    19.7 -#include <asm/smp.h>
    19.8 -
    19.9 -#define APIC_DFR_VALUE	(APIC_DFR_FLAT)
   19.10 -
   19.11 -static inline cpumask_t target_cpus(void)
   19.12 -{ 
   19.13 -#ifdef CONFIG_SMP
   19.14 -	return cpu_online_map;
   19.15 -#else
   19.16 -	return cpumask_of_cpu(0);
   19.17 -#endif
   19.18 -} 
   19.19 -#define TARGET_CPUS (target_cpus())
   19.20 -
   19.21 -#define NO_BALANCE_IRQ (0)
   19.22 -#define esr_disable (0)
   19.23 -
   19.24 -#define INT_DELIVERY_MODE dest_LowestPrio
   19.25 -#define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
   19.26 -
   19.27 -static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
   19.28 -{
   19.29 -	return physid_isset(apicid, bitmap);
   19.30 -}
   19.31 -
   19.32 -static inline unsigned long check_apicid_present(int bit)
   19.33 -{
   19.34 -	return physid_isset(bit, phys_cpu_present_map);
   19.35 -}
   19.36 -
   19.37 -/*
   19.38 - * Set up the logical destination ID.
   19.39 - *
   19.40 - * Intel recommends to set DFR, LDR and TPR before enabling
   19.41 - * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
   19.42 - * document number 292116).  So here it goes...
   19.43 - */
   19.44 -static inline void init_apic_ldr(void)
   19.45 -{
   19.46 -	unsigned long val;
   19.47 -
   19.48 -	apic_write_around(APIC_DFR, APIC_DFR_VALUE);
   19.49 -	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
   19.50 -	val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
   19.51 -	apic_write_around(APIC_LDR, val);
   19.52 -}
   19.53 -
   19.54 -static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
   19.55 -{
   19.56 -	return phys_map;
   19.57 -}
   19.58 -
   19.59 -static inline void clustered_apic_check(void)
   19.60 -{
   19.61 -	printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
   19.62 -					"Flat", nr_ioapics);
   19.63 -}
   19.64 -
   19.65 -static inline int apicid_to_node(int logical_apicid)
   19.66 -{
   19.67 -	return 0;
   19.68 -}
   19.69 -
   19.70 -/* Mapping from cpu number to logical apicid */
   19.71 -static inline int cpu_to_logical_apicid(int cpu)
   19.72 -{
   19.73 -	return 1 << cpu;
   19.74 -}
   19.75 -
   19.76 -static inline int cpu_present_to_apicid(int mps_cpu)
   19.77 -{
   19.78 -	if (mps_cpu < get_physical_broadcast())
   19.79 -		return  mps_cpu;
   19.80 -	else
   19.81 -		return BAD_APICID;
   19.82 -}
   19.83 -
   19.84 -static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
   19.85 -{
   19.86 -	return physid_mask_of_physid(phys_apicid);
   19.87 -}
   19.88 -
   19.89 -static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
   19.90 -{
   19.91 -	return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
   19.92 -}
   19.93 -
   19.94 -static inline int apic_id_registered(void)
   19.95 -{
   19.96 -	return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map);
   19.97 -}
   19.98 -
   19.99 -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  19.100 -{
  19.101 -	return cpus_addr(cpumask)[0];
  19.102 -}
  19.103 -
  19.104 -static inline void enable_apic_mode(void)
  19.105 -{
  19.106 -}
  19.107 -
  19.108 -static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  19.109 -{
  19.110 -	return cpuid_apic >> index_msb;
  19.111 -}
  19.112 -
  19.113 -#endif /* __ASM_MACH_APIC_H */
    20.1 --- a/xen/include/asm-x86/mach-es7000/mach_apic.h	Tue Apr 04 14:04:32 2006 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,185 +0,0 @@
    20.4 -#ifndef __ASM_MACH_APIC_H
    20.5 -#define __ASM_MACH_APIC_H
    20.6 -
    20.7 -extern u8 bios_cpu_apicid[];
    20.8 -
    20.9 -#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
   20.10 -#define esr_disable (1)
   20.11 -
   20.12 -static inline int apic_id_registered(void)
   20.13 -{
   20.14 -	        return (1);
   20.15 -}
   20.16 -
   20.17 -static inline cpumask_t target_cpus(void)
   20.18 -{ 
   20.19 -#if defined CONFIG_ES7000_CLUSTERED_APIC
   20.20 -	return CPU_MASK_ALL;
   20.21 -#else
   20.22 -	return cpumask_of_cpu(smp_processor_id());
   20.23 -#endif
   20.24 -}
   20.25 -#define TARGET_CPUS	(target_cpus())
   20.26 -
   20.27 -#if defined CONFIG_ES7000_CLUSTERED_APIC
   20.28 -#define APIC_DFR_VALUE		(APIC_DFR_CLUSTER)
   20.29 -#define INT_DELIVERY_MODE	(dest_LowestPrio)
   20.30 -#define INT_DEST_MODE		(1)    /* logical delivery broadcast to all procs */
   20.31 -#define NO_BALANCE_IRQ 		(1)
   20.32 -#undef  WAKE_SECONDARY_VIA_INIT
   20.33 -#define WAKE_SECONDARY_VIA_MIP
   20.34 -#else
   20.35 -#define APIC_DFR_VALUE		(APIC_DFR_FLAT)
   20.36 -#define INT_DELIVERY_MODE	(dest_Fixed)
   20.37 -#define INT_DEST_MODE		(0)    /* phys delivery to target procs */
   20.38 -#define NO_BALANCE_IRQ 		(0)
   20.39 -#undef  APIC_DEST_LOGICAL
   20.40 -#define APIC_DEST_LOGICAL	0x0
   20.41 -#define WAKE_SECONDARY_VIA_INIT
   20.42 -#endif
   20.43 -
   20.44 -static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
   20.45 -{ 
   20.46 -	return 0;
   20.47 -} 
   20.48 -static inline unsigned long check_apicid_present(int bit) 
   20.49 -{
   20.50 -	return physid_isset(bit, phys_cpu_present_map);
   20.51 -}
   20.52 -
   20.53 -#define apicid_cluster(apicid) (apicid & 0xF0)
   20.54 -
   20.55 -static inline unsigned long calculate_ldr(int cpu)
   20.56 -{
   20.57 -	unsigned long id;
   20.58 -	id = xapic_phys_to_log_apicid(cpu);
   20.59 -	return (SET_APIC_LOGICAL_ID(id));
   20.60 -}
   20.61 -
   20.62 -/*
   20.63 - * Set up the logical destination ID.
   20.64 - *
   20.65 - * Intel recommends to set DFR, LdR and TPR before enabling
   20.66 - * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
   20.67 - * document number 292116).  So here it goes...
   20.68 - */
   20.69 -static inline void init_apic_ldr(void)
   20.70 -{
   20.71 -	unsigned long val;
   20.72 -	int cpu = smp_processor_id();
   20.73 -
   20.74 -	apic_write_around(APIC_DFR, APIC_DFR_VALUE);
   20.75 -	val = calculate_ldr(cpu);
   20.76 -	apic_write_around(APIC_LDR, val);
   20.77 -}
   20.78 -
   20.79 -extern void es7000_sw_apic(void);
   20.80 -static inline void enable_apic_mode(void)
   20.81 -{
   20.82 -	es7000_sw_apic();
   20.83 -	return;
   20.84 -}
   20.85 -
   20.86 -extern int apic_version [MAX_APICS];
   20.87 -static inline void clustered_apic_check(void)
   20.88 -{
   20.89 -	int apic = bios_cpu_apicid[smp_processor_id()];
   20.90 -	printk("Enabling APIC mode:  %s.  Using %d I/O APICs, target cpus %lx\n",
   20.91 -		(apic_version[apic] == 0x14) ? 
   20.92 -		"Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(TARGET_CPUS)[0]);
   20.93 -}
   20.94 -
   20.95 -static inline int apicid_to_node(int logical_apicid)
   20.96 -{
   20.97 -	return 0;
   20.98 -}
   20.99 -
  20.100 -
  20.101 -static inline int cpu_present_to_apicid(int mps_cpu)
  20.102 -{
  20.103 -	if (!mps_cpu)
  20.104 -		return boot_cpu_physical_apicid;
  20.105 -	else if (mps_cpu < NR_CPUS)
  20.106 -		return (int) bios_cpu_apicid[mps_cpu];
  20.107 -	else
  20.108 -		return BAD_APICID;
  20.109 -}
  20.110 -
  20.111 -static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  20.112 -{
  20.113 -	static int id = 0;
  20.114 -	physid_mask_t mask;
  20.115 -	mask = physid_mask_of_physid(id);
  20.116 -	++id;
  20.117 -	return mask;
  20.118 -}
  20.119 -
  20.120 -extern u8 cpu_2_logical_apicid[];
  20.121 -/* Mapping from cpu number to logical apicid */
  20.122 -static inline int cpu_to_logical_apicid(int cpu)
  20.123 -{
  20.124 -       if (cpu >= NR_CPUS)
  20.125 -	       return BAD_APICID;
  20.126 -       return (int)cpu_2_logical_apicid[cpu];
  20.127 -}
  20.128 -
  20.129 -static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  20.130 -{
  20.131 -	/* For clustered we don't have a good way to do this yet - hack */
  20.132 -	return physids_promote(0xff);
  20.133 -}
  20.134 -
  20.135 -extern unsigned int boot_cpu_physical_apicid;
  20.136 -static inline int check_phys_apicid_present(int cpu_physical_apicid)
  20.137 -{
  20.138 -	boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
  20.139 -	return (1);
  20.140 -}
  20.141 -
  20.142 -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  20.143 -{
  20.144 -	int num_bits_set;
  20.145 -	int cpus_found = 0;
  20.146 -	int cpu;
  20.147 -	int apicid;	
  20.148 -
  20.149 -	num_bits_set = cpus_weight(cpumask);
  20.150 -	/* Return id to all */
  20.151 -	if (num_bits_set == NR_CPUS)
  20.152 -#if defined CONFIG_ES7000_CLUSTERED_APIC
  20.153 -		return 0xFF;
  20.154 -#else
  20.155 -		return cpu_to_logical_apicid(0);
  20.156 -#endif
  20.157 -	/* 
  20.158 -	 * The cpus in the mask must all be on the apic cluster.  If are not 
  20.159 -	 * on the same apicid cluster return default value of TARGET_CPUS. 
  20.160 -	 */
  20.161 -	cpu = first_cpu(cpumask);
  20.162 -	apicid = cpu_to_logical_apicid(cpu);
  20.163 -	while (cpus_found < num_bits_set) {
  20.164 -		if (cpu_isset(cpu, cpumask)) {
  20.165 -			int new_apicid = cpu_to_logical_apicid(cpu);
  20.166 -			if (apicid_cluster(apicid) != 
  20.167 -					apicid_cluster(new_apicid)){
  20.168 -				printk ("%s: Not a valid mask!\n",__FUNCTION__);
  20.169 -#if defined CONFIG_ES7000_CLUSTERED_APIC
  20.170 -				return 0xFF;
  20.171 -#else
  20.172 -				return cpu_to_logical_apicid(0);
  20.173 -#endif
  20.174 -			}
  20.175 -			apicid = new_apicid;
  20.176 -			cpus_found++;
  20.177 -		}
  20.178 -		cpu++;
  20.179 -	}
  20.180 -	return apicid;
  20.181 -}
  20.182 -
  20.183 -static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  20.184 -{
  20.185 -	return cpuid_apic >> index_msb;
  20.186 -}
  20.187 -
  20.188 -#endif /* __ASM_MACH_APIC_H */
    21.1 --- a/xen/include/asm-x86/mach-generic/mach_apic.h	Tue Apr 04 14:04:32 2006 +0100
    21.2 +++ b/xen/include/asm-x86/mach-generic/mach_apic.h	Tue Apr 04 15:00:41 2006 +0100
    21.3 @@ -2,28 +2,40 @@
    21.4  #define __ASM_MACH_APIC_H
    21.5  
    21.6  #include <asm/genapic.h>
    21.7 +#include <asm/smp.h>
    21.8  
    21.9 -#define esr_disable (genapic->ESR_DISABLE)
   21.10 -#define NO_BALANCE_IRQ (genapic->no_balance_irq)
   21.11 +/* ESR was originally disabled in Linux for NUMA-Q. Do we really need to? */
   21.12 +#define esr_disable (0)
   21.13 +
   21.14 +/* The following are dependent on APIC delivery mode (logical vs. physical). */
   21.15  #define INT_DELIVERY_MODE (genapic->int_delivery_mode)
   21.16  #define INT_DEST_MODE (genapic->int_dest_mode)
   21.17 -#undef APIC_DEST_LOGICAL
   21.18 -#define APIC_DEST_LOGICAL (genapic->apic_destination_logical)
   21.19  #define TARGET_CPUS	  (genapic->target_cpus())
   21.20 -#define apic_id_registered (genapic->apic_id_registered)
   21.21  #define init_apic_ldr (genapic->init_apic_ldr)
   21.22 -#define ioapic_phys_id_map (genapic->ioapic_phys_id_map)
   21.23  #define clustered_apic_check (genapic->clustered_apic_check) 
   21.24 -#define apicid_to_node (genapic->apicid_to_node)
   21.25 -#define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid) 
   21.26 -#define cpu_present_to_apicid (genapic->cpu_present_to_apicid)
   21.27 -#define apicid_to_cpu_present (genapic->apicid_to_cpu_present)
   21.28 -#define check_apicid_present (genapic->check_apicid_present)
   21.29 -#define check_phys_apicid_present (genapic->check_phys_apicid_present)
   21.30 -#define check_apicid_used (genapic->check_apicid_used)
   21.31  #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
   21.32 -#define enable_apic_mode (genapic->enable_apic_mode)
   21.33 -#define phys_pkg_id (genapic->phys_pkg_id)
   21.34 +
   21.35 +extern void es7000_sw_apic(void);
   21.36 +static inline void enable_apic_mode(void)
   21.37 +{
   21.38 +	es7000_sw_apic();
   21.39 +	return;
   21.40 +}
   21.41 +
   21.42 +/* No sane NUMA support right now. We should parse ACPI SRAT. */
   21.43 +static inline int apicid_to_node(int logical_apicid)
   21.44 +{
   21.45 +	return 0;
   21.46 +}
   21.47 +
   21.48 +extern u8 bios_cpu_apicid[];
   21.49 +static inline int cpu_present_to_apicid(int mps_cpu)
   21.50 +{
   21.51 +	if (mps_cpu < NR_CPUS)
   21.52 +		return (int)bios_cpu_apicid[mps_cpu];
   21.53 +	else
   21.54 +		return BAD_APICID;
   21.55 +}
   21.56  
   21.57  static inline int mpc_apic_id(struct mpc_config_processor *m, 
   21.58  			struct mpc_config_translation *translation_record)
   21.59 @@ -47,4 +59,41 @@ static inline int multi_timer_check(int 
   21.60  
   21.61  extern void generic_bigsmp_probe(void);
   21.62  
   21.63 +/*
   21.64 + * The following functions based around phys_cpu_present_map are disabled in
   21.65 + * some i386 Linux subarchitectures, and in x86_64 'cluster' genapic mode. I'm
   21.66 + * really not sure why, since all local APICs should have distinct physical
   21.67 + * IDs, and we need to know what they are.
   21.68 + */
   21.69 +static inline int apic_id_registered(void)
   21.70 +{
   21.71 +	return physid_isset(GET_APIC_ID(apic_read(APIC_ID)),
   21.72 +			    phys_cpu_present_map);
   21.73 +}
   21.74 +
   21.75 +static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
   21.76 +{
   21.77 +	return phys_map;
   21.78 +}
   21.79 +
   21.80 +static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
   21.81 +{
   21.82 +	return physid_isset(apicid, bitmap);
   21.83 +}
   21.84 +
   21.85 +static inline unsigned long check_apicid_present(int apicid)
   21.86 +{
   21.87 +	return physid_isset(apicid, phys_cpu_present_map);
   21.88 +}
   21.89 +
   21.90 +static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
   21.91 +{
   21.92 +	return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
   21.93 +}
   21.94 +
   21.95 +static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
   21.96 +{
   21.97 +	return physid_mask_of_physid(phys_apicid);
   21.98 +}
   21.99 +
  21.100  #endif /* __ASM_MACH_APIC_H */
    22.1 --- a/xen/include/asm-x86/mach-summit/mach_apic.h	Tue Apr 04 14:04:32 2006 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,167 +0,0 @@
    22.4 -#ifndef __ASM_MACH_APIC_H
    22.5 -#define __ASM_MACH_APIC_H
    22.6 -
    22.7 -#include <xen/config.h>
    22.8 -#include <asm/smp.h>
    22.9 -
   22.10 -#define esr_disable (1)
   22.11 -#define NO_BALANCE_IRQ (0)
   22.12 -
   22.13 -/* In clustered mode, the high nibble of APIC ID is a cluster number.
   22.14 - * The low nibble is a 4-bit bitmap. */
   22.15 -#define XAPIC_DEST_CPUS_SHIFT	4
   22.16 -#define XAPIC_DEST_CPUS_MASK	((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
   22.17 -#define XAPIC_DEST_CLUSTER_MASK	(XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
   22.18 -
   22.19 -#define APIC_DFR_VALUE	(APIC_DFR_CLUSTER)
   22.20 -
   22.21 -static inline cpumask_t target_cpus(void)
   22.22 -{
   22.23 -	/* CPU_MASK_ALL (0xff) has undefined behaviour with
   22.24 -	 * dest_LowestPrio mode logical clustered apic interrupt routing
   22.25 -	 * Just start on cpu 0.  IRQ balancing will spread load
   22.26 -	 */
   22.27 -	return cpumask_of_cpu(0);
   22.28 -} 
   22.29 -#define TARGET_CPUS	(target_cpus())
   22.30 -
   22.31 -#define INT_DELIVERY_MODE (dest_LowestPrio)
   22.32 -#define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
   22.33 -
   22.34 -static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
   22.35 -{
   22.36 -	return 0;
   22.37 -} 
   22.38 -
   22.39 -/* we don't use the phys_cpu_present_map to indicate apicid presence */
   22.40 -static inline unsigned long check_apicid_present(int bit) 
   22.41 -{
   22.42 -	return 1;
   22.43 -}
   22.44 -
   22.45 -#define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
   22.46 -
   22.47 -extern u8 bios_cpu_apicid[];
   22.48 -extern u8 cpu_2_logical_apicid[];
   22.49 -
   22.50 -static inline void init_apic_ldr(void)
   22.51 -{
   22.52 -	unsigned long val, id;
   22.53 -	int i, count;
   22.54 -	u8 lid;
   22.55 -	u8 my_id = (u8)hard_smp_processor_id();
   22.56 -	u8 my_cluster = (u8)apicid_cluster(my_id);
   22.57 -
   22.58 -	/* Create logical APIC IDs by counting CPUs already in cluster. */
   22.59 -	for (count = 0, i = NR_CPUS; --i >= 0; ) {
   22.60 -		lid = cpu_2_logical_apicid[i];
   22.61 -		if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
   22.62 -			++count;
   22.63 -	}
   22.64 -	/* We only have a 4 wide bitmap in cluster mode.  If a deranged
   22.65 -	 * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */
   22.66 -	BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT);
   22.67 -	id = my_cluster | (1UL << count);
   22.68 -	apic_write_around(APIC_DFR, APIC_DFR_VALUE);
   22.69 -	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
   22.70 -	val |= SET_APIC_LOGICAL_ID(id);
   22.71 -	apic_write_around(APIC_LDR, val);
   22.72 -}
   22.73 -
   22.74 -static inline int apic_id_registered(void)
   22.75 -{
   22.76 -	return 1;
   22.77 -}
   22.78 -
   22.79 -static inline void clustered_apic_check(void)
   22.80 -{
   22.81 -	printk("Enabling APIC mode:  Summit.  Using %d I/O APICs\n",
   22.82 -						nr_ioapics);
   22.83 -}
   22.84 -
   22.85 -static inline int apicid_to_node(int logical_apicid)
   22.86 -{
   22.87 -	return logical_apicid >> 5;          /* 2 clusterids per CEC */
   22.88 -}
   22.89 -
   22.90 -/* Mapping from cpu number to logical apicid */
   22.91 -static inline int cpu_to_logical_apicid(int cpu)
   22.92 -{
   22.93 -       if (cpu >= NR_CPUS)
   22.94 -	       return BAD_APICID;
   22.95 -	return (int)cpu_2_logical_apicid[cpu];
   22.96 -}
   22.97 -
   22.98 -static inline int cpu_present_to_apicid(int mps_cpu)
   22.99 -{
  22.100 -	if (mps_cpu < NR_CPUS)
  22.101 -		return (int)bios_cpu_apicid[mps_cpu];
  22.102 -	else
  22.103 -		return BAD_APICID;
  22.104 -}
  22.105 -
  22.106 -static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_id_map)
  22.107 -{
  22.108 -	/* For clustered we don't have a good way to do this yet - hack */
  22.109 -	return physids_promote(0x0F);
  22.110 -}
  22.111 -
  22.112 -static inline physid_mask_t apicid_to_cpu_present(int apicid)
  22.113 -{
  22.114 -	return physid_mask_of_physid(0);
  22.115 -}
  22.116 -
  22.117 -static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  22.118 -{
  22.119 -	return 1;
  22.120 -}
  22.121 -
  22.122 -static inline void enable_apic_mode(void)
  22.123 -{
  22.124 -}
  22.125 -
  22.126 -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  22.127 -{
  22.128 -	int num_bits_set;
  22.129 -	int cpus_found = 0;
  22.130 -	int cpu;
  22.131 -	int apicid;	
  22.132 -
  22.133 -	num_bits_set = cpus_weight(cpumask);
  22.134 -	/* Return id to all */
  22.135 -	if (num_bits_set == NR_CPUS)
  22.136 -		return (int) 0xFF;
  22.137 -	/* 
  22.138 -	 * The cpus in the mask must all be on the apic cluster.  If are not 
  22.139 -	 * on the same apicid cluster return default value of TARGET_CPUS. 
  22.140 -	 */
  22.141 -	cpu = first_cpu(cpumask);
  22.142 -	apicid = cpu_to_logical_apicid(cpu);
  22.143 -	while (cpus_found < num_bits_set) {
  22.144 -		if (cpu_isset(cpu, cpumask)) {
  22.145 -			int new_apicid = cpu_to_logical_apicid(cpu);
  22.146 -			if (apicid_cluster(apicid) != 
  22.147 -					apicid_cluster(new_apicid)){
  22.148 -				printk ("%s: Not a valid mask!\n",__FUNCTION__);
  22.149 -				return 0xFF;
  22.150 -			}
  22.151 -			apicid = apicid | new_apicid;
  22.152 -			cpus_found++;
  22.153 -		}
  22.154 -		cpu++;
  22.155 -	}
  22.156 -	return apicid;
  22.157 -}
  22.158 -
  22.159 -/* cpuid returns the value latched in the HW at reset, not the APIC ID
  22.160 - * register's value.  For any box whose BIOS changes APIC IDs, like
  22.161 - * clustered APIC systems, we must use hard_smp_processor_id.
  22.162 - *
  22.163 - * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
  22.164 - */
  22.165 -static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  22.166 -{
  22.167 -	return hard_smp_processor_id() >> index_msb;
  22.168 -}
  22.169 -
  22.170 -#endif /* __ASM_MACH_APIC_H */
    23.1 --- a/xen/include/asm-x86/mach-summit/mach_mpparse.h	Tue Apr 04 14:04:32 2006 +0100
    23.2 +++ b/xen/include/asm-x86/mach-summit/mach_mpparse.h	Tue Apr 04 15:00:41 2006 +0100
    23.3 @@ -1,8 +1,6 @@
    23.4  #ifndef __ASM_MACH_MPPARSE_H
    23.5  #define __ASM_MACH_MPPARSE_H
    23.6  
    23.7 -#include <mach_apic.h>
    23.8 -
    23.9  extern int use_cyclone;
   23.10  
   23.11  #ifdef CONFIG_X86_SUMMIT_NUMA
    24.1 --- a/xen/include/asm-x86/mach_ipi.h	Tue Apr 04 14:04:32 2006 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,11 +0,0 @@
    24.4 -#ifndef __ASM_MACH_IPI_H
    24.5 -#define __ASM_MACH_IPI_H
    24.6 -
    24.7 -#include <asm/genapic.h>
    24.8 -
    24.9 -void send_IPI_mask_bitmask(cpumask_t mask, int vector);
   24.10 -void send_IPI_mask_sequence(cpumask_t mask, int vector);
   24.11 -
   24.12 -#define send_IPI_mask (genapic->send_ipi_mask)
   24.13 -
   24.14 -#endif /* __ASM_MACH_IPI_H */