Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Apr 2014 19:04:15 +0000 (12:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Apr 2014 19:04:15 +0000 (12:04 -0700)
Pullx86 core platform updates from Peter Anvin:
 "This is the x86/platform branch with the objectionable IOSF patches
  removed.

  What is left is proper memory handling for Intel GPUs, and a change to
  the Calgary IOMMU code which will be required to make kexec work
  sanely on those platforms after some upcoming kexec changes"

* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, calgary: Use 8M TCE table size by default
  x86/gpu: Print the Intel graphics stolen memory range
  x86/gpu: Add Intel graphics stolen memory quirk for gen2 platforms
  x86/gpu: Add vfunc for Intel graphics stolen memory base address

1  2 
arch/x86/kernel/early-quirks.c

@@@ -203,15 -203,18 +203,15 @@@ static void __init intel_remapping_chec
        revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
  
        /*
 -       * Revision 13 of all triggering devices id in this quirk have
 -       * a problem draining interrupts when irq remapping is enabled,
 -       * and should be flagged as broken.  Additionally revisions 0x12
 -       * and 0x22 of device id 0x3405 has this problem.
 +       * Revision <= 13 of all triggering devices id in this quirk
 +       * have a problem draining interrupts when irq remapping is
 +       * enabled, and should be flagged as broken. Additionally
 +       * revision 0x22 of device id 0x3405 has this problem.
         */
 -      if (revision == 0x13)
 +      if (revision <= 0x13)
                set_irq_remapping_broken();
 -      else if ((device == 0x3405) &&
 -          ((revision == 0x12) ||
 -           (revision == 0x22)))
 +      else if (device == 0x3405 && revision == 0x22)
                set_irq_remapping_broken();
 -
  }
  
  /*
   *
   * And yes, so far on current devices the base addr is always under 4G.
   */
