MIPS: improve BMIPS support
v2 cover MIPS: improve BMIPS support
This patchset aims at unifying the different BMIPS support code to allow building a kernel that runs on multiple BCM63XX SoCs which might have different BMIPS flavours on them, regardless of SMP support enabled in the kernel.
The first few patches clean up BMIPS itself and prepare it for multi-cpu support, while the latter add support to BCM63XX for running a SMP kernel with support for all SoCs, even those that do not have a SMP capable CPU.
This patchset is runtime tested on BCM6348, BCM6328 and BCM6368, to verify that it actually does what it claims it does.
Lacking hardware, it is only build tested for BMIPS4380 and BMIPS5000.
Changes V1 -> V2:
* dropped the compilation fix (a different fix was already comitted)
* rebased on the cpu-type cleanup patches
* used the cpu-type cleanup effects to remove the macros and replace them with normal switch-cases.
* Let BCM47XX_SSB also select BMIPS32_3300
Jonas Gorski (13):
MIPS: BCM63XX: disable SMP also on BCM3368
MIPS: allow asm/cpu.h to be included from assembly
MIPS: BMIPS: change compile time checks to runtime checks
MIPS: BMIPS: merge CPU options into one option
MIPS: BMIPS: select CPU_SUPPORTS_HIGHMEM
MIPS: BMIPS: select CPU_HAS_PREFETCH
MIPS: BMIPS: extend BMIPS3300 to include BMIPS32
MIPS: BMIPS: add a smp ops registration helper
MIPS: BCM63XX: always register bmips smp ops
MIPS: BCM63XX: let the individual SoCs select the appropriate CPUs
MIPS: BCM47XX: select BMIPS CPUs for BCM47XX_SSB
MIPS: cpu-type: guard BMIPS variants with SYS_HAS_CPU_BMIPS*
MIPS: BCM63XX: drop SYS_HAS_CPU_MIPS32R1
arch/mips/Kconfig | 84 +++++------ arch/mips/bcm47xx/Kconfig | 1 + arch/mips/bcm63xx/Kconfig | 8 + arch/mips/bcm63xx/prom.c | 14 +- arch/mips/include/asm/bmips.h | 29 +++- arch/mips/include/asm/cpu-type.h | 13 +- arch/mips/include/asm/cpu.h | 3 + arch/mips/kernel/bmips_vec.S | 55 +++++-- arch/mips/kernel/smp-bmips.c | 312 ++++++++++++++++++++++++--------------- 9 files changed, 329 insertions(+), 190 deletions(-)
Signature · 1 line
1.8.5.1
PATCH v2 1/13 MIPS: BCM63XX: disable SMP also on BCM3368
BCM3368 has the same shared TLB as BCM6358.
--- arch/mips/bcm63xx/prom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/bcm63xx/prom.c +4 -4
@@ -64,9 +64,9 @@ void __init prom_init(void)register_smp_ops (&bmips_smp_ops);/* -* BCM6328 might not have its second CPU enabled, while BCM6358 -* needs special handling for its shared TLB, so disable SMP -* for now. +* BCM6328 might not have its second CPU enabled, while BCM3368 +* and BCM6358 need special handling for their shared TLB, so +* disable SMP for now. */ if (BCMCPU_IS_6328 ()) { reg = bcm_readl(BCM_6328_OTP_BASE +
@@ -74,7 +74,7 @@ void __init prom_init(void)if (reg &OTP_6328_REG3_TP1_DISABLED ) bmips_smp_enabled =0 ; - }else if (BCMCPU_IS_6358 ()) { + }else if (BCMCPU_IS_3368 () ||BCMCPU_IS_6358 ()) { bmips_smp_enabled =0 ; }
Signature · 1 line
1.8.5.1
PATCH v2 2/13 MIPS: allow asm/cpu.h to be included from assembly
In reply to Jonas GorskiAdd guards around the enum to allow including cpu.h from assembly.
--- arch/mips/include/asm/cpu.h | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/include/asm/cpu.h +3 -0
@@ -249,6 +249,8 @@#define FPIR_IMP_NONE 0x0000 +#if !defined(__ASSEMBLY__) +enum cpu_type_enum { CPU_UNKNOWN,
@@ -301,6 +303,7 @@ enum cpu_type_enum {CPU_LAST }; +#endif /* !__ASSEMBLY */ /* * ISA Level encodings
Signature · 1 line
1.8.5.1
PATCH v2 3/13 MIPS: BMIPS: change compile time checks to runtime checks
In reply to Jonas GorskiAllow building for all bmips cpus at the same time by changing ifdefs to checks for the cpu type, or adding appropriate checks to the assembly.
Since BMIPS43XX and BMIPS5000 require different IPI implementations, split the SMP ops into one for each, so the runtime overhead is only at registration time for them.
---
V1 -> V2:
* use switch (cpu_type()) instead of if () else if () ...
* split the smp ops into bmips43xx and bmips5000
arch/mips/bcm63xx/prom.c | 2 +- arch/mips/include/asm/bmips.h | 3 +- arch/mips/kernel/bmips_vec.S | 55 ++++++-- arch/mips/kernel/smp-bmips.c | 312 +++++++++++++++++++++++++----------------- 4 files changed, 235 insertions(+), 137 deletions(-)
arch/mips/bcm63xx/prom.c +1 -1
@@ -61,7 +61,7 @@ void __init prom_init(void)if (IS_ENABLED (CONFIG_CPU_BMIPS4350 ) &&IS_ENABLED (CONFIG_SMP )) {/* set up SMP */ -register_smp_ops (&bmips_smp_ops); +register_smp_ops (&bmips43xx_smp_ops);/* * BCM6328 might not have its second CPU enabled, while BCM3368
arch/mips/include/asm/bmips.h +2 -1
@@ -47,7 +47,8 @@#include <linux/cpumask.h> #include <asm/r4kcache.h> -extern struct plat_smp_ops bmips_smp_ops; +extern struct plat_smp_ops bmips43xx_smp_ops; +extern struct plat_smp_ops bmips5000_smp_ops;extern char bmips_reset_nmi_vec;extern char bmips_reset_nmi_vec_end;extern char bmips_smp_movevec;
arch/mips/kernel/bmips_vec.S +43 -12
109 lines not on this page · raw message
arch/mips/kernel/smp-bmips.c +189 -123
418 lines not on this page · raw message
Signature · 1 line
1.8.5.1
PATCH v2 4/13 MIPS: BMIPS: merge CPU options into one option
In reply to Jonas GorskiInstead of treating each flavour as an exclusive CPU to select, make BMIPS the only option and let SYS_HAS_CPU_BMIPS* decide for which flavours to include support.
Run tested on BMIPS3300 and BMIPS4350, only build tested for BMIPS4380 and BMIPS5000.
---
V1 -> V2:
* Let the SYS_HAS_CPU_BMIPS* symbols select SYS_HAS_CPU_BMIPS instead of requiring users to select it
arch/mips/Kconfig | 80 +++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 41 deletions(-)
arch/mips/Kconfig +39 -41
@@ -1378,41 +1378,21 @@ config CPU_CAVIUM_OCTEON can have up to 16 Mips64v2 cores and 8 integrated gigabit ethernets. Full details can be found at http://www.caviumnetworks.com. -config CPU_BMIPS3300 - bool "BMIPS3300" - depends on SYS_HAS_CPU_BMIPS3300 - select CPU_BMIPS - help - Broadcom BMIPS3300 processors. - -config CPU_BMIPS4350 - bool "BMIPS4350" - depends on SYS_HAS_CPU_BMIPS4350 - select CPU_BMIPS - select SYS_SUPPORTS_SMP - select SYS_SUPPORTS_HOTPLUG_CPU - help - Broadcom BMIPS4350 ("VIPER") processors. - -config CPU_BMIPS4380 - bool "BMIPS4380" - depends on SYS_HAS_CPU_BMIPS4380 - select CPU_BMIPS - select SYS_SUPPORTS_SMP - select SYS_SUPPORTS_HOTPLUG_CPU - help - Broadcom BMIPS4380 processors. - -config CPU_BMIPS5000 - bool "BMIPS5000" - depends on SYS_HAS_CPU_BMIPS5000 - select CPU_BMIPS - select CPU_SUPPORTS_HIGHMEM - select MIPS_CPU_SCACHE - select SYS_SUPPORTS_SMP - select SYS_SUPPORTS_HOTPLUG_CPU +config CPU_BMIPS + bool "Broadcom BMIPS" + depends on SYS_HAS_CPU_BMIPS + select CPU_MIPS32 + select CPU_BMIPS3300 if SYS_HAS_CPU_BMIPS3300 + select CPU_BMIPS4350 if SYS_HAS_CPU_BMIPS4350 + select CPU_BMIPS4380 if SYS_HAS_CPU_BMIPS4380 + select CPU_BMIPS5000 if SYS_HAS_CPU_BMIPS5000 + select CPU_SUPPORTS_32BIT_KERNEL + select DMA_NONCOHERENT + select IRQ_CPU + select SWAP_IO_SPACE + select WEAK_ORDERING help - Broadcom BMIPS5000 processors. + Support for BMIPS3300/4350/4380 and BMIPS5000 processors. config CPU_XLR bool "Netlogic XLR SoC"
@@ -1495,14 +1475,25 @@ config CPU_LOONGSON1 select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_HIGHMEM -config CPU_BMIPS +config CPU_BMIPS3300 bool - select CPU_MIPS32 - select CPU_SUPPORTS_32BIT_KERNEL - select DMA_NONCOHERENT - select IRQ_CPU - select SWAP_IO_SPACE - select WEAK_ORDERING + +config CPU_BMIPS4350 + bool + select SYS_SUPPORTS_SMP + select SYS_SUPPORTS_HOTPLUG_CPU + +config CPU_BMIPS4380 + bool + select SYS_SUPPORTS_SMP + select SYS_SUPPORTS_HOTPLUG_CPU + +config CPU_BMIPS5000 + bool + select CPU_SUPPORTS_HIGHMEM + select MIPS_CPU_SCACHE + select SYS_SUPPORTS_SMP + select SYS_SUPPORTS_HOTPLUG_CPU config SYS_HAS_CPU_LOONGSON2E bool
@@ -1576,17 +1567,24 @@ config SYS_HAS_CPU_SB1 config SYS_HAS_CPU_CAVIUM_OCTEON bool +config SYS_HAS_CPU_BMIPS + bool + config SYS_HAS_CPU_BMIPS3300 bool + select SYS_HAS_CPU_BMIPS config SYS_HAS_CPU_BMIPS4350 bool + select SYS_HAS_CPU_BMIPS config SYS_HAS_CPU_BMIPS4380 bool + select SYS_HAS_CPU_BMIPS config SYS_HAS_CPU_BMIPS5000 bool + select SYS_HAS_CPU_BMIPS config SYS_HAS_CPU_XLR bool
Signature · 1 line
1.8.5.1
PATCH v2 5/13 MIPS: BMIPS: select CPU_SUPPORTS_HIGHMEM
In reply to Jonas GorskiAll BMIPS CPUs support HIGHMEM, so it should be selected by CPU_BMIPS.
--- arch/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Kconfig +1 -1
@@ -1391,6 +1391,7 @@ config CPU_BMIPS select IRQ_CPU select SWAP_IO_SPACE select WEAK_ORDERING + select CPU_SUPPORTS_HIGHMEM help Support for BMIPS3300/4350/4380 and BMIPS5000 processors.
@@ -1490,7 +1491,6 @@ config CPU_BMIPS4380 config CPU_BMIPS5000 bool - select CPU_SUPPORTS_HIGHMEM select MIPS_CPU_SCACHE select SYS_SUPPORTS_SMP select SYS_SUPPORTS_HOTPLUG_CPU
Signature · 1 line
1.8.5.1
PATCH v2 6/13 MIPS: BMIPS: select CPU_HAS_PREFETCH
In reply to Jonas GorskiAs they are MIPS32 CPUs they do support the prefetch opcode.
--- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/Kconfig +1 -0
@@ -1392,6 +1392,7 @@ config CPU_BMIPS select SWAP_IO_SPACE select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM + select CPU_HAS_PREFETCH help Support for BMIPS3300/4350/4380 and BMIPS5000 processors.
Signature · 1 line
1.8.5.1
PATCH v2 7/13 MIPS: BMIPS: extend BMIPS3300 to include BMIPS32
In reply to Jonas GorskiCodewise there is no difference between these two, so it does not make sense to treat them differently. Also chip families having one of these tend to have the other.
--- arch/mips/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/Kconfig +4 -4
@@ -1382,7 +1382,7 @@ config CPU_BMIPS bool "Broadcom BMIPS" depends on SYS_HAS_CPU_BMIPS select CPU_MIPS32 - select CPU_BMIPS3300 if SYS_HAS_CPU_BMIPS3300 + select CPU_BMIPS32_3300 if SYS_HAS_CPU_BMIPS32_3300 select CPU_BMIPS4350 if SYS_HAS_CPU_BMIPS4350 select CPU_BMIPS4380 if SYS_HAS_CPU_BMIPS4380 select CPU_BMIPS5000 if SYS_HAS_CPU_BMIPS5000
@@ -1394,7 +1394,7 @@ config CPU_BMIPS select CPU_SUPPORTS_HIGHMEM select CPU_HAS_PREFETCH help - Support for BMIPS3300/4350/4380 and BMIPS5000 processors. + Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors. config CPU_XLR bool "Netlogic XLR SoC"
@@ -1477,7 +1477,7 @@ config CPU_LOONGSON1 select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_HIGHMEM -config CPU_BMIPS3300 +config CPU_BMIPS32_3300 bool config CPU_BMIPS4350
@@ -1571,7 +1571,7 @@ config SYS_HAS_CPU_CAVIUM_OCTEON config SYS_HAS_CPU_BMIPS bool -config SYS_HAS_CPU_BMIPS3300 +config SYS_HAS_CPU_BMIPS32_3300 bool select SYS_HAS_CPU_BMIPS
Signature · 1 line
1.8.5.1
PATCH v2 8/13 MIPS: BMIPS: add a smp ops registration helper
In reply to Jonas GorskiAdd a helper similar to the generic register_XXX_smp_ops() for bmips. Register SMP UP ops in case of BMIPS32/3300.
---
V1 -> V2:
* use SMP_UP (ops) in case of BMIPS32_3300
arch/mips/Kconfig | 1 + arch/mips/bcm63xx/prom.c | 2 +- arch/mips/include/asm/bmips.h | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-)
arch/mips/Kconfig +1 -0
@@ -1478,6 +1478,7 @@ config CPU_LOONGSON1 select CPU_SUPPORTS_HIGHMEM config CPU_BMIPS32_3300 + select SMP_UP if SMP bool config CPU_BMIPS4350
arch/mips/bcm63xx/prom.c +1 -1
@@ -61,7 +61,7 @@ void __init prom_init(void)if (IS_ENABLED (CONFIG_CPU_BMIPS4350 ) &&IS_ENABLED (CONFIG_SMP )) {/* set up SMP */ -register_smp_ops (&bmips43xx_smp_ops); +register_bmips_smp_ops ();/* * BCM6328 might not have its second CPU enabled, while BCM3368
arch/mips/include/asm/bmips.h +26 -0
@@ -46,9 +46,35 @@#include <linux/cpumask.h> #include <asm/r4kcache.h> +#include <asm/smp-ops.h> extern struct plat_smp_ops bmips43xx_smp_ops;extern struct plat_smp_ops bmips5000_smp_ops; + +static inline int register_bmips_smp_ops (void ) +{ +#if IS_ENABLED (CONFIG_CPU_BMIPS ) &&IS_ENABLED (CONFIG_SMP ) +switch (current_cpu_type ()) { +case CPU_BMIPS32 : +case CPU_BMIPS3300 : +return register_up_smp_ops (); +case CPU_BMIPS4350 : +case CPU_BMIPS4380 : +register_smp_ops (&bmips43xx_smp_ops); +break ; +case CPU_BMIPS5000 : +register_smp_ops (&bmips5000_smp_ops); +break ; +default : +return -ENODEV ; + } + +return 0 ; +#else +return -ENODEV ; +#endif +} +extern char bmips_reset_nmi_vec;extern char bmips_reset_nmi_vec_end;extern char bmips_smp_movevec;
Signature · 1 line
1.8.5.1
PATCH v2 9/13 MIPS: BCM63XX: always register bmips smp ops
In reply to Jonas GorskiUse the return value for guarding further SMP setup.
--- arch/mips/bcm63xx/prom.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/mips/bcm63xx/prom.c +2 -4
@@ -59,10 +59,8 @@ void __init prom_init(void)/* do low level board init */ board_prom_init (); -if (IS_ENABLED (CONFIG_CPU_BMIPS4350 ) &&IS_ENABLED (CONFIG_SMP )) { -/* set up SMP */ -register_bmips_smp_ops (); - +/* set up SMP */ +if (!register_bmips_smp_ops ()) {/* * BCM6328 might not have its second CPU enabled, while BCM3368 * and BCM6358 need special handling for their shared TLB, so
Signature · 1 line
1.8.5.1
PATCH v2 10/13 MIPS: BCM63XX: let the individual SoCs select the appropriate CPUs
In reply to Jonas GorskiLet each supported chip select the appropirate SYS_HAS_CPU_BMIPS* option for its embedded processor, so support will be conditionally included.
--- arch/mips/Kconfig | 1 - arch/mips/bcm63xx/Kconfig | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
arch/mips/Kconfig +0 -1
@@ -132,7 +132,6 @@ config BCM63XX select DMA_NONCOHERENT select IRQ_CPU select SYS_HAS_CPU_MIPS32_R1 - select SYS_HAS_CPU_BMIPS4350 if !BCM63XX_CPU_6338 && !BCM63XX_CPU_6345 && !BCM63XX_CPU_6348 select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN select SYS_HAS_EARLY_PRINTK
arch/mips/bcm63xx/Kconfig +8 -0
@@ -3,33 +3,41 @@ menu "CPU support" config BCM63XX_CPU_3368 bool "support 3368 CPU" + select SYS_HAS_CPU_BMIPS4350 select HW_HAS_PCI config BCM63XX_CPU_6328 bool "support 6328 CPU" + select SYS_HAS_CPU_BMIPS4350 select HW_HAS_PCI config BCM63XX_CPU_6338 bool "support 6338 CPU" + select SYS_HAS_CPU_BMIPS32_3300 select HW_HAS_PCI config BCM63XX_CPU_6345 bool "support 6345 CPU" + select SYS_HAS_CPU_BMIPS32_3300 config BCM63XX_CPU_6348 bool "support 6348 CPU" + select SYS_HAS_CPU_BMIPS32_3300 select HW_HAS_PCI config BCM63XX_CPU_6358 bool "support 6358 CPU" + select SYS_HAS_CPU_BMIPS4350 select HW_HAS_PCI config BCM63XX_CPU_6362 bool "support 6362 CPU" + select SYS_HAS_CPU_BMIPS4350 select HW_HAS_PCI config BCM63XX_CPU_6368 bool "support 6368 CPU" + select SYS_HAS_CPU_BMIPS4350 select HW_HAS_PCI endmenu
Signature · 1 line
1.8.5.1
PATCH v2 11/13 MIPS: BCM47XX: select BMIPS CPUs for BCM47XX_SSB
In reply to Jonas GorskiLet BCM47XX_SSB select the appropriate BMIPS CPUs enountered on those systems.
--- arch/mips/bcm47xx/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/bcm47xx/Kconfig +1 -0
@@ -2,6 +2,7 @@ if BCM47XX config BCM47XX_SSB bool "SSB Support for Broadcom BCM47XX" + select SYS_HAS_CPU_BMIPS32_3300 select SSB select SSB_DRIVER_MIPS select SSB_DRIVER_EXTIF
Signature · 1 line
1.8.5.1
PATCH v2 12/13 MIPS: cpu-type: guard BMIPS variants with SYS_HAS_CPU_BMIPS*
In reply to Jonas GorskiBMIPS32 and BMIPS3300 also need to be available for MIPS32R1, as bcm47xx might not select BMIPS.
--- arch/mips/include/asm/cpu-type.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/mips/include/asm/cpu-type.h +10 -3
@@ -27,10 +27,7 @@ static inline int __pure __get_cpu_type(const int cpu_type)#ifdef CONFIG_SYS_HAS_CPU_MIPS32_R1 case CPU_4KC :case CPU_ALCHEMY : -case CPU_BMIPS3300 : -case CPU_BMIPS4350 :case CPU_PR4450 : -case CPU_BMIPS32 :case CPU_JZRISC :#endif
@@ -163,6 +160,16 @@ static inline int __pure __get_cpu_type(const int cpu_type)case CPU_CAVIUM_OCTEON2 :#endif +#if defined(CONFIG_SYS_HAS_CPU_BMIPS32_3300 ) || \ + defined (CONFIG_SYS_HAS_CPU_MIPS32_R1 ) +case CPU_BMIPS32 : +case CPU_BMIPS3300 : +#endif + +#ifdef CONFIG_SYS_HAS_CPU_BMIPS4350 +case CPU_BMIPS4350 : +#endif +#ifdef CONFIG_SYS_HAS_CPU_BMIPS4380 case CPU_BMIPS4380 :#endif
Signature · 1 line
1.8.5.1
PATCH v2 13/13 MIPS: BCM63XX: drop SYS_HAS_CPU_MIPS32R1
In reply to Jonas GorskiAll MIPS cores on BCM63XX identify as Broadcom, not MIPS, so no need to support non-broadcom MIPS CPUs. This also ensures that CPU_BMIPS is always selected.
--- arch/mips/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/mips/Kconfig +0 -1
@@ -131,7 +131,6 @@ config BCM63XX select CSRC_R4K select DMA_NONCOHERENT select IRQ_CPU - select SYS_HAS_CPU_MIPS32_R1 select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN select SYS_HAS_EARLY_PRINTK
Signature · 1 line
1.8.5.1