Skip to contentSkip to conversation

Add support for Microwatt-based SoCs

RFC PATCH In review Paul Mackerras 6 participants 14 messages May 9, 2020 – May 14, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

cover Add support for Microwatt-based SoCs

This patch series adds support for running Linux on a Microwatt SoC (system on chip) implementation on an FPGA. Microwatt is a small Power ISA implementation, targetted at FPGAs, aiming for PowerISA v3.0B compliance. It does not currently implement any floating-point or vector instructions, hypervisor mode, big-endian mode, 32-bit mode, or the HPT/SLB MMU facilities. However, it does support enough to run Linux (as of my "mmu" branch plus Ben's "litedram" branch").

Paul.

#1 lore raw

RFC PATCH 1/4 powerpc/radix: Fix compilation for radix with CONFIG_SMP=n

This fixes the compile errors we currently get with CONFIG_SMP=n and CONFIG_PPC_RADIX_MMU=y.

---
 arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 ++
 arch/powerpc/mm/book3s64/radix_tlb.c                | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +2 -0
index ca8db193ae38..adcc6114d170 100644
@@ -68,6 +68,8 @@ extern void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmad
 #define radix__flush_all_mm(mm)		radix__local_flush_all_mm(mm)
 #define radix__flush_tlb_page(vma,addr)	radix__local_flush_tlb_page(vma,addr)
 #define radix__flush_tlb_page_psize(mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p)
+#define exit_flush_lazy_tlbs(mm)	do { } while (0)
+#define __flush_all_mm(mm, fullmm)	radix__local_flush_all_mm(mm)
 #endif
 extern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr);
 extern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr);
arch/powerpc/mm/book3s64/radix_tlb.c +0 -2
index 03f43c924e00..e3ea026cf91e 100644
@@ -776,8 +776,6 @@ void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
 }
 EXPORT_SYMBOL(radix__flush_tlb_page);
 
-#else /* CONFIG_SMP */
-#define radix__flush_all_mm radix__local_flush_all_mm
 #endif /* CONFIG_SMP */
 
 static void do_tlbiel_kernel(void *info)
Signature · 1 line
2.25.3
#2 lore raw

Re: [PATCH RFC 1/4] powerpc/radix: Fix compilation for radix with CONFIG_SMP=n

Excerpts from Paul Mackerras's message of May 9, 2020 3:02 pm:

Quoted 2 lines

This fixes the compile errors we currently get with CONFIG_SMP=n and CONFIG_PPC_RADIX_MMU=y.

