Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jul 2016 07:28:15 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302554 - head/sys/dev/hyperv/vmbus
Message-ID:  <201607110728.u6B7SFog066633@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607110728.u6B7SFog066633>