.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2009 Freescale Semiconductor, Inc. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or |
---|
5 | | - * modify it under the terms of the GNU General Public License |
---|
6 | | - * as published by the Free Software Foundation; either version |
---|
7 | | - * 2 of the License, or (at your option) any later version. |
---|
8 | 4 | * |
---|
9 | 5 | * provides masks and opcode images for use by code generation, emulation |
---|
10 | 6 | * and for instructions that older assemblers might not know about |
---|
.. | .. |
---|
15 | 11 | #include <linux/smp.h> |
---|
16 | 12 | #include <linux/threads.h> |
---|
17 | 13 | |
---|
| 14 | +#include <asm/cputhreads.h> |
---|
18 | 15 | #include <asm/ppc-opcode.h> |
---|
19 | 16 | #include <asm/feature-fixups.h> |
---|
| 17 | +#include <asm/kvm_ppc.h> |
---|
20 | 18 | |
---|
21 | 19 | #define PPC_DBELL_MSG_BRDCAST (0x04000000) |
---|
22 | 20 | #define PPC_DBELL_TYPE(x) (((x) & 0xf) << (63-36)) |
---|
.. | .. |
---|
91 | 89 | |
---|
92 | 90 | #endif /* CONFIG_PPC_BOOK3S */ |
---|
93 | 91 | |
---|
94 | | -extern void doorbell_global_ipi(int cpu); |
---|
95 | | -extern void doorbell_core_ipi(int cpu); |
---|
96 | | -extern int doorbell_try_core_ipi(int cpu); |
---|
97 | 92 | extern void doorbell_exception(struct pt_regs *regs); |
---|
98 | 93 | |
---|
99 | 94 | static inline void ppc_msgsnd(enum ppc_dbell type, u32 flags, u32 tag) |
---|
.. | .. |
---|
104 | 99 | _ppc_msgsnd(msg); |
---|
105 | 100 | } |
---|
106 | 101 | |
---|
| 102 | +#ifdef CONFIG_SMP |
---|
| 103 | + |
---|
| 104 | +/* |
---|
| 105 | + * Doorbells must only be used if CPU_FTR_DBELL is available. |
---|
| 106 | + * msgsnd is used in HV, and msgsndp is used in !HV. |
---|
| 107 | + * |
---|
| 108 | + * These should be used by platform code that is aware of restrictions. |
---|
| 109 | + * Other arch code should use ->cause_ipi. |
---|
| 110 | + * |
---|
| 111 | + * doorbell_global_ipi() sends a dbell to any target CPU. |
---|
| 112 | + * Must be used only by architectures that address msgsnd target |
---|
| 113 | + * by PIR/get_hard_smp_processor_id. |
---|
| 114 | + */ |
---|
| 115 | +static inline void doorbell_global_ipi(int cpu) |
---|
| 116 | +{ |
---|
| 117 | + u32 tag = get_hard_smp_processor_id(cpu); |
---|
| 118 | + |
---|
| 119 | + kvmppc_set_host_ipi(cpu); |
---|
| 120 | + /* Order previous accesses vs. msgsnd, which is treated as a store */ |
---|
| 121 | + ppc_msgsnd_sync(); |
---|
| 122 | + ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag); |
---|
| 123 | +} |
---|
| 124 | + |
---|
| 125 | +/* |
---|
| 126 | + * doorbell_core_ipi() sends a dbell to a target CPU in the same core. |
---|
| 127 | + * Must be used only by architectures that address msgsnd target |
---|
| 128 | + * by TIR/cpu_thread_in_core. |
---|
| 129 | + */ |
---|
| 130 | +static inline void doorbell_core_ipi(int cpu) |
---|
| 131 | +{ |
---|
| 132 | + u32 tag = cpu_thread_in_core(cpu); |
---|
| 133 | + |
---|
| 134 | + kvmppc_set_host_ipi(cpu); |
---|
| 135 | + /* Order previous accesses vs. msgsnd, which is treated as a store */ |
---|
| 136 | + ppc_msgsnd_sync(); |
---|
| 137 | + ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag); |
---|
| 138 | +} |
---|
| 139 | + |
---|
| 140 | +/* |
---|
| 141 | + * Attempt to cause a core doorbell if destination is on the same core. |
---|
| 142 | + * Returns 1 on success, 0 on failure. |
---|
| 143 | + */ |
---|
| 144 | +static inline int doorbell_try_core_ipi(int cpu) |
---|
| 145 | +{ |
---|
| 146 | + int this_cpu = get_cpu(); |
---|
| 147 | + int ret = 0; |
---|
| 148 | + |
---|
| 149 | + if (cpumask_test_cpu(cpu, cpu_sibling_mask(this_cpu))) { |
---|
| 150 | + doorbell_core_ipi(cpu); |
---|
| 151 | + ret = 1; |
---|
| 152 | + } |
---|
| 153 | + |
---|
| 154 | + put_cpu(); |
---|
| 155 | + |
---|
| 156 | + return ret; |
---|
| 157 | +} |
---|
| 158 | + |
---|
| 159 | +#endif /* CONFIG_SMP */ |
---|
| 160 | + |
---|
107 | 161 | #endif /* _ASM_POWERPC_DBELL_H */ |
---|