Did I already fix this, or does it keep getting broken?! :(

Anyway fine by me if it's required.

Thanks,
Nick

#3 lore raw

Re: [PATCH RFC 1/4] powerpc/radix: Fix compilation for radix with CONFIG_SMP=n

Quoted 8 lines · Nicholas Piggin

Excerpts from Paul Mackerras's message of May 9, 2020 3:02 pm:

Quoted 2 lines

This fixes the compile errors we currently get with CONFIG_SMP=n and CONFIG_PPC_RADIX_MMU=y.

Did I already fix this, or does it keep getting broken?! :(

Anyway fine by me if it's required.

You're right, your fix was merged in 5.7-rc1.

Cheers,

Joel

#4 lore raw

RFC PATCH 2/4 powerpc: Add Microwatt platform

In reply to Paul Mackerras

Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP.

This adds a new machine type to support FPGA-based SoCs with a Microwatt core.

---
 arch/powerpc/Kconfig                      |    2 +-
 arch/powerpc/configs/microwatt_defconfig  | 1418 +++++++++++++++++++++
 arch/powerpc/platforms/Kconfig            |    1 +
 arch/powerpc/platforms/Makefile           |    1 +
 arch/powerpc/platforms/microwatt/Kconfig  |    9 +
 arch/powerpc/platforms/microwatt/Makefile |    1 +
 arch/powerpc/platforms/microwatt/setup.c  |   40 +
 7 files changed, 1471 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/configs/microwatt_defconfig
 create mode 100644 arch/powerpc/platforms/microwatt/Kconfig
 create mode 100644 arch/powerpc/platforms/microwatt/Makefile
 create mode 100644 arch/powerpc/platforms/microwatt/setup.c
arch/powerpc/Kconfig +1 -1
index 497b7d0b2d7e..97286b8312f5 100644
@@ -407,7 +407,7 @@ config HUGETLB_PAGE_SIZE_VARIABLE
 
 config MATH_EMULATION
 	bool "Math emulation"
-	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE
+	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE || PPC_MICROWATT
 	help
 	  Some PowerPC chips designed for embedded applications do not have
 	  a floating-point unit and therefore do not implement the
arch/powerpc/configs/microwatt_defconfig new file +1418 -0

1,418 lines not on this page · raw message

arch/powerpc/platforms/Kconfig +1 -0
index 1f8025383caa..5b701acc6afa 100644
@@ -20,6 +20,7 @@ source "arch/powerpc/platforms/embedded6xx/Kconfig"
 source "arch/powerpc/platforms/44x/Kconfig"
 source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
+source "arch/powerpc/platforms/microwatt/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 143d4417f6cc..edcb54cdb1a8 100644
@@ -22,3 +22,4 @@ obj-$(CONFIG_PPC_CELL)		+= cell/
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
+obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
arch/powerpc/platforms/microwatt/Kconfig new file +9 -0
new file mode 100644
index 000000000000..981f722ae9ce
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+config PPC_MICROWATT
+	depends on PPC64 && PPC_BOOK3S
+	bool "Microwatt SoC platform"
+	select PPC_XICS
+	select PPC_NATIVE
+	help
+          This option enables support for FPGA-based Microwatt implementations.
+
arch/powerpc/platforms/microwatt/Makefile new file +1 -0
new file mode 100644
index 000000000000..e6885b3b2ee7
@@ -0,0 +1 @@
+obj-y	+= setup.o
arch/powerpc/platforms/microwatt/setup.c new file +40 -0
new file mode 100644
index 000000000000..3cfc5955a6fe
@@ -0,0 +1,40 @@
+/*
+ * Microwatt FPGA-based SoC platform setup code.
+ *
+ * Copyright 2020 Paul Mackerras ([email protected]), IBM Corp.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/stddef.h>
+#include <linux/init.h>
+#include <linux/of.h>
+#include <asm/machdep.h>
+#include <asm/time.h>
+
+static void __init microwatt_calibrate_decr(void)
+{
+	ppc_tb_freq = 100000000;
+	ppc_proc_freq = 100000000;
+}
+
+static void __init microwatt_setup_arch(void)
+{
+}
+
+static void __init microwatt_init_IRQ(void)
+{
+}
+
+static int __init microwatt_probe(void)
+{
+	return of_machine_is_compatible("microwatt-soc");
+}
+
+define_machine(microwatt) {
+	.name			= "microwatt",
+	.probe			= microwatt_probe,
+	.setup_arch		= microwatt_setup_arch,
+	.init_IRQ		= microwatt_init_IRQ,
+	.calibrate_decr		= microwatt_calibrate_decr,
+};
Signature · 1 line
2.25.3
#5 lore raw

Re: [PATCH RFC 2/4] powerpc: Add Microwatt platform

Excerpts from Paul Mackerras's message of May 9, 2020 3:02 pm:

Quoted 6 lines

Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP.

This adds a new machine type to support FPGA-based SoCs with a Microwatt core.

Very cool!

Would there be any point sharing this with the "naked metal" platform Alistair has for booting POWER in L3 without OPAL? Or is it easy enough to have a several different simple 64s platforms?

I have an HPT conditional compile patch and a few other diet Kconfig things I'll now be better justified to try get merged :)

Thanks,
Nick

#6 lore raw

Re: [PATCH RFC 2/4] powerpc: Add Microwatt platform

Quoted 5 lines · AEST Nicholas Piggin

Excerpts from Paul Mackerras's message of May 9, 2020 3:02 pm:

Quoted 4 lines

Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP.

Quoted 8 lines
Quoted 2 lines

This adds a new machine type to support FPGA-based SoCs with a Microwatt core.

Very cool!

Would there be any point sharing this with the "naked metal" platform Alistair has for booting POWER in L3 without OPAL? Or is it easy enough to have a several different simple 64s platforms?

It looks pretty similar at the moment, I've been meaning to clean those patches up and send them upstream but Paul has beaten me to it. The main difference so far is how the console is setup. For booting cache contained I was using a device tree pointing at a standard UART driver and enabling the standard OF platform device tree probing.

- Alistair

Quoted 5 lines

I have an HPT conditional compile patch and a few other diet Kconfig things I'll now be better justified to try get merged :)

Thanks,
Nick

#7 lore raw

Re: [PATCH RFC 2/4] powerpc: Add Microwatt platform

Excerpts from Alistair Popple's message of May 9, 2020 6:36 pm:

Quoted 15 lines · AEST Nicholas Piggin
Quoted 5 lines

Excerpts from Paul Mackerras's message of May 9, 2020 3:02 pm:

Quoted 4 lines

Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP.

Quoted 8 lines
Quoted 2 lines

This adds a new machine type to support FPGA-based SoCs with a Microwatt core.

Very cool!

Would there be any point sharing this with the "naked metal" platform Alistair has for booting POWER in L3 without OPAL? Or is it easy enough to have a several different simple 64s platforms?

Quoted 5 lines

It looks pretty similar at the moment, I've been meaning to clean those patches up and send them upstream but Paul has beaten me to it. The main difference so far is how the console is setup. For booting cache contained I was using a device tree pointing at a standard UART driver and enabling the standard OF platform device tree probing.

Well I'd only merge them if you think it makes sense. If the platform is a perfectly good abstraction for the differences and merging them would just result in painful special cases it wouldn't be worthwhile. It's clearly not a lot of code.

Thanks,
Nick

#8 lore raw

Re: [PATCH RFC 2/4] powerpc: Add Microwatt platform

In reply to Paul Mackerras
Quoted 3 lines · Paul Mackerras

Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP.

... or FP or VSX or Altivec?

What about transactional memory?

Quoted 45 lines

This adds a new machine type to support FPGA-based SoCs with a Microwatt core.

---
 arch/powerpc/Kconfig                      |    2 +-
 arch/powerpc/configs/microwatt_defconfig  | 1418 +++++++++++++++++++++
 arch/powerpc/platforms/Kconfig            |    1 +
 arch/powerpc/platforms/Makefile           |    1 +
 arch/powerpc/platforms/microwatt/Kconfig  |    9 +
 arch/powerpc/platforms/microwatt/Makefile |    1 +
 arch/powerpc/platforms/microwatt/setup.c  |   40 +
 7 files changed, 1471 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/configs/microwatt_defconfig
 create mode 100644 arch/powerpc/platforms/microwatt/Kconfig
 create mode 100644 arch/powerpc/platforms/microwatt/Makefile
 create mode 100644 arch/powerpc/platforms/microwatt/setup.c
arch/powerpc/Kconfig +1 -1
index 497b7d0b2d7e..97286b8312f5 100644
@@ -407,7 +407,7 @@ config HUGETLB_PAGE_SIZE_VARIABLE
 
 config MATH_EMULATION
 	bool "Math emulation"
-	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE
+	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE || PPC_MICROWATT
 	help
 	  Some PowerPC chips designed for embedded applications do not have
 	  a floating-point unit and therefore do not implement the
arch/powerpc/configs/microwatt_defconfig new file +8 -0
new file mode 100644
index 000000000000..f4f4c965a786
@@ -0,0 +1,1418 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/powerpc 5.6.0 Kernel Configuration
+#
+
+#
+# Compiler: powerpc64le-linux-gnu-gcc (GCC) 9.2.1 20190827 (Red Hat Cross 9.2.1-1)
+#

arch/powerpc/configs/microwatt_defconfig line 18

Quoted 10 lines
arch/powerpc/configs/microwatt_defconfig new file +10 -0
+CONFIG_CC_IS_GCC=y
+CONFIG_GCC_VERSION=90201
+CONFIG_CLANG_VERSION=0
+CONFIG_CC_HAS_ASM_GOTO=y
+CONFIG_CC_HAS_ASM_INLINE=y
+CONFIG_CC_HAS_WARN_MAYBE_UNINITIALIZED=y
+CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED=y
+CONFIG_IRQ_WORK=y
+CONFIG_BUILDTIME_TABLE_SORT=y
+CONFIG_THREAD_INFO_IN_TASK=y

This should be a minimised config generated with savedefconfig.

Quoted 27 lines
arch/powerpc/platforms/Kconfig +1 -0
index 1f8025383caa..5b701acc6afa 100644
@@ -20,6 +20,7 @@ source "arch/powerpc/platforms/embedded6xx/Kconfig"
 source "arch/powerpc/platforms/44x/Kconfig"
 source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
+source "arch/powerpc/platforms/microwatt/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 143d4417f6cc..edcb54cdb1a8 100644
@@ -22,3 +22,4 @@ obj-$(CONFIG_PPC_CELL)		+= cell/
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
+obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
arch/powerpc/platforms/microwatt/Kconfig new file +0 -0
new file mode 100644
index 000000000000..981f722ae9ce

arch/powerpc/platforms/microwatt/Kconfig line 3

Quoted 3 lines
arch/powerpc/platforms/microwatt/Kconfig new file +3 -0
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+config PPC_MICROWATT
+	depends on PPC64 && PPC_BOOK3S

That can just be PPC_BOOK3S_64

I think it should also depend on !CPU_BIG_ENDIAN && !SMP ?

Should it also select MATH_EMULATION?
And MATH_EMULATION_FULL ?

Quoted 28 lines
arch/powerpc/platforms/microwatt/Kconfig new file +6 -0
+	bool "Microwatt SoC platform"
+	select PPC_XICS
+	select PPC_NATIVE
+	help
+          This option enables support for FPGA-based Microwatt implementations.
+
arch/powerpc/platforms/microwatt/Makefile new file +1 -0
new file mode 100644
index 000000000000..e6885b3b2ee7
@@ -0,0 +1 @@
+obj-y	+= setup.o
arch/powerpc/platforms/microwatt/setup.c new file +9 -0
new file mode 100644
index 000000000000..3cfc5955a6fe
@@ -0,0 +1,40 @@
+/*
+ * Microwatt FPGA-based SoC platform setup code.
+ *
+ * Copyright 2020 Paul Mackerras ([email protected]), IBM Corp.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/stddef.h>

arch/powerpc/platforms/microwatt/setup.c line 19

Quoted 10 lines
arch/powerpc/platforms/microwatt/setup.c new file +10 -0
+#include <linux/init.h>
+#include <linux/of.h>
+#include <asm/machdep.h>
+#include <asm/time.h>
+
+static void __init microwatt_calibrate_decr(void)
+{
+	ppc_tb_freq = 100000000;
+	ppc_proc_freq = 100000000;
+}

Why can't those come via the device tree?

arch/powerpc/platforms/microwatt/setup.c line 23

Quoted 4 lines
arch/powerpc/platforms/microwatt/setup.c new file +4 -0
+
+static void __init microwatt_setup_arch(void)
+{
+}

That can be NULL in ppc_md.

arch/powerpc/platforms/microwatt/setup.c line 27

Quoted 3 lines
arch/powerpc/platforms/microwatt/setup.c new file +3 -0
+static void __init microwatt_init_IRQ(void)
+{
+}

Can be NULL in ppc_md.

Quoted 14 lines
arch/powerpc/platforms/microwatt/setup.c new file +12 -0
+static int __init microwatt_probe(void)
+{
+	return of_machine_is_compatible("microwatt-soc");
+}
+
+define_machine(microwatt) {
+	.name			= "microwatt",
+	.probe			= microwatt_probe,
+	.setup_arch		= microwatt_setup_arch,
+	.init_IRQ		= microwatt_init_IRQ,
+	.calibrate_decr		= microwatt_calibrate_decr,
+};
Signature · 1 line
2.25.3

cheers

#9 lore raw

RFC PATCH 3/4 powerpc/microwatt: Add early debug UART support for Microwatt

In reply to Paul Mackerras

Currently microwatt-based SoCs come with a "potato" UART. This adds udbg support for the potato UART, giving us both an early debug console, and a runtime console using the hvc-udbg support.

---
 arch/powerpc/Kconfig.debug               |   6 ++
 arch/powerpc/include/asm/udbg.h          |   1 +
 arch/powerpc/kernel/udbg.c               |   2 +
 arch/powerpc/platforms/microwatt/setup.c | 108 +++++++++++++++++++++++
 4 files changed, 117 insertions(+)
arch/powerpc/Kconfig.debug +6 -0
index 0b063830eea8..399abc6d2af7 100644
@@ -277,6 +277,12 @@ config PPC_EARLY_DEBUG_MEMCONS
 	  This console provides input and output buffers stored within the
 	  kernel BSS and should be safe to select on any system. A debugger
 	  can then be used to read kernel output or send input to the console.
+
+config PPC_EARLY_DEBUG_MICROWATT
+       bool "Microwatt potato UART"
+       help
+         Select this to enable early debugging using the potato UART
+	 included in the Microwatt SOC.
 endchoice
 
 config PPC_MEMCONS_OUTPUT_SIZE
arch/powerpc/include/asm/udbg.h +1 -0
index 0ea9e70ed78b..2dbd2d3b0591 100644
@@ -53,6 +53,7 @@ extern void __init udbg_init_ehv_bc(void);
 extern void __init udbg_init_ps3gelic(void);
 extern void __init udbg_init_debug_opal_raw(void);
 extern void __init udbg_init_debug_opal_hvsi(void);
+extern void __init udbg_init_debug_microwatt(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/udbg.c +2 -0
index 01595e8cafe7..e614993021c6 100644
@@ -67,6 +67,8 @@ void __init udbg_early_init(void)
 	udbg_init_debug_opal_raw();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI)
 	udbg_init_debug_opal_hvsi();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_MICROWATT)
+	udbg_init_debug_microwatt();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/microwatt/setup.c +108 -0

121 lines not on this page · raw message

Signature · 1 line
2.25.3
Reviewed-by on v1 3/4
#10 lore raw

Re: [PATCH RFC 3/4] powerpc/microwatt: Add early debug UART support for Microwatt

Hi!

arch/powerpc/platforms/microwatt/setup.c line 40

Quoted 3 lines · Paul Mackerras
arch/powerpc/platforms/microwatt/setup.c +3 -0
+	__asm__ volatile("mtmsrd %3,0; ldcix %0,%1,%2; mtmsrd %4,0"
+			 : "=r" (val) : "b" (potato_uart_base), "r" (offset),
+			   "r" (msr & ~MSR_DR), "r" (msr));

That should be "=&r"(val) (an earlyclobber), because when %0 is written, %4 will still be used later.

Looks fine otherwise.

Segher

#11 lore raw

Re: [PATCH RFC 3/4] powerpc/microwatt: Add early debug UART support for Microwatt

In reply to Paul Mackerras
Quoted 3 lines · Paul Mackerras

Currently microwatt-based SoCs come with a "potato" UART. This adds udbg support for the potato UART, giving us both an early debug console, and a runtime console using the hvc-udbg support.

Can y'all get a real UART?

There's more code here than in the platform itself.

cheers

#12 lore raw

RFC PATCH 4/4 powerpc/radix: Add support for microwatt's PRTBL SPR

In reply to Paul Mackerras

Microwatt currently doesn't implement hypervisor mode and therefore doesn't implement the partition table. It does implement the process table and radix page table walks.

This adds code to write the base address of the process table to the PRTBL SPR, which has been assigned SPR 720 for now, as that is in the range of SPR numbers assigned for experimental use. PRTBL is only written when we have neither the FW_FEATURE_LPAR feature nor the CPU_FTR_HVMODE feature.

---
 arch/powerpc/include/asm/reg.h           |  1 +
 arch/powerpc/mm/book3s64/radix_pgtable.c | 13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/reg.h +1 -0
index 1aa46dff0957..6ea3fc42740d 100644
@@ -721,6 +721,7 @@
 #endif
 #define SPRN_TIR	0x1BE	/* Thread Identification Register */
 #define SPRN_PTCR	0x1D0	/* Partition table control Register */
+#define SPRN_PRTBL	0x2D0	/* Process table pointer */
 #define SPRN_PSPB	0x09F	/* Problem State Priority Boost reg */
 #define SPRN_PTEHI	0x3D5	/* 981 7450 PTE HI word (S/W TLB load) */
 #define SPRN_PTELO	0x3D6	/* 982 7450 PTE LO word (S/W TLB load) */
arch/powerpc/mm/book3s64/radix_pgtable.c +9 -4
index dd1bea45325c..2e6a376c9d82 100644
@@ -600,10 +600,15 @@ void __init radix__early_init_mmu(void)
 	radix_init_pgtable();
 
 	if (!firmware_has_feature(FW_FEATURE_LPAR)) {
-		lpcr = mfspr(SPRN_LPCR);
-		mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
-		radix_init_partition_table();
-		radix_init_amor();
+		if (cpu_has_feature(CPU_FTR_HVMODE)) {
+			lpcr = mfspr(SPRN_LPCR);
+			mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
+			radix_init_partition_table();
+			radix_init_amor();
+		} else {
+			mtspr(SPRN_PRTBL, (__pa(process_tb) |
+					   (PRTB_SIZE_SHIFT - 12)));
+		}
 	} else {
 		radix_init_pseries();
 	}
Signature · 1 line
2.25.3
#13 lore raw

Re: [PATCH RFC 4/4] powerpc/radix: Add support for microwatt's PRTBL SPR

Excerpts from Paul Mackerras's message of May 9, 2020 3:04 pm:

Quoted 9 lines

Microwatt currently doesn't implement hypervisor mode and therefore doesn't implement the partition table. It does implement the process table and radix page table walks.

This adds code to write the base address of the process table to the PRTBL SPR, which has been assigned SPR 720 for now, as that is in the range of SPR numbers assigned for experimental use. PRTBL is only written when we have neither the FW_FEATURE_LPAR feature nor the CPU_FTR_HVMODE feature.

What do you think about adding a FW_FEATURE and/or CPU_FTR for microwatt?

No big deal now, but I'm sure you'll be adding other things.

Thanks,
Nick

Quoted 47 lines
---
 arch/powerpc/include/asm/reg.h           |  1 +
 arch/powerpc/mm/book3s64/radix_pgtable.c | 13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/reg.h +1 -0
index 1aa46dff0957..6ea3fc42740d 100644
@@ -721,6 +721,7 @@
 #endif
 #define SPRN_TIR	0x1BE	/* Thread Identification Register */
 #define SPRN_PTCR	0x1D0	/* Partition table control Register */
+#define SPRN_PRTBL	0x2D0	/* Process table pointer */
 #define SPRN_PSPB	0x09F	/* Problem State Priority Boost reg */
 #define SPRN_PTEHI	0x3D5	/* 981 7450 PTE HI word (S/W TLB load) */
 #define SPRN_PTELO	0x3D6	/* 982 7450 PTE LO word (S/W TLB load) */
arch/powerpc/mm/book3s64/radix_pgtable.c +9 -4
index dd1bea45325c..2e6a376c9d82 100644
@@ -600,10 +600,15 @@ void __init radix__early_init_mmu(void)
 	radix_init_pgtable();
 
 	if (!firmware_has_feature(FW_FEATURE_LPAR)) {
-		lpcr = mfspr(SPRN_LPCR);
-		mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
-		radix_init_partition_table();
-		radix_init_amor();
+		if (cpu_has_feature(CPU_FTR_HVMODE)) {
+			lpcr = mfspr(SPRN_LPCR);
+			mtspr(SPRN_LPCR, lpcr | LPCR_UPRT | LPCR_HR);
+			radix_init_partition_table();
+			radix_init_amor();
+		} else {
+			mtspr(SPRN_PRTBL, (__pa(process_tb) |
+					   (PRTB_SIZE_SHIFT - 12)));
+		}
 	} else {
 		radix_init_pseries();
 	}
Signature · 1 line
2.25.3