|
20 | 20 | #include <asm/kvm_ppc.h> |
21 | 21 |
|
22 | 22 | #ifdef CONFIG_SMP |
23 | | -void doorbell_setup_this_cpu(void) |
| 23 | + |
| 24 | +/* |
| 25 | + * Doorbells must only be used if CPU_FTR_DBELL is available. |
| 26 | + * msgsnd is used in HV, and msgsndp is used in !HV. |
| 27 | + * |
| 28 | + * These should be used by platform code that is aware of restrictions. |
| 29 | + * Other arch code should use ->cause_ipi. |
| 30 | + * |
| 31 | + * doorbell_global_ipi() sends a dbell to any target CPU. |
| 32 | + * Must be used only by architectures that address msgsnd target |
| 33 | + * by PIR/get_hard_smp_processor_id. |
| 34 | + */ |
| 35 | +void doorbell_global_ipi(int cpu) |
24 | 36 | { |
25 | | - unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK; |
| 37 | + u32 tag = get_hard_smp_processor_id(cpu); |
26 | 38 |
|
27 | | - smp_muxed_ipi_set_data(smp_processor_id(), tag); |
| 39 | + kvmppc_set_host_ipi(cpu, 1); |
| 40 | + /* Order previous accesses vs. msgsnd, which is treated as a store */ |
| 41 | + mb(); |
| 42 | + ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag); |
28 | 43 | } |
29 | 44 |
|
30 | | -void doorbell_cause_ipi(int cpu, unsigned long data) |
| 45 | +/* |
| 46 | + * doorbell_core_ipi() sends a dbell to a target CPU in the same core. |
| 47 | + * Must be used only by architectures that address msgsnd target |
| 48 | + * by TIR/cpu_thread_in_core. |
| 49 | + */ |
| 50 | +void doorbell_core_ipi(int cpu) |
31 | 51 | { |
| 52 | + u32 tag = cpu_thread_in_core(cpu); |
| 53 | + |
| 54 | + kvmppc_set_host_ipi(cpu, 1); |
32 | 55 | /* Order previous accesses vs. msgsnd, which is treated as a store */ |
33 | 56 | mb(); |
34 | | - ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, data); |
| 57 | + ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, tag); |
| 58 | +} |
| 59 | + |
| 60 | +/* |
| 61 | + * Attempt to cause a core doorbell if destination is on the same core. |
| 62 | + * Returns 1 on success, 0 on failure. |
| 63 | + */ |
| 64 | +int doorbell_try_core_ipi(int cpu) |
| 65 | +{ |
| 66 | + int this_cpu = get_cpu(); |
| 67 | + int ret = 0; |
| 68 | + |
| 69 | + if (cpumask_test_cpu(cpu, cpu_sibling_mask(this_cpu))) { |
| 70 | + doorbell_core_ipi(cpu); |
| 71 | + ret = 1; |
| 72 | + } |
| 73 | + |
| 74 | + put_cpu(); |
| 75 | + |
| 76 | + return ret; |
35 | 77 | } |
36 | 78 |
|
37 | 79 | void doorbell_exception(struct pt_regs *regs) |
|
0 commit comments