Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 21 Oct 2010 20:18:06 +0000 (13:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 21 Oct 2010 20:18:06 +0000 (13:18 -0700)
* 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: Remove stale pmtimer_64.c
  x86, cleanups: Use clear_page/copy_page rather than memset/memcpy
  x86: Remove unnecessary #ifdef ACPI/X86_IO_ACPI
  x86, cleanup: Remove obsolete boot_cpu_id variable

1  2 
arch/x86/kernel/Makefile
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/early-quirks.c
arch/x86/kernel/setup.c
arch/x86/mm/k8topology_64.c

diff --combined arch/x86/kernel/Makefile
@@@ -11,8 -11,6 +11,8 @@@ ifdef CONFIG_FUNCTION_TRACE
  CFLAGS_REMOVE_tsc.o = -pg
  CFLAGS_REMOVE_rtc.o = -pg
  CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
 +CFLAGS_REMOVE_pvclock.o = -pg
 +CFLAGS_REMOVE_kvmclock.o = -pg
  CFLAGS_REMOVE_ftrace.o = -pg
  CFLAGS_REMOVE_early_printk.o = -pg
  endif
@@@ -34,8 -32,7 +34,8 @@@ GCOV_PROFILE_paravirt.o               := 
  obj-y                 := process_$(BITS).o signal.o entry_$(BITS).o
  obj-y                 += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
  obj-y                 += time.o ioport.o ldt.o dumpstack.o
 -obj-y                 += setup.o x86_init.o i8259.o irqinit.o
 +obj-y                 += setup.o x86_init.o i8259.o irqinit.o jump_label.o
 +obj-$(CONFIG_IRQ_WORK)  += irq_work.o
  obj-$(CONFIG_X86_VISWS)       += visws_quirks.o
  obj-$(CONFIG_X86_32)  += probe_roms_32.o
  obj-$(CONFIG_X86_32)  += sys_i386_32.o i386_ksyms_32.o
@@@ -90,7 -87,7 +90,7 @@@ obj-$(CONFIG_EARLY_PRINTK)    += early_pri
  obj-$(CONFIG_HPET_TIMER)      += hpet.o
  obj-$(CONFIG_APB_TIMER)               += apb_timer.o
  
 -obj-$(CONFIG_K8_NB)           += k8.o
 +obj-$(CONFIG_AMD_NB)          += amd_nb.o
  obj-$(CONFIG_DEBUG_RODATA_TEST)       += test_rodata.o
  obj-$(CONFIG_DEBUG_NX_TEST)   += test_nx.o
  
@@@ -123,7 -120,6 +123,6 @@@ obj-$(CONFIG_SWIOTLB)                      += pci-swiotlb.
  # 64 bit specific files
  ifeq ($(CONFIG_X86_64),y)
        obj-$(CONFIG_X86_UV)            += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o
-       obj-$(CONFIG_X86_PM_TIMER)      += pmtimer_64.o
        obj-$(CONFIG_AUDIT)             += audit_64.o
  
        obj-$(CONFIG_GART_IOMMU)        += pci-gart_64.o aperture_64.o
@@@ -162,7 -162,7 +162,7 @@@ int __init arch_early_irq_init(void
  
        cfg = irq_cfgx;
        count = ARRAY_SIZE(irq_cfgx);
-       node= cpu_to_node(boot_cpu_id);
+       node = cpu_to_node(0);
  
        for (i = 0; i < count; i++) {
                desc = irq_to_desc(i);
@@@ -306,19 -306,14 +306,19 @@@ void arch_init_copy_chip_data(struct ir
  
        old_cfg = old_desc->chip_data;
  
 -      memcpy(cfg, old_cfg, sizeof(struct irq_cfg));
 +      cfg->vector = old_cfg->vector;
 +      cfg->move_in_progress = old_cfg->move_in_progress;
 +      cpumask_copy(cfg->domain, old_cfg->domain);
 +      cpumask_copy(cfg->old_domain, old_cfg->old_domain);
  
        init_copy_irq_2_pin(old_cfg, cfg, node);
  }
  
 -static void free_irq_cfg(struct irq_cfg *old_cfg)
 +static void free_irq_cfg(struct irq_cfg *cfg)
  {
 -      kfree(old_cfg);
 +      free_cpumask_var(cfg->domain);
 +      free_cpumask_var(cfg->old_domain);
 +      kfree(cfg);
  }
  
  void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc)
@@@ -1488,7 -1483,7 +1488,7 @@@ static void __init setup_IO_APIC_irqs(v
        int notcon = 0;
        struct irq_desc *desc;
        struct irq_cfg *cfg;
-       int node = cpu_to_node(boot_cpu_id);
+       int node = cpu_to_node(0);
  
        apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
  
  void setup_IO_APIC_irq_extra(u32 gsi)
  {
        int apic_id = 0, pin, idx, irq;
-       int node = cpu_to_node(boot_cpu_id);
+       int node = cpu_to_node(0);
        struct irq_desc *desc;
        struct irq_cfg *cfg;
  
@@@ -1733,8 -1728,6 +1733,8 @@@ __apicdebuginit(void) print_IO_APIC(voi
                struct irq_pin_list *entry;
  
                cfg = desc->chip_data;
 +              if (!cfg)
 +                      continue;
                entry = cfg->irq_2_pin;
                if (!entry)
                        continue;
@@@ -2932,7 -2925,7 +2932,7 @@@ static inline void __init check_timer(v
  {
        struct irq_desc *desc = irq_to_desc(0);
        struct irq_cfg *cfg = desc->chip_data;
-       int node = cpu_to_node(boot_cpu_id);
+       int node = cpu_to_node(0);
        int apic1, pin1, apic2, pin2;
        unsigned long flags;
        int no_pin1 = 0;
@@@ -3286,7 -3279,7 +3286,7 @@@ unsigned int create_irq_nr(unsigned in
  
  int create_irq(void)
  {
-       int node = cpu_to_node(boot_cpu_id);
+       int node = cpu_to_node(0);
        unsigned int irq_want;
        int irq;
  
@@@ -3908,7 -3901,7 +3908,7 @@@ static int __io_apic_set_pci_routing(st
        if (dev)
                node = dev_to_node(dev);
        else
-               node = cpu_to_node(boot_cpu_id);
+               node = cpu_to_node(0);
  
        desc = irq_to_desc_alloc_node(irq, node);
        if (!desc) {
@@@ -148,7 -148,7 +148,7 @@@ static void __cpuinit amd_k7_smp_check(
  {
  #ifdef CONFIG_SMP
        /* calling is from identify_secondary_cpu() ? */
-       if (c->cpu_index == boot_cpu_id)
+       if (!c->cpu_index)
                return;
  
        /*
@@@ -253,51 -253,37 +253,51 @@@ static int __cpuinit nearby_node(int ap
  #endif
  
  /*
 - * Fixup core topology information for AMD multi-node processors.
 - * Assumption: Number of cores in each internal node is the same.
 + * Fixup core topology information for
 + * (1) AMD multi-node processors
 + *     Assumption: Number of cores in each internal node is the same.
 + * (2) AMD processors supporting compute units
   */
  #ifdef CONFIG_X86_HT
 -static void __cpuinit amd_fixup_dcm(struct cpuinfo_x86 *c)
 +static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
  {
 -      unsigned long long value;
 -      u32 nodes, cores_per_node;
 +      u32 nodes;
 +      u8 node_id;
        int cpu = smp_processor_id();
  
 -      if (!cpu_has(c, X86_FEATURE_NODEID_MSR))
 -              return;
 +      /* get information required for multi-node processors */
 +      if (cpu_has(c, X86_FEATURE_TOPOEXT)) {
 +              u32 eax, ebx, ecx, edx;
  
 -      /* fixup topology information only once for a core */
 -      if (cpu_has(c, X86_FEATURE_AMD_DCM))
 -              return;
 +              cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
 +              nodes = ((ecx >> 8) & 7) + 1;
 +              node_id = ecx & 7;
  
 -      rdmsrl(MSR_FAM10H_NODE_ID, value);
 +              /* get compute unit information */
 +              smp_num_siblings = ((ebx >> 8) & 3) + 1;
 +              c->compute_unit_id = ebx & 0xff;
 +      } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
 +              u64 value;
  
 -      nodes = ((value >> 3) & 7) + 1;
 -      if (nodes == 1)
 +              rdmsrl(MSR_FAM10H_NODE_ID, value);
 +              nodes = ((value >> 3) & 7) + 1;
 +              node_id = value & 7;
 +      } else
                return;
  
 -      set_cpu_cap(c, X86_FEATURE_AMD_DCM);
 -      cores_per_node = c->x86_max_cores / nodes;
 +      /* fixup multi-node processor information */
 +      if (nodes > 1) {
 +              u32 cores_per_node;
 +
 +              set_cpu_cap(c, X86_FEATURE_AMD_DCM);
 +              cores_per_node = c->x86_max_cores / nodes;
  
 -      /* store NodeID, use llc_shared_map to store sibling info */
 -      per_cpu(cpu_llc_id, cpu) = value & 7;
 +              /* store NodeID, use llc_shared_map to store sibling info */
 +              per_cpu(cpu_llc_id, cpu) = node_id;
  
 -      /* fixup core id to be in range from 0 to (cores_per_node - 1) */
 -      c->cpu_core_id = c->cpu_core_id % cores_per_node;
 +              /* core id to be in range from 0 to (cores_per_node - 1) */
 +              c->cpu_core_id = c->cpu_core_id % cores_per_node;
 +      }
  }
  #endif
  
@@@ -318,7 -304,9 +318,7 @@@ static void __cpuinit amd_detect_cmp(st
        c->phys_proc_id = c->initial_apicid >> bits;
        /* use socket ID also for last level cache */
        per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
 -      /* fixup topology information on multi-node processors */
 -      if ((c->x86 == 0x10) && (c->x86_model == 9))
 -              amd_fixup_dcm(c);
 +      amd_get_topology(c);
  #endif
  }
  
@@@ -424,23 -412,6 +424,23 @@@ static void __cpuinit early_init_amd(st
                        set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
        }
  #endif
 +
 +      /* We need to do the following only once */
 +      if (c != &boot_cpu_data)
 +              return;
 +
 +      if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
 +
 +              if (c->x86 > 0x10 ||
 +                  (c->x86 == 0x10 && c->x86_model >= 0x2)) {
 +                      u64 val;
 +
 +                      rdmsrl(MSR_K7_HWCR, val);
 +                      if (!(val & BIT(24)))
 +                              printk(KERN_WARNING FW_BUG "TSC doesn't count "
 +                                      "with P0 frequency!\n");
 +              }
 +      }
  }
  
  static void __cpuinit init_amd(struct cpuinfo_x86 *c)
  #endif
  
        if (c->extended_cpuid_level >= 0x80000006) {
 -              if ((c->x86 >= 0x0f) && (cpuid_edx(0x80000006) & 0xf000))
 +              if (cpuid_edx(0x80000006) & 0xf000)
                        num_cache_leaves = 4;
                else
                        num_cache_leaves = 3;
@@@ -698,7 -669,7 +698,7 @@@ bool cpu_has_amd_erratum(const int *err
        }
  
        /* OSVW unavailable or ID unknown, match family-model-stepping range */
 -      ms = (cpu->x86_model << 8) | cpu->x86_mask;
 +      ms = (cpu->x86_model << 4) | cpu->x86_mask;
        while ((range = *erratum++))
                if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
                    (ms >= AMD_MODEL_RANGE_START(range)) &&
@@@ -545,7 -545,7 +545,7 @@@ void __cpuinit cpu_detect(struct cpuinf
        }
  }
  
 -static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
 +void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
  {
        u32 tfms, xlvl;
        u32 ebx;
@@@ -665,7 -665,7 +665,7 @@@ static void __init early_identify_cpu(s
                this_cpu->c_early_init(c);
  
  #ifdef CONFIG_SMP
-       c->cpu_index = boot_cpu_id;
+       c->cpu_index = 0;
  #endif
        filter_cpuid_features(c, false);
  }
@@@ -39,7 -39,6 +39,7 @@@ static void __cpuinit early_init_intel(
                        misc_enable &= ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID;
                        wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
                        c->cpuid_level = cpuid_eax(0);
 +                      get_cpu_cap(c);
                }
        }
  
@@@ -170,7 -169,7 +170,7 @@@ static void __cpuinit intel_smp_check(s
  {
  #ifdef CONFIG_SMP
        /* calling is from identify_secondary_cpu() ? */
-       if (c->cpu_index == boot_cpu_id)
+       if (!c->cpu_index)
                return;
  
        /*
@@@ -18,6 -18,7 +18,6 @@@
  #include <asm/apic.h>
  #include <asm/iommu.h>
  #include <asm/gart.h>
 -#include <asm/hpet.h>
  
  static void __init fix_hypertransport_config(int num, int slot, int func)
  {
@@@ -96,7 -97,6 +96,6 @@@ static void __init nvidia_bugs(int num
  
  }
  
- #if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
  #if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
  static u32 __init ati_ixp4x0_rev(int num, int slot, int func)
  {
        d &= 0xff;
        return d;
  }
- #endif
  
  static void __init ati_bugs(int num, int slot, int func)
  {
@@@ -191,6 -190,21 +189,6 @@@ static void __init ati_bugs_contd(int n
  }
  #endif
  
 -/*
 - * Force the read back of the CMP register in hpet_next_event()
 - * to work around the problem that the CMP register write seems to be
 - * delayed. See hpet_next_event() for details.
 - *
 - * We do this on all SMBUS incarnations for now until we have more
 - * information about the affected chipsets.
 - */
 -static void __init ati_hpet_bugs(int num, int slot, int func)
 -{
 -#ifdef CONFIG_HPET_TIMER
 -      hpet_readback_cmp = 1;
 -#endif
 -}
 -
  #define QFLAG_APPLY_ONCE      0x1
  #define QFLAG_APPLIED         0x2
  #define QFLAG_DONE            (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@@ -220,6 -234,8 +218,6 @@@ static struct chipset early_qrk[] __ini
          PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
        { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
          PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
 -      { PCI_VENDOR_ID_ATI, PCI_ANY_ID,
 -        PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_hpet_bugs },
        {}
  };
  
diff --combined arch/x86/kernel/setup.c
  #include <asm/percpu.h>
  #include <asm/topology.h>
  #include <asm/apicdef.h>
 -#include <asm/k8.h>
 +#include <asm/amd_nb.h>
  #ifdef CONFIG_X86_64
  #include <asm/numa_64.h>
  #endif
  #include <asm/mce.h>
 +#include <asm/alternative.h>
  
  /*
   * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
@@@ -126,7 -125,6 +126,6 @@@ unsigned long max_pfn_mapped
  RESERVE_BRK(dmi_alloc, 65536);
  #endif
  
- unsigned int boot_cpu_id __read_mostly;
  
  static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
  unsigned long _brk_end = (unsigned long)__brk_base;
@@@ -619,7 -617,79 +618,7 @@@ static __init void reserve_ibft_region(
                reserve_early_overlap_ok(addr, addr + size, "ibft");
  }
  
 -#ifdef CONFIG_X86_RESERVE_LOW_64K
 -static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
 -{
 -      printk(KERN_NOTICE
 -              "%s detected: BIOS may corrupt low RAM, working around it.\n",
 -              d->ident);
 -
 -      e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
 -      sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 -
 -      return 0;
 -}
 -#endif
 -
 -/* List of systems that have known low memory corruption BIOS problems */
 -static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
 -#ifdef CONFIG_X86_RESERVE_LOW_64K
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "AMI BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
 -              },
 -      },
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "Phoenix BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
 -              },
 -      },
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "Phoenix/MSC BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix/MSC"),
 -              },
 -      },
 -      /*
 -       * AMI BIOS with low memory corruption was found on Intel DG45ID and
 -       * DG45FC boards.
 -       * It has a different DMI_BIOS_VENDOR = "Intel Corp.", for now we will
 -       * match only DMI_BOARD_NAME and see if there is more bad products
 -       * with this vendor.
 -       */
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "AMI BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_BOARD_NAME, "DG45ID"),
 -              },
 -      },
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "AMI BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_BOARD_NAME, "DG45FC"),
 -              },
 -      },
 -      /*
 -       * The Dell Inspiron Mini 1012 has DMI_BIOS_VENDOR = "Dell Inc.", so
 -       * match on the product name.
 -       */
 -      {
 -              .callback = dmi_low_memory_corruption,
 -              .ident = "Phoenix BIOS",
 -              .matches = {
 -                      DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1012"),
 -              },
 -      },
 -#endif
 -      {}
 -};
 +static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
  
  static void __init trim_bios_range(void)
  {
         * A special case is the first 4Kb of memory;
         * This is a BIOS owned area, not kernel ram, but generally
         * not listed as such in the E820 table.
 +       *
 +       * This typically reserves additional memory (64KiB by default)
 +       * since some BIOSes are known to corrupt low memory.  See the
 +       * Kconfig help text for X86_RESERVE_LOW.
         */
 -      e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
 +      e820_update_range(0, ALIGN(reserve_low, PAGE_SIZE),
 +                        E820_RAM, E820_RESERVED);
 +
        /*
         * special case: Some BIOSen report the PC BIOS
         * area (640->1Mb) as ram even though it is not.
        sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
  }
  
 +static int __init parse_reservelow(char *p)
 +{
 +      unsigned long long size;
 +
 +      if (!p)
 +              return -EINVAL;
 +
 +      size = memparse(p, &p);
 +
 +      if (size < 4096)
 +              size = 4096;
 +
 +      if (size > 640*1024)
 +              size = 640*1024;
 +
 +      reserve_low = size;
 +
 +      return 0;
 +}
 +
 +early_param("reservelow", parse_reservelow);
 +
  /*
   * Determine if we were loaded by an EFI loader.  If so, then we have also been
   * passed the efi memmap, systab, etc., so we should use these data structures
@@@ -683,7 -725,6 +682,7 @@@ void __init setup_arch(char **cmdline_p
  {
        int acpi = 0;
        int k8 = 0;
 +      unsigned long flags;
  
  #ifdef CONFIG_X86_32
        memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
  
        dmi_scan_machine();
  
 -      dmi_check_system(bad_bios_dmi_table);
 -
        /*
         * VMware detection requires dmi to be available, so this
         * needs to be done after dmi_scan_machine, for the BP.
        paging_init();
        x86_init.paging.pagetable_setup_done(swapper_pg_dir);
  
 +      setup_trampoline_page_table();
 +
        tboot_probe();
  
  #ifdef CONFIG_X86_64
        x86_init.oem.banner();
  
        mcheck_init();
 +
 +      local_irq_save(flags);
 +      arch_init_ideal_nop5();
 +      local_irq_restore(flags);
  }
  
  #ifdef CONFIG_X86_32
@@@ -22,7 -22,7 +22,7 @@@
  #include <asm/numa.h>
  #include <asm/mpspec.h>
  #include <asm/apic.h>
 -#include <asm/k8.h>
 +#include <asm/amd_nb.h>
  
  static struct bootnode __initdata nodes[8];
  static nodemask_t __initdata nodes_parsed = NODE_MASK_NONE;
@@@ -54,8 -54,8 +54,8 @@@ static __init int find_northbridge(void
  static __init void early_get_boot_cpu_id(void)
  {
        /*
-        * need to get boot_cpu_id so can use that to create apicid_to_node
-        * in k8_scan_nodes()
+        * need to get the APIC ID of the BSP so can use that to
+        * create apicid_to_node in k8_scan_nodes()
         */
  #ifdef CONFIG_X86_MPPARSE
        /*
@@@ -212,7 -212,7 +212,7 @@@ int __init k8_scan_nodes(void
        bits = boot_cpu_data.x86_coreid_bits;
        cores = (1<<bits);
        apicid_base = 0;
-       /* need to get boot_cpu_id early for system with apicid lifting */
+       /* get the APIC ID of the BSP early for systems with apicid lifting */
        early_get_boot_cpu_id();
        if (boot_cpu_physical_apicid > 0) {
                pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid);