[Intel-gfx] [RFC] x86/e820: Add E820_RESERVED_GFX for graphics memory

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Fri Apr 22 13:29:28 UTC 2016


Add a type of memory alongside E820_RESERVED_KERN that is specifically
reserved for graphics usage, E820_RESERVED_GFX. An example is Intel
Gen graphics stolen memory.

Cc: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 arch/x86/include/uapi/asm/e820.h | 5 +++++
 arch/x86/kernel/e820.c           | 8 +++++++-
 arch/x86/kernel/early-quirks.c   | 2 +-
 arch/x86/kernel/tboot.c          | 3 ++-
 arch/x86/mm/init_64.c            | 9 ++++++---
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
index 9dafe59..f5324f4 100644
--- a/arch/x86/include/uapi/asm/e820.h
+++ b/arch/x86/include/uapi/asm/e820.h
@@ -53,6 +53,11 @@
  */
 #define E820_RESERVED_KERN        128
 
+/*
+ * RAM to be reserved for graphics device use.
+ */
+#define E820_RESERVED_GFX         129
+
 #ifndef __ASSEMBLY__
 #include <linux/types.h>
 struct e820entry {
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 621b501..9bbdbc0 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -136,6 +136,7 @@ static void __init e820_print_type(u32 type)
 	switch (type) {
 	case E820_RAM:
 	case E820_RESERVED_KERN:
+	case E820_RESERVED_GFX:
 		printk(KERN_CONT "usable");
 		break;
 	case E820_RESERVED:
@@ -694,7 +695,9 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
 
 		pfn = PFN_DOWN(ei->addr + ei->size);
 
-		if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
+		if (ei->type != E820_RAM &&
+		    ei->type != E820_RESERVED_KERN &&
+		    ei->type != E820_RESERVED_GFX)
 			register_nosave_region(PFN_UP(ei->addr), pfn);
 
 		if (pfn >= limit_pfn)
@@ -916,6 +919,7 @@ static const char *e820_type_to_string(int e820_type)
 {
 	switch (e820_type) {
 	case E820_RESERVED_KERN:
+	case E820_RESERVED_GFX:
 	case E820_RAM:	return "System RAM";
 	case E820_ACPI:	return "ACPI Tables";
 	case E820_NVS:	return "ACPI Non-volatile Storage";
@@ -930,6 +934,7 @@ static unsigned long e820_type_to_iomem_type(int e820_type)
 {
 	switch (e820_type) {
 	case E820_RESERVED_KERN:
+	case E820_RESERVED_GFX:
 	case E820_RAM:
 		return IORESOURCE_SYSTEM_RAM;
 	case E820_ACPI:
@@ -954,6 +959,7 @@ static unsigned long e820_type_to_iores_desc(int e820_type)
 	case E820_PRAM:
 		return IORES_DESC_PERSISTENT_MEMORY_LEGACY;
 	case E820_RESERVED_KERN:
+	case E820_RESERVED_GFX:
 	case E820_RAM:
 	case E820_UNUSABLE:
 	default:
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index d2f75b4..7c87b2f 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -539,7 +539,7 @@ intel_graphics_stolen(int num, int slot, int func,
 	       "0x%llx-0x%llx\n", base, base + size - 1);
 
 	/* Mark this space as reserved */
-	e820_add_region(base, size, E820_RESERVED);
+	e820_add_region(base, size, E820_RESERVED_GFX);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 }
 
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index e72a07f..077d0c7 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -196,7 +196,8 @@ static int tboot_setup_sleep(void)
 
 	for (i = 0; i < e820.nr_map; i++) {
 		if ((e820.map[i].type != E820_RAM)
-		 && (e820.map[i].type != E820_RESERVED_KERN))
+		 && (e820.map[i].type != E820_RESERVED_KERN)
+		 && (e820.map[i].type != E820_RESERVED_GFX))
 			continue;
 
 		add_mac_region(e820.map[i].addr, e820.map[i].size);
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 214afda..d426fae 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -415,7 +415,8 @@ phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
 		if (addr >= end) {
 			if (!after_bootmem &&
 			    !e820_any_mapped(addr & PAGE_MASK, next, E820_RAM) &&
-			    !e820_any_mapped(addr & PAGE_MASK, next, E820_RESERVED_KERN))
+			    !e820_any_mapped(addr & PAGE_MASK, next, E820_RESERVED_KERN) &&
+			    !e820_any_mapped(addr & PAGE_MASK, next, E820_RESERVED_GFX))
 				set_pte(pte, __pte(0));
 			continue;
 		}
@@ -463,7 +464,8 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
 		if (address >= end) {
 			if (!after_bootmem &&
 			    !e820_any_mapped(address & PMD_MASK, next, E820_RAM) &&
-			    !e820_any_mapped(address & PMD_MASK, next, E820_RESERVED_KERN))
+			    !e820_any_mapped(address & PMD_MASK, next, E820_RESERVED_KERN) &&
+			    !e820_any_mapped(address & PMD_MASK, next, E820_RESERVED_GFX))
 				set_pmd(pmd, __pmd(0));
 			continue;
 		}
@@ -537,7 +539,8 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
 		if (addr >= end) {
 			if (!after_bootmem &&
 			    !e820_any_mapped(addr & PUD_MASK, next, E820_RAM) &&
-			    !e820_any_mapped(addr & PUD_MASK, next, E820_RESERVED_KERN))
+			    !e820_any_mapped(addr & PUD_MASK, next, E820_RESERVED_KERN) &&
+			    !e820_any_mapped(addr & PUD_MASK, next, E820_RESERVED_GFX))
 				set_pud(pud, __pud(0));
 			continue;
 		}
-- 
2.5.5



More information about the Intel-gfx mailing list