2019-10-22 17:14:03

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 1/5] MIPS: SGI-IP27: collect externs in new header file

IP27 code has a few externs distributed over .c files. Collect them
together into one commcon header file.

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/sgi-ip27/ip27-common.h | 9 +++++++++
arch/mips/sgi-ip27/ip27-init.c | 4 ++--
arch/mips/sgi-ip27/ip27-reset.c | 2 ++
arch/mips/sgi-ip27/ip27-smp.c | 4 ++--
arch/mips/sgi-ip27/ip27-timer.c | 2 ++
5 files changed, 17 insertions(+), 4 deletions(-)
create mode 100644 arch/mips/sgi-ip27/ip27-common.h

diff --git a/arch/mips/sgi-ip27/ip27-common.h b/arch/mips/sgi-ip27/ip27-common.h
new file mode 100644
index 000000000000..e9e9f1dc8c20
--- /dev/null
+++ b/arch/mips/sgi-ip27/ip27-common.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __IP27_COMMON_H
+#define __IP27_COMMON_H
+
+extern void ip27_reboot_setup(void);
+extern void hub_rt_clock_event_init(void);
+
+#endif /* __IP27_COMMON_H */
diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
index 1dad799758c4..f48e2b3990f6 100644
--- a/arch/mips/sgi-ip27/ip27-init.c
+++ b/arch/mips/sgi-ip27/ip27-init.c
@@ -36,6 +36,8 @@
#include <asm/sn/sn0/ip27.h>
#include <asm/sn/mapped_kernel.h>

+#include "ip27-common.h"
+
#define CPU_NONE (cpuid_t)-1

static DECLARE_BITMAP(hub_init_mask, MAX_COMPACT_NODES);
@@ -113,8 +115,6 @@ get_nasid(void)
>> NSRI_NODEID_SHFT);
}

-extern void ip27_reboot_setup(void);
-
void __init plat_mem_setup(void)
{
u64 p, e, n_mode;
diff --git a/arch/mips/sgi-ip27/ip27-reset.c b/arch/mips/sgi-ip27/ip27-reset.c
index c90228d0d4c2..74d078247e49 100644
--- a/arch/mips/sgi-ip27/ip27-reset.c
+++ b/arch/mips/sgi-ip27/ip27-reset.c
@@ -26,6 +26,8 @@
#include <asm/sn/gda.h>
#include <asm/sn/sn0/hub.h>

+#include "ip27-common.h"
+
void machine_restart(char *command) __noreturn;
void machine_halt(void) __noreturn;
void machine_power_off(void) __noreturn;
diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c
index 386702abe660..c38df7c62964 100644
--- a/arch/mips/sgi-ip27/ip27-smp.c
+++ b/arch/mips/sgi-ip27/ip27-smp.c
@@ -27,6 +27,8 @@
#include <asm/sn/sn0/hubio.h>
#include <asm/sn/sn0/ip27.h>

+#include "ip27-common.h"
+
/*
* Takes as first input the PROM assigned cpu id, and the kernel
* assigned cpu id as the second.
@@ -147,8 +149,6 @@ static void ip27_init_cpu(void)

static void ip27_smp_finish(void)
{
- extern void hub_rt_clock_event_init(void);
-
hub_rt_clock_event_init();
local_irq_enable();
}
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 9ca775465a91..d53a29070e12 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -38,6 +38,8 @@
#include <asm/sn/sn0/hubio.h>
#include <asm/pci/bridge.h>

+#include "ip27-common.h"
+
static int rt_next_event(unsigned long delta, struct clock_event_device *evt)
{
unsigned int cpu = smp_processor_id();
--
2.16.4


2019-10-22 17:14:21

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 5/5] MIPS: SGI-IP27: reduce ARC usage to a minimum

IP27 uses ARC prom only for parsing prom arguments and has a hack
for IP27 to make the ARC code behave. By introducing config symbol
ARC_CMDLINE_ONLY IP27 only drags in ARC cmdline parsing and does
everything else in IP27 specific code.

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/Kconfig | 4 ++++
arch/mips/fw/arc/Makefile | 4 ++++
arch/mips/fw/arc/identify.c | 10 ----------
arch/mips/sgi-ip27/ip27-init.c | 14 ++++++++++++++
4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2ef3129cc4ad..376d0ec0d1d6 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -674,6 +674,7 @@ config SGI_IP27
select ARCH_SPARSEMEM_ENABLE
select FW_ARC
select FW_ARC64
+ select ARC_CMDLINE_ONLY
select BOOT_ELF64
select DEFAULT_SGI_PARTITION
select SYS_HAS_EARLY_PRINTK
@@ -1377,6 +1378,9 @@ config MIPS_L1_CACHE_SHIFT
config HAVE_STD_PC_SERIAL_PORT
bool

+config ARC_CMDLINE_ONLY
+ bool
+
config ARC_CONSOLE
bool "ARC console support"
depends on SGI_IP22 || SGI_IP28 || (SNI_RM && CPU_LITTLE_ENDIAN)
diff --git a/arch/mips/fw/arc/Makefile b/arch/mips/fw/arc/Makefile
index 3cc82d7fe548..64d685efcc77 100644
--- a/arch/mips/fw/arc/Makefile
+++ b/arch/mips/fw/arc/Makefile
@@ -3,8 +3,12 @@
# Makefile for the ARC prom monitor library routines under Linux.
#

+ifdef CONFIG_ARC_CMDLINE_ONLY
+lib-y += cmdline.o
+else
lib-y += cmdline.o env.o file.o identify.o init.o \
misc.o
+endif

lib-$(CONFIG_ARC_MEMORY) += memory.o
lib-$(CONFIG_ARC_CONSOLE) += arc_con.o
diff --git a/arch/mips/fw/arc/identify.c b/arch/mips/fw/arc/identify.c
index 7530c7b2fd39..5527e0f54079 100644
--- a/arch/mips/fw/arc/identify.c
+++ b/arch/mips/fw/arc/identify.c
@@ -31,10 +31,6 @@ static struct smatch mach_table[] = {
.arcname = "SGI-IP22",
.liname = "SGI Indy",
.flags = PROM_FLAG_ARCS,
- }, {
- .arcname = "SGI-IP27",
- .liname = "SGI Origin",
- .flags = PROM_FLAG_ARCS,
}, {
.arcname = "SGI-IP28",
.liname = "SGI IP28",
@@ -103,13 +99,7 @@ void __init prom_identify_arch(void)
*/
p = ArcGetChild(PROM_NULL_COMPONENT);
if (p == NULL) {
-#ifdef CONFIG_SGI_IP27
- /* IP27 PROM misbehaves, seems to not implement ARC
- GetChild(). So we just assume it's an IP27. */
- iname = "SGI-IP27";
-#else
iname = "Unknown";
-#endif
} else
iname = (char *) (long) p->iname;

diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
index d160fb219d6d..971aa0d5d534 100644
--- a/arch/mips/sgi-ip27/ip27-init.c
+++ b/arch/mips/sgi-ip27/ip27-init.c
@@ -13,9 +13,11 @@
#include <linux/mm.h>
#include <linux/export.h>
#include <linux/cpumask.h>
+#include <asm/bootinfo.h>
#include <asm/cpu.h>
#include <asm/io.h>
#include <asm/pgtable.h>
+#include <asm/sgialib.h>
#include <asm/time.h>
#include <asm/sn/types.h>
#include <asm/sn/sn0/addrs.h>
@@ -160,3 +162,15 @@ void __init plat_mem_setup(void)
ioport_resource.end = ~0UL;
set_io_port_base(IO_BASE);
}
+
+const char *get_system_type(void)
+{
+ return "SGI Origin";
+}
+
+void __init prom_init(void)
+{
+ prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);
+ prom_meminit();
+}
+
--
2.16.4

