All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Cc: daniel.vetter@freedesktop.org, ville.syrjala@freedesktop.org
Subject: [RFC] x86/e820: Add E820_RESERVED_GFX for graphics memory
Date: Fri, 22 Apr 2016 16:29:28 +0300	[thread overview]
Message-ID: <1461331768-27473-1-git-send-email-joonas.lahtinen@linux.intel.com> (raw)

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@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2016-04-22 13:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 13:29 Joonas Lahtinen [this message]
2016-04-25 11:25 ` ✗ Fi.CI.BAT: failure for x86/e820: Add E820_RESERVED_GFX for graphics memory Patchwork
2016-04-25 13:25 ` [RFC] " Joonas Lahtinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461331768-27473-1-git-send-email-joonas.lahtinen@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=daniel.vetter@freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.