Skip to contentSkip to conversation

powerpc/powernv: fix POWER9 msgsnd addressing

PATCH New Nicholas Piggin 1 participant 2 messages Mar 12, 2017

Subsystems (2)
lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/powernv: fix POWER9 msgsnd addressing

ISAv3 changes the addressing mode of msgsnd from TIR to PIR. Without this change, all doorbell IPIs on bare metal go to core 0 threads.

---
 arch/powerpc/include/asm/dbell.h |  4 ----
 arch/powerpc/kernel/dbell.c      | 12 +++++++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/dbell.h +0 -4
index 378167377065..b9d3b52e2a2c 100644
@@ -35,8 +35,6 @@ enum ppc_dbell {
 #ifdef CONFIG_PPC_BOOK3S
 
 #define PPC_DBELL_MSGTYPE		PPC_DBELL_SERVER
-#define SPRN_DOORBELL_CPUTAG		SPRN_TIR
-#define PPC_DBELL_TAG_MASK		0x7f
 
 static inline void _ppc_msgsnd(u32 msg)
 {
@@ -49,8 +47,6 @@ static inline void _ppc_msgsnd(u32 msg)
 #else /* CONFIG_PPC_BOOK3S */
 
 #define PPC_DBELL_MSGTYPE		PPC_DBELL
-#define SPRN_DOORBELL_CPUTAG		SPRN_PIR
-#define PPC_DBELL_TAG_MASK		0x3fff
 
 static inline void _ppc_msgsnd(u32 msg)
 {
arch/powerpc/kernel/dbell.c +11 -1
index 2128f3a96c32..b2011a261045 100644
@@ -22,7 +22,17 @@
 #ifdef CONFIG_SMP
 void doorbell_setup_this_cpu(void)
 {
-	unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK;
+	unsigned long tag;
+
+#ifdef CONFIG_PPC_BOOK3S
+	if (cpu_has_feature(CPU_FTR_HVMODE) && cpu_has_feature(CPU_FTR_ARCH_300))
+		tag = mfspr(SPRN_PIR) & 0xfffff;
+	else
+		tag = mfspr(SPRN_TIR) & 0x7f;
+
+#else
+	tag = mfspr(SPRN_PIR) & 0x3fff;
+#endif
 
 	smp_muxed_ipi_set_data(smp_processor_id(), tag);
 }
Signature · 1 line
2.11.0
author reviewer
#1 lore raw

PATCH 1/1 KVM: PPC: Book3S HV: Use msgsync for hypervisor doorbells on POWER9

When msgsnd is used for IPIs to other cores, msgsync must be executed by the target to order stores performed on the source before its msgsnd (provided the source executes the appropriate sync).

Fixes 1704a81ccebc ("KVM: PPC: Book3S HV: Use msgsnd for IPIs to other cores on POWER9")

---
Hi,

I found this by inspection only and don't have a way to test it (I have no POWER9 KVM set up yet). I don't know the KVM interrupt code very well, so it might not be the right way to fix it. Flames welcome.

Thanks,
Nick

 arch/powerpc/include/asm/ppc-opcode.h   | 2 ++
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++
 2 files changed, 5 insertions(+)
arch/powerpc/include/asm/ppc-opcode.h +2 -0
index e7d6d86563ee..142d78d645f4 100644
@@ -161,6 +161,7 @@
 #define PPC_INST_MFTMR			0x7c0002dc
 #define PPC_INST_MSGSND			0x7c00019c
 #define PPC_INST_MSGCLR			0x7c0001dc
+#define PPC_INST_MSGSYNC		0x7c0006ec
 #define PPC_INST_MSGSNDP		0x7c00011c
 #define PPC_INST_MTTMR			0x7c0003dc
 #define PPC_INST_NOP			0x60000000
@@ -345,6 +346,7 @@
 					___PPC_RB(b) | __PPC_EH(eh))
 #define PPC_MSGSND(b)		stringify_in_c(.long PPC_INST_MSGSND | \
 					___PPC_RB(b))
+#define PPC_MSGSYNC		stringify_in_c(.long PPC_INST_MSGSYNC)
 #define PPC_MSGCLR(b)		stringify_in_c(.long PPC_INST_MSGCLR | \
 					___PPC_RB(b))
 #define PPC_MSGSNDP(b)		stringify_in_c(.long PPC_INST_MSGSNDP | \
arch/powerpc/kvm/book3s_hv_rmhandlers.S +3 -0
index 7c6477d1840a..caba3afe787d 100644
@@ -1239,6 +1239,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
 	/* Hypervisor doorbell - exit only if host IPI flag set */
 	cmpwi	r12, BOOK3S_INTERRUPT_H_DOORBELL
 	bne	3f
+BEGIN_FTR_SECTION
+	PPC_MSGSYNC
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
 	lbz	r0, HSTATE_HOST_IPI(r13)
 	cmpwi	r0, 0
 	beq	4f
Signature · 1 line
2.11.0