From ccf8c766c0525a767688cbf89383829394406f3b Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Thu, 23 Jun 2016 05:08:17 +0000 Subject: [PATCH] MFC 300487 hyperv/vmbus: Move IDT vector to vmbus_softc Prepare to get rid of the hv_setup_arg. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6449 --- sys/dev/hyperv/vmbus/hv_hv.c | 5 ++-- sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c | 29 ++++++++------------- sys/dev/hyperv/vmbus/hv_vmbus_priv.h | 6 ----- sys/dev/hyperv/vmbus/vmbus_var.h | 1 + 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/sys/dev/hyperv/vmbus/hv_hv.c b/sys/dev/hyperv/vmbus/hv_hv.c index dcfc2f825002..3cbdae649ab7 100644 --- a/sys/dev/hyperv/vmbus/hv_hv.c +++ b/sys/dev/hyperv/vmbus/hv_hv.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define HV_NANOSECONDS_PER_SEC 1000000000L @@ -220,8 +221,8 @@ hv_vmbus_signal_event(void *con_id) */ void hv_vmbus_synic_init(void *arg) - { + struct vmbus_softc *sc = vmbus_get_softc(); int cpu; uint64_t hv_vcpu_index; hv_vmbus_synic_simp simp; @@ -266,7 +267,7 @@ hv_vmbus_synic_init(void *arg) /*HV_SHARED_SINT_IDT_VECTOR + 0x20; */ shared_sint.as_uint64_t = 0; - shared_sint.u.vector = setup_args->vector; + shared_sint.u.vector = sc->vmbus_idtvec; shared_sint.u.masked = FALSE; shared_sint.u.auto_eoi = TRUE; diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c index 034e6fb853ee..aacb81d4e020 100644 --- a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c +++ b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c @@ -455,26 +455,18 @@ vmbus_bus_init(void) sc = vmbus_get_softc(); /* - * Find a free IDT slot for vmbus callback. + * Find a free IDT vector for vmbus messages/events. */ - hv_vmbus_g_context.hv_cb_vector = vmbus_vector_alloc(); - - if (hv_vmbus_g_context.hv_cb_vector == 0) { - if(bootverbose) - printf("Error VMBUS: Cannot find free IDT slot for " - "vmbus callback!\n"); + sc->vmbus_idtvec = vmbus_vector_alloc(); + if (sc->vmbus_idtvec == 0) { + device_printf(sc->vmbus_dev, "cannot find free IDT vector\n"); ret = ENXIO; goto cleanup; } - - if(bootverbose) - printf("VMBUS: vmbus callback vector %d\n", - hv_vmbus_g_context.hv_cb_vector); - - /* - * Notify the hypervisor of our vector. - */ - setup_args.vector = hv_vmbus_g_context.hv_cb_vector; + if(bootverbose) { + device_printf(sc->vmbus_dev, "vmbus IDT vector %d\n", + sc->vmbus_idtvec); + } CPU_FOREACH(j) { snprintf(buf, sizeof(buf), "cpu%d:hyperv", j); @@ -574,7 +566,7 @@ vmbus_bus_init(void) } } - vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); + vmbus_vector_free(sc->vmbus_idtvec); cleanup: return (ret); @@ -630,6 +622,7 @@ vmbus_sysinit(void *arg __unused) static int vmbus_detach(device_t dev) { + struct vmbus_softc *sc = device_get_softc(dev); int i; hv_vmbus_release_unattached_channels(); @@ -650,7 +643,7 @@ vmbus_detach(device_t dev) } } - vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); + vmbus_vector_free(sc->vmbus_idtvec); return (0); } diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h index e27c5f47f7d1..2619c0df31bb 100644 --- a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h +++ b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h @@ -216,11 +216,6 @@ typedef struct { struct taskqueue *hv_event_queue[MAXCPU]; struct taskqueue *hv_msg_tq[MAXCPU]; struct task hv_msg_task[MAXCPU]; - /* - * Host use this vector to intrrupt guest for vmbus channel - * event and msg. - */ - unsigned int hv_cb_vector; } hv_vmbus_context; /* @@ -763,7 +758,6 @@ void hv_et_intr(struct trapframe*); void vmbus_scan(void); typedef struct { - unsigned int vector; void *page_buffers[2 * MAXCPU]; } hv_setup_args; diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h index 40c7224f9b13..0aab7d207d46 100644 --- a/sys/dev/hyperv/vmbus/vmbus_var.h +++ b/sys/dev/hyperv/vmbus/vmbus_var.h @@ -39,6 +39,7 @@ struct vmbus_softc { void (*vmbus_event_proc)(struct vmbus_softc *, int); struct vmbus_pcpu_data vmbus_pcpu[MAXCPU]; device_t vmbus_dev; + int vmbus_idtvec; }; extern struct vmbus_softc *vmbus_sc;