Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/vmbus/vmbus.c
Show First 20 Lines • Show All 514 Lines • ▼ Show 20 Lines | vmbus_req_channels(struct vmbus_softc *sc) | ||||
return error; | return error; | ||||
} | } | ||||
static void | static void | ||||
vmbus_scan_done_task(void *xsc, int pending __unused) | vmbus_scan_done_task(void *xsc, int pending __unused) | ||||
{ | { | ||||
struct vmbus_softc *sc = xsc; | struct vmbus_softc *sc = xsc; | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
sc->vmbus_scandone = true; | sc->vmbus_scandone = true; | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
wakeup(&sc->vmbus_scandone); | wakeup(&sc->vmbus_scandone); | ||||
} | } | ||||
static void | static void | ||||
vmbus_scan_done(struct vmbus_softc *sc, | vmbus_scan_done(struct vmbus_softc *sc, | ||||
const struct vmbus_message *msg __unused) | const struct vmbus_message *msg __unused) | ||||
{ | { | ||||
Show All 38 Lines | device_printf(sc->vmbus_dev, "channel request failed: %d\n", | ||||
error); | error); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Wait for all vmbus devices from the initial channel offers to be | * Wait for all vmbus devices from the initial channel offers to be | ||||
* attached. | * attached. | ||||
*/ | */ | ||||
GIANT_REQUIRED; | bus_topo_assert(); | ||||
while (!sc->vmbus_scandone) | while (!sc->vmbus_scandone) | ||||
mtx_sleep(&sc->vmbus_scandone, &Giant, 0, "vmbusdev", 0); | mtx_sleep(&sc->vmbus_scandone, bus_topo_mtx(), 0, "vmbusdev", 0); | ||||
if (bootverbose) { | if (bootverbose) { | ||||
device_printf(sc->vmbus_dev, "device scan, probe and attach " | device_printf(sc->vmbus_dev, "device scan, probe and attach " | ||||
"done\n"); | "done\n"); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
vmbus_scan_teardown(struct vmbus_softc *sc) | vmbus_scan_teardown(struct vmbus_softc *sc) | ||||
{ | { | ||||
GIANT_REQUIRED; | bus_topo_assert(); | ||||
if (sc->vmbus_devtq != NULL) { | if (sc->vmbus_devtq != NULL) { | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
taskqueue_free(sc->vmbus_devtq); | taskqueue_free(sc->vmbus_devtq); | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
sc->vmbus_devtq = NULL; | sc->vmbus_devtq = NULL; | ||||
} | } | ||||
if (sc->vmbus_subchtq != NULL) { | if (sc->vmbus_subchtq != NULL) { | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
taskqueue_free(sc->vmbus_subchtq); | taskqueue_free(sc->vmbus_subchtq); | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
sc->vmbus_subchtq = NULL; | sc->vmbus_subchtq = NULL; | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
vmbus_chanmsg_handle(struct vmbus_softc *sc, const struct vmbus_message *msg) | vmbus_chanmsg_handle(struct vmbus_softc *sc, const struct vmbus_message *msg) | ||||
{ | { | ||||
vmbus_chanmsg_proc_t msg_proc; | vmbus_chanmsg_proc_t msg_proc; | ||||
▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
vmbus_add_child(struct vmbus_channel *chan) | vmbus_add_child(struct vmbus_channel *chan) | ||||
{ | { | ||||
struct vmbus_softc *sc = chan->ch_vmbus; | struct vmbus_softc *sc = chan->ch_vmbus; | ||||
device_t parent = sc->vmbus_dev; | device_t parent = sc->vmbus_dev; | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
chan->ch_dev = device_add_child(parent, NULL, -1); | chan->ch_dev = device_add_child(parent, NULL, -1); | ||||
if (chan->ch_dev == NULL) { | if (chan->ch_dev == NULL) { | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
device_printf(parent, "device_add_child for chan%u failed\n", | device_printf(parent, "device_add_child for chan%u failed\n", | ||||
chan->ch_id); | chan->ch_id); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
device_set_ivars(chan->ch_dev, chan); | device_set_ivars(chan->ch_dev, chan); | ||||
device_probe_and_attach(chan->ch_dev); | device_probe_and_attach(chan->ch_dev); | ||||
bus_topo_unlock(); | |||||
mtx_unlock(&Giant); | |||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
vmbus_delete_child(struct vmbus_channel *chan) | vmbus_delete_child(struct vmbus_channel *chan) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
mtx_lock(&Giant); | bus_topo_lock(); | ||||
if (chan->ch_dev != NULL) { | if (chan->ch_dev != NULL) { | ||||
error = device_delete_child(chan->ch_vmbus->vmbus_dev, | error = device_delete_child(chan->ch_vmbus->vmbus_dev, | ||||
chan->ch_dev); | chan->ch_dev); | ||||
chan->ch_dev = NULL; | chan->ch_dev = NULL; | ||||
} | } | ||||
mtx_unlock(&Giant); | bus_topo_unlock(); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
vmbus_sysctl_version(SYSCTL_HANDLER_ARGS) | vmbus_sysctl_version(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
struct vmbus_softc *sc = arg1; | struct vmbus_softc *sc = arg1; | ||||
char verstr[16]; | char verstr[16]; | ||||
▲ Show 20 Lines • Show All 571 Lines • Show Last 20 Lines |