Skip to content

Commit b87ac02

Browse files
npigginmpe
authored andcommitted
powerpc: Introduce msgsnd/doorbell barrier primitives
POWER9 changes requirements and adds new instructions for synchronization. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent b866cc2 commit b87ac02

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

arch/powerpc/include/asm/dbell.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ static inline void _ppc_msgsnd(u32 msg)
4444
__asm__ __volatile__ (PPC_MSGSNDP(%0) : : "r" (msg));
4545
}
4646

47+
/* sync before sending message */
48+
static inline void ppc_msgsnd_sync(void)
49+
{
50+
__asm__ __volatile__ ("sync" : : : "memory");
51+
}
52+
53+
/* sync after taking message interrupt */
54+
static inline void ppc_msgsync(void)
55+
{
56+
}
57+
4758
#else /* CONFIG_PPC_BOOK3S */
4859

4960
#define PPC_DBELL_MSGTYPE PPC_DBELL
@@ -53,6 +64,17 @@ static inline void _ppc_msgsnd(u32 msg)
5364
__asm__ __volatile__ (PPC_MSGSND(%0) : : "r" (msg));
5465
}
5566

67+
/* sync before sending message */
68+
static inline void ppc_msgsnd_sync(void)
69+
{
70+
__asm__ __volatile__ ("sync" : : : "memory");
71+
}
72+
73+
/* sync after taking message interrupt */
74+
static inline void ppc_msgsync(void)
75+
{
76+
}
77+
5678
#endif /* CONFIG_PPC_BOOK3S */
5779

5880
extern void doorbell_global_ipi(int cpu);

arch/powerpc/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ extern const char *smp_ipi_name[];
128128
extern void smp_muxed_ipi_message_pass(int cpu, int msg);
129129
extern void smp_muxed_ipi_set_message(int cpu, int msg);
130130
extern irqreturn_t smp_ipi_demux(void);
131+
extern irqreturn_t smp_ipi_demux_relaxed(void);
131132

132133
void smp_init_pSeries(void);
133134
void smp_init_cell(void);

arch/powerpc/kernel/dbell.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void doorbell_global_ipi(int cpu)
3838

3939
kvmppc_set_host_ipi(cpu, 1);
4040
/* Order previous accesses vs. msgsnd, which is treated as a store */
41-
mb();
41+
ppc_msgsnd_sync();
4242
ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag);
4343
}
4444

@@ -53,7 +53,7 @@ void doorbell_core_ipi(int cpu)
5353

5454
kvmppc_set_host_ipi(cpu, 1);
5555
/* Order previous accesses vs. msgsnd, which is treated as a store */
56-
mb();
56+
ppc_msgsnd_sync();
5757
ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag);
5858
}
5959

@@ -82,12 +82,14 @@ void doorbell_exception(struct pt_regs *regs)
8282

8383
irq_enter();
8484

85+
ppc_msgsync();
86+
8587
may_hard_irq_enable();
8688

8789
kvmppc_set_host_ipi(smp_processor_id(), 0);
8890
__this_cpu_inc(irq_stat.doorbell_irqs);
8991

90-
smp_ipi_demux();
92+
smp_ipi_demux_relaxed(); /* already performed the barrier */
9193

9294
irq_exit();
9395
set_irq_regs(old_regs);

arch/powerpc/kernel/smp.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,18 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
245245
#endif
246246

247247
irqreturn_t smp_ipi_demux(void)
248+
{
249+
mb(); /* order any irq clear */
250+
251+
return smp_ipi_demux_relaxed();
252+
}
253+
254+
/* sync-free variant. Callers should ensure synchronization */
255+
irqreturn_t smp_ipi_demux_relaxed(void)
248256
{
249257
struct cpu_messages *info;
250258
unsigned long all;
251259

252-
mb(); /* order any irq clear */
253-
254260
info = this_cpu_ptr(&ipi_message);
255261
do {
256262
all = xchg(&info->messages, 0);

0 commit comments

Comments
 (0)