mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>
Cc: <devicetree@vger.kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	"Paul Burton" <paul.burton@imgtec.com>,
	<linux-kernel@vger.kernel.org>,
	James Hogan <james.hogan@imgtec.com>,
	Markos Chandras <markos.chandras@imgtec.com>,
	"Ralf Baechle" <ralf@linux-mips.org>
Subject: [PATCH 12/15] MIPS: malta: remove fw_memblock_t abstraction
Date: Fri, 22 May 2015 16:51:11 +0100	[thread overview]
Message-ID: <1432309875-9712-13-git-send-email-paul.burton@imgtec.com> (raw)
In-Reply-To: <1432309875-9712-1-git-send-email-paul.burton@imgtec.com>

The fw_getmdesc function & fw_memblock_t abstraction is only used by
Malta, and so far as I can tell serves no purpose beyond making the code
less clear than it could be. Remove the useless level of abstraction.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/fw/fw.h      | 16 -------
 arch/mips/mti-malta/malta-memory.c | 93 ++++++++++++--------------------------
 2 files changed, 29 insertions(+), 80 deletions(-)

diff --git a/arch/mips/include/asm/fw/fw.h b/arch/mips/include/asm/fw/fw.h
index f3e6978..d0ef8b4 100644
--- a/arch/mips/include/asm/fw/fw.h
+++ b/arch/mips/include/asm/fw/fw.h
@@ -10,21 +10,6 @@
 
 #include <asm/bootinfo.h>	/* For cleaner code... */
 
-enum fw_memtypes {
-	fw_dontuse,
-	fw_code,
-	fw_free,
-};
-
-typedef struct {
-	unsigned long base;	/* Within KSEG0 */
-	unsigned int size;	/* bytes */
-	enum fw_memtypes type;	/* fw_memtypes */
-} fw_memblock_t;
-
-/* Maximum number of memory block descriptors. */
-#define FW_MAX_MEMBLOCKS	32
-
 extern int fw_argc;
 extern int *_fw_argv;
 extern int *_fw_envp;
@@ -38,7 +23,6 @@ extern int *_fw_envp;
 
 extern void fw_init_cmdline(void);
 extern char *fw_getcmdline(void);
-extern fw_memblock_t *fw_getmdesc(int);
 extern void fw_meminit(void);
 extern char *fw_getenv(char *name);
 extern unsigned long fw_getenvl(char *name);
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c
index b769657..5660cd6 100644
--- a/arch/mips/mti-malta/malta-memory.c
+++ b/arch/mips/mti-malta/malta-memory.c
@@ -21,19 +21,25 @@
 #include <asm/sections.h>
 #include <asm/fw/fw.h>
 
-static fw_memblock_t mdesc[FW_MAX_MEMBLOCKS];
-
 /* determined physical memory size, not overridden by command line args	 */
 unsigned long physical_memsize = 0L;
 
-fw_memblock_t * __init fw_getmdesc(int eva)
+static void free_init_pages_eva_malta(void *begin, void *end)
+{
+	free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin),
+			__pa_symbol((unsigned long *)end));
+}
+
+void __init fw_meminit(void)
 {
 	char *memsize_str, *ememsize_str = NULL, *ptr;
 	unsigned long memsize = 0, ememsize = 0;
+	unsigned long kernel_start_phys, kernel_end_phys;
 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
+	bool eva = config_enabled(CONFIG_EVA);
 	int tmp;
 
-	/* otherwise look in the environment */
+	free_init_pages_eva = eva ? free_init_pages_eva_malta : NULL;
 
 	memsize_str = fw_getenv("memsize");
 	if (memsize_str) {
@@ -92,15 +98,14 @@ fw_memblock_t * __init fw_getmdesc(int eva)
 	if (memsize > 0x7fff0000)
 		memsize = 0x7fff0000;
 
-	memset(mdesc, 0, sizeof(mdesc));
-
-	mdesc[0].type = fw_dontuse;
-	mdesc[0].base = PHYS_OFFSET;
-	mdesc[0].size = 0x00001000;
+	add_memory_region(PHYS_OFFSET, 0x00001000, BOOT_MEM_RESERVED);
 
-	mdesc[1].type = fw_code;
-	mdesc[1].base = mdesc[0].base + 0x00001000UL;
-	mdesc[1].size = 0x000ef000;
+	/*
+	 * YAMON may still be using the region of memory from 0x1000 to 0xfffff
+	 * if it has started secondary CPUs.
+	 */
+	add_memory_region(PHYS_OFFSET + 0x00001000, 0x000ef000,
+			  BOOT_MEM_ROM_DATA);
 
 	/*
 	 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the
@@ -109,59 +114,19 @@ fw_memblock_t * __init fw_getmdesc(int eva)
 	 * This mean that this area can't be used as DMA memory for PCI
 	 * devices.
 	 */
-	mdesc[2].type = fw_dontuse;
-	mdesc[2].base = mdesc[0].base + 0x000f0000UL;
-	mdesc[2].size = 0x00010000;
-
-	mdesc[3].type = fw_dontuse;
-	mdesc[3].base = mdesc[0].base + 0x00100000UL;
-	mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) -
-		0x00100000UL;
-
-	mdesc[4].type = fw_free;
-	mdesc[4].base = mdesc[0].base + CPHYSADDR(PFN_ALIGN(&_end));
-	mdesc[4].size = memsize - CPHYSADDR(mdesc[4].base);
-
-	return &mdesc[0];
-}
-
-static void free_init_pages_eva_malta(void *begin, void *end)
-{
-	free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin),
-			__pa_symbol((unsigned long *)end));
-}
+	add_memory_region(PHYS_OFFSET + 0x000f0000, 0x00010000,
+			  BOOT_MEM_RESERVED);
 
