Merge branch 'x86/amd-nb' into x86/apic-cleanups
authorThomas Gleixner <tglx@linutronix.de>
Thu, 9 Dec 2010 17:17:25 +0000 (18:17 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 9 Dec 2010 17:17:25 +0000 (18:17 +0100)
Reason: apic cleanup series depends on x86/apic, x86/amd-nb x86/platform

Conflicts:
arch/x86/include/asm/io_apic.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1  2 
arch/x86/include/asm/apic.h
arch/x86/include/asm/io_apic.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/setup.c

@@@ -141,13 -141,13 +141,13 @@@ static inline void native_apic_msr_writ
  
  static inline u32 native_apic_msr_read(u32 reg)
  {
-       u32 low, high;
+       u64 msr;
  
        if (reg == APIC_DFR)
                return -1;
  
-       rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
-       return low;
+       rdmsrl(APIC_BASE_MSR + (reg >> 4), msr);
+       return (u32)msr;
  }
  
  static inline void native_x2apic_wait_icr_idle(void)
@@@ -181,12 -181,12 +181,12 @@@ extern void enable_x2apic(void)
  extern void x2apic_icr_write(u32 low, u32 id);
  static inline int x2apic_enabled(void)
  {
-       int msr, msr2;
+       u64 msr;
  
        if (!cpu_has_x2apic)
                return 0;
  
-       rdmsr(MSR_IA32_APICBASE, msr, msr2);
+       rdmsrl(MSR_IA32_APICBASE, msr);
        if (msr & X2APIC_ENABLE)
                return 1;
        return 0;
@@@ -238,7 -238,6 +238,7 @@@ extern void setup_boot_APIC_clock(void)
  extern void setup_secondary_APIC_clock(void);
  extern int APIC_init_uniprocessor(void);
  extern void enable_NMI_through_LVT0(void);
 +extern int apic_force_enable(void);
  
  /*
   * On 32bit this is mach-xxx local
@@@ -159,7 -159,7 +159,7 @@@ struct io_apic_irq_attr
  extern int io_apic_set_pci_routing(struct device *dev, int irq,
                 struct io_apic_irq_attr *irq_attr);
  void setup_IO_APIC_irq_extra(u32 gsi);
 -extern void ioapic_init_mappings(void);
 +extern void ioapic_and_gsi_init(void);
  extern void ioapic_insert_resources(void);
  
  extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
@@@ -168,8 -168,10 +168,10 @@@ extern int save_IO_APIC_setup(struct IO
  extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
  extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
  
 -extern void probe_nr_irqs_gsi(void);
+ extern int get_nr_irqs_gsi(void);
  extern void setup_ioapic_ids_from_mpc(void);
 +extern void setup_ioapic_ids_from_mpc_nocheck(void);
  
  struct mp_ioapic_gsi{
        u32 gsi_base;
@@@ -187,8 -189,9 +189,8 @@@ extern void __init pre_init_apic_IRQ0(v
  #define io_apic_assign_pci_irqs 0
  #define setup_ioapic_ids_from_mpc x86_init_noop
  static const int timer_through_8259 = 0;
 -static inline void ioapic_init_mappings(void) { }
 +static inline void ioapic_and_gsi_init(void) { }
  static inline void ioapic_insert_resources(void) { }
 -static inline void probe_nr_irqs_gsi(void)    { }
  #define gsi_top (NR_IRQS_LEGACY)
  static inline int mp_find_ioapic(u32 gsi) { return 0; }
  
@@@ -52,7 -52,6 +52,6 @@@
  #include <asm/mce.h>
  #include <asm/kvm_para.h>
  #include <asm/tsc.h>
- #include <asm/atomic.h>
  
  unsigned int num_processors;
  
@@@ -1531,60 -1530,13 +1530,60 @@@ static int __init detect_init_APIC(void
        return 0;
  }
  #else
 +
 +static int apic_verify(void)
 +{
 +      u32 features, h, l;
 +
 +      /*
 +       * The APIC feature bit should now be enabled
 +       * in `cpuid'
 +       */
 +      features = cpuid_edx(1);
 +      if (!(features & (1 << X86_FEATURE_APIC))) {
 +              pr_warning("Could not enable APIC!\n");
 +              return -1;
 +      }
 +      set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
 +      mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
 +
 +      /* The BIOS may have set up the APIC at some other address */
 +      rdmsr(MSR_IA32_APICBASE, l, h);
 +      if (l & MSR_IA32_APICBASE_ENABLE)
 +              mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
 +
 +      pr_info("Found and enabled local APIC!\n");
 +      return 0;
 +}
 +
 +int apic_force_enable(void)
 +{
 +      u32 h, l;
 +
 +      if (disable_apic)
 +              return -1;
 +
 +      /*
 +       * Some BIOSes disable the local APIC in the APIC_BASE
 +       * MSR. This can only be done in software for Intel P6 or later
 +       * and AMD K7 (Model > 1) or later.
 +       */
 +      rdmsr(MSR_IA32_APICBASE, l, h);
 +      if (!(l & MSR_IA32_APICBASE_ENABLE)) {
 +              pr_info("Local APIC disabled by BIOS -- reenabling.\n");
 +              l &= ~MSR_IA32_APICBASE_BASE;
 +              l |= MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE;
 +              wrmsr(MSR_IA32_APICBASE, l, h);
 +              enabled_via_apicbase = 1;
 +      }
 +      return apic_verify();
 +}
 +
  /*
   * Detect and initialize APIC
   */
  static int __init detect_init_APIC(void)
  {
 -      u32 h, l, features;
 -
        /* Disabled by kernel option? */
        if (disable_apic)
                return -1;
                                "you can enable it with \"lapic\"\n");
                        return -1;
                }
 -              /*
 -               * Some BIOSes disable the local APIC in the APIC_BASE
 -               * MSR. This can only be done in software for Intel P6 or later
 -               * and AMD K7 (Model > 1) or later.
 -               */
 -              rdmsr(MSR_IA32_APICBASE, l, h);
 -              if (!(l & MSR_IA32_APICBASE_ENABLE)) {
 -                      pr_info("Local APIC disabled by BIOS -- reenabling.\n");
 -                      l &= ~MSR_IA32_APICBASE_BASE;
 -                      l |= MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE;
 -                      wrmsr(MSR_IA32_APICBASE, l, h);
 -                      enabled_via_apicbase = 1;
 -              }
 -      }
 -      /*
 -       * The APIC feature bit should now be enabled
 -       * in `cpuid'
 -       */
 -      features = cpuid_edx(1);
 -      if (!(features & (1 << X86_FEATURE_APIC))) {
 -              pr_warning("Could not enable APIC!\n");
 -              return -1;
 +              if (apic_force_enable())
 +                      return -1;
 +      } else {
 +              if (apic_verify())
 +                      return -1;
        }
 -      set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
 -      mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
 -
 -      /* The BIOS may have set up the APIC at some other address */
 -      rdmsr(MSR_IA32_APICBASE, l, h);
 -      if (l & MSR_IA32_APICBASE_ENABLE)
 -              mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
 -
 -      pr_info("Found and enabled local APIC!\n");
  
        apic_pm_activate();
  
