x86/gpu: reserve ICL's graphics stolen memory
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 4 May 2018 20:32:51 +0000 (13:32 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 10 Jul 2018 23:28:47 +0000 (16:28 -0700)
ICL changes the registers and addresses to 64 bits.

I also briefly looked at implementing an u64 version of the PCI config
read functions, but I concluded this wouldn't be trivial, so it's not
worth doing it for a single user that can't have any racing problems
while reading the register in two separate operations.

v2:
 - Scrub the development (non-public) changelog (Joonas).
 - Remove the i915.ko bits so this can be easily backported in order
   to properly avoid stolen memory even on machines without i915.ko
   (Joonas).
 - CC stable for the reasons above.

Issue: VIZ-9250
CC: stable@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Fixes: 412310019a20 ("drm/i915/icl: Add initial Icelake definitions.")
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180504203252.28048-1-paulo.r.zanoni@intel.com
arch/x86/kernel/early-quirks.c
include/drm/i915_drm.h

index bae0d32e327b5ae536dc155c705443be86144670..72c2cf961d44ba26c6e428797b1990c0b5e94b5b 100644 (file)
@@ -340,6 +340,18 @@ static resource_size_t __init gen3_stolen_base(int num, int slot, int func,
        return bsm & INTEL_BSM_MASK;
 }
 
+static resource_size_t __init gen11_stolen_base(int num, int slot, int func,
+                                               resource_size_t stolen_size)
+{
+       u64 bsm;
+
+       bsm = read_pci_config(num, slot, func, INTEL_GEN11_BSM_DW0);
+       bsm &= INTEL_BSM_MASK;
+       bsm |= (u64)read_pci_config(num, slot, func, INTEL_GEN11_BSM_DW1) << 32;
+
+       return bsm;
+}
+
 static resource_size_t __init i830_stolen_size(int num, int slot, int func)
 {
        u16 gmch_ctrl;
@@ -500,6 +512,11 @@ static const struct intel_early_ops chv_early_ops __initconst = {
        .stolen_size = chv_stolen_size,
 };
 
+static const struct intel_early_ops gen11_early_ops __initconst = {
+       .stolen_base = gen11_stolen_base,
+       .stolen_size = gen9_stolen_size,
+};
+
 static const struct pci_device_id intel_early_ids[] __initconst = {
        INTEL_I830_IDS(&i830_early_ops),
        INTEL_I845G_IDS(&i845_early_ops),
@@ -531,6 +548,7 @@ static const struct pci_device_id intel_early_ids[] __initconst = {
        INTEL_CFL_IDS(&gen9_early_ops),
        INTEL_GLK_IDS(&gen9_early_ops),
        INTEL_CNL_IDS(&gen9_early_ops),
+       INTEL_ICL_11_IDS(&gen11_early_ops),
 };
 
 struct resource intel_graphics_stolen_res __ro_after_init = DEFINE_RES_MEM(0, 0);
index c9e5a6621b954c26823978b4b735119457117260..c44703f471b37d4dfa110b8a0b9368fc3c43d6b3 100644 (file)
@@ -95,7 +95,9 @@ extern struct resource intel_graphics_stolen_res;
 #define    I845_TSEG_SIZE_512K (2 << 1)
 #define    I845_TSEG_SIZE_1M   (3 << 1)
 
-#define INTEL_BSM 0x5c
+#define INTEL_BSM              0x5c
+#define INTEL_GEN11_BSM_DW0    0xc0
+#define INTEL_GEN11_BSM_DW1    0xc4
 #define   INTEL_BSM_MASK       (-(1u << 20))
 
 #endif                         /* _I915_DRM_H_ */