-static int __init fw_memtype_classify(unsigned int type)
-{
-	switch (type) {
-	case fw_free:
-		return BOOT_MEM_RAM;
-	case fw_code:
-		return BOOT_MEM_ROM_DATA;
-	default:
-		return BOOT_MEM_RESERVED;
-	}
-}
-
-void __init fw_meminit(void)
-{
-	fw_memblock_t *p;
-
-	p = fw_getmdesc(config_enabled(CONFIG_EVA));
-	free_init_pages_eva = (config_enabled(CONFIG_EVA) ?
-			       free_init_pages_eva_malta : NULL);
-
-	while (p->size) {
-		long type;
-		unsigned long base, size;
-
-		type = fw_memtype_classify(p->type);
-		base = p->base;
-		size = p->size;
-
-		add_memory_region(base, size, type);
-		p++;
-	}
+	/*
+	 * Reserve the memory used by kernel code, and allow the rest of RAM to
+	 * be used.
+	 */
+	kernel_start_phys = PHYS_OFFSET + 0x00100000;
+	kernel_end_phys = PHYS_OFFSET + CPHYSADDR(PFN_ALIGN(&_end));
+	add_memory_region(kernel_start_phys, kernel_end_phys,
+			  BOOT_MEM_RESERVED);
+	add_memory_region(kernel_end_phys, memsize - kernel_end_phys,
+			  BOOT_MEM_RAM);
 }
 
 void __init prom_free_prom_memory(void)
-- 
2.4.1


  parent reply	other threads:[~2015-05-22 15:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 15:50 [PATCH 00/15] MIPS Malta DT Conversion Paul Burton
2015-05-22 15:51 ` [PATCH 01/15] MIPS: define GCR_GIC_STATUS register fields Paul Burton
2015-05-22 15:51 ` [PATCH 02/15] MIPS: include errno.h for ENODEV in mips-cm.h Paul Burton
2015-05-22 15:51 ` [PATCH 03/15] MIPS: malta: basic DT plumbing Paul Burton
2015-05-22 15:51 ` [PATCH 04/15] MIPS: i8259: DT support Paul Burton
2015-05-22 15:51 ` [PATCH 05/15] irqchip: mips-gic: register IRQ domain with MIPS_GIC_IRQ_BASE Paul Burton
2015-05-22 17:27   ` Jason Cooper
2015-05-22 15:51 ` [PATCH 06/15] MIPS: malta: probe interrupt controllers via DT Paul Burton
2015-05-22 15:51 ` [PATCH 07/15] MIPS: remove [SR]ocIt(2) IRQ handling code Paul Burton
2015-05-22 15:51 ` [PATCH 08/15] of_serial: support for UARTs on I/O ports Paul Burton
2015-05-26 13:53   ` Peter Hurley
2015-05-22 15:51 ` [PATCH 09/15] MIPS: malta: probe UARTs using DT Paul Burton
2015-05-22 15:51 ` [PATCH 10/15] MIPS: malta: probe RTC via DT Paul Burton
2015-05-22 15:51 ` [PATCH 11/15] MIPS: malta: probe pflash " Paul Burton
2015-05-22 15:51 ` Paul Burton [this message]
2015-05-22 15:51 ` [PATCH 13/15] MIPS: malta: remove nonsense memory limit Paul Burton
2015-05-22 15:51 ` [PATCH 14/15] MIPS: malta: setup RAM regions via DT Paul Burton
2015-10-29  4:39   ` Rob Herring
2015-05-22 15:51 ` [PATCH 15/15] MIPS: malta: setup post-I/O hole RAM on non-EVA Paul Burton
2015-05-25  7:59 ` [PATCH 00/15] MIPS Malta DT Conversion Rob Landley
2015-05-25 13:29   ` Paul Burton

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=1432309875-9712-13-git-send-email-paul.burton@imgtec.com \
    --to=paul.burton@imgtec.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mark.rutland@arm.com \
    --cc=markos.chandras@imgtec.com \
    --cc=pawel.moll@arm.com \
    --cc=ralf@linux-mips.org \
    --cc=robh+dt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®