From: Jayachandran C <jchandra@broadcom.com>
To: <linux-mips@linux-mips.org>
Cc: Jayachandran C <jchandra@broadcom.com>, <ralf@linux-mips.org>
Subject: [PATCH 2/5] MIPS: Add platform function to fixup memory
Date: Fri, 9 May 2014 21:39:21 +0530 [thread overview]
Message-ID: <1399651764-14202-2-git-send-email-jchandra@broadcom.com> (raw)
In-Reply-To: <1399651764-14202-1-git-send-email-jchandra@broadcom.com>
Provide a function plat_mem_fixup() that is called after memory
command line args are parsed. This can be used to fixup memory
regions including those passed thru device tree and command line.
In XLR/XLP, use this to reduce the size of the memory segments so
that prefetch will not access illegal addresses.
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
arch/mips/kernel/setup.c | 4 +++
arch/mips/netlogic/common/Makefile | 1 +
arch/mips/netlogic/common/memory.c | 53 ++++++++++++++++++++++++++++++++++++
arch/mips/netlogic/xlp/setup.c | 14 ----------
arch/mips/netlogic/xlr/setup.c | 3 +-
5 files changed, 59 insertions(+), 16 deletions(-)
create mode 100644 arch/mips/netlogic/common/memory.c
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a842154..74c5f6d 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -610,6 +610,7 @@ static void __init request_crashkernel(struct resource *res)
static void __init arch_mem_init(char **cmdline_p)
{
extern void plat_mem_setup(void);
+ extern void plat_mem_fixup(void);
/* call board setup routine */
plat_mem_setup();
@@ -653,6 +654,9 @@ static void __init arch_mem_init(char **cmdline_p)
pr_info("User-defined physical RAM map:\n");
print_memory_map();
}
+#if defined(CONFIG_CPU_XLP) || defined(CONFIG_CPU_XLR)
+ plat_mem_fixup();
+#endif
bootmem_init();
#ifdef CONFIG_PROC_VMCORE
diff --git a/arch/mips/netlogic/common/Makefile b/arch/mips/netlogic/common/Makefile
index 362739d..44b0e7e 100644
--- a/arch/mips/netlogic/common/Makefile
+++ b/arch/mips/netlogic/common/Makefile
@@ -1,5 +1,6 @@
obj-y += irq.o time.o
obj-y += nlm-dma.o
obj-y += reset.o
+obj-y += memory.o
obj-$(CONFIG_SMP) += smp.o smpboot.o
obj-$(CONFIG_EARLY_PRINTK) += earlycons.o
diff --git a/arch/mips/netlogic/common/memory.c b/arch/mips/netlogic/common/memory.c
new file mode 100644
index 0000000..980c102
--- /dev/null
+++ b/arch/mips/netlogic/common/memory.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2003-2014 Broadcom Corporation
+ * All Rights Reserved
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the Broadcom
+ * license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include <asm/bootinfo.h>
+#include <asm/types.h>
+
+static const int prefetch_backup = 512;
+
+void __init plat_mem_fixup(void)
+{
+ int i;
+
+ /* fixup entries for prefetch */
+ for (i = 0; i < boot_mem_map.nr_map; i++) {
+ if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
+ continue;
+ boot_mem_map.map[i].size -= prefetch_backup;
+ }
+}
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index 135a38f..bf4f6d3 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -65,18 +65,6 @@ static void nlm_linux_exit(void)
cpu_wait();
}
-static void nlm_fixup_mem(void)
-{
- const int pref_backup = 512;
- int i;
-
- for (i = 0; i < boot_mem_map.nr_map; i++) {
- if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
- continue;
- boot_mem_map.map[i].size -= pref_backup;
- }
-}
-
static void __init xlp_init_mem_from_bars(void)
{
uint64_t map[16];
@@ -115,8 +103,6 @@ void __init plat_mem_setup(void)
pr_info("Using DRAM BARs for memory map.\n");
xlp_init_mem_from_bars();
}
- /* Calculate and setup wired entries for mapped kernel */
- nlm_fixup_mem();
}
const char *get_system_type(void)
diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c
index d118b9a..714f6a3 100644
--- a/arch/mips/netlogic/xlr/setup.c
+++ b/arch/mips/netlogic/xlr/setup.c
@@ -144,7 +144,6 @@ static void prom_add_memory(void)
{
struct nlm_boot_mem_map *bootm;
u64 start, size;
- u64 pref_backup = 512; /* avoid pref walking beyond end */
int i;
bootm = (void *)(long)nlm_prom_info.psb_mem_map;
@@ -158,7 +157,7 @@ static void prom_add_memory(void)
if (i == 0 && start == 0 && size == 0x0c000000)
size = 0x0ff00000;
- add_memory_region(start, size - pref_backup, BOOT_MEM_RAM);
+ add_memory_region(start, size, BOOT_MEM_RAM);
}
}
--
1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Jayachandran C <jchandra@broadcom.com>
To: linux-mips@linux-mips.org
Cc: Jayachandran C <jchandra@broadcom.com>, ralf@linux-mips.org
Subject: [PATCH 2/5] MIPS: Add platform function to fixup memory
Date: Fri, 9 May 2014 21:39:21 +0530 [thread overview]
Message-ID: <1399651764-14202-2-git-send-email-jchandra@broadcom.com> (raw)
Message-ID: <20140509160921.gYTBycC4l0Z0WrA0HbCHenPCd8N2b5ZMa9f0N9DjRKA@z> (raw)
In-Reply-To: <1399651764-14202-1-git-send-email-jchandra@broadcom.com>
Provide a function plat_mem_fixup() that is called after memory
command line args are parsed. This can be used to fixup memory
regions including those passed thru device tree and command line.
In XLR/XLP, use this to reduce the size of the memory segments so
that prefetch will not access illegal addresses.
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
arch/mips/kernel/setup.c | 4 +++
arch/mips/netlogic/common/Makefile | 1 +
arch/mips/netlogic/common/memory.c | 53 ++++++++++++++++++++++++++++++++++++
arch/mips/netlogic/xlp/setup.c | 14 ----------
arch/mips/netlogic/xlr/setup.c | 3 +-
5 files changed, 59 insertions(+), 16 deletions(-)
create mode 100644 arch/mips/netlogic/common/memory.c
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a842154..74c5f6d 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -610,6 +610,7 @@ static void __init request_crashkernel(struct resource *res)
static void __init arch_mem_init(char **cmdline_p)
{
extern void plat_mem_setup(void);
+ extern void plat_mem_fixup(void);
/* call board setup routine */
plat_mem_setup();
@@ -653,6 +654,9 @@ static void __init arch_mem_init(char **cmdline_p)
pr_info("User-defined physical RAM map:\n");
print_memory_map();
}
+#if defined(CONFIG_CPU_XLP) || defined(CONFIG_CPU_XLR)
+ plat_mem_fixup();
+#endif
bootmem_init();
#ifdef CONFIG_PROC_VMCORE
diff --git a/arch/mips/netlogic/common/Makefile b/arch/mips/netlogic/common/Makefile
index 362739d..44b0e7e 100644
--- a/arch/mips/netlogic/common/Makefile
+++ b/arch/mips/netlogic/common/Makefile
@@ -1,5 +1,6 @@
obj-y += irq.o time.o
obj-y += nlm-dma.o
obj-y += reset.o
+obj-y += memory.o
obj-$(CONFIG_SMP) += smp.o smpboot.o
obj-$(CONFIG_EARLY_PRINTK) += earlycons.o
diff --git a/arch/mips/netlogic/common/memory.c b/arch/mips/netlogic/common/memory.c
new file mode 100644
index 0000000..980c102
--- /dev/null
+++ b/arch/mips/netlogic/common/memory.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2003-2014 Broadcom Corporation
+ * All Rights Reserved
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the Broadcom
+ * license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include <asm/bootinfo.h>
+#include <asm/types.h>
+
+static const int prefetch_backup = 512;
+
+void __init plat_mem_fixup(void)
+{
+ int i;
+
+ /* fixup entries for prefetch */
+ for (i = 0; i < boot_mem_map.nr_map; i++) {
+ if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
+ continue;
+ boot_mem_map.map[i].size -= prefetch_backup;
+ }
+}
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index 135a38f..bf4f6d3 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -65,18 +65,6 @@ static void nlm_linux_exit(void)
cpu_wait();
}
-static void nlm_fixup_mem(void)
-{
- const int pref_backup = 512;
- int i;
-
- for (i = 0; i < boot_mem_map.nr_map; i++) {
- if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
- continue;
- boot_mem_map.map[i].size -= pref_backup;
- }
-}
-
static void __init xlp_init_mem_from_bars(void)
{
uint64_t map[16];
@@ -115,8 +103,6 @@ void __init plat_mem_setup(void)
pr_info("Using DRAM BARs for memory map.\n");
xlp_init_mem_from_bars();
}
- /* Calculate and setup wired entries for mapped kernel */
- nlm_fixup_mem();
}
const char *get_system_type(void)
diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c
index d118b9a..714f6a3 100644
--- a/arch/mips/netlogic/xlr/setup.c
+++ b/arch/mips/netlogic/xlr/setup.c
@@ -144,7 +144,6 @@ static void prom_add_memory(void)
{
struct nlm_boot_mem_map *bootm;
u64 start, size;
- u64 pref_backup = 512; /* avoid pref walking beyond end */
int i;
bootm = (void *)(long)nlm_prom_info.psb_mem_map;
@@ -158,7 +157,7 @@ static void prom_add_memory(void)
if (i == 0 && start == 0 && size == 0x0c000000)
size = 0x0ff00000;
- add_memory_region(start, size - pref_backup, BOOT_MEM_RAM);
+ add_memory_region(start, size, BOOT_MEM_RAM);
}
}
--
1.7.9.5
next prev parent reply other threads:[~2014-05-09 16:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 15:28 [PATCH RFC 0/5] Mapped kernel support for Broadcom XLP Jayachandran C
2014-05-09 15:28 ` Jayachandran C
2014-05-09 15:28 ` [PATCH 1/4] MIPS: Add platform function to fixup memory Jayachandran C
2014-05-09 15:28 ` Jayachandran C
2014-05-09 15:28 ` [PATCH 2/4] MIPS: Netlogic: Mapped kernel support Jayachandran C
2014-05-09 15:28 ` Jayachandran C
2014-05-09 15:28 ` [PATCH 3/4] MIPS: Compress MAPPED kernels Jayachandran C
2014-05-09 15:28 ` Jayachandran C
2014-05-09 15:28 ` [PATCH 4/4] MIPS: Netlogic: Map kernel with 1G/4G pages on XLPII Jayachandran C
2014-05-09 15:28 ` Jayachandran C
2014-05-09 16:05 ` [PATCH RFC 0/5] Mapped kernel support for Broadcom XLP Jayachandran C.
2014-05-09 16:05 ` Jayachandran C.
2014-05-09 16:09 ` [PATCH 1/5] MIPS: Make MAPPED_KERNEL config option common Jayachandran C
2014-05-09 16:09 ` Jayachandran C
2014-05-09 16:09 ` Jayachandran C [this message]
2014-05-09 16:09 ` [PATCH 2/5] MIPS: Add platform function to fixup memory Jayachandran C
2014-05-09 16:09 ` [PATCH 3/5] MIPS: Netlogic: Mapped kernel support Jayachandran C
2014-05-09 16:09 ` Jayachandran C
2014-05-09 16:09 ` [PATCH 4/5] MIPS: Compress MAPPED kernels Jayachandran C
2014-05-09 16:09 ` Jayachandran C
2014-05-09 16:09 ` [PATCH 5/5] MIPS: Netlogic: Map kernel with 1G/4G pages on XLPII Jayachandran C
2014-05-09 16:09 ` Jayachandran C
-- strict thread matches above, loose matches on Subject: below --
2015-01-16 12:38 [PATCH 0/5] Mapped kernel support for Broadcom XLP/XLPII Jayachandran C
2015-01-16 12:38 ` [PATCH 2/5] MIPS: Add platform function to fixup memory Jayachandran C
2015-01-16 12:38 ` Jayachandran C
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=1399651764-14202-2-git-send-email-jchandra@broadcom.com \
--to=jchandra@broadcom.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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