2019-10-22 17:14:29

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 4/5] MIPS: arc: use function argument for passing argc/argv to prom_init_cmdline

prom_argc and prom_argv are only used by prom_init_cmdline(), so
we could pass them directly as function argument.

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/fw/arc/cmdline.c | 16 +++++++++++-----
arch/mips/fw/arc/init.c | 7 +------
arch/mips/include/asm/sgialib.h | 9 +--------
3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c
index c0122a1dc587..155c5e911723 100644
--- a/arch/mips/fw/arc/cmdline.c
+++ b/arch/mips/fw/arc/cmdline.c
@@ -17,6 +17,12 @@

#undef DEBUG_CMDLINE

+/*
+ * A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
+ * These macro take care of sign extension.
+ */
+#define prom_argv(index) ((char *) (long)argv[(index)])
+
static char *ignored[] = {
"ConsoleIn=",
"ConsoleOut=",
@@ -32,14 +38,14 @@ static char *used_arc[][2] = {
{ "OSLoadOptions=", "" }
};

-static char * __init move_firmware_args(char* cp)
+static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
{
char *s;
int actr, i;

actr = 1; /* Always ignore argv[0] */

- while (actr < prom_argc) {
+ while (actr < argc) {
for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
int len = strlen(used_arc[i][0]);

@@ -64,7 +70,7 @@ static char * __init move_firmware_args(char* cp)
return cp;
}

-void __init prom_init_cmdline(void)
+void __init prom_init_cmdline(int argc, LONG *argv)
{
char *cp;
int actr, i;
@@ -76,9 +82,9 @@ void __init prom_init_cmdline(void)
* Move ARC variables to the beginning to make sure they can be
* overridden by later arguments.
*/
- cp = move_firmware_args(cp);
+ cp = move_firmware_args(argc, argv, cp);

- while (actr < prom_argc) {
+ while (actr < argc) {
for (i = 0; i < ARRAY_SIZE(ignored); i++) {
int len = strlen(ignored[i]);

diff --git a/arch/mips/fw/arc/init.c b/arch/mips/fw/arc/init.c
index c713292462aa..f9d1dea9b2ca 100644
--- a/arch/mips/fw/arc/init.c
+++ b/arch/mips/fw/arc/init.c
@@ -18,8 +18,6 @@

/* Master romvec interface. */
struct linux_romvec *romvec;
-int prom_argc;
-LONG *_prom_argv;

#if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
/* stack for calling 32bit ARC prom */
@@ -32,9 +30,6 @@ void __init prom_init(void)

romvec = ROMVECTOR;

- prom_argc = fw_arg0;
- _prom_argv = (LONG *) fw_arg1;
-
if (pb->magic != 0x53435241) {
printk(KERN_CRIT "Aieee, bad prom vector magic %08lx\n",
(unsigned long) pb->magic);
@@ -42,7 +37,7 @@ void __init prom_init(void)
;
}

- prom_init_cmdline();
+ prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);
prom_identify_arch();
printk(KERN_INFO "PROMLIB: ARC firmware Version %d Revision %d\n",
pb->ver, pb->rev);
diff --git a/arch/mips/include/asm/sgialib.h b/arch/mips/include/asm/sgialib.h
index 40ab4ef0b1dc..80f900417f7e 100644
--- a/arch/mips/include/asm/sgialib.h
+++ b/arch/mips/include/asm/sgialib.h
@@ -15,13 +15,6 @@
#include <asm/sgiarcs.h>

extern struct linux_romvec *romvec;
-extern int prom_argc;
-
-extern LONG *_prom_argv;
-
-/* A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
- These macros take care of sign extension. */
-#define prom_argv(index) ((char *) (long) _prom_argv[(index)])

extern int prom_flags;

@@ -55,7 +48,7 @@ extern void prom_identify_arch(void);
extern PCHAR ArcGetEnvironmentVariable(PCHAR name);

/* ARCS command line parsing. */
-extern void prom_init_cmdline(void);
+extern void prom_init_cmdline(int argc, LONG *argv);

/* File operations. */
extern LONG ArcRead(ULONG fd, PVOID buf, ULONG num, PULONG cnt);
--
2.16.4

2019-10-22 17:15:58

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 3/5] MIPS: arc: remove unused stuff

remove unused _prom_envp and prom_argc macro.

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/fw/arc/init.c | 3 +--
arch/mips/include/asm/sgialib.h | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/mips/fw/arc/init.c b/arch/mips/fw/arc/init.c
index 4ac6466a8872..c713292462aa 100644
--- a/arch/mips/fw/arc/init.c
+++ b/arch/mips/fw/arc/init.c
@@ -19,7 +19,7 @@
/* Master romvec interface. */
struct linux_romvec *romvec;
int prom_argc;
-LONG *_prom_argv, *_prom_envp;
+LONG *_prom_argv;

#if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
/* stack for calling 32bit ARC prom */
@@ -34,7 +34,6 @@ void __init prom_init(void)

prom_argc = fw_arg0;
_prom_argv = (LONG *) fw_arg1;
- _prom_envp = (LONG *) fw_arg2;

if (pb->magic != 0x53435241) {
printk(KERN_CRIT "Aieee, bad prom vector magic %08lx\n",
diff --git a/arch/mips/include/asm/sgialib.h b/arch/mips/include/asm/sgialib.h
index 21d17eb25ed8..40ab4ef0b1dc 100644
--- a/arch/mips/include/asm/sgialib.h
+++ b/arch/mips/include/asm/sgialib.h
@@ -17,12 +17,11 @@
extern struct linux_romvec *romvec;
extern int prom_argc;

-extern LONG *_prom_argv, *_prom_envp;
+extern LONG *_prom_argv;

/* A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
These macros take care of sign extension. */
#define prom_argv(index) ((char *) (long) _prom_argv[(index)])
-#define prom_argc(index) ((char *) (long) _prom_argc[(index)])

extern int prom_flags;

--
2.16.4

2019-10-24 20:24:38

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH 1/5] MIPS: SGI-IP27: collect externs in new header file

Hello,

Thomas Bogendoerfer wrote:
> IP27 code has a few externs distributed over .c files. Collect them
> together into one commcon header file.

Series applied to mips-next.

> MIPS: SGI-IP27: collect externs in new header file
> commit 249be5633cdb
> https://git.kernel.org/mips/c/249be5633cdb
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>
>
> MIPS: SGI-IP27: move registering of smp ops into IP27 specific code
> commit c823f4160978
> https://git.kernel.org/mips/c/c823f4160978
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>
>
> MIPS: arc: remove unused stuff
> commit cbd09241dd9d
> https://git.kernel.org/mips/c/cbd09241dd9d
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>
>
> MIPS: arc: use function argument for passing argc/argv to prom_init_cmdline
> commit 7b16831d1eb1
> https://git.kernel.org/mips/c/7b16831d1eb1
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>
>
> MIPS: SGI-IP27: reduce ARC usage to a minimum
> commit e942242784d0
> https://git.kernel.org/mips/c/e942242784d0
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>

Thanks,
Paul

[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]