From owner-svn-src-all@freebsd.org Wed May 25 05:22:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BF1CB48F45; Wed, 25 May 2016 05:22:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AF951045; Wed, 25 May 2016 05:22:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4P5MaH2087789; Wed, 25 May 2016 05:22:36 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4P5Maiw087785; Wed, 25 May 2016 05:22:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201605250522.u4P5Maiw087785@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 25 May 2016 05:22:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300650 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2016 05:22:37 -0000 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 *