Deleted Added
full compact
vmbus.c (307449) vmbus.c (307450)
1/*-
2 * Copyright (c) 2009-2012,2016 Microsoft Corp.
3 * Copyright (c) 2012 NetApp Inc.
4 * Copyright (c) 2012 Citrix Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * VM Bus Driver Implementation
31 */
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2012,2016 Microsoft Corp.
3 * Copyright (c) 2012 NetApp Inc.
4 * Copyright (c) 2012 Citrix Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * VM Bus Driver Implementation
31 */
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/vmbus/vmbus.c 307449 2016-10-17 01:59:42Z sephe $");
33__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/vmbus/vmbus.c 307450 2016-10-17 02:02:44Z sephe $");
34
35#include <sys/param.h>
36#include <sys/bus.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/malloc.h>
40#include <sys/module.h>
41#include <sys/proc.h>

--- 1057 unchanged lines hidden (view full) ---

1099 int ret;
1100
1101 if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED)
1102 return (0);
1103 sc->vmbus_flags |= VMBUS_FLAG_ATTACHED;
1104
1105 mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF);
1106 sc->vmbus_gpadl = VMBUS_GPADL_START;
34
35#include <sys/param.h>
36#include <sys/bus.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/malloc.h>
40#include <sys/module.h>
41#include <sys/proc.h>

--- 1057 unchanged lines hidden (view full) ---

1099 int ret;
1100
1101 if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED)
1102 return (0);
1103 sc->vmbus_flags |= VMBUS_FLAG_ATTACHED;
1104
1105 mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF);
1106 sc->vmbus_gpadl = VMBUS_GPADL_START;
1107 mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF);
1108 TAILQ_INIT(&sc->vmbus_chlist);
1107 mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF);
1108 TAILQ_INIT(&sc->vmbus_prichans);
1109 sc->vmbus_chmap = malloc(
1110 sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF,
1111 M_WAITOK | M_ZERO);
1112
1113 /*
1114 * Create context for "post message" Hypercalls
1115 */
1116 sc->vmbus_msg_hc = vmbus_msghc_ctx_create(

--- 54 unchanged lines hidden (view full) ---

1171 vmbus_intr_teardown(sc);
1172 vmbus_dma_free(sc);
1173 if (sc->vmbus_msg_hc != NULL) {
1174 vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc);
1175 sc->vmbus_msg_hc = NULL;
1176 }
1177 free(sc->vmbus_chmap, M_DEVBUF);
1178 mtx_destroy(&sc->vmbus_scan_lock);
1109 sc->vmbus_chmap = malloc(
1110 sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF,
1111 M_WAITOK | M_ZERO);
1112
1113 /*
1114 * Create context for "post message" Hypercalls
1115 */
1116 sc->vmbus_msg_hc = vmbus_msghc_ctx_create(

--- 54 unchanged lines hidden (view full) ---

1171 vmbus_intr_teardown(sc);
1172 vmbus_dma_free(sc);
1173 if (sc->vmbus_msg_hc != NULL) {
1174 vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc);
1175 sc->vmbus_msg_hc = NULL;
1176 }
1177 free(sc->vmbus_chmap, M_DEVBUF);
1178 mtx_destroy(&sc->vmbus_scan_lock);
1179 mtx_destroy(&sc->vmbus_chlist_lock);
1179 mtx_destroy(&sc->vmbus_prichan_lock);
1180
1181 return (ret);
1182}
1183
1184static void
1185vmbus_event_proc_dummy(struct vmbus_softc *sc __unused, int cpu __unused)
1186{
1187}

--- 46 unchanged lines hidden (view full) ---

1234 vmbus_doattach(sc);
1235}
1236
1237static int
1238vmbus_detach(device_t dev)
1239{
1240 struct vmbus_softc *sc = device_get_softc(dev);
1241
1180
1181 return (ret);
1182}
1183
1184static void
1185vmbus_event_proc_dummy(struct vmbus_softc *sc __unused, int cpu __unused)
1186{
1187}

--- 46 unchanged lines hidden (view full) ---

1234 vmbus_doattach(sc);
1235}
1236
1237static int
1238vmbus_detach(device_t dev)
1239{
1240 struct vmbus_softc *sc = device_get_softc(dev);
1241
1242 hv_vmbus_release_unattached_channels(sc);
1242 vmbus_chan_destroy_all(sc);
1243
1244 vmbus_disconnect(sc);
1245
1246 if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) {
1247 sc->vmbus_flags &= ~VMBUS_FLAG_SYNIC;
1248 smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
1249 }
1250
1251 vmbus_intr_teardown(sc);
1252 vmbus_dma_free(sc);
1253
1254 if (sc->vmbus_msg_hc != NULL) {
1255 vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc);
1256 sc->vmbus_msg_hc = NULL;
1257 }
1258
1259 free(sc->vmbus_chmap, M_DEVBUF);
1260 mtx_destroy(&sc->vmbus_scan_lock);
1243
1244 vmbus_disconnect(sc);
1245
1246 if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) {
1247 sc->vmbus_flags &= ~VMBUS_FLAG_SYNIC;
1248 smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
1249 }
1250
1251 vmbus_intr_teardown(sc);
1252 vmbus_dma_free(sc);
1253
1254 if (sc->vmbus_msg_hc != NULL) {
1255 vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc);
1256 sc->vmbus_msg_hc = NULL;
1257 }
1258
1259 free(sc->vmbus_chmap, M_DEVBUF);
1260 mtx_destroy(&sc->vmbus_scan_lock);
1261 mtx_destroy(&sc->vmbus_chlist_lock);
1261 mtx_destroy(&sc->vmbus_prichan_lock);
1262
1263 return (0);
1264}
1265
1266static device_method_t vmbus_methods[] = {
1267 /* Device interface */
1268 DEVMETHOD(device_probe, vmbus_probe),
1269 DEVMETHOD(device_attach, vmbus_attach),

--- 38 unchanged lines hidden ---
1262
1263 return (0);
1264}
1265
1266static device_method_t vmbus_methods[] = {
1267 /* Device interface */
1268 DEVMETHOD(device_probe, vmbus_probe),
1269 DEVMETHOD(device_attach, vmbus_attach),

--- 38 unchanged lines hidden ---