@@@ -1934,7 -1934,8 +1934,7 @@@ void disable_IO_APIC(void
   *
   * by Matt Domsch <Matt_Domsch@dell.com>  Tue Dec 21 12:25:05 CST 1999
   */
 -
 -void __init setup_ioapic_ids_from_mpc(void)
 +void __init setup_ioapic_ids_from_mpc_nocheck(void)
  {
        union IO_APIC_reg_00 reg_00;
        physid_mask_t phys_id_present_map;
        unsigned char old_id;
        unsigned long flags;
  
 -      if (acpi_ioapic)
 -              return;
 -      /*
 -       * Don't check I/O APIC IDs for xAPIC systems.  They have
 -       * no meaning without the serial APIC bus.
 -       */
 -      if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
 -              || APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
 -              return;
        /*
         * This is broken; anything with a real cpu count has to
         * circumvent this idiocy regardless.
                        physids_or(phys_id_present_map, phys_id_present_map, tmp);
                }
  
 -
                /*
                 * We need to adjust the IRQ routing table
                 * if the ID changed.
                        apic_printk(APIC_VERBOSE, " ok.\n");
        }
  }
 +
 +void __init setup_ioapic_ids_from_mpc(void)
 +{
 +
 +      if (acpi_ioapic)
 +              return;
 +      /*
 +       * Don't check I/O APIC IDs for xAPIC systems.  They have
 +       * no meaning without the serial APIC bus.
 +       */
 +      if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
 +              || APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
 +              return;
 +      setup_ioapic_ids_from_mpc_nocheck();
 +}
  #endif
  
  int no_timer_check __initdata;
@@@ -3113,7 -3109,7 +3113,7 @@@ void destroy_irq(unsigned int irq
  
        irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
  
-       if (intr_remapping_enabled)
+       if (irq_remapped(cfg))
                free_irte(irq);
        raw_spin_lock_irqsave(&vector_lock, flags);
        __clear_irq_vector(irq, cfg);
@@@ -3335,7 -3331,7 +3335,7 @@@ static int setup_msi_irq(struct pci_de
        return 0;
  }
  
- int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
+ int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
  {
        int node, ret, sub_handle, index = 0;
        unsigned int irq, irq_want;
@@@ -3393,7 -3389,7 +3393,7 @@@ error
        return ret;
  }
  
- void arch_teardown_msi_irq(unsigned int irq)
+ void native_teardown_msi_irq(unsigned int irq)
  {
        destroy_irq(irq);
  }
@@@ -3643,7 -3639,7 +3643,7 @@@ int __init io_apic_get_redir_entries (i
        return reg_01.bits.entries + 1;
  }
  
 -void __init probe_nr_irqs_gsi(void)
 +static void __init probe_nr_irqs_gsi(void)
  {
        int nr;
  
        printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
  }
  
+ int get_nr_irqs_gsi(void)
+ {
+       return nr_irqs_gsi;
+ }
  #ifdef CONFIG_SPARSE_IRQ
  int __init arch_probe_nr_irqs(void)
  {
@@@ -3955,7 -3956,7 +3960,7 @@@ static struct resource * __init ioapic_
        return res;
  }
  
 -void __init ioapic_init_mappings(void)
 +void __init ioapic_and_gsi_init(void)
  {
        unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
        struct resource *ioapic_res;
@@@ -3993,8 -3994,6 +3998,8 @@@ fake_ioapic_page
                ioapic_res->end = ioapic_phys + IO_APIC_SLOT_SIZE - 1;
                ioapic_res++;
        }
 +
 +      probe_nr_irqs_gsi();
  }
  
  void __init ioapic_insert_resources(void)
diff --combined arch/x86/kernel/setup.c
@@@ -694,12 -694,23 +694,23 @@@ static u64 __init get_max_mapped(void
  void __init setup_arch(char **cmdline_p)
  {
        int acpi = 0;
-       int k8 = 0;
+       int amd = 0;
        unsigned long flags;
  
  #ifdef CONFIG_X86_32
        memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
        visws_early_detect();
+       /*
+        * copy kernel address range established so far and switch
+        * to the proper swapper page table
+        */
+       clone_pgd_range(swapper_pg_dir     + KERNEL_PGD_BOUNDARY,
+                       initial_page_table + KERNEL_PGD_BOUNDARY,
+                       KERNEL_PGD_PTRS);
+       load_cr3(swapper_pg_dir);
+       __flush_tlb_all();
  #else
        printk(KERN_INFO "Command line: %s\n", boot_command_line);
  #endif
  
        x86_init.oem.arch_setup();
  
+       resource_alloc_from_bottom = 0;
+       iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
        setup_memory_map();
        parse_setup_data();
        /* update the e820_saved too */
        acpi = acpi_numa_init();
  #endif
  
- #ifdef CONFIG_K8_NUMA
+ #ifdef CONFIG_AMD_NUMA
        if (!acpi)
-               k8 = !k8_numa_init(0, max_pfn);
+               amd = !amd_numa_init(0, max_pfn);
  #endif
  
-       initmem_init(0, max_pfn, acpi, k8);
+       initmem_init(0, max_pfn, acpi, amd);
        memblock_find_dma_reserve();
        dma32_reserve_bootmem();
  
        paging_init();
        x86_init.paging.pagetable_setup_done(swapper_pg_dir);
  
-       setup_trampoline_page_table();
+ #ifdef CONFIG_X86_32
+       /* sync back kernel address range */
+       clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
+                       swapper_pg_dir     + KERNEL_PGD_BOUNDARY,
+                       KERNEL_PGD_PTRS);
+ #endif
  
        tboot_probe();
  
  #endif
  
        init_apic_mappings();
 -      ioapic_init_mappings();
 -
 -      /* need to wait for io_apic is mapped */
 -      probe_nr_irqs_gsi();
 +      ioapic_and_gsi_init();
  
        kvm_guest_init();