linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: aneesh.kumar@linux.vnet.ibm.com, mpe@ellerman.id.au,
	mikey@neuling.org, oohall@gmail.com
Subject: [RFC 6/7] TEST: Reserve system memory to be emulated as device memory
Date: Tue,  3 May 2016 11:59:25 +0530	[thread overview]
Message-ID: <1462256966-19321-7-git-send-email-khandual@linux.vnet.ibm.com> (raw)
In-Reply-To: <1462256966-19321-1-git-send-email-khandual@linux.vnet.ibm.com>

While booting, cap system memory at SYSRAM_END and start recording
the memory from DEVRAM_START as reserved memory.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/prom.h | 15 +++++++++++++++
 arch/powerpc/kernel/prom.c      | 11 +++++++++++
 2 files changed, 26 insertions(+)

diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 7f436ba..a4ec240e4 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -165,5 +165,20 @@ struct of_drconf_cell {
  */
 extern unsigned char ibm_architecture_vec[];
 
+#define SYSRAM_END	0x400000000
+#define DEVRAM_START	0xb00000000
+#define NR_RESERVE	500
+
+enum resmem_elements {
+	MEM_BASE = 0,
+	MEM_SIZE = 1,
+	MEM_NODE = 2,
+	MEM_MAX = 3
+};
+
+struct resmem {
+	u64     mem[NR_RESERVE][MEM_MAX];
+	u64     nr;
+};
 #endif /* __KERNEL__ */
 #endif /* _POWERPC_PROM_H */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a15fe1d..9b3bf2e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -438,6 +438,8 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
 }
 
 #ifdef CONFIG_PPC_PSERIES
+struct resmem rmem;
+EXPORT_SYMBOL(rmem);
 /*
  * Interpret the ibm,dynamic-memory property in the
  * /ibm,dynamic-reconfiguration-memory node.
@@ -471,6 +473,7 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 	if (usm != NULL)
 		is_kexec_kdump = 1;
 
+	memset(&rmem, 0, sizeof(struct resmem));
 	for (; n != 0; --n) {
 		base = dt_mem_next_cell(dt_root_addr_cells, &dm);
 		flags = of_read_number(&dm[3], 1);
@@ -508,6 +511,14 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 				if ((base + size) > 0x80000000ul)
 					size = 0x80000000ul - base;
 			}
+			if (base > DEVRAM_START) {
+				rmem.mem[rmem.nr][MEM_BASE] = base;
+				rmem.mem[rmem.nr][MEM_SIZE] = size;
+				rmem.nr++;
+				continue;
+			}
+			if (base > SYSRAM_END)
+				continue;
 			memblock_add(base, size);
 		} while (--rngs);
 	}
-- 
1.8.3.1

  parent reply	other threads:[~2016-05-03  6:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03  6:29 [RFC 0/7] Enable ZONE_DEVICE on POWER Anshuman Khandual
2016-05-03  6:29 ` [RFC 1/7] powerpc/mm: Make vmemmap_populate accommodate ZONE_DEVICE memory Anshuman Khandual
2016-05-03  8:04   ` Balbir Singh
2016-05-03  8:25     ` Anshuman Khandual
2016-05-03  6:29 ` [RFC 2/7] powerpc/mm: Enable support for ZONE_DEVICE on PPC_BOOK3S_64 platforms Anshuman Khandual
2016-05-03  6:29 ` [RFC 3/7] powerpc/mm: Define TOP_ZONE as a constant Anshuman Khandual
2016-05-03  8:12   ` Balbir Singh
2016-05-03  6:29 ` [RFC 4/7] powerpc/mm: Set MAX_ZONE_PFN to 0 for all zones beyond TOP_ZONE Anshuman Khandual
2016-05-03  8:13   ` Balbir Singh
2016-05-03  6:29 ` [RFC 5/7] mm/memremap: Export pfn_first, pfn_end, find_pagemap functions Anshuman Khandual
2016-05-03  6:29 ` Anshuman Khandual [this message]
2016-05-03  6:29 ` [RFC 7/7] TEST: Driver to test device memory through ZONE_DEVICE Anshuman Khandual
2016-05-03  8:21   ` Balbir Singh

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=1462256966-19321-7-git-send-email-khandual@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=oohall@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).