From owner-svn-src-all@freebsd.org Mon Jul 11 07:28:16 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 9411EB90105; Mon, 11 Jul 2016 07:28:16 +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 6AF64130B; Mon, 11 Jul 2016 07:28:16 +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 u6B7SFRY066636; Mon, 11 Jul 2016 07:28:15 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6B7SFog066633; Mon, 11 Jul 2016 07:28:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201607110728.u6B7SFog066633@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 11 Jul 2016 07:28:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302554 - 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: Mon, 11 Jul 2016 07:28:16 -0000 Author: sephe Date: Mon Jul 11 07:28:15 2016 New Revision: 302554 URL: https://svnweb.freebsd.org/changeset/base/302554 Log: hyperv/vmbus: Use post message Hypercall APIs for unload MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6861 Modified: head/sys/dev/hyperv/vmbus/hv_connection.c head/sys/dev/hyperv/vmbus/vmbus.c head/sys/dev/hyperv/vmbus/vmbus_reg.h Modified: head/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_connection.c Mon Jul 11 07:24:56 2016 (r302553) +++ head/sys/dev/hyperv/vmbus/hv_connection.c Mon Jul 11 07:28:15 2016 (r302554) @@ -92,19 +92,13 @@ hv_vmbus_connect(struct vmbus_softc *sc) int hv_vmbus_disconnect(void) { - int ret = 0; - hv_vmbus_channel_unload msg; - - msg.message_type = HV_CHANNEL_MESSAGE_UNLOAD; - - ret = hv_vmbus_post_message(&msg, sizeof(hv_vmbus_channel_unload)); mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); free(hv_vmbus_g_connection.channels, M_DEVBUF); hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - return (ret); + return (0); } static __inline void Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 07:24:56 2016 (r302553) +++ head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 07:28:15 2016 (r302554) @@ -99,6 +99,7 @@ static int vmbus_init(struct vmbus_sof static int vmbus_init_contact(struct vmbus_softc *, uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); +static void vmbus_uninit(struct vmbus_softc *); static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); @@ -420,6 +421,32 @@ vmbus_init(struct vmbus_softc *sc) return ENXIO; } +static void +vmbus_uninit(struct vmbus_softc *sc) +{ + struct vmbus_chanmsg_unload *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for unload\n"); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_UNLOAD; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "unload msg hypercall failed\n"); + } +} + static int vmbus_req_channels(struct vmbus_softc *sc) { @@ -1134,6 +1161,8 @@ vmbus_detach(device_t dev) struct vmbus_softc *sc = device_get_softc(dev); hv_vmbus_release_unattached_channels(); + + vmbus_uninit(sc); hv_vmbus_disconnect(); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Jul 11 07:24:56 2016 (r302553) +++ head/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Jul 11 07:28:15 2016 (r302554) @@ -86,6 +86,7 @@ CTASSERT(sizeof(struct vmbus_evtflags) = #define VMBUS_CHANMSG_TYPE_CHANNEL_REQ 3 /* REQ */ #define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */ +#define VMBUS_CHANMSG_TYPE_UNLOAD 16 /* REQ */ struct vmbus_chanmsg_hdr { uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ @@ -113,4 +114,9 @@ struct vmbus_chanmsg_channel_req { struct vmbus_chanmsg_hdr chm_hdr; } __packed; +/* VMBUS_CHANMSG_TYPE_UNLOAD */ +struct vmbus_chanmsg_unload { + struct vmbus_chanmsg_hdr chm_hdr; +} __packed; + #endif /* !_VMBUS_REG_H_ */