From patchwork Fri Apr 22 13:29:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonas Lahtinen X-Patchwork-Id: 8911941 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AB056BF29F for ; Fri, 22 Apr 2016 13:28:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5B66201C7 for ; Fri, 22 Apr 2016 13:28:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B3F3B20142 for ; Fri, 22 Apr 2016 13:28:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 033E66EEDE; Fri, 22 Apr 2016 13:28:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 16A9C6EEDE for ; Fri, 22 Apr 2016 13:28:16 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 22 Apr 2016 06:28:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,517,1455004800"; d="scan'208";a="89995463" Received: from jlahtine-desk.ger.corp.intel.com ([10.252.19.124]) by fmsmga004.fm.intel.com with ESMTP; 22 Apr 2016 06:28:13 -0700 From: Joonas Lahtinen To: Intel graphics driver community testing & development Date: Fri, 22 Apr 2016 16:29:28 +0300 Message-Id: <1461331768-27473-1-git-send-email-joonas.lahtinen@linux.intel.com> X-Mailer: git-send-email 2.5.5 Cc: daniel.vetter@freedesktop.org, ville.syrjala@freedesktop.org Subject: [Intel-gfx] [RFC] x86/e820: Add E820_RESERVED_GFX for graphics memory X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Joonas Lahtinen --- 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 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; }