summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/hyperv/vmbus/hv_hv.c7
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c27
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_priv.h5
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_var.h4
4 files changed, 16 insertions, 27 deletions
diff --git a/sys/dev/hyperv/vmbus/hv_hv.c b/sys/dev/hyperv/vmbus/hv_hv.c
index 5bcd00f..289b577 100644
--- a/sys/dev/hyperv/vmbus/hv_hv.c
+++ b/sys/dev/hyperv/vmbus/hv_hv.c
@@ -96,13 +96,6 @@ u_int hyperv_recommends;
static u_int hyperv_pm_features;
static u_int hyperv_features3;
-/**
- * Globals
- */
-hv_vmbus_context hv_vmbus_g_context = {
- .syn_ic_initialized = FALSE,
-};
-
static struct timecounter hv_timecounter = {
hv_get_timecount, 0, ~0u, HV_NANOSECONDS_PER_SEC/100, "Hyper-V", HV_NANOSECONDS_PER_SEC/100
};
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
index 4432287..b2d561a 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
@@ -68,8 +68,6 @@ __FBSDID("$FreeBSD$");
struct vmbus_softc *vmbus_sc;
-static int vmbus_inited;
-
static char *vmbus_ids[] = { "VMBUS", NULL };
extern inthand_t IDTVEC(hv_vmbus_callback);
@@ -264,8 +262,6 @@ vmbus_synic_setup(void *arg __unused)
wrmsr(HV_X64_MSR_SCONTROL, sctrl.as_uint64_t);
- hv_vmbus_g_context.syn_ic_initialized = TRUE;
-
/*
* Set up the cpuid mapping from Hyper-V to FreeBSD.
* The array is indexed using FreeBSD cpuid.
@@ -280,9 +276,6 @@ vmbus_synic_teardown(void *arg)
hv_vmbus_synic_simp simp;
hv_vmbus_synic_siefp siefp;
- if (!hv_vmbus_g_context.syn_ic_initialized)
- return;
-
shared_sint.as_uint64_t = rdmsr(
HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT);
@@ -608,14 +601,12 @@ vmbus_probe(device_t dev)
static int
vmbus_bus_init(void)
{
- struct vmbus_softc *sc;
+ struct vmbus_softc *sc = vmbus_get_softc();
int ret;
- if (vmbus_inited)
+ if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED)
return (0);
-
- vmbus_inited = 1;
- sc = vmbus_get_softc();
+ sc->vmbus_flags |= VMBUS_FLAG_ATTACHED;
/*
* Allocate DMA stuffs.
@@ -631,10 +622,13 @@ vmbus_bus_init(void)
if (ret != 0)
goto cleanup;
+ /*
+ * Setup SynIC.
+ */
if (bootverbose)
- printf("VMBUS: Calling smp_rendezvous, smp_started = %d\n",
- smp_started);
+ device_printf(sc->vmbus_dev, "smp_started = %d\n", smp_started);
smp_rendezvous(NULL, vmbus_synic_setup, NULL, NULL);
+ sc->vmbus_flags |= VMBUS_FLAG_SYNIC;
/*
* Connect to VMBus in the root partition
@@ -725,7 +719,10 @@ vmbus_detach(device_t dev)
hv_vmbus_release_unattached_channels();
hv_vmbus_disconnect();
- smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
+ if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) {
+ sc->vmbus_flags &= ~VMBUS_FLAG_SYNIC;
+ smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
+ }
vmbus_intr_teardown(sc);
vmbus_dma_free(sc);
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
index 5c0892b..a1eb808 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
@@ -200,10 +200,6 @@ enum {
struct vmbus_message;
union vmbus_event_flags;
-typedef struct {
- hv_bool_uint8_t syn_ic_initialized;
-} hv_vmbus_context;
-
/*
* Define hypervisor message types
*/
@@ -635,7 +631,6 @@ typedef enum {
* Global variables
*/
-extern hv_vmbus_context hv_vmbus_g_context;
extern hv_vmbus_connection hv_vmbus_g_connection;
extern u_int hyperv_features;
diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h
index b65c83c..982e7a1 100644
--- a/sys/dev/hyperv/vmbus/vmbus_var.h
+++ b/sys/dev/hyperv/vmbus/vmbus_var.h
@@ -55,8 +55,12 @@ struct vmbus_softc {
/* Rarely used fields */
device_t vmbus_dev;
int vmbus_idtvec;
+ uint32_t vmbus_flags; /* see VMBUS_FLAG_ */
};
+#define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */
+#define VMBUS_FLAG_SYNIC 0x0002 /* SynIC was setup */
+
extern struct vmbus_softc *vmbus_sc;
static __inline struct vmbus_softc *
OpenPOWER on IntegriCloud