Discussion:
[ORLinux] [PATCH v2 02/29] openrisc: use boot_command_line instead of private cmd_line
Rob Herring
2013-10-07 16:29:10 UTC
Permalink
From: Rob Herring <rob.herring at calxeda.com>

Save some pointless copying of the kernel command line and just use
boot_command_line instead. The DT code already handles CONFIG_CMDLINE,
so a separate copy is not needed.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Reviewed-by: Grant Likely <grant.likely at linaro.org>
---
arch/openrisc/kernel/prom.c | 7 +------
arch/openrisc/kernel/setup.c | 4 +---
2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
index a63e768..bf3fd05 100644
--- a/arch/openrisc/kernel/prom.c
+++ b/arch/openrisc/kernel/prom.c
@@ -47,8 +47,6 @@
#include <asm/sections.h>
#include <asm/setup.h>

-extern char cmd_line[COMMAND_LINE_SIZE];
-
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
size &= PAGE_MASK;
@@ -67,15 +65,12 @@ void __init early_init_devtree(void *params)
* device-tree, including the platform type, initrd location and
* size, TCE reserve, and more ...
*/
- of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
+ of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);

/* Scan memory nodes and rebuild MEMBLOCKs */
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory, NULL);

- /* Save command line for /proc/cmdline and then parse parameters */
- strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
-
memblock_allow_resize();

/* We must copy the flattend device tree from init memory to regular
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index d7359ff..719c5c8 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -50,8 +50,6 @@

#include "vmlinux.h"

-char __initdata cmd_line[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
-
static unsigned long __init setup_memory(void)
{
unsigned long bootmap_size;
@@ -316,7 +314,7 @@ void __init setup_arch(char **cmdline_p)
conswitchp = &dummy_con;
#endif

- *cmdline_p = cmd_line;
+ *cmdline_p = boot_command_line;

printk(KERN_INFO "OpenRISC Linux -- http://openrisc.net\n");
}
--
1.8.1.2
Rob Herring
2013-10-07 16:29:13 UTC
Permalink
From: Rob Herring <rob.herring at calxeda.com>

Use the common unflatten_and_copy_device_tree to copy the built-in FDT
out of init section. This moves the copy later in the boot, but there
do not appear to be any references to strings in the FDT before the copy.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
---
arch/openrisc/kernel/prom.c | 13 -------------
arch/openrisc/kernel/setup.c | 2 +-
2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
index bf3fd05..3b94972 100644
--- a/arch/openrisc/kernel/prom.c
+++ b/arch/openrisc/kernel/prom.c
@@ -55,8 +55,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)

void __init early_init_devtree(void *params)
{
- void *alloc;
-
/* Setup flat device-tree pointer */
initial_boot_params = params;

@@ -72,17 +70,6 @@ void __init early_init_devtree(void *params)
of_scan_flat_dt(early_init_dt_scan_memory, NULL);

memblock_allow_resize();
-
- /* We must copy the flattend device tree from init memory to regular
- * memory because the device tree references the strings in it
- * directly.
- */
-
- alloc = __va(memblock_alloc(initial_boot_params->totalsize, PAGE_SIZE));
-
- memcpy(alloc, initial_boot_params, initial_boot_params->totalsize);
-
- initial_boot_params = alloc;
}

#ifdef CONFIG_BLK_DEV_INITRD
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index 719c5c8..09a769b 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -283,7 +283,7 @@ void __init setup_arch(char **cmdline_p)
{
unsigned long max_low_pfn;

- unflatten_device_tree();
+ unflatten_and_copy_device_tree();

setup_cpuinfo();
--
1.8.1.2
Rob Herring
2013-10-07 16:29:25 UTC
Permalink
From: Rob Herring <rob.herring at calxeda.com>

Convert openrisc to use new early_init_dt_scan function.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
---
arch/openrisc/kernel/prom.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
index 3b94972..fbed459 100644
--- a/arch/openrisc/kernel/prom.c
+++ b/arch/openrisc/kernel/prom.c
@@ -55,20 +55,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)

void __init early_init_devtree(void *params)
{
- /* Setup flat device-tree pointer */
- initial_boot_params = params;
-
-
- /* Retrieve various informations from the /chosen node of the
- * device-tree, including the platform type, initrd location and
- * size, TCE reserve, and more ...
- */
- of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
-
- /* Scan memory nodes and rebuild MEMBLOCKs */
- of_scan_flat_dt(early_init_dt_scan_root, NULL);
- of_scan_flat_dt(early_init_dt_scan_memory, NULL);
-
+ early_init_dt_scan(params);
memblock_allow_resize();
}
--
1.8.1.2
Rob Herring
2013-10-07 16:29:27 UTC
Permalink
From: Rob Herring <rob.herring at calxeda.com>

