diff mbox

[2/2] x86 early quirk: detect & reserve graphics stolen memory for Intel devices

Message ID 1374614157-8324-3-git-send-email-jbarnes@virtuousgeek.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jesse Barnes July 23, 2013, 9:15 p.m. UTC
We need to do this early on before the E820 map is modified or
conflicting resources assigned on top.
---
 arch/x86/kernel/early-quirks.c |   91 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
diff mbox

Patch

diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 94ab6b9..6017e45 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -208,6 +208,95 @@  static void __init intel_remapping_check(int num, int slot, int func)
 
 }
 
+static const struct pci_device_id gen3_method_ids[] = {
+	INTEL_I830_IDS(NULL),
+	INTEL_I845G_IDS(NULL),
+	INTEL_I85X_IDS(NULL),
+	INTEL_I865G_IDS(NULL),
+	INTEL_I915G_IDS(NULL),
+	INTEL_I915GM_IDS(NULL),
+	INTEL_I945G_IDS(NULL),
+	INTEL_I945GM_IDS(NULL),
+	INTEL_VLV_M_IDS(NULL),
+	INTEL_VLV_D_IDS(NULL),
+	INTEL_PINEVIEW_IDS(NULL),
+};
+static const struct pci_device_id gen4_method_ids[] = {
+	INTEL_I965G_IDS(NULL),
+	INTEL_G33_IDS(NULL),
+	INTEL_I965GM_IDS(NULL),
+	INTEL_GM45_IDS(NULL),
+	INTEL_G45_IDS(NULL),
+	INTEL_IRONLAKE_D_IDS(NULL),
+	INTEL_IRONLAKE_M_IDS(NULL),
+};
+static const struct pci_device_id gen6_method_ids[] = {
+	INTEL_SNB_D_IDS(NULL),
+	INTEL_SNB_M_IDS(NULL),
+	INTEL_IVB_M_IDS(NULL),
+	INTEL_IVB_D_IDS(NULL),
+	INTEL_IVB_Q_IDS(NULL),
+	INTEL_HSW_D_IDS(NULL),
+	INTEL_HSW_M_IDS(NULL),
+};
+
+static void __init intel_gen3_method(int num, int slot, int func,
+				     u32 *start, size_t *size)
+{
+}
+
+static void __init intel_gen4_method(int num, int slot, int func,
+				     u32 *start, size_t *size)
+{
+}
+
+static void __init intel_gen6_method(int num, int slot, int func,
+				     u32 *start, size_t *size)
+{
+}
+
+static void __init intel_graphics_stolen(int num, int slot, int func)
+{
+	size_t size;
+	int i;
+	u32 start;
+	u16 device, subvendor, subdevice;
+
+	device = read_pci_config_word(num, slot, func, PCI_DEVICE_ID);
+	subvendor = read_pci_config_word(num, slot, func, PCI_SUBVENDOR_ID);
+	subdevice = read_pci_config_word(num, slot, func, PCI_SUBDEVICE_ID);
+
+	for (i = 0; i < ARRAY_SIZE(gen3_method_ids); i++) {
+		if (gen3_method_ids[i].device == device) {
+			intel_gen3_method(num, slot, func, &start, &size);
+			goto found;
+		}
+	}
+
+	for (i = 0; i < ARRAY_SIZE(gen4_method_ids); i++) {
+		if (gen4_method_ids[i].device == device) {
+			intel_gen4_method(num, slot, func, &start, &size);
+			goto found;
+		}
+	}
+
+	for (i = 0; i < ARRAY_SIZE(gen6_method_ids); i++) {
+		if (gen6_method_ids[i].device == device &&
+		    (gen6_method_ids[i].subvendor == PCI_ANY_ID ||
+		     gen6_method_ids[i].subvendor == subvendor) &&
+		    (gen6_method_ids[i].subdevice == PCI_ANY_ID ||
+		     gen6_method_ids[i].subdevce == subdevice)) {
+			intel_gen6_method(num, slot, func, &start, &size);
+			goto found;
+		}
+	}
+
+	/* No match, don't bother reserving */
+	return;
+found:
+	/* Mark this space as reserved */
+}
+
 #define QFLAG_APPLY_ONCE 	0x1
 #define QFLAG_APPLIED		0x2
 #define QFLAG_DONE		(QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -241,6 +330,8 @@  static struct chipset early_qrk[] __initdata = {
 	  PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
 	{ PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST,
 	  PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
+	{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_CLASS_DISPLAY, PCI_ANY_ID,
+	  QFLAG_APPLY_ONCE, intel_graphics_stolen }
 	{}
 };