- static u32 __init intel_stolen_base(int num, int slot, int func)
+ static u32 __init intel_stolen_base(int num, int slot, int func, size_t stolen_size)
  {
        u32 base;
  
  #define MB(x) (KB (KB (x)))
  #define GB(x) (MB (KB (x)))
  
+ static size_t __init i830_tseg_size(void)
+ {
+       u8 tmp = read_pci_config_byte(0, 0, 0, I830_ESMRAMC);
+       if (!(tmp & TSEG_ENABLE))
+               return 0;
+       if (tmp & I830_TSEG_SIZE_1M)
+               return MB(1);
+       else
+               return KB(512);
+ }
+ static size_t __init i845_tseg_size(void)
+ {
+       u8 tmp = read_pci_config_byte(0, 0, 0, I845_ESMRAMC);
+       if (!(tmp & TSEG_ENABLE))
+               return 0;
+       switch (tmp & I845_TSEG_SIZE_MASK) {
+       case I845_TSEG_SIZE_512K:
+               return KB(512);
+       case I845_TSEG_SIZE_1M:
+               return MB(1);
+       default:
+               WARN_ON(1);
+               return 0;
+       }
+ }
+ static size_t __init i85x_tseg_size(void)
+ {
+       u8 tmp = read_pci_config_byte(0, 0, 0, I85X_ESMRAMC);
+       if (!(tmp & TSEG_ENABLE))
+               return 0;
+       return MB(1);
+ }
+ static size_t __init i830_mem_size(void)
+ {
+       return read_pci_config_byte(0, 0, 0, I830_DRB3) * MB(32);
+ }
+ static size_t __init i85x_mem_size(void)
+ {
+       return read_pci_config_byte(0, 0, 1, I85X_DRB3) * MB(32);
+ }
+ /*
+  * On 830/845/85x the stolen memory base isn't available in any
+  * register. We need to calculate it as TOM-TSEG_SIZE-stolen_size.
+  */
+ static u32 __init i830_stolen_base(int num, int slot, int func, size_t stolen_size)
+ {
+       return i830_mem_size() - i830_tseg_size() - stolen_size;
+ }
+ static u32 __init i845_stolen_base(int num, int slot, int func, size_t stolen_size)
+ {
+       return i830_mem_size() - i845_tseg_size() - stolen_size;
+ }
+ static u32 __init i85x_stolen_base(int num, int slot, int func, size_t stolen_size)
+ {
+       return i85x_mem_size() - i85x_tseg_size() - stolen_size;
+ }
+ static u32 __init i865_stolen_base(int num, int slot, int func, size_t stolen_size)
+ {
+       /*
+        * FIXME is the graphics stolen memory region
+        * always at TOUD? Ie. is it always the last
+        * one to be allocated by the BIOS?
+        */
+       return read_pci_config_16(0, 0, 0, I865_TOUD) << 16;
+ }
+ static size_t __init i830_stolen_size(int num, int slot, int func)
+ {
+       size_t stolen_size;
+       u16 gmch_ctrl;
+       gmch_ctrl = read_pci_config_16(0, 0, 0, I830_GMCH_CTRL);
+       switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
+       case I830_GMCH_GMS_STOLEN_512:
+               stolen_size = KB(512);
+               break;
+       case I830_GMCH_GMS_STOLEN_1024:
+               stolen_size = MB(1);
+               break;
+       case I830_GMCH_GMS_STOLEN_8192:
+               stolen_size = MB(8);
+               break;
+       case I830_GMCH_GMS_LOCAL:
+               /* local memory isn't part of the normal address space */
+               stolen_size = 0;
+               break;
+       default:
+               return 0;
+       }
+       return stolen_size;
+ }
  static size_t __init gen3_stolen_size(int num, int slot, int func)
  {
        size_t stolen_size;
@@@ -310,7 -421,7 +418,7 @@@ static size_t __init gen6_stolen_size(i
        return gmch_ctrl << 25; /* 32 MB units */
  }
  
- static inline size_t gen8_stolen_size(int num, int slot, int func)
+ static size_t gen8_stolen_size(int num, int slot, int func)
  {
        u16 gmch_ctrl;
  
        return gmch_ctrl << 25; /* 32 MB units */
  }
  
- typedef size_t (*stolen_size_fn)(int num, int slot, int func);
+ struct intel_stolen_funcs {
+       size_t (*size)(int num, int slot, int func);
+       u32 (*base)(int num, int slot, int func, size_t size);
+ };
+ static const struct intel_stolen_funcs i830_stolen_funcs = {
+       .base = i830_stolen_base,
+       .size = i830_stolen_size,
+ };
+ static const struct intel_stolen_funcs i845_stolen_funcs = {
+       .base = i845_stolen_base,
+       .size = i830_stolen_size,
+ };
+ static const struct intel_stolen_funcs i85x_stolen_funcs = {
+       .base = i85x_stolen_base,
+       .size = gen3_stolen_size,
+ };
+ static const struct intel_stolen_funcs i865_stolen_funcs = {
+       .base = i865_stolen_base,
+       .size = gen3_stolen_size,
+ };
+ static const struct intel_stolen_funcs gen3_stolen_funcs = {
+       .base = intel_stolen_base,
+       .size = gen3_stolen_size,
+ };
+ static const struct intel_stolen_funcs gen6_stolen_funcs = {
+       .base = intel_stolen_base,
+       .size = gen6_stolen_size,
+ };
+ static const struct intel_stolen_funcs gen8_stolen_funcs = {
+       .base = intel_stolen_base,
+       .size = gen8_stolen_size,
+ };
  
  static struct pci_device_id intel_stolen_ids[] __initdata = {
-       INTEL_I915G_IDS(gen3_stolen_size),
-       INTEL_I915GM_IDS(gen3_stolen_size),
-       INTEL_I945G_IDS(gen3_stolen_size),
-       INTEL_I945GM_IDS(gen3_stolen_size),
-       INTEL_VLV_M_IDS(gen6_stolen_size),
-       INTEL_VLV_D_IDS(gen6_stolen_size),
-       INTEL_PINEVIEW_IDS(gen3_stolen_size),
-       INTEL_I965G_IDS(gen3_stolen_size),
-       INTEL_G33_IDS(gen3_stolen_size),
-       INTEL_I965GM_IDS(gen3_stolen_size),
-       INTEL_GM45_IDS(gen3_stolen_size),
-       INTEL_G45_IDS(gen3_stolen_size),
-       INTEL_IRONLAKE_D_IDS(gen3_stolen_size),
-       INTEL_IRONLAKE_M_IDS(gen3_stolen_size),
-       INTEL_SNB_D_IDS(gen6_stolen_size),
-       INTEL_SNB_M_IDS(gen6_stolen_size),
-       INTEL_IVB_M_IDS(gen6_stolen_size),
-       INTEL_IVB_D_IDS(gen6_stolen_size),
-       INTEL_HSW_D_IDS(gen6_stolen_size),
-       INTEL_HSW_M_IDS(gen6_stolen_size),
-       INTEL_BDW_M_IDS(gen8_stolen_size),
-       INTEL_BDW_D_IDS(gen8_stolen_size)
+       INTEL_I830_IDS(&i830_stolen_funcs),
+       INTEL_I845G_IDS(&i845_stolen_funcs),
+       INTEL_I85X_IDS(&i85x_stolen_funcs),
+       INTEL_I865G_IDS(&i865_stolen_funcs),
+       INTEL_I915G_IDS(&gen3_stolen_funcs),
+       INTEL_I915GM_IDS(&gen3_stolen_funcs),
+       INTEL_I945G_IDS(&gen3_stolen_funcs),
+       INTEL_I945GM_IDS(&gen3_stolen_funcs),
+       INTEL_VLV_M_IDS(&gen6_stolen_funcs),
+       INTEL_VLV_D_IDS(&gen6_stolen_funcs),
+       INTEL_PINEVIEW_IDS(&gen3_stolen_funcs),
+       INTEL_I965G_IDS(&gen3_stolen_funcs),
+       INTEL_G33_IDS(&gen3_stolen_funcs),
+       INTEL_I965GM_IDS(&gen3_stolen_funcs),
+       INTEL_GM45_IDS(&gen3_stolen_funcs),
+       INTEL_G45_IDS(&gen3_stolen_funcs),
+       INTEL_IRONLAKE_D_IDS(&gen3_stolen_funcs),
+       INTEL_IRONLAKE_M_IDS(&gen3_stolen_funcs),
+       INTEL_SNB_D_IDS(&gen6_stolen_funcs),
+       INTEL_SNB_M_IDS(&gen6_stolen_funcs),
+       INTEL_IVB_M_IDS(&gen6_stolen_funcs),
+       INTEL_IVB_D_IDS(&gen6_stolen_funcs),
+       INTEL_HSW_D_IDS(&gen6_stolen_funcs),
+       INTEL_HSW_M_IDS(&gen6_stolen_funcs),
+       INTEL_BDW_M_IDS(&gen8_stolen_funcs),
+       INTEL_BDW_D_IDS(&gen8_stolen_funcs)
  };
  
  static void __init intel_graphics_stolen(int num, int slot, int func)
  
        for (i = 0; i < ARRAY_SIZE(intel_stolen_ids); i++) {
                if (intel_stolen_ids[i].device == device) {
-                       stolen_size_fn stolen_size =
-                               (stolen_size_fn)intel_stolen_ids[i].driver_data;
-                       size = stolen_size(num, slot, func);
-                       start = intel_stolen_base(num, slot, func);
+                       const struct intel_stolen_funcs *stolen_funcs =
+                               (const struct intel_stolen_funcs *)intel_stolen_ids[i].driver_data;
+                       size = stolen_funcs->size(num, slot, func);
+                       start = stolen_funcs->base(num, slot, func, size);
                        if (size && start) {
+                               printk(KERN_INFO "Reserving Intel graphics stolen memory at 0x%x-0x%x\n",
+                                      start, start + (u32)size - 1);
                                /* Mark this space as reserved */
                                e820_add_region(start, size, E820_RESERVED);
                                sanitize_e820_map(e820.map,