Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/cpumask.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <xen/events.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <xen/hvc-console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "xen-ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "smp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static DEFINE_PER_CPU(struct xen_common_irq, xen_resched_irq) = { .irq = -1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static DEFINE_PER_CPU(struct xen_common_irq, xen_callfunc_irq) = { .irq = -1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static DEFINE_PER_CPU(struct xen_common_irq, xen_callfuncsingle_irq) = { .irq = -1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static DEFINE_PER_CPU(struct xen_common_irq, xen_debug_irq) = { .irq = -1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Reschedule call back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	inc_irq_stat(irq_resched_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	scheduler_ipi();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) void xen_smp_intr_free(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	if (per_cpu(xen_resched_irq, cpu).irq >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu).irq, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		per_cpu(xen_resched_irq, cpu).irq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		kfree(per_cpu(xen_resched_irq, cpu).name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		per_cpu(xen_resched_irq, cpu).name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (per_cpu(xen_callfunc_irq, cpu).irq >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		unbind_from_irqhandler(per_cpu(xen_callfunc_irq, cpu).irq, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		per_cpu(xen_callfunc_irq, cpu).irq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		kfree(per_cpu(xen_callfunc_irq, cpu).name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		per_cpu(xen_callfunc_irq, cpu).name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (per_cpu(xen_debug_irq, cpu).irq >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu).irq, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		per_cpu(xen_debug_irq, cpu).irq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		kfree(per_cpu(xen_debug_irq, cpu).name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		per_cpu(xen_debug_irq, cpu).name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (per_cpu(xen_callfuncsingle_irq, cpu).irq >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu).irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 				       NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		per_cpu(xen_callfuncsingle_irq, cpu).irq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		kfree(per_cpu(xen_callfuncsingle_irq, cpu).name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		per_cpu(xen_callfuncsingle_irq, cpu).name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) int xen_smp_intr_init(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	char *resched_name, *callfunc_name, *debug_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				    cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				    xen_reschedule_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 				    IRQF_PERCPU|IRQF_NOBALANCING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				    resched_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 				    NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	per_cpu(xen_resched_irq, cpu).irq = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	per_cpu(xen_resched_irq, cpu).name = resched_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 				    cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 				    xen_call_function_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 				    IRQF_PERCPU|IRQF_NOBALANCING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 				    callfunc_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 				    NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	per_cpu(xen_callfunc_irq, cpu).irq = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	per_cpu(xen_callfunc_irq, cpu).name = callfunc_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!xen_fifo_events) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 					     xen_debug_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 					     IRQF_PERCPU | IRQF_NOBALANCING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 					     debug_name, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		per_cpu(xen_debug_irq, cpu).irq = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		per_cpu(xen_debug_irq, cpu).name = debug_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				    cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				    xen_call_function_single_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 				    IRQF_PERCPU|IRQF_NOBALANCING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 				    callfunc_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 				    NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	per_cpu(xen_callfuncsingle_irq, cpu).irq = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	xen_smp_intr_free(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) void __init xen_smp_cpus_done(unsigned int max_cpus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	int cpu, rc, count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (xen_hvm_domain())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		native_smp_cpus_done(max_cpus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		calculate_max_logical_packages();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (xen_have_vcpu_info_placement)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	for_each_online_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		if (xen_vcpu_nr(cpu) < MAX_VIRT_CPUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		rc = remove_cpu(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		if (rc == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			 * Reset vcpu_info so this cpu cannot be onlined again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			xen_vcpu_info_reset(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			pr_warn("%s: failed to bring CPU %d down, error %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				__func__, cpu, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	WARN(count, "%s: brought %d CPUs offline\n", __func__, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) void xen_smp_send_reschedule(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static void __xen_send_IPI_mask(const struct cpumask *mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			      int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	unsigned cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	for_each_cpu_and(cpu, mask, cpu_online_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		xen_send_IPI_one(cpu, vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) void xen_smp_send_call_function_ipi(const struct cpumask *mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	__xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	/* Make sure other vcpus get a chance to run if they need to. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	for_each_cpu(cpu, mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if (xen_vcpu_stolen(cpu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) void xen_smp_send_call_function_single_ipi(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	__xen_send_IPI_mask(cpumask_of(cpu),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			  XEN_CALL_FUNCTION_SINGLE_VECTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static inline int xen_map_vector(int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	int xen_vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	switch (vector) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	case RESCHEDULE_VECTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		xen_vector = XEN_RESCHEDULE_VECTOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	case CALL_FUNCTION_VECTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		xen_vector = XEN_CALL_FUNCTION_VECTOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	case CALL_FUNCTION_SINGLE_VECTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		xen_vector = XEN_CALL_FUNCTION_SINGLE_VECTOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	case IRQ_WORK_VECTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		xen_vector = XEN_IRQ_WORK_VECTOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #ifdef CONFIG_X86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	case NMI_VECTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	case APIC_DM_NMI: /* Some use that instead of NMI_VECTOR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		xen_vector = XEN_NMI_VECTOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		xen_vector = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		printk(KERN_ERR "xen: vector 0x%x is not implemented\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	return xen_vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) void xen_send_IPI_mask(const struct cpumask *mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			      int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	int xen_vector = xen_map_vector(vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (xen_vector >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		__xen_send_IPI_mask(mask, xen_vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) void xen_send_IPI_all(int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	int xen_vector = xen_map_vector(vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if (xen_vector >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		__xen_send_IPI_mask(cpu_online_mask, xen_vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void xen_send_IPI_self(int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	int xen_vector = xen_map_vector(vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (xen_vector >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		xen_send_IPI_one(smp_processor_id(), xen_vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) void xen_send_IPI_mask_allbutself(const struct cpumask *mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 				int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	unsigned cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	unsigned int this_cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	int xen_vector = xen_map_vector(vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (!(num_online_cpus() > 1) || (xen_vector < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	for_each_cpu_and(cpu, mask, cpu_online_mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		if (this_cpu == cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		xen_send_IPI_one(cpu, xen_vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) void xen_send_IPI_allbutself(int vector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	xen_send_IPI_mask_allbutself(cpu_online_mask, vector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	irq_enter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	generic_smp_call_function_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	inc_irq_stat(irq_call_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	irq_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	irq_enter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	generic_smp_call_function_single_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	inc_irq_stat(irq_call_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	irq_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }