drm/i915: use the ICL stolen memory
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 4 May 2018 20:32:52 +0000 (13:32 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 10 Jul 2018 23:29:56 +0000 (16:29 -0700)
Now that our stolen memory is already reserved by the x86 subsystem
(since commit "x86/gpu: reserve ICL's graphics stolen memory"), make
use of it.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: x86@kernel.org
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180504203252.28048-2-paulo.r.zanoni@intel.com
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_reg.h

index 055f8687776d0317f6c8363228e63833482c1578..53440bf876501ced342bf8d931af8b64fc8e564e 100644 (file)
@@ -344,6 +344,35 @@ static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
        *size = stolen_top - *base;
 }
 
+static void icl_get_stolen_reserved(struct drm_i915_private *dev_priv,
+                                   resource_size_t *base,
+                                   resource_size_t *size)
+{
+       u64 reg_val = I915_READ64(GEN6_STOLEN_RESERVED);
+
+       DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = 0x%016llx\n", reg_val);
+
+       *base = reg_val & GEN11_STOLEN_RESERVED_ADDR_MASK;
+
+       switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
+       case GEN8_STOLEN_RESERVED_1M:
+               *size = 1024 * 1024;
+               break;
+       case GEN8_STOLEN_RESERVED_2M:
+               *size = 2 * 1024 * 1024;
+               break;
+       case GEN8_STOLEN_RESERVED_4M:
+               *size = 4 * 1024 * 1024;
+               break;
+       case GEN8_STOLEN_RESERVED_8M:
+               *size = 8 * 1024 * 1024;
+               break;
+       default:
+               *size = 8 * 1024 * 1024;
+               MISSING_CASE(reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK);
+       }
+}
+
 int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 {
        resource_size_t reserved_base, stolen_top;
@@ -400,7 +429,9 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
                        gen7_get_stolen_reserved(dev_priv,
                                                 &reserved_base, &reserved_size);
                break;
-       default:
+       case 8:
+       case 9:
+       case 10:
                if (IS_LP(dev_priv))
                        chv_get_stolen_reserved(dev_priv,
                                                &reserved_base, &reserved_size);
@@ -408,6 +439,11 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
                        bdw_get_stolen_reserved(dev_priv,
                                                &reserved_base, &reserved_size);
                break;
+       case 11:
+       default:
+               icl_get_stolen_reserved(dev_priv, &reserved_base,
+                                       &reserved_size);
+               break;
        }
 
        /*
index 0424e45f88dbc6f4c105b0ac54e689301ad54d15..b95bab7a3d24a5dc0b4adb59270b6e2196ee8884 100644 (file)
@@ -412,6 +412,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define GEN8_STOLEN_RESERVED_4M                (2 << 7)
 #define GEN8_STOLEN_RESERVED_8M                (3 << 7)
 #define GEN6_STOLEN_RESERVED_ENABLE    (1 << 0)
+#define GEN11_STOLEN_RESERVED_ADDR_MASK        (0xFFFFFFFFFFFULL << 20)
 
 /* VGA stuff */