Create a weak version of early_init_dt_add_memory_arch which uses
memblock. This will unify all architectures except ones with custom
memory bank structs.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will.deacon at arm.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: Jonas Bonn <jonas at southpole.se>
Acked-by: Grant Likely <grant.likely at linaro.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: linux at lists.openrisc.net
Cc: devicetree at vger.kernel.org
---
arch/arm64/kernel/setup.c | 18 ------------------
arch/microblaze/kernel/prom.c | 5 -----
arch/openrisc/kernel/prom.c | 6 ------
drivers/of/fdt.c | 19 +++++++++++++++++++
4 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 4a5f624..7feb0c9 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -147,24 +147,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
pr_info("Machine: %s\n", machine_name);
}

-void __init early_init_dt_add_memory_arch(u64 base, u64 size)
-{
- base &= PAGE_MASK;
- size &= PAGE_MASK;
- if (base + size < PHYS_OFFSET) {
- pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
- base, base + size);
- return;
- }
- if (base < PHYS_OFFSET) {
- pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
- base, PHYS_OFFSET);
- size -= PHYS_OFFSET - base;
- base = PHYS_OFFSET;
- }
- memblock_add(base, size);
-}
-
/*
* Limit the memory size that was specified via FDT.
*/
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index e13686e..951e4d6 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -41,11 +41,6 @@
#include <asm/sections.h>
#include <asm/pci-bridge.h>

-void __init early_init_dt_add_memory_arch(u64 base, u64 size)
-{
- memblock_add(base, size);
-}
-
#ifdef CONFIG_EARLY_PRINTK
static char *stdout;

diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
index fbed459..6dbcaa8 100644
--- a/arch/openrisc/kernel/prom.c
+++ b/arch/openrisc/kernel/prom.c
@@ -47,12 +47,6 @@
#include <asm/sections.h>
#include <asm/setup.h>

-void __init early_init_dt_add_memory_arch(u64 base, u64 size)
-{
- size &= PAGE_MASK;
- memblock_add(base, size);
-}
-
void __init early_init_devtree(void *params)
{
early_init_dt_scan(params);
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bfbfda5..5bc55b6 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -775,6 +775,25 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
}

#ifdef CONFIG_HAVE_MEMBLOCK
+void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+ const u64 phys_offset = __pa(PAGE_OFFSET);
+ base &= PAGE_MASK;
+ size &= PAGE_MASK;
+ if (base + size < phys_offset) {
+ pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+ base, base + size);
+ return;
+ }
+ if (base < phys_offset) {
+ pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+ base, phys_offset);
+ size -= phys_offset - base;
+ base = phys_offset;
+ }
+ memblock_add(base, size);
+}
+
/*
* called from unflatten_device_tree() to bootstrap devicetree itself
* Architectures can override this definition if memblock isn't used
--
1.8.1.2
Catalin Marinas
2013-10-07 16:32:20 UTC
Permalink
Post by Rob Herring
From: Rob Herring <rob.herring at calxeda.com>
Create a weak version of early_init_dt_add_memory_arch which uses
memblock. This will unify all architectures except ones with custom
memory bank structs.
Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will.deacon at arm.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: Jonas Bonn <jonas at southpole.se>
Acked-by: Grant Likely <grant.likely at linaro.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: linux at lists.openrisc.net
Cc: devicetree at vger.kernel.org
Acked-by: Catalin Marinas <catalin.marinas at arm.com>

Rob Herring
2013-10-07 16:29:31 UTC
Permalink
From: Rob Herring <rob.herring at calxeda.com>

It appears openrisc prom.c was just copied from another arch with a
bunch of unnecessary includes. Remove all the unecessary ones.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
---
arch/openrisc/kernel/prom.c | 22 ----------------------
1 file changed, 22 deletions(-)

diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
index 2aae474..6a44340 100644
--- a/arch/openrisc/kernel/prom.c
+++ b/arch/openrisc/kernel/prom.c
@@ -18,34 +18,12 @@
*
*/

-#include <stdarg.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
#include <linux/init.h>
-#include <linux/threads.h>
-#include <linux/spinlock.h>
#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/stringify.h>
-#include <linux/delay.h>
-#include <linux/initrd.h>
-#include <linux/bitops.h>
-#include <linux/module.h>
-#include <linux/kexec.h>
-#include <linux/debugfs.h>
-#include <linux/irq.h>
#include <linux/memblock.h>
#include <linux/of_fdt.h>

-#include <asm/prom.h>
#include <asm/page.h>
-#include <asm/processor.h>
-#include <asm/irq.h>
-#include <linux/io.h>
-#include <asm/mmu.h>
-#include <asm/pgtable.h>
-#include <asm/sections.h>
-#include <asm/setup.h>

void __init early_init_devtree(void *params)
{
--
1.8.1.2
Loading...