Microwatt updates
Subsystems (2)
PATCH 2/5 powerpc/microwatt: Device-tree updates
In reply to Paul MackerrasMicrowatt now implements ISA v3.1 (SFFS compliancy subset), including prefixed instructions, scv/rfscv, and the FSCR, HFSCR, TAR, and CTRL registers. The privileged mode of operation is now hypervisor mode and there is no privileged non-hypervisor mode; the MSR[HV] bit is forced to 1.
Besides updating the ibm,powerpc-cpu-features property to reflect the above, this also makes the following changes relating to peripheral devices:
- Add gpio controller.
- Remove high-speed property from SD controller, for the case where the interface is connected through 200 ohm protection resisters.
- Put an alias for the ethernet in /chosen.
--- arch/powerpc/boot/dts/microwatt.dts | 73 ++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 11 deletions(-)
arch/powerpc/boot/dts/microwatt.dts +62 -11
@@ -1,4 +1,5 @@ /dts-v1/; +#include <dt-bindings/gpio/gpio.h> / { #size-cells = <0x02>;
@@ -8,6 +9,7 @@ / { aliases { serial0 = &UART0; + ethernet = &enet0; }; reserved-memory {
@@ -35,40 +37,79 @@ cpus { ibm,powerpc-cpu-features { display-name = "Microwatt"; - isa = <3000>; + isa = <3010>; device_type = "cpu-features"; compatible = "ibm,powerpc-cpu-features"; mmu-radix { isa = <3000>; - usable-privilege = <2>; + usable-privilege = <6>; + os-support = <0>; }; little-endian { - isa = <2050>; - usable-privilege = <3>; + isa = <0>; + usable-privilege = <7>; + os-support = <0>; hwcap-bit-nr = <1>; }; cache-inhibited-large-page { - isa = <2040>; - usable-privilege = <2>; + isa = <0>; + usable-privilege = <6>; + os-support = <0>; }; fixed-point-v3 { isa = <3000>; - usable-privilege = <3>; + usable-privilege = <7>; }; no-execute { - isa = <2010>; + isa = <0x00>; usable-privilege = <2>; + os-support = <0>; }; floating-point { + hfscr-bit-nr = <0>; hwcap-bit-nr = <27>; isa = <0>; - usable-privilege = <3>; + usable-privilege = <7>; + hv-support = <1>; + os-support = <0>; + }; + + prefixed-instructions { + hfscr-bit-nr = <13>; + fscr-bit-nr = <13>; + isa = <3010>; + usable-privilege = <7>; + os-support = <1>; + hv-support = <1>; + }; + + tar { + hfscr-bit-nr = <8>; + fscr-bit-nr = <8>; + isa = <2070>; + usable-privilege = <7>; + os-support = <1>; + hv-support = <1>; + hwcap-bit-nr = <58>; + }; + + control-register { + isa = <0>; + usable-privilege = <7>; + }; + + system-call-vectored { + isa = <2070>; + usable-privilege = <7>; + os-support = <1>; + fscr-bit-nr = <12>; + hwcap-bit-nr = <52>; }; };
@@ -138,7 +179,18 @@ UART0: serial@2000 { interrupts = <0x10 0x1>; }; - ethernet@8020000 { + gpio: gpio@7000 { + device_type = "gpio"; + compatible = "faraday,ftgpio010"; + gpio-controller; + #gpio-cells = <2>; + reg = <0x7000 0x80>; + interrupts = <0x14 1>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + enet0: ethernet@8020000 { compatible = "litex,liteeth"; reg = <0x8021000 0x100 0x8020800 0x100
@@ -160,7 +212,6 @@ mmc@8040000 { reg-names = "phy", "core", "reader", "writer", "irq"; bus-width = <4>; interrupts = <0x13 1>; - cap-sd-highspeed; clocks = <&sys_clk>; }; };
Signature · 1 line
2.47.1
PATCH 1/5 powerpc/microwatt: Select COMMON_CLK in order to get the clock framework
In reply to Paul MackerrasThis is to allow us to select Litex MMC host controller driver, which drives the litesdcard gateware.
--- arch/powerpc/platforms/microwatt/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/microwatt/Kconfig +1 -0
@@ -6,6 +6,7 @@ config PPC_MICROWATT select PPC_ICS_NATIVE select PPC_ICP_NATIVE select PPC_UDBG_16550 + select COMMON_CLK help This option enables support for FPGA-based Microwatt implementations.
Signature · 1 line
2.47.1
PATCH 3/5 powerpc/microwatt: Define an idle power-save function
In reply to Paul MackerrasThis uses the 'wait' instruction to pause instruction execution when idle until an interrupt occurs.
--- arch/powerpc/platforms/microwatt/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/platforms/microwatt/setup.c +9 -0
@@ -34,10 +34,19 @@ static void __init microwatt_setup_arch(void)microwatt_rng_init (); } +static void microwatt_idle (void ) +{ +if (!prep_irq_for_idle ()) +return ; + + __asm__ __volatile__ ("wait" ); +} +define_machine (microwatt) { .name = "microwatt", .compatible = "microwatt-soc", .init_IRQ = microwatt_init_IRQ, .setup_arch = microwatt_setup_arch, .progress = udbg_progress, + .power_save = microwatt_idle, };
Signature · 1 line
2.47.1
cover Microwatt updates
This patch series updates the kernel support for the Microwatt soft-core and its implementation on FPGA systems, particularly the Digilent Arty A7-100 FPGA development board.
Microwatt now supports almost all of the features of the SFFS (Scalar Fixed-poin and Floating-point Subset) compliancy subset of Power ISA version 3.1C, including prefixed instructions and the fixed-point hash (ROP mitigation) instructions. It is also now SMP-capable, and a dual-core system will fit on the Arty A7-100 board.
Microwatt does not have broadcast TLB invalidations in SMP systems; the kernel already has code to deal with this. One of the patches in this series provides a config option to allow platforms to select unconditionally the behaviour where cross-CPU TLB invalidations are handled using inter-processor interrupts.
Paul.
--- arch/powerpc/boot/dts/microwatt.dts | 107 +++++++++++++++++++++++---- arch/powerpc/mm/book3s64/pgtable.c | 10 ++- arch/powerpc/platforms/Kconfig.cputype | 12 +++ arch/powerpc/platforms/microwatt/Kconfig | 4 +- arch/powerpc/platforms/microwatt/Makefile | 1 + arch/powerpc/platforms/microwatt/microwatt.h | 1 + arch/powerpc/platforms/microwatt/setup.c | 19 +++++ 7 files changed, 138 insertions(+), 16 deletions(-)
PATCH 4/5 powerpc: Define config option for processors without broadcast TLBIE
Power ISA v3.1 implementations in the Linux Compliancy Subset and lower are not required to implement broadcast TLBIE, and in fact Microwatt doesn't. To avoid the need to specify "disable_tlbie" on the kernel command line on SMP Microwatt systems, this defines a config option that asserts that broadcast TLBIE should never be used (the kernel will instead use IPIs to trigger local TLBIEs on other CPUs when required).
--- arch/powerpc/mm/book3s64/pgtable.c | 10 ++++++++-- arch/powerpc/platforms/Kconfig.cputype | 12 ++++++++++++ arch/powerpc/platforms/microwatt/Kconfig | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)
arch/powerpc/mm/book3s64/pgtable.c +8 -2
@@ -588,10 +588,16 @@ int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, }#endif +#ifndef CONFIG_PPC_RADIX_NO_BROADCAST_TLBIE +#define DEFAULT_TLBIE_ENABLE true +#else +#define DEFAULT_TLBIE_ENABLE false +#endif +/* * Does the CPU support tlbie? */ -bool tlbie_capable__read_mostly = true; +bool tlbie_capable__read_mostly =DEFAULT_TLBIE_ENABLE ;EXPORT_SYMBOL (tlbie_capable);/*
@@ -599,7 +605,7 @@ EXPORT_SYMBOL(tlbie_capable);* address spaces? tlbie may still be used for nMMU accelerators, and for KVM * guest address spaces. */ -bool tlbie_enabled__read_mostly = true; +bool tlbie_enabled__read_mostly =DEFAULT_TLBIE_ENABLE ;static int __init setup_disable_tlbie (char *str) {
arch/powerpc/platforms/Kconfig.cputype +12 -0
@@ -449,6 +449,18 @@ config PPC_RADIX_MMU_DEFAULT If you're unsure, say Y. +config PPC_RADIX_NO_BROADCAST_TLBIE + depends on PPC_RADIX_MMU + help + Power ISA v3.1 implementations in the Linux Compliancy Subset + and lower are not required to implement broadcast TLBIE + instructions, that is, a TLB invalidation instruction + performed on one CPU is not required to operate on the TLBs + in all CPUs in the system. Instead, the kernel does an IPI + to each relevant CPU to get it to do a local TLBIE instruction. + Select this option to force global invalidations to be done via + IPIs unconditionally. + config PPC_KERNEL_PREFIXED depends on PPC_HAVE_PREFIXED_SUPPORT depends on CC_HAS_PREFIXED
arch/powerpc/platforms/microwatt/Kconfig +1 -0
@@ -7,6 +7,7 @@ config PPC_MICROWATT select PPC_ICP_NATIVE select PPC_UDBG_16550 select COMMON_CLK + select PPC_RADIX_NO_BROADCAST_TLBIE help This option enables support for FPGA-based Microwatt implementations.
Signature · 1 line
2.47.1
PATCH 5/5 powerpc/microwatt: Add SMP support
In reply to Paul MackerrasThis adds support for Microwatt systems with more than one core, and updates the device tree for a 2-core version. (This does not prevent the kernel from running on a single-core system.)
--- arch/powerpc/boot/dts/microwatt.dts | 34 ++++++++++++++++++-- arch/powerpc/platforms/microwatt/Kconfig | 2 +- arch/powerpc/platforms/microwatt/Makefile | 1 + arch/powerpc/platforms/microwatt/microwatt.h | 1 + arch/powerpc/platforms/microwatt/setup.c | 10 ++++++ 5 files changed, 45 insertions(+), 3 deletions(-)
arch/powerpc/boot/dts/microwatt.dts +32 -2
@@ -142,6 +142,36 @@ PowerPC,Microwatt@0 { ibm,mmu-lpid-bits = <12>; ibm,mmu-pid-bits = <20>; }; + + PowerPC,Microwatt@1 { + i-cache-sets = <2>; + ibm,dec-bits = <64>; + reservation-granule-size = <64>; + clock-frequency = <100000000>; + timebase-frequency = <100000000>; + i-tlb-sets = <1>; + ibm,ppc-interrupt-server#s = <1>; + i-cache-block-size = <64>; + d-cache-block-size = <64>; + d-cache-sets = <2>; + i-tlb-size = <64>; + cpu-version = <0x990000>; + status = "okay"; + i-cache-size = <0x1000>; + ibm,processor-radix-AP-encodings = <0x0c 0xa0000010 0x20000015 0x4000001e>; + tlb-size = <0>; + tlb-sets = <0>; + device_type = "cpu"; + d-tlb-size = <128>; + d-tlb-sets = <2>; + reg = <1>; + general-purpose; + 64-bit; + d-cache-size = <0x1000>; + ibm,chip-id = <0>; + ibm,mmu-lpid-bits = <12>; + ibm,mmu-pid-bits = <20>; + }; }; soc@c0000000 {
@@ -154,8 +184,8 @@ soc@c0000000 { interrupt-controller@4000 { compatible = "openpower,xics-presentation", "ibm,ppc-xicp"; - ibm,interrupt-server-ranges = <0x0 0x1>; - reg = <0x4000 0x100>; + ibm,interrupt-server-ranges = <0x0 0x2>; + reg = <0x4000 0x10 0x4010 0x10>; }; ICS: interrupt-controller@5000 {
arch/powerpc/platforms/microwatt/Kconfig +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config PPC_MICROWATT - depends on PPC_BOOK3S_64 && !SMP + depends on PPC_BOOK3S_64 bool "Microwatt SoC platform" select PPC_XICS select PPC_ICS_NATIVE
arch/powerpc/platforms/microwatt/Makefile +1 -0
@@ -1 +1,2 @@ obj-y += setup.o rng.o +obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/microwatt/microwatt.h +1 -0
@@ -3,5 +3,6 @@#define _MICROWATT_Hvoid microwatt_rng_init (void ); +void microwatt_init_smp (void );#endif /* _MICROWATT_H */
arch/powerpc/platforms/microwatt/setup.c +10 -0
@@ -29,6 +29,15 @@ static int __init microwatt_populate(void) }machine_arch_initcall (microwatt, microwatt_populate); +static int __init microwatt_probe (void ) +{ +/* Main reason for having this is to start the other CPU(s) */ +#ifdef CONFIG_SMP +microwatt_init_smp (); +#endif +return 1 ; +} +static void __init microwatt_setup_arch (void ) {microwatt_rng_init ();
@@ -45,6 +54,7 @@ static void microwatt_idle(void)define_machine (microwatt) { .name = "microwatt", .compatible = "microwatt-soc", + .probe = microwatt_probe, .init_IRQ = microwatt_init_IRQ, .setup_arch = microwatt_setup_arch, .progress = udbg_progress,
Signature · 1 line
2.47.1
Re: [PATCH 1/5] powerpc/microwatt: Select COMMON_CLK in order to get the clock framework
In reply to Paul MackerrasQuoted 4 lines · Paul Mackerras
This is to allow us to select Litex MMC host controller driver, which drives the litesdcard gateware.
Signed-off-by Paul Mackerras <[email protected]>
Quoted 16 lines
--- arch/powerpc/platforms/microwatt/Kconfig | 1 + 1 file changed, 1 insertion(+)arch/powerpc/platforms/microwatt/Kconfig +1
-0@@ -6,6 +6,7 @@ config PPC_MICROWATT select PPC_ICS_NATIVE select PPC_ICP_NATIVE select PPC_UDBG_16550 + select COMMON_CLK help This option enables support for FPGA-based Microwatt implementations.
Nicholas Piggin
reviewerRe: [PATCH 3/5] powerpc/microwatt: Define an idle power-save function
In reply to Paul MackerrasQuoted 13 lines · Paul Mackerras
This uses the 'wait' instruction to pause instruction execution when idle until an interrupt occurs.
Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/platforms/microwatt/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/powerpc/platforms/microwatt/setup.c +0
-0
arch/powerpc/platforms/microwatt/setup.c static void __init microwatt_setup_arch(void) · line 43
Quoted 10 lines
arch/powerpc/platforms/microwatt/setup.c +7
-0@@ -34,10 +34,19 @@ static void __init microwatt_setup_arch(void)microwatt_rng_init (); } +static void microwatt_idle (void ) +{ +if (!prep_irq_for_idle ()) +return ; + + __asm__ __volatile__ ("wait" ); +}
Does wait cause MSR[EE] to be set? If not, do you need to use prep_irq_for_idle_irqsoff() here maybe?
Thanks,
Nick
Quoted 9 lines
arch/powerpc/platforms/microwatt/setup.c +2
-0+define_machine (microwatt) { .name = "microwatt", .compatible = "microwatt-soc", .init_IRQ = microwatt_init_IRQ, .setup_arch = microwatt_setup_arch, .progress = udbg_progress, + .power_save = microwatt_idle, };
Re: [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE
In reply to Paul MackerrasQuoted 20 lines · Paul Mackerras
Power ISA v3.1 implementations in the Linux Compliancy Subset and lower are not required to implement broadcast TLBIE, and in fact Microwatt doesn't. To avoid the need to specify "
disable_tlbie" on the kernel command line on SMP Microwatt systems, this defines a config option that asserts that broadcast TLBIE should never be used (the kernel will instead use IPIs to trigger local TLBIEs on other CPUs when required).Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/mm/book3s64/pgtable.c | 10 ++++++++-- arch/powerpc/platforms/Kconfig.cputype | 12 ++++++++++++ arch/powerpc/platforms/microwatt/Kconfig | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)arch/powerpc/mm/book3s64/pgtable.c +0
-0
arch/powerpc/mm/book3s64/pgtable.c int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, · line 591
Quoted 4 lines
arch/powerpc/mm/book3s64/pgtable.c +1
-0@@ -588,10 +588,16 @@ int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, }#endif +#ifndef CONFIG_PPC_RADIX_NO_BROADCAST_TLBIE
Hate to bikeshed, but would it be annoying to make this an affirmative option?
Quoted 31 lines
arch/powerpc/mm/book3s64/pgtable.c +7
-2+#define DEFAULT_TLBIE_ENABLE true +#else +#define DEFAULT_TLBIE_ENABLE false +#endif +/* * Does the CPU support tlbie? */ -bool tlbie_capable__read_mostly = true; +bool tlbie_capable__read_mostly =DEFAULT_TLBIE_ENABLE ;EXPORT_SYMBOL (tlbie_capable);/* @@ -599,7 +605,7 @@ EXPORT_SYMBOL(tlbie_capable);* address spaces? tlbie may still be used for nMMU accelerators, and for KVM * guest address spaces. */ -bool tlbie_enabled__read_mostly = true; +bool tlbie_enabled__read_mostly =DEFAULT_TLBIE_ENABLE ;static int __init setup_disable_tlbie (char *str) {arch/powerpc/platforms/Kconfig.cputype +1
-0@@ -449,6 +449,18 @@ config PPC_RADIX_MMU_DEFAULT If you're unsure, say Y. +config PPC_RADIX_NO_BROADCAST_TLBIE
arch/powerpc/platforms/Kconfig.cputype config PPC_RADIX_MMU_DEFAULT · line 462
Quoted 10 lines
arch/powerpc/platforms/Kconfig.cputype +10
-0+ depends on PPC_RADIX_MMU + help + Power ISA v3.1 implementations in the Linux Compliancy Subset + and lower are not required to implement broadcast TLBIE + instructions, that is, a TLB invalidation instruction + performed on one CPU is not required to operate on the TLBs + in all CPUs in the system. Instead, the kernel does an IPI + to each relevant CPU to get it to do a local TLBIE instruction. + Select this option to force global invalidations to be done via + IPIs unconditionally.
... when using radix MMU. Hash MMU requires broadcast TLBIE.
Nitpicks aside, looks okay to me.
Quoted 16 lines
arch/powerpc/platforms/Kconfig.cputype +1
-0+ config PPC_KERNEL_PREFIXED depends on PPC_HAVE_PREFIXED_SUPPORT depends on CC_HAS_PREFIXEDarch/powerpc/platforms/microwatt/Kconfig +1
-0@@ -7,6 +7,7 @@ config PPC_MICROWATT select PPC_ICP_NATIVE select PPC_UDBG_16550 select COMMON_CLK + select PPC_RADIX_NO_BROADCAST_TLBIE help This option enables support for FPGA-based Microwatt implementations.
Nicholas Piggin
reviewerRe: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Paul MackerrasQuoted 5 lines · Paul Mackerras
This adds support for Microwatt systems with more than one core, and updates the device tree for a 2-core version. (This does not prevent the kernel from running on a single-core system.)
Signed-off-by Paul Mackerras <[email protected]>
Well, I'm impressed you added SMP :)
What happens with a 1 CPU system? Do we time out waiting for secondaries and continue, or is there something more graceful?
Quoted 77 lines
--- arch/powerpc/boot/dts/microwatt.dts | 34 ++++++++++++++++++-- arch/powerpc/platforms/microwatt/Kconfig | 2 +- arch/powerpc/platforms/microwatt/Makefile | 1 + arch/powerpc/platforms/microwatt/microwatt.h | 1 + arch/powerpc/platforms/microwatt/setup.c | 10 ++++++ 5 files changed, 45 insertions(+), 3 deletions(-)arch/powerpc/boot/dts/microwatt.dts +32
-2@@ -142,6 +142,36 @@ PowerPC,Microwatt@0 { ibm,mmu-lpid-bits = <12>; ibm,mmu-pid-bits = <20>; }; + + PowerPC,Microwatt@1 { + i-cache-sets = <2>; + ibm,dec-bits = <64>; + reservation-granule-size = <64>; + clock-frequency = <100000000>; + timebase-frequency = <100000000>; + i-tlb-sets = <1>; + ibm,ppc-interrupt-server#s = <1>; + i-cache-block-size = <64>; + d-cache-block-size = <64>; + d-cache-sets = <2>; + i-tlb-size = <64>; + cpu-version = <0x990000>; + status = "okay"; + i-cache-size = <0x1000>; + ibm,processor-radix-AP-encodings = <0x0c 0xa0000010 0x20000015 0x4000001e>; + tlb-size = <0>; + tlb-sets = <0>; + device_type = "cpu"; + d-tlb-size = <128>; + d-tlb-sets = <2>; + reg = <1>; + general-purpose; + 64-bit; + d-cache-size = <0x1000>; + ibm,chip-id = <0>; + ibm,mmu-lpid-bits = <12>; + ibm,mmu-pid-bits = <20>; + }; }; soc@c0000000 {@@ -154,8 +184,8 @@ soc@c0000000 { interrupt-controller@4000 { compatible = "openpower,xics-presentation", "ibm,ppc-xicp"; - ibm,interrupt-server-ranges = <0x0 0x1>; - reg = <0x4000 0x100>; + ibm,interrupt-server-ranges = <0x0 0x2>; + reg = <0x4000 0x10 0x4010 0x10>; }; ICS: interrupt-controller@5000 {arch/powerpc/platforms/microwatt/Kconfig +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config PPC_MICROWATT - depends on PPC_BOOK3S_64 && !SMP + depends on PPC_BOOK3S_64 bool "Microwatt SoC platform" select PPC_XICS select PPC_ICS_NATIVEarch/powerpc/platforms/microwatt/Makefile +0
-0
arch/powerpc/platforms/microwatt/Makefile line 2
Quoted 2 lines
arch/powerpc/platforms/microwatt/Makefile +1
-0@@ -1 +1,2 @@ obj-y += setup.o rng.o +obj-$(CONFIG_SMP) += smp.o
Hmm.... git add arch/powerpc/platforms/microwatt/smp.c ?
Quoted 16 lines
arch/powerpc/platforms/microwatt/microwatt.h +1
-0@@ -3,5 +3,6 @@#define _MICROWATT_Hvoid microwatt_rng_init (void ); +void microwatt_init_smp (void );#endif /* _MICROWATT_H */ arch/powerpc/platforms/microwatt/setup.c +0
-0
arch/powerpc/platforms/microwatt/setup.c static int __init microwatt_populate(void) · line 37
Quoted 9 lines
arch/powerpc/platforms/microwatt/setup.c +6
-0@@ -29,6 +29,15 @@ static int __init microwatt_populate(void) }machine_arch_initcall (microwatt, microwatt_populate); +static int __init microwatt_probe (void ) +{ +/* Main reason for having this is to start the other CPU(s) */ +#ifdef CONFIG_SMP +microwatt_init_smp (); +#endif
Could use
if (IS_ENABLED(CONFIG_SMP)) microwatt_init_smp();
Thanks,
Nick
Quoted 14 lines
arch/powerpc/platforms/microwatt/setup.c +4
-0+return 1 ; +} +static void __init microwatt_setup_arch (void ) {microwatt_rng_init ();@@ -45,6 +54,7 @@ static void microwatt_idle(void)define_machine (microwatt) { .name = "microwatt", .compatible = "microwatt-soc", + .probe = microwatt_probe, .init_IRQ = microwatt_init_IRQ, .setup_arch = microwatt_setup_arch, .progress = udbg_progress,
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Paul MackerrasQuoted 5 lines · Paul Mackerras
Microwatt now implements ISA v3.1 (SFFS compliancy subset), including prefixed instructions, scv/rfscv, and the FSCR, HFSCR, TAR, and CTRL registers. The privileged mode of operation is now hypervisor mode and there is no privileged non-hypervisor mode; the MSR[HV] bit is forced to 1.
Cool. Lots of development in microwatt.
Come to think of it we should have put a broadcast-tlbie feature in there and you wouldn't need the other patch. That can go on the todo list I guess.
system-call-vectored was available in ISA v3.0. Not that we do much with it at the moment IIRC, but there were dreams of wiring it in for compat guests. With that fixed,
Thanks,
Nick
Quoted 150 lines
Besides updating the ibm,powerpc-cpu-features property to reflect the above, this also makes the following changes relating to peripheral devices:
- Add gpio controller.
- Remove high-speed property from SD controller, for the case where the interface is connected through 200 ohm protection resisters.
- Put an alias for the ethernet in /chosen.Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/boot/dts/microwatt.dts | 73 ++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 11 deletions(-)arch/powerpc/boot/dts/microwatt.dts +62
-11@@ -1,4 +1,5 @@ /dts-v1/; +#include <dt-bindings/gpio/gpio.h> / { #size-cells = <0x02>;@@ -8,6 +9,7 @@ / { aliases { serial0 = &UART0; + ethernet = &enet0; }; reserved-memory {@@ -35,40 +37,79 @@ cpus { ibm,powerpc-cpu-features { display-name = "Microwatt"; - isa = <3000>; + isa = <3010>; device_type = "cpu-features"; compatible = "ibm,powerpc-cpu-features"; mmu-radix { isa = <3000>; - usable-privilege = <2>; + usable-privilege = <6>; + os-support = <0>; }; little-endian { - isa = <2050>; - usable-privilege = <3>; + isa = <0>; + usable-privilege = <7>; + os-support = <0>; hwcap-bit-nr = <1>; }; cache-inhibited-large-page { - isa = <2040>; - usable-privilege = <2>; + isa = <0>; + usable-privilege = <6>; + os-support = <0>; }; fixed-point-v3 { isa = <3000>; - usable-privilege = <3>; + usable-privilege = <7>; }; no-execute { - isa = <2010>; + isa = <0x00>; usable-privilege = <2>; + os-support = <0>; }; floating-point { + hfscr-bit-nr = <0>; hwcap-bit-nr = <27>; isa = <0>; - usable-privilege = <3>; + usable-privilege = <7>; + hv-support = <1>; + os-support = <0>; + }; + + prefixed-instructions { + hfscr-bit-nr = <13>; + fscr-bit-nr = <13>; + isa = <3010>; + usable-privilege = <7>; + os-support = <1>; + hv-support = <1>; + }; + + tar { + hfscr-bit-nr = <8>; + fscr-bit-nr = <8>; + isa = <2070>; + usable-privilege = <7>; + os-support = <1>; + hv-support = <1>; + hwcap-bit-nr = <58>; + }; + + control-register { + isa = <0>; + usable-privilege = <7>; + }; + + system-call-vectored { + isa = <2070>; + usable-privilege = <7>; + os-support = <1>; + fscr-bit-nr = <12>; + hwcap-bit-nr = <52>; }; };@@ -138,7 +179,18 @@ UART0: serial@2000 { interrupts = <0x10 0x1>; }; - ethernet@8020000 { + gpio: gpio@7000 { + device_type = "gpio"; + compatible = "faraday,ftgpio010"; + gpio-controller; + #gpio-cells = <2>; + reg = <0x7000 0x80>; + interrupts = <0x14 1>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + enet0: ethernet@8020000 { compatible = "litex,liteeth"; reg = <0x8021000 0x100 0x8020800 0x100@@ -160,7 +212,6 @@ mmc@8040000 { reg-names = "phy", "core", "reader", "writer", "irq"; bus-width = <4>; interrupts = <0x13 1>; - cap-sd-highspeed; clocks = <&sys_clk>; }; };
Re: [PATCH 3/5] powerpc/microwatt: Define an idle power-save function
In reply to Nicholas PigginQuoted 17 lines · Nicholas Piggin
Quoted 16 lines · Paul Mackerras
This uses the 'wait' instruction to pause instruction execution when idle until an interrupt occurs.
Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/platforms/microwatt/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/powerpc/platforms/microwatt/setup.c +0
-0@@ -34,10 +34,19 @@ static void __init microwatt_setup_arch(void)microwatt_rng_init (); }
Quoted 10 lines
arch/powerpc/platforms/microwatt/setup.c static void __init microwatt_setup_arch(void) · line 43
Quoted 7 lines
arch/powerpc/platforms/microwatt/setup.c +7
-0+static void microwatt_idle (void ) +{ +if (!prep_irq_for_idle ()) +return ; + + __asm__ __volatile__ ("wait" ); +}Does wait cause MSR[EE] to be set? If not, do you need to use
prep_irq_for_idle_irqsoff()here maybe?
The wait instruction doesn't do anything to MSR[EE], but a pending external interrupt (or any asynchronous exception condition) will terminate the wait regardless of MSR[EE].
So yes, it does like I should be using prep_irq_for_idle_irqsoff().
Thanks,
Paul.
Re: [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE
In reply to Nicholas PigginQuoted 24 lines · Nicholas Piggin
Quoted 23 lines · Paul Mackerras
Power ISA v3.1 implementations in the Linux Compliancy Subset and lower are not required to implement broadcast TLBIE, and in fact Microwatt doesn't. To avoid the need to specify "
disable_tlbie" on the kernel command line on SMP Microwatt systems, this defines a config option that asserts that broadcast TLBIE should never be used (the kernel will instead use IPIs to trigger local TLBIEs on other CPUs when required).Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/mm/book3s64/pgtable.c | 10 ++++++++-- arch/powerpc/platforms/Kconfig.cputype | 12 ++++++++++++ arch/powerpc/platforms/microwatt/Kconfig | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)arch/powerpc/mm/book3s64/pgtable.c +0
-0@@ -588,10 +588,16 @@ int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, }#endif
Quoted 4 lines
arch/powerpc/mm/book3s64/pgtable.c int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, · line 591
Quoted 1 line
arch/powerpc/mm/book3s64/pgtable.c +1
-0+#ifndef CONFIG_PPC_RADIX_NO_BROADCAST_TLBIE Hate to bikeshed, but would it be annoying to make this an affirmative option?
I guess we'd have to make all the platforms that do have broadcast tlbie (and a book3s-64 MMU with radix) select that option. Which would be powernv and pseries, I would think. If that's correct then it's probably not too annoying. Should I do that in v2?
Paul.
Re: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Nicholas PigginQuoted 11 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
This adds support for Microwatt systems with more than one core, and updates the device tree for a 2-core version. (This does not prevent the kernel from running on a single-core system.)
Signed-off-by Paul Mackerras <[email protected]>Well, I'm impressed you added SMP :)
What happens with a 1 CPU system? Do we time out waiting for secondaries and continue, or is there something more graceful?
There's a field in the SYSCON register which tells you how many cores there are. microwatt_init_smp() looks at that field and only starts the CPUs that are there.
Oops, sorry, I see that I forgot to do 'git add' on arch/powerpc/platforms/microwatt/smp.c. Here it is (I'll include it properly in v2, of course):
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* SMP support functions for Microwatt
* Copyright 2025 Paul Mackerras <[email protected]> */
#include <linux/kernel.h>
#include <linux/smp.h>
#include <linux/io.h>
#include <asm/early_ioremap.h>
#include <asm/xics.h>
#include "microwatt.h"
static void __init microwatt_smp_probe(void)
{
xics_smp_probe();
}static void microwatt_smp_setup_cpu(int cpu)
{
if (cpu != 0)
xics_setup_cpu();
}static struct smp_ops_t microwatt_smp_ops = {
.probe = microwatt_smp_probe,
.message_pass = NULL, /* Use smp_muxed_ipi_message_pass */
.kick_cpu = smp_generic_kick_cpu,
.setup_cpu = microwatt_smp_setup_cpu,
};
/* XXX get from device tree */
#define SYSCON_BASE 0xc0000000
#define SYSCON_CPU_CTRL 0x58
void __init microwatt_init_smp(void)
{
volatile unsigned char __iomem *syscon;
int ncpus;
int timeout;
syscon = early_ioremap(SYSCON_BASE, 0x100);
if (syscon == NULL) {
pr_err("Failed to map SYSCON\n");
return;
}
ncpus = (readl(syscon + SYSCON_CPU_CTRL) >> 8) & 0xff;
if (ncpus < 2)
goto out;
smp_ops = µwatt_smp_ops;
/*
* Write two instructions at location 0:
* mfspr r3, PIR
* b __secondary_hold
*/
*(unsigned int *)KERNELBASE = 0x7c7ffaa6;
*(unsigned int *)(KERNELBASE+4) = 0x4800005c;
/* enable the other CPUs, they start at location 0 */
writel((1ul << ncpus) - 1, syscon + SYSCON_CPU_CTRL);
timeout = 10000;
while (!__secondary_hold_acknowledge) {
if (--timeout == 0)
break;
barrier();
}out:
early_iounmap((void *)syscon, 0x100); }
Paul.
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Nicholas PigginQuoted 7 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
Microwatt now implements ISA v3.1 (SFFS compliancy subset), including prefixed instructions, scv/rfscv, and the FSCR, HFSCR, TAR, and CTRL registers. The privileged mode of operation is now hypervisor mode and there is no privileged non-hypervisor mode; the MSR[HV] bit is forced to 1.
Quoted 5 lines
Cool. Lots of development in microwatt.
Come to think of it we should have put a broadcast-tlbie feature in there and you wouldn't need the other patch. That can go on the todo list I guess.
I thought about doing that, but it would add complexity and I'm not sure it would actually have any measurable performance benefit. When I saw it was optional in the ISA for LCS and below, and that the kernel has all the machinery for handling the cross-CPU invalidations via IPI, it became very much the path of least resistance to use the kernel machinery.
Quoted 3 lines
system-call-vectored was available in ISA v3.0. Not that we do much with it at the moment IIRC, but there were dreams of wiring it in for compat guests. With that fixed,
Interesting. I looked in my copy of v2.07 (PowerISA_V2.07_PUBLIC.pdf) and it mentions rfscv in a couple of places, but has no description of scv or rfscv. I'll change it to v3.0.
Thanks,
Paul.
Nicholas Piggin
reviewerRe: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Paul MackerrasQuoted 8 lines · Paul Mackerras
Quoted 7 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
This adds support for Microwatt systems with more than one core, and updates the device tree for a 2-core version. (This does not prevent the kernel from running on a single-core system.)
Signed-off-by Paul Mackerras <[email protected]>
Quoted 8 lines
Quoted 4 lines
Well, I'm impressed you added SMP :)
What happens with a 1 CPU system? Do we time out waiting for secondaries and continue, or is there something more graceful?
There's a field in the SYSCON register which tells you how many cores there are.
microwatt_init_smp()looks at that field and only starts the CPUs that are there.
Ah, nice.
Quoted 37 lines
Oops, sorry, I see that I forgot to do 'git add' on
arch/powerpc/platforms/microwatt/smp.c. Here it is (I'll include it properly in v2, of course):// SPDX-License-Identifier: GPL-2.0-or-later
/*
* SMP support functions for Microwatt
* Copyright 2025 Paul Mackerras <[email protected]> */#include <
linux/kernel.h>
#include <linux/smp.h>
#include <linux/io.h>
#include <asm/early_ioremap.h>
#include <asm/xics.h>#include "
microwatt.h"static void
__initmicrowatt_smp_probe(void){ xics_smp_probe(); }static void
microwatt_smp_setup_cpu(int cpu){ if (cpu != 0) xics_setup_cpu(); }static struct
smp_ops_tmicrowatt_smp_ops= {
.probe =microwatt_smp_probe,
.message_pass = NULL, /* Usesmp_muxed_ipi_message_pass*/
.kick_cpu =smp_generic_kick_cpu,
.setup_cpu =microwatt_smp_setup_cpu,
};
Quoted 2 lines
/* XXX get from device tree */
#defineSYSCON_BASE0xc0000000
#define SYSCON_LENGTH 0x100
?
Quoted 10 lines
#define
SYSCON_CPU_CTRL0x58void
__initmicrowatt_init_smp(void){ volatile unsigned char __iomem *syscon; int ncpus; int timeout; syscon = early_ioremap(SYSCON_BASE, 0x100);
ioremap is not up by SMP init time? I always have to trawl through init spaghetti to work it out. I guess it's early SMP init.
Quoted 10 lines
if (syscon == NULL) {
pr_err("Failed to map SYSCON\n");
return;
}
ncpus = (readl(syscon + SYSCON_CPU_CTRL) >> 8) & 0xff;
if (ncpus < 2)
goto out;
smp_ops = µwatt_smp_ops;Quoted 7 lines
/* * Write two instructions at location 0: * mfspr r3, PIR * b __secondary_hold */ *(unsigned int *)KERNELBASE = 0x7c7ffaa6; *(unsigned int *)(KERNELBASE+4) = 0x4800005c;
Could move constants to PPC_INST_ ?
Quoted 11 lines
/* enable the other CPUs, they start at location 0 */
writel((1ul << ncpus) - 1, syscon + SYSCON_CPU_CTRL);
timeout = 10000;
while (!__secondary_hold_acknowledge) {
if (--timeout == 0)
break;
barrier();
}Quoted 3 lines
out:
early_iounmap((void *)syscon, 0x100); }
Looks okay otherwise.
Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE
In reply to Paul MackerrasQuoted 30 lines · Paul Mackerras
Quoted 24 lines · Nicholas Piggin
Quoted 23 lines · Paul Mackerras
Power ISA v3.1 implementations in the Linux Compliancy Subset and lower are not required to implement broadcast TLBIE, and in fact Microwatt doesn't. To avoid the need to specify "
disable_tlbie" on the kernel command line on SMP Microwatt systems, this defines a config option that asserts that broadcast TLBIE should never be used (the kernel will instead use IPIs to trigger local TLBIEs on other CPUs when required).Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/mm/book3s64/pgtable.c | 10 ++++++++-- arch/powerpc/platforms/Kconfig.cputype | 12 ++++++++++++ arch/powerpc/platforms/microwatt/Kconfig | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)arch/powerpc/mm/book3s64/pgtable.c +0
-0@@ -588,10 +588,16 @@ int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, }#endif Quoted 4 lines
arch/powerpc/mm/book3s64/pgtable.c int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl, · line 591
Quoted 1 line
arch/powerpc/mm/book3s64/pgtable.c +1
-0+#ifndef CONFIG_PPC_RADIX_NO_BROADCAST_TLBIE Hate to bikeshed, but would it be annoying to make this an affirmative option?
Quoted 4 lines
I guess we'd have to make all the platforms that do have broadcast tlbie (and a book3s-64 MMU with radix) select that option. Which would be powernv and pseries, I would think. If that's correct then it's probably not too annoying. Should I do that in v2?
I think you're right, powernv and pseries. If you wouldn't mind doing it please.
Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Paul MackerrasQuoted 14 lines · Paul Mackerras
Quoted 7 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
Microwatt now implements ISA v3.1 (SFFS compliancy subset), including prefixed instructions, scv/rfscv, and the FSCR, HFSCR, TAR, and CTRL registers. The privileged mode of operation is now hypervisor mode and there is no privileged non-hypervisor mode; the MSR[HV] bit is forced to 1.
Quoted 5 lines
Cool. Lots of development in microwatt.
Come to think of it we should have put a broadcast-tlbie feature in there and you wouldn't need the other patch. That can go on the todo list I guess.
Quoted 6 lines
I thought about doing that, but it would add complexity and I'm not sure it would actually have any measurable performance benefit. When I saw it was optional in the ISA for LCS and below, and that the kernel has all the machinery for handling the cross-CPU invalidations via IPI, it became very much the path of least resistance to use the kernel machinery.
I was unclear, I meant we (well, I) should have added that feature to the cpufeatures device tree. I'm sure I did because I also added the IPI+TLBIEL support but must be mistaken or never submitted it.
Perfectly reasonable to not add broadcast tlbie in microwatt.
Quoted 8 lines
Quoted 4 lines
system-call-vectored was available in ISA v3.0. Not that we do much with it at the moment IIRC, but there were dreams of wiring it in for compat guests. With that fixed,
Interesting. I looked in my copy of v2.07 (PowerISA_V2.07_PUBLIC.pdf) and it mentions rfscv in a couple of places, but has no description of scv or rfscv. I'll change it to v3.0.
Yeah that must be a mistake in the 2.07 doc.
Thanks,
Nick
Michael Ellerman
reviewerRe: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Paul MackerrasQuoted 76 lines · Paul Mackerras
Quoted 11 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
This adds support for Microwatt systems with more than one core, and updates the device tree for a 2-core version. (This does not prevent the kernel from running on a single-core system.)
Signed-off-by Paul Mackerras <[email protected]>Well, I'm impressed you added SMP :)
What happens with a 1 CPU system? Do we time out waiting for secondaries and continue, or is there something more graceful?
There's a field in the SYSCON register which tells you how many cores there are.
microwatt_init_smp()looks at that field and only starts the CPUs that are there.Oops, sorry, I see that I forgot to do 'git add' on
arch/powerpc/platforms/microwatt/smp.c. Here it is (I'll include it properly in v2, of course):// SPDX-License-Identifier: GPL-2.0-or-later
/*
* SMP support functions for Microwatt
* Copyright 2025 Paul Mackerras <[email protected]> */#include <
linux/kernel.h>
#include <linux/smp.h>
#include <linux/io.h>
#include <asm/early_ioremap.h>
#include <asm/xics.h>#include "
microwatt.h"static void
__initmicrowatt_smp_probe(void){ xics_smp_probe(); }static void
microwatt_smp_setup_cpu(int cpu){ if (cpu != 0) xics_setup_cpu(); }static struct
smp_ops_tmicrowatt_smp_ops= {
.probe =microwatt_smp_probe,
.message_pass = NULL, /* Usesmp_muxed_ipi_message_pass*/
.kick_cpu =smp_generic_kick_cpu,
.setup_cpu =microwatt_smp_setup_cpu,
};/* XXX get from device tree */
#defineSYSCON_BASE0xc0000000#define
SYSCON_CPU_CTRL0x58void
__initmicrowatt_init_smp(void){ volatile unsigned char __iomem *syscon; int ncpus; int timeout; syscon = early_ioremap(SYSCON_BASE, 0x100); if (syscon == NULL) { pr_err("Failed to map SYSCON\n"); return; } ncpus = (readl(syscon + SYSCON_CPU_CTRL) >> 8) & 0xff; if (ncpus < 2) goto out; smp_ops = µwatt_smp_ops;
Quoted 7 lines
/* * Write two instructions at location 0: * mfspr r3, PIR * b __secondary_hold */ *(unsigned int *)KERNELBASE = 0x7c7ffaa6; *(unsigned int *)(KERNELBASE+4) = 0x4800005c;
There's macros that would make these a little nicer, ie. PPC_RAW_MFSPR() and PPC_RAW_BRANCH().
Quoted 9 lines
/* enable the other CPUs, they start at location 0 */
writel((1ul << ncpus) - 1, syscon + SYSCON_CPU_CTRL);
timeout = 10000;
while (!__secondary_hold_acknowledge) {
if (--timeout == 0)
break;
barrier();
}I assume CPU 0 always boots first?
Is the loop actually necessary? It only waits for a single non-zero CPU to come up after all, not all of them.
cheers
Re: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Nicholas PigginQuoted 8 lines · Nicholas Piggin
Quoted 6 lines · Paul Mackerras
void
__initmicrowatt_init_smp(void){ volatile unsigned char __iomem *syscon; int ncpus; int timeout;
Quoted 5 lines
Quoted 1 line
syscon = early_ioremap(SYSCON_BASE, 0x100);ioremap is not up by SMP init time? I always have to trawl through init spaghetti to work it out. I guess it's early SMP init.
I had a little difficulty with this, and ended up with this function (microwatt_init_smp) being called at platform probe time, which is why the early_ioremap. We need the secondary CPUs spinning in __secondary_hold before smp_release_cpus() gets called, because that is what sends them to generic_secondary_smp_init().
Now smp_release_cpus() is called in setup_arch() before even the platform's setup_arch() function. (And also, smp_setup_cpu_maps() gets called even earlier.) Hence the choice of the platform probe function.
On platforms with OF and RTAS, the secondary CPUs are started and left spinning in __secondary_hold by prom_init(), which is right at the beginning, before the kernel proper starts executing. Microwatt doesn't have OF or RTAS, and the secondary CPUs are held in reset until microwatt_init_smp() releases them (and then they start at 0). Doing that as early as possible therefore more-or-less matches what OF/RTAS platforms do.
Paul.
Re: [PATCH 5/5] powerpc/microwatt: Add SMP support
In reply to Michael EllermanQuoted 4 lines · Michael Ellerman
Paul Mackerras <[email protected]> writes:
There's macros that would make these a little nicer, ie.
PPC_RAW_MFSPR()andPPC_RAW_BRANCH().
Thanks, I'll use them.
Quoted 11 lines
Quoted 9 lines
/* enable the other CPUs, they start at location 0 */ writel((1ul << ncpus) - 1, syscon + SYSCON_CPU_CTRL); timeout = 10000; while (!__secondary_hold_acknowledge) { if (--timeout == 0) break; barrier(); }I assume CPU 0 always boots first?
Yes, on reset, only CPU 0 starts executing, and the rest are held in the reset state until that writel() to SYSCON_CPU_CTRL enables them. They all then start executing at location 0.
Quoted 2 lines
Is the loop actually necessary? It only waits for a single non-zero CPU to come up after all, not all of them.
Yes, it only waits for the first one to get to the point of setting __secondary_hold_acknowledge, but that might take a microsecond or so, meaning we do need a loop (or I suppose a udelay(10) would probably also be sufficient). The assumption is that any others will get into the loop very shortly after the first. If that proves incorrect, it would be possible instead to start them one by one, clearing __secondary_hold_acknowledge each time (but I don't have a way to test such code at present).
Paul.
Hi!
Quoted 9 lines · Paul Mackerras
This patch series updates the kernel support for the Microwatt soft-core and its implementation on FPGA systems, particularly the Digilent Arty A7-100 FPGA development board.
Microwatt now supports almost all of the features of the SFFS (Scalar Fixed-poin and Floating-point Subset) compliancy subset of Power ISA version 3.1C, including prefixed instructions and the fixed-point hash (ROP mitigation) instructions. It is also now SMP-capable, and a dual-core system will fit on the Arty A7-100 board.
Congratulations!
Quoted 1 line
Microwatt does not have broadcast TLB invalidations in SMP systems;
So it isn't *really* SMP. Compare 603 vs. 604. With enough software (OS) trickery you can make some things work, but :-) (There have been many 603 multiprocessor systems as well, to draw the analogy further than wanted :-) )
Quoted 4 lines
the kernel already has code to deal with this. One of the patches in this series provides a config option to allow platforms to select unconditionally the behaviour where cross-CPU TLB invalidations are handled using inter-processor interrupts.
Are there plans to broadcast the (SMP cache invalidation) messages? Will uwatt support some real bus protocol, for example?
Again, congrats on this great milestone! Does this floating point support do square roots as well (aka "gpopt"; does it do "gfxopt" for that matter, fsel?) fsqrt is kinda tricky to get to work fully correctly :-)
Segher
Re: [PATCH 3/5] powerpc/microwatt: Define an idle power-save function
In reply to Paul MackerrasHi!
arch/powerpc/platforms/microwatt/setup.c static void __init microwatt_setup_arch(void) · line 43
Quoted 7 lines
arch/powerpc/platforms/microwatt/setup.c +7
-0+static void microwatt_idle (void ) +{ +if (!prep_irq_for_idle ()) +return ; + + __asm__ __volatile__ ("wait" ); +}
All asm without outputs is always implicitly volatile (if it wasn't, it could always be transfirmed whatever way you want, like, optimised away completely).
It can still be useful for documentation purposes of course, but here it is the other way around really, it is just cargo cult :-(
Segher
Re: [PATCH 3/5] powerpc/microwatt: Define an idle power-save function
In reply to Nicholas PigginQuoted 2 lines · Nicholas Piggin
Does wait cause MSR[EE] to be set? If not, do you need to use
prep_irq_for_idle_irqsoff()here maybe?
Assuming this does implement the standard ISA 2.03 wait instruction (and it better), this does not do anything other than to stop fetching and execution until some later event happens.
What values of the WC field does uwatt implement?
Segher
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Paul MackerrasReview
Quoted 2 lines · Paul Mackerras
(quoted diff) +1
-1- isa = <3000>; + isa = <3010>;
Does this mean 3.1, or 3.01? If the former, can this also encode 3.1C? Should uwatt say to support that?
arch/powerpc/boot/dts/microwatt.dts cpus { · line 55
Quoted 8 lines
arch/powerpc/boot/dts/microwatt.dts +3
-2little-endian { - isa = <2050>; - usable-privilege = <3>; + isa = <0>; + usable-privilege = <7>; + os-support = <0>; hwcap-bit-nr = <1>; };
What does "isa" in this node mean? Why is it changed to 0? (I don't know this node at all, I only know a property with the same name).
arch/powerpc/boot/dts/microwatt.dts cpus { · line 61
Quoted 7 lines
arch/powerpc/boot/dts/microwatt.dts +3
-2cache-inhibited-large-page { - isa = <2040>; - usable-privilege = <2>; + isa = <0>; + usable-privilege = <6>; + os-support = <0>; };
Similar question here.
arch/powerpc/boot/dts/microwatt.dts cpus { · line 72
Quoted 5 lines
arch/powerpc/boot/dts/microwatt.dts +2
-1- isa = <2010>; + isa = <0x00>; usable-privilege = <2>; + os-support = <0>; };
And here. That's a quite woolly way to say "0" btw ;-)
Segher
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Nicholas PigginQuoted 9 lines · Nicholas Piggin
Quoted 5 lines · Paul Mackerras
Microwatt now implements ISA v3.1 (SFFS compliancy subset), including prefixed instructions, scv/rfscv, and the FSCR, HFSCR, TAR, and CTRL registers. The privileged mode of operation is now hypervisor mode and there is no privileged non-hypervisor mode; the MSR[HV] bit is forced to 1.
Cool. Lots of development in microwatt.
Quoted 7 lines
Come to think of it we should have put a broadcast-tlbie feature in there and you wouldn't need the other patch. That can go on the todo list I guess.
system-call-vectored was available in ISA v3.0. Not that we do much with it at the moment IIRC, but there were dreams of wiring it in for compat guests. With that fixed,
This patch says 2.07 for it (if that is what 2070 mens(if that is what 2070 means). Something's not right :-)
Quoted 7 lines
arch/powerpc/boot/dts/microwatt.dts cpus { · line 113
Quoted 7 lines
arch/powerpc/boot/dts/microwatt.dts +6
-0+ system-call-vectored { + isa = <2070>; + usable-privilege = <7>; + os-support = <1>; + fscr-bit-nr = <12>; + hwcap-bit-nr = <52>; };
Segher
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Paul MackerrasQuoted 3 lines · Paul Mackerras
Interesting. I looked in my copy of v2.07 (PowerISA_V2.07_PUBLIC.pdf) and it mentions rfscv in a couple of places, but has no description of scv or rfscv. I'll change it to v3.0.
Huh, rfscv is 3.0 and later according to later versions of the ISA.
Segher
Re: [PATCH 2/5] powerpc/microwatt: Device-tree updates
In reply to Nicholas PigginQuoted 1 line · Nicholas Piggin
Perfectly reasonable to not add broadcast tlbie in microwatt.
If you call "the easy way out" reasonable, then sure. This pretty trivial hardware addition causes so many software headaches whenn missing, it isn't funny. "Friends don't let friends skimp on minimal system support features", etc. :-)
Segher
Re: [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE
In reply to Paul MackerrasQuoted 3 lines · Paul Mackerras
Power ISA v3.1 implementations in the Linux Compliancy Subset and lower are not required to implement broadcast TLBIE, and in fact Microwatt doesn't.
But this pretty much means that such systems cannot be SMP systems at all. Implementing the necessary synchronisation using some cobbled-together rickety jury-rigged contraption is not anyone's goal.
Interesting that you did not see any performance loss, btw! Well you didn't try it on anything bigger than a simple dual CPU :-)
Segher
Re: [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE
In reply to Paul MackerrasQuoted 7 lines · Paul Mackerras
Quoted 2 lines
Hate to bikeshed, but would it be annoying to make this an affirmative option?
I guess we'd have to make all the platforms that do have broadcast tlbie (and a book3s-64 MMU with radix) select that option. Which would be powernv and pseries, I would think. If that's correct then it's probably not too annoying. Should I do that in v2?
Such an option would mean "this platform implements the Power architecture correctly". Interesting :-)
Segher
Quoted 7 lines · Segher Boessenkool
Hi!
Quoted 4 lines · Paul Mackerras
This patch series updates the kernel support for the Microwatt soft-core and its implementation on FPGA systems, particularly the Digilent Arty A7-100 FPGA development board.
Quoted 7 lines
Quoted 5 lines
Microwatt now supports almost all of the features of the SFFS (Scalar Fixed-poin and Floating-point Subset) compliancy subset of Power ISA version 3.1C, including prefixed instructions and the fixed-point hash (ROP mitigation) instructions. It is also now SMP-capable, and a dual-core system will fit on the Arty A7-100 board.
Congratulations!
Thanks!
Quoted 3 lines
Quoted 1 line
Microwatt does not have broadcast TLB invalidations in SMP systems;
So it isn't *really* SMP. Compare 603 vs. 604. With enough software
Actually, the term "SMP" is about latency to memory, indicating that all CPUs have access to memory with similar latency. It doesn't say anything about coherency, either of memory caches or TLBs. So yes, Microwatt is SMP.
And for the record, the instruction and data caches are coherent, which is what matters to user-space. Stuff to do with the TLB is not visible to user-space. And the ISA explicitly says "TLBs are non-coherent caches of the HTABs and Radix Trees" (Book III section 6.10.1).
Quoted 3 lines
(OS) trickery you can make some things work, but :-) (There have been many 603 multiprocessor systems as well, to draw the analogy further than wanted :-) )
603 was a looong time ago, I don't recall the details.
Regarding broadcast TLBIEs, the protocols and mechanisms for doing that are known to be complex and slow in the IBM Power processors (ask Derek Williams about that :). Anton found that in fact doing only local TLBIEs and using IPIs gave *better* performance on IBM Power systems than using hardware broadcast TLBIEs in many cases (the reason being that software knows which other CPUs might have a given TLB entry, often quite a small set, whereas hardware doesn't, and has to send the invalidation to every CPU and wait for a response from every CPU). Add to that, that most other SMP-capable CPU architectures don't do broadcast TLB invalidations, Intel x86 for example.
Quoted 6 lines
Quoted 4 lines
the kernel already has code to deal with this. One of the patches in this series provides a config option to allow platforms to select unconditionally the behaviour where cross-CPU TLB invalidations are handled using inter-processor interrupts.
Are there plans to broadcast the (SMP cache invalidation) messages?
Cache (i.e. instruction and data cache) - yes, they *are* coherent. More precisely, the D caches are write-through, and all I and D caches snoop writes to memory (including DMA writes) and invalidate any cache lines being written to.
Quoted 1 line
Will uwatt support some real bus protocol, for example?
"Real" meaning using tri-state bus drivers, like we did in the 90s? :)
Quoted 4 lines
Again, congrats on this great milestone! Does this floating point support do square roots as well (aka "gpopt"; does it do "gfxopt" for that matter, fsel?) fsqrt is kinda tricky to get to work fully correctly :-)
Yes, fsqrt and fsel are implemented in hardware, and are accurate to the last bit. Also, the FPU handles denormalized values in hardware (both input and output) and implements all exception handling as per the ISA, including the trap-enabled overflow cases. Feel free to run whatever tests you like and report bugs. But we're getting a bit off-topic from the kernel patches. :)
Paul.
Re: [PATCH 3/5] powerpc/microwatt: Define an idle power-save function
In reply to Segher BoessenkoolQuoted 5 lines · Segher Boessenkool
Quoted 2 lines · Nicholas Piggin
Does wait cause MSR[EE] to be set? If not, do you need to use
prep_irq_for_idle_irqsoff()here maybe?Assuming this does implement the standard ISA 2.03 wait instruction
ISA 2.03? I don't have a copy of 2.03. I looked in 2.04 and the wait instruction there has a different extended opcode from the ISA 3.0/3.1 wait instruction. Why is ISA 2.03 at all relevant to anything here? In any case, the description of the wait instruction in 2.04 doesn't actually say that it waits for anything other than all previous instructions being finished.
Quoted 4 lines
(and it better), this does not do anything other than to stop fetching and execution until some later event happens.
What values of the WC field does uwatt implement?
Just WC=0; for other values it's a no-op. (Which is still arguably correct given that execution is allowed to resume when an implementation-dependent event occurs; P9 for instance just stops for a few microseconds, if I recall correctly, for any WC value.)
Paul.
[Sorry, I wanted to reply earlier, but it stayed in my drafts folder for a month]
On Sat, Feb 01, 2025 at 12:22:51PM +1100, Paul Mackerras wrote:
[snipped]
Quoted 13 lines
603 was a looong time ago, I don't recall the details.
Regarding broadcast TLBIEs, the protocols and mechanisms for doing that are known to be complex and slow in the IBM Power processors (ask Derek Williams about that :). Anton found that in fact doing only local TLBIEs and using IPIs gave *better* performance on IBM Power systems than using hardware broadcast TLBIEs in many cases (the reason being that software knows which other CPUs might have a given TLB entry, often quite a small set, whereas hardware doesn't, and has to send the invalidation to every CPU and wait for a response from every CPU). Add to that, that most other SMP-capable CPU architectures don't do broadcast TLB invalidations, Intel x86 for example.
Actually it's coming to x86, at least on the AMD side:
https://lore.kernel.org/all/[email protected]/
with performance numbers which look rather good.
I don't know how it looks like at the level of the hardware protocol, but implementing it on a single chip/socket is likely relatively simple.
Gabriel
Quoted 31 lines
Quoted 7 lines
Quoted 5 lines
the kernel already has code to deal with this. One of the patches in this series provides a config option to allow platforms to select unconditionally the behaviour where cross-CPU TLB invalidations are handled using inter-processor interrupts.
Are there plans to broadcast the (SMP cache invalidation) messages?
Cache (i.e. instruction and data cache) - yes, they *are* coherent. More precisely, the D caches are write-through, and all I and D caches snoop writes to memory (including DMA writes) and invalidate any cache lines being written to.
Quoted 1 line
Will uwatt support some real bus protocol, for example?
"Real" meaning using tri-state bus drivers, like we did in the 90s? :)
Quoted 4 lines
Again, congrats on this great milestone! Does this floating point support do square roots as well (aka "gpopt"; does it do "gfxopt" for that matter, fsel?) fsqrt is kinda tricky to get to work fully correctly :-)
Yes, fsqrt and fsel are implemented in hardware, and are accurate to the last bit. Also, the FPU handles denormalized values in hardware (both input and output) and implements all exception handling as per the ISA, including the trap-enabled overflow cases. Feel free to run whatever tests you like and report bugs. But we're getting a bit off-topic from the kernel patches. :)
Paul.