Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/vmbus/vmbus.c
Show All 28 Lines | |||||
/* | /* | ||||
* VM Bus Driver Implementation | * VM Bus Driver Implementation | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/interrupt.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/linker.h> | #include <sys/linker.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
▲ Show 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | vmbus_handle_intr(struct trapframe *trap_frame) | ||||
/* | /* | ||||
* Disable preemption. | * Disable preemption. | ||||
*/ | */ | ||||
critical_enter(); | critical_enter(); | ||||
/* | /* | ||||
* Do a little interrupt counting. | * Do a little interrupt counting. | ||||
*/ | */ | ||||
(*VMBUS_PCPU_GET(sc, intr_cnt, cpu))++; | VMBUS_PCPU_GET(sc, intr_cnt, cpu)->ie_intrcnt++; | ||||
vmbus_handle_intr1(sc, trap_frame, cpu); | vmbus_handle_intr1(sc, trap_frame, cpu); | ||||
/* | /* | ||||
* Enable preemption. | * Enable preemption. | ||||
*/ | */ | ||||
critical_exit(); | critical_exit(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
vmbus_intr_setup(struct vmbus_softc *sc) | vmbus_intr_setup(struct vmbus_softc *sc) | ||||
{ | { | ||||
int cpu; | int cpu; | ||||
CPU_FOREACH(cpu) { | CPU_FOREACH(cpu) { | ||||
char buf[MAXCOMLEN + 1]; | |||||
cpuset_t cpu_mask; | cpuset_t cpu_mask; | ||||
int error; | |||||
/* Allocate an interrupt counter for Hyper-V interrupt */ | /* Allocate an interrupt counter for Hyper-V interrupt */ | ||||
snprintf(buf, sizeof(buf), "cpu%d:hyperv", cpu); | error = intr_event_create(VMBUS_PCPU_PTR(sc, intr_cnt, cpu), | ||||
intrcnt_add(buf, VMBUS_PCPU_PTR(sc, intr_cnt, cpu)); | NULL, 0, NULL, NULL, NULL, NULL, "cpu%d:hyperv", cpu); | ||||
if (error != 0) | |||||
return (error); | |||||
/* | /* | ||||
* Setup taskqueue to handle events. Task will be per- | * Setup taskqueue to handle events. Task will be per- | ||||
* channel. | * channel. | ||||
*/ | */ | ||||
VMBUS_PCPU_GET(sc, event_tq, cpu) = taskqueue_create_fast( | VMBUS_PCPU_GET(sc, event_tq, cpu) = taskqueue_create_fast( | ||||
"hyperv event", M_WAITOK, taskqueue_thread_enqueue, | "hyperv event", M_WAITOK, taskqueue_thread_enqueue, | ||||
VMBUS_PCPU_PTR(sc, event_tq, cpu)); | VMBUS_PCPU_PTR(sc, event_tq, cpu)); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (sc->vmbus_idtvec >= 0) { | ||||
sc->vmbus_idtvec = -1; | sc->vmbus_idtvec = -1; | ||||
} | } | ||||
#if defined(__amd64__) && defined(KLD_MODULE) | #if defined(__amd64__) && defined(KLD_MODULE) | ||||
pmap_pti_remove_kva(VMBUS_ISR_ADDR, VMBUS_ISR_ADDR + PAGE_SIZE); | pmap_pti_remove_kva(VMBUS_ISR_ADDR, VMBUS_ISR_ADDR + PAGE_SIZE); | ||||
#endif | #endif | ||||
CPU_FOREACH(cpu) { | CPU_FOREACH(cpu) { | ||||
if (VMBUS_PCPU_GET(sc, intr_cnt, cpu) != NULL) | |||||
intr_event_destroy(VMBUS_PCPU_GET(sc, intr_cnt, cpu)); | |||||
if (VMBUS_PCPU_GET(sc, event_tq, cpu) != NULL) { | if (VMBUS_PCPU_GET(sc, event_tq, cpu) != NULL) { | ||||
taskqueue_free(VMBUS_PCPU_GET(sc, event_tq, cpu)); | taskqueue_free(VMBUS_PCPU_GET(sc, event_tq, cpu)); | ||||
VMBUS_PCPU_GET(sc, event_tq, cpu) = NULL; | VMBUS_PCPU_GET(sc, event_tq, cpu) = NULL; | ||||
} | } | ||||
if (VMBUS_PCPU_GET(sc, message_tq, cpu) != NULL) { | if (VMBUS_PCPU_GET(sc, message_tq, cpu) != NULL) { | ||||
taskqueue_drain(VMBUS_PCPU_GET(sc, message_tq, cpu), | taskqueue_drain(VMBUS_PCPU_GET(sc, message_tq, cpu), | ||||
VMBUS_PCPU_PTR(sc, message_task, cpu)); | VMBUS_PCPU_PTR(sc, message_task, cpu)); | ||||
taskqueue_free(VMBUS_PCPU_GET(sc, message_tq, cpu)); | taskqueue_free(VMBUS_PCPU_GET(sc, message_tq, cpu)); | ||||
▲ Show 20 Lines • Show All 644 Lines • Show Last 20 Lines |