Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] MIPS: alchemy: Share prom_init implementation
@ 2020-10-05 11:28 Thomas Bogendoerfer
  2020-10-05 11:28 ` [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define Thomas Bogendoerfer
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-05 11:28 UTC (permalink / raw)
  To: linux-mips, linux-kernel

All boards have the same prom_init() function. Move it to common code and
delete the duplicates.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 arch/mips/alchemy/board-gpr.c          | 17 -----------------
 arch/mips/alchemy/board-mtx1.c         | 17 -----------------
 arch/mips/alchemy/board-xxs1500.c      | 18 ------------------
 arch/mips/alchemy/common/prom.c        | 20 ++++++++++++++++++++
 arch/mips/alchemy/devboards/platform.c | 17 -----------------
 5 files changed, 20 insertions(+), 69 deletions(-)

diff --git a/arch/mips/alchemy/board-gpr.c b/arch/mips/alchemy/board-gpr.c
index 6c47318946e4..f587c40b6d00 100644
--- a/arch/mips/alchemy/board-gpr.c
+++ b/arch/mips/alchemy/board-gpr.c
@@ -31,23 +31,6 @@ const char *get_system_type(void)
 	return "GPR";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c
index 23093535399f..68ea57511629 100644
--- a/arch/mips/alchemy/board-mtx1.c
+++ b/arch/mips/alchemy/board-mtx1.c
@@ -30,23 +30,6 @@ const char *get_system_type(void)
 	return "MTX-1";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/board-xxs1500.c b/arch/mips/alchemy/board-xxs1500.c
index c67dfe1f4997..b184baa4e56a 100644
--- a/arch/mips/alchemy/board-xxs1500.c
+++ b/arch/mips/alchemy/board-xxs1500.c
@@ -25,24 +25,6 @@ const char *get_system_type(void)
 	return "XXS1500";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/common/prom.c b/arch/mips/alchemy/common/prom.c
index af312b5e33f6..cfa203064d3c 100644
--- a/arch/mips/alchemy/common/prom.c
+++ b/arch/mips/alchemy/common/prom.c
@@ -34,6 +34,8 @@
  */
 
 #include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sizes.h>
 #include <linux/string.h>
 
 #include <asm/bootinfo.h>
@@ -76,6 +78,24 @@ char *prom_getenv(char *envname)
 	return NULL;
 }
 
+void __init prom_init(void)
+{
+	unsigned char *memsize_str;
+	unsigned long memsize;
+
+	prom_argc = (int)fw_arg0;
+	prom_argv = (char **)fw_arg1;
+	prom_envp = (char **)fw_arg2;
+
+	prom_init_cmdline();
+
+	memsize_str = prom_getenv("memsize");
+	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
+		memsize = SZ_64M; /* minimum memsize is 64MB RAM */
+
+	add_memory_region(0, memsize, BOOT_MEM_RAM);
+}
+
 static inline unsigned char str2hexnum(unsigned char c)
 {
 	if (c >= '0' && c <= '9')
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c
index 8d4b65c3268a..754bdd2ca630 100644
--- a/arch/mips/alchemy/devboards/platform.c
+++ b/arch/mips/alchemy/devboards/platform.c
@@ -20,23 +20,6 @@
 
 #include <prom.h>
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = (int)fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 64 << 20; /* all devboards have at least 64MB RAM */
-
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	if (alchemy_get_cputype() == ALCHEMY_CPU_AU1300)
-- 
2.16.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define
  2020-10-05 11:28 [PATCH] MIPS: alchemy: Share prom_init implementation Thomas Bogendoerfer
@ 2020-10-05 11:28 ` Thomas Bogendoerfer
  2020-10-06 11:31   ` Thomas Bogendoerfer
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-05 11:28 UTC (permalink / raw)
  To: linux-mips, linux-kernel

There are no users of PAGE_USERIO.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 arch/mips/include/asm/pgtable.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index dd7a0f552cac..e5ef0fdd4838 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -37,8 +37,6 @@ struct vm_area_struct;
 				 _PAGE_GLOBAL | _page_cachable_default)
 #define PAGE_KERNEL_NC	__pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
 				 _PAGE_GLOBAL | _CACHE_CACHABLE_NONCOHERENT)
-#define PAGE_USERIO	__pgprot(_PAGE_PRESENT | _PAGE_WRITE | \
-				 _page_cachable_default)
 #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
 			__WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED)
 
-- 
2.16.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define
  2020-10-05 11:28 ` [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define Thomas Bogendoerfer
@ 2020-10-06 11:31   ` Thomas Bogendoerfer
  2020-10-07  2:11     ` Huacai Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-06 11:31 UTC (permalink / raw)
  To: linux-mips, linux-kernel

On Mon, Oct 05, 2020 at 01:28:46PM +0200, Thomas Bogendoerfer wrote:
> There are no users of PAGE_USERIO.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
>  arch/mips/include/asm/pgtable.h | 2 --
>  1 file changed, 2 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define
  2020-10-06 11:31   ` Thomas Bogendoerfer
@ 2020-10-07  2:11     ` Huacai Chen
  2020-10-07  6:44       ` Thomas Bogendoerfer
  0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2020-10-07  2:11 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: open list:MIPS, LKML

s/used/unused/g, but it is too late, I'm sorry.

Huacai

On Tue, Oct 6, 2020 at 7:31 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Mon, Oct 05, 2020 at 01:28:46PM +0200, Thomas Bogendoerfer wrote:
> > There are no users of PAGE_USERIO.
> >
> > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > ---
> >  arch/mips/include/asm/pgtable.h | 2 --
> >  1 file changed, 2 deletions(-)
>
> applied to mips-next.
>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define
  2020-10-07  2:11     ` Huacai Chen
@ 2020-10-07  6:44       ` Thomas Bogendoerfer
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-07  6:44 UTC (permalink / raw)
  To: Huacai Chen; +Cc: open list:MIPS, LKML

On Wed, Oct 07, 2020 at 10:11:46AM +0800, Huacai Chen wrote:
> s/used/unused/g, but it is too late, I'm sorry.

d'oh, I should probably wait a day longer before applying. Thank you for
your feedback.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] MIPS: alchemy: Share prom_init implementation
  2020-10-05  9:48 [PATCH] MIPS: alchemy: Share prom_init implementation Thomas Bogendoerfer
@ 2020-10-06 11:31 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-06 11:31 UTC (permalink / raw)
  To: linux-mips, linux-kernel

On Mon, Oct 05, 2020 at 11:48:14AM +0200, Thomas Bogendoerfer wrote:
> All boards have the same prom_init() function. Move it to common code and
> delete the duplicates.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
>  arch/mips/alchemy/board-gpr.c          | 17 -----------------
>  arch/mips/alchemy/board-mtx1.c         | 17 -----------------
>  arch/mips/alchemy/board-xxs1500.c      | 18 ------------------
>  arch/mips/alchemy/common/prom.c        | 20 ++++++++++++++++++++
>  arch/mips/alchemy/devboards/platform.c | 17 -----------------
>  5 files changed, 20 insertions(+), 69 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] MIPS: alchemy: Share prom_init implementation
@ 2020-10-05  9:48 Thomas Bogendoerfer
  2020-10-06 11:31 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-10-05  9:48 UTC (permalink / raw)
  To: linux-mips, linux-kernel

All boards have the same prom_init() function. Move it to common code and
delete the duplicates.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 arch/mips/alchemy/board-gpr.c          | 17 -----------------
 arch/mips/alchemy/board-mtx1.c         | 17 -----------------
 arch/mips/alchemy/board-xxs1500.c      | 18 ------------------
 arch/mips/alchemy/common/prom.c        | 20 ++++++++++++++++++++
 arch/mips/alchemy/devboards/platform.c | 17 -----------------
 5 files changed, 20 insertions(+), 69 deletions(-)

diff --git a/arch/mips/alchemy/board-gpr.c b/arch/mips/alchemy/board-gpr.c
index 6c47318946e4..f587c40b6d00 100644
--- a/arch/mips/alchemy/board-gpr.c
+++ b/arch/mips/alchemy/board-gpr.c
@@ -31,23 +31,6 @@ const char *get_system_type(void)
 	return "GPR";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c
index 23093535399f..68ea57511629 100644
--- a/arch/mips/alchemy/board-mtx1.c
+++ b/arch/mips/alchemy/board-mtx1.c
@@ -30,23 +30,6 @@ const char *get_system_type(void)
 	return "MTX-1";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/board-xxs1500.c b/arch/mips/alchemy/board-xxs1500.c
index c67dfe1f4997..b184baa4e56a 100644
--- a/arch/mips/alchemy/board-xxs1500.c
+++ b/arch/mips/alchemy/board-xxs1500.c
@@ -25,24 +25,6 @@ const char *get_system_type(void)
 	return "XXS1500";
 }
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 0x04000000;
-
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
diff --git a/arch/mips/alchemy/common/prom.c b/arch/mips/alchemy/common/prom.c
index af312b5e33f6..cfa203064d3c 100644
--- a/arch/mips/alchemy/common/prom.c
+++ b/arch/mips/alchemy/common/prom.c
@@ -34,6 +34,8 @@
  */
 
 #include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sizes.h>
 #include <linux/string.h>
 
 #include <asm/bootinfo.h>
@@ -76,6 +78,24 @@ char *prom_getenv(char *envname)
 	return NULL;
 }
 
+void __init prom_init(void)
+{
+	unsigned char *memsize_str;
+	unsigned long memsize;
+
+	prom_argc = (int)fw_arg0;
+	prom_argv = (char **)fw_arg1;
+	prom_envp = (char **)fw_arg2;
+
+	prom_init_cmdline();
+
+	memsize_str = prom_getenv("memsize");
+	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
+		memsize = SZ_64M; /* minimum memsize is 64MB RAM */
+
+	add_memory_region(0, memsize, BOOT_MEM_RAM);
+}
+
 static inline unsigned char str2hexnum(unsigned char c)
 {
 	if (c >= '0' && c <= '9')
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c
index 8d4b65c3268a..754bdd2ca630 100644
--- a/arch/mips/alchemy/devboards/platform.c
+++ b/arch/mips/alchemy/devboards/platform.c
@@ -20,23 +20,6 @@
 
 #include <prom.h>
 
-void __init prom_init(void)
-{
-	unsigned char *memsize_str;
-	unsigned long memsize;
-
-	prom_argc = (int)fw_arg0;
-	prom_argv = (char **)fw_arg1;
-	prom_envp = (char **)fw_arg2;
-
-	prom_init_cmdline();
-	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
-		memsize = 64 << 20; /* all devboards have at least 64MB RAM */
-
-	add_memory_region(0, memsize, BOOT_MEM_RAM);
-}
-
 void prom_putchar(char c)
 {
 	if (alchemy_get_cputype() == ALCHEMY_CPU_AU1300)
-- 
2.16.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 11:28 [PATCH] MIPS: alchemy: Share prom_init implementation Thomas Bogendoerfer
2020-10-05 11:28 ` [PATCH] MIPS: pgtable: Remove used PAGE_USERIO define Thomas Bogendoerfer
2020-10-06 11:31   ` Thomas Bogendoerfer
2020-10-07  2:11     ` Huacai Chen
2020-10-07  6:44       ` Thomas Bogendoerfer
  -- strict thread matches above, loose matches on Subject: below --
2020-10-05  9:48 [PATCH] MIPS: alchemy: Share prom_init implementation Thomas Bogendoerfer
2020-10-06 11:31 ` Thomas Bogendoerfer

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org
	public-inbox-index linux-mips

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git