drm/i915: Extend BIOS stolen mem handling to all platform
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 11 Sep 2014 11:28:08 +0000 (13:28 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 19 Sep 2014 12:41:19 +0000 (14:41 +0200)
Based upon a patch from Deepak, but reworked to only apply on gen7+
and with the logic a bit clarified.

v2: Fix s/SHIFT/MASK/ fumble that Ville spotted.

Cc: Deepak S <deepak.s@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_reg.h

index 21c025a..85fda6b 100644 (file)
@@ -289,6 +289,7 @@ void i915_gem_cleanup_stolen(struct drm_device *dev)
 int i915_gem_init_stolen(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
+       u32 tmp;
        int bios_reserved = 0;
 
 #ifdef CONFIG_INTEL_IOMMU
@@ -308,8 +309,16 @@ int i915_gem_init_stolen(struct drm_device *dev)
        DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
                      dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
 
-       if (IS_VALLEYVIEW(dev))
-               bios_reserved = 1024*1024; /* top 1M on VLV/BYT */
+       if (INTEL_INFO(dev)->gen >= 8) {
+               tmp = I915_READ(GEN7_BIOS_RESERVED);
+               tmp >>= GEN8_BIOS_RESERVED_SHIFT;
+               tmp &= GEN8_BIOS_RESERVED_MASK;
+               bios_reserved = (1024*1024) << tmp;
+       } else if (IS_GEN7(dev)) {
+               tmp = I915_READ(GEN7_BIOS_RESERVED);
+               bios_reserved = tmp & GEN7_BIOS_RESERVED_256K ?
+                       256*1024 : 1024*1024;
+       }
 
        if (WARN_ON(bios_reserved > dev_priv->gtt.stolen_size))
                return 0;
index b65bdfc..ad8179b 100644 (file)
 #define GAB_CTL                                0x24000
 #define   GAB_CTL_CONT_AFTER_PAGEFAULT (1<<8)
 
+#define GEN7_BIOS_RESERVED             0x1082C0
+#define GEN7_BIOS_RESERVED_1M          (0 << 5)
+#define GEN7_BIOS_RESERVED_256K                (1 << 5)
+#define GEN8_BIOS_RESERVED_SHIFT       7
+#define GEN7_BIOS_RESERVED_MASK        0x1
+#define GEN8_BIOS_RESERVED_MASK        0x3
+
+
 /* VGA stuff */
 
 #define VGA_ST01_MDA 0x3ba