Index: sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c =================================================================== --- sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c +++ sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c @@ -122,7 +122,6 @@ union ccb *ccb; struct storvsc_softc *softc; struct callout callout; - struct sema synch_sema; /*Synchronize the request/response if needed */ struct sglist *bounce_sgl; unsigned int bounce_sgl_count; uint64_t not_aligned_seg_bits; @@ -387,8 +386,6 @@ /* request the host to create multi-channel */ memset(request, 0, sizeof(struct hv_storvsc_request)); - - sema_init(&request->synch_sema, 0, ("stor_synch_sema")); vstor_packet = &request->vstor_packet; @@ -405,8 +402,8 @@ HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); /* wait for 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - if (ret != 0) { + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); + if (ret != 0) { printf("Storvsc_error: create multi-channel timeout, %d\n", ret); return; @@ -454,11 +451,6 @@ vstor_packet = &request->vstor_packet; request->softc = sc; - /** - * Initiate the vsc/vsp initialization protocol on the open channel - */ - sema_init(&request->synch_sema, 0, ("stor_synch_sema")); - vstor_packet->operation = VSTOR_OPERATION_BEGININITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; @@ -475,7 +467,7 @@ goto cleanup; /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); if (ret != 0) goto cleanup; @@ -508,7 +500,7 @@ goto cleanup; /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); if (ret) goto cleanup; @@ -537,7 +529,7 @@ goto cleanup; /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); if (ret != 0) goto cleanup; @@ -574,7 +566,7 @@ } /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); if (ret != 0) goto cleanup; @@ -591,7 +583,6 @@ storvsc_send_multichannel_request(dev, max_chans); cleanup: - sema_destroy(&request->synch_sema); return (ret); } @@ -631,7 +622,9 @@ return ret; } + mtx_lock(&sc->hs_lock); ret = hv_storvsc_channel_init(dev); + mtx_unlock(&sc->hs_lock); return (ret); } @@ -655,8 +648,6 @@ request->softc = sc; vstor_packet = &request->vstor_packet; - sema_init(&request->synch_sema, 0, "stor synch sema"); - vstor_packet->operation = VSTOR_OPERATION_RESETBUS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; @@ -671,7 +662,7 @@ goto cleanup; } - ret = sema_timedwait(&request->synch_sema, 5 * hz); /* KYS 5 seconds */ + ret = msleep(request, &sc->hs_lock, PRIBIO, "CINIT", 5 * hz); if (ret) { goto cleanup; @@ -684,7 +675,6 @@ */ cleanup: - sema_destroy(&request->synch_sema); return (ret); } #endif /* HVS_HOST_RESET */ @@ -860,7 +850,7 @@ (request == &sc->hs_reset_req)) { memcpy(&request->vstor_packet, packet, sizeof(struct vstor_packet)); - sema_post(&request->synch_sema); + wakeup(request); } else { vstor_packet = (struct vstor_packet *)packet; switch(vstor_packet->operation) { @@ -1003,8 +993,7 @@ for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; ++i) { reqp = malloc(sizeof(struct hv_storvsc_request), - M_DEVBUF, M_WAITOK|M_ZERO); - reqp->softc = sc; + M_DEVBUF, M_WAITOK); LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link); }