Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 05:22:36 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300650 - head/sys/dev/hyperv/vmbus
Message-ID:  <201605250522.u4P5Maiw087785@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Wed May 25 05:22:35 2016
New Revision: 300650
URL: https://svnweb.freebsd.org/changeset/base/300650

Log:
  hyperv/vmbus: Move two global flags into vmbus softc
  
  And pack them into one flag field.
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D6522

Modified:
  head/sys/dev/hyperv/vmbus/hv_hv.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  head/sys/dev/hyperv/vmbus/vmbus_var.h

Modified: head/sys/dev/hyperv/vmbus/hv_hv.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_hv.c	Wed May 25 05:20:34 2016	(r300649)
+++ head/sys/dev/hyperv/vmbus/hv_hv.c	Wed May 25 05:22:35 2016	(r300650)
@@ -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
 };

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Wed May 25 05:20:34 2016	(r300649)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Wed May 25 05:22:35 2016	(r300650)
@@ -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);

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Wed May 25 05:20:34 2016	(r300649)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Wed May 25 05:22:35 2016	(r300650)
@@ -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;

Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed May 25 05:20:34 2016	(r300649)
+++ head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed May 25 05:22:35 2016	(r300650)
@@ -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 *



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605250522.u4P5Maiw087785>