Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2016 06:17:16 +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: r302706 - in head/sys/dev/hyperv: include vmbus
Message-ID:  <201607130617.u6D6HGdZ016592@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Wed Jul 13 06:17:15 2016
New Revision: 302706
URL: https://svnweb.freebsd.org/changeset/base/302706

Log:
  hyperv: Get rid of hv_device, which is unnecessary indirection.
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D7034

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  head/sys/dev/hyperv/vmbus/vmbus.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h	Wed Jul 13 06:09:34 2016	(r302705)
+++ head/sys/dev/hyperv/include/hyperv.h	Wed Jul 13 06:17:15 2016	(r302706)
@@ -399,24 +399,6 @@ typedef struct {
 
 #define HW_MACADDR_LEN	6
 
-enum {
-	HV_VMBUS_IVAR_TYPE,
-	HV_VMBUS_IVAR_INSTANCE,
-	HV_VMBUS_IVAR_NODE,
-	HV_VMBUS_IVAR_DEVCTX,
-	HV_VMBUS_IVAR_CHAN,
-};
-
-#define HV_VMBUS_ACCESSOR(var, ivar, type) \
-		__BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type)
-
-struct hv_vmbus_channel;
-
-HV_VMBUS_ACCESSOR(type, TYPE,  const char *)
-HV_VMBUS_ACCESSOR(devctx, DEVCTX,  struct hv_device *)
-HV_VMBUS_ACCESSOR(channel, CHAN, struct hv_vmbus_channel *)
-
-
 /*
  * Common defines for Hyper-V ICs
  */
@@ -538,7 +520,6 @@ typedef union {
 } __packed hv_vmbus_connection_id;
 
 typedef struct hv_vmbus_channel {
-	struct hv_device*		device;
 	device_t			ch_dev;
 	struct vmbus_softc		*vmbus_sc;
 	hv_vmbus_channel_state		state;
@@ -652,15 +633,6 @@ hv_set_channel_read_state(hv_vmbus_chann
 	channel->batched_reading = state;
 }
 
-typedef struct hv_device {
-	hv_guid		    class_id;
-	hv_guid		    device_id;
-	device_t	    device;
-	hv_vmbus_channel*   channel;
-} hv_device;
-
-
-
 int		hv_vmbus_channel_recv_packet(
 				hv_vmbus_channel*	channel,
 				void*			buffer,
@@ -742,4 +714,10 @@ hv_get_phys_addr(void *virt)
 	return (ret);
 }
 
+static __inline struct hv_vmbus_channel *
+vmbus_get_channel(device_t dev)
+{
+	return device_get_ivars(dev);
+}
+
 #endif  /* __HYPERV_H__ */

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Wed Jul 13 06:09:34 2016	(r302705)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Wed Jul 13 06:17:15 2016	(r302706)
@@ -106,10 +106,10 @@ vmbus_channel_sysctl_create(hv_vmbus_cha
 	hv_vmbus_channel* primary_ch = channel->primary_channel;
 
 	if (primary_ch == NULL) {
-		dev = channel->device->device;
+		dev = channel->ch_dev;
 		ch_id = channel->ch_id;
 	} else {
-		dev = primary_ch->device->device;
+		dev = primary_ch->ch_dev;
 		ch_id = primary_ch->ch_id;
 		sub_ch_id = channel->ch_subidx;
 	}

Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Wed Jul 13 06:09:34 2016	(r302705)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Wed Jul 13 06:17:15 2016	(r302706)
@@ -162,7 +162,6 @@ vmbus_channel_process_offer(hv_vmbus_cha
 			 * It is a sub channel offer, process it.
 			 */
 			new_channel->primary_channel = channel;
-			new_channel->device = channel->device;
 			new_channel->ch_dev = channel->ch_dev;
 			mtx_lock(&channel->sc_lock);
 			TAILQ_INSERT_TAIL(&channel->sc_list_anchor,
@@ -207,13 +206,6 @@ vmbus_channel_process_offer(hv_vmbus_cha
 	new_channel->state = HV_CHANNEL_OPEN_STATE;
 
 	/*
-	 * Start the process of binding this offer to the driver
-	 * (We need to set the device field before calling
-	 * hv_vmbus_child_device_add())
-	 */
-	new_channel->device = hv_vmbus_child_device_create(new_channel);
-
-	/*
 	 * Add the new device to the bus. This will kick off device-driver
 	 * binding which eventually invokes the device driver's AddDevice()
 	 * method.

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Wed Jul 13 06:09:34 2016	(r302705)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Wed Jul 13 06:17:15 2016	(r302706)
@@ -212,9 +212,6 @@ void			hv_vmbus_free_vmbus_channel(hv_vm
 void			hv_vmbus_release_unattached_channels(
 			    struct vmbus_softc *);
 
-struct hv_device*	hv_vmbus_child_device_create(
-			    struct hv_vmbus_channel *channel);
-
 int			hv_vmbus_child_device_register(
 					struct hv_vmbus_channel *chan);
 int			hv_vmbus_child_device_unregister(

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c	Wed Jul 13 06:09:34 2016	(r302705)
+++ head/sys/dev/hyperv/vmbus/vmbus.c	Wed Jul 13 06:17:15 2016	(r302706)
@@ -960,29 +960,6 @@ vmbus_intr_teardown(struct vmbus_softc *
 static int
 vmbus_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
 {
-	struct hv_device *child_dev_ctx = device_get_ivars(child);
-
-	switch (index) {
-	case HV_VMBUS_IVAR_TYPE:
-		*result = (uintptr_t)&child_dev_ctx->class_id;
-		return (0);
-
-	case HV_VMBUS_IVAR_INSTANCE:
-		*result = (uintptr_t)&child_dev_ctx->device_id;
-		return (0);
-
-	case HV_VMBUS_IVAR_DEVCTX:
-		*result = (uintptr_t)child_dev_ctx;
-		return (0);
-
-	case HV_VMBUS_IVAR_NODE:
-		*result = (uintptr_t)child_dev_ctx->device;
-		return (0);
-
-	case HV_VMBUS_IVAR_CHAN:
-		*result = (uintptr_t)child_dev_ctx->channel;
-		return (0);
-	}
 	return (ENOENT);
 }
 
@@ -992,11 +969,11 @@ vmbus_child_pnpinfo_str(device_t dev, de
 	const struct hv_vmbus_channel *chan;
 	char guidbuf[HYPERV_GUID_STRLEN];
 
-	if (device_get_ivars(child) == NULL) {
+	chan = vmbus_get_channel(child);
+	if (chan == NULL) {
 		/* Event timer device, which does not belong to a channel */
 		return (0);
 	}
-	chan = vmbus_get_channel(child);
 
 	strlcat(buf, "classid=", buflen);
 	hyperv_guid2str(&chan->ch_guid_type, guidbuf, sizeof(guidbuf));
@@ -1009,23 +986,6 @@ vmbus_child_pnpinfo_str(device_t dev, de
 	return (0);
 }
 
-struct hv_device *
-hv_vmbus_child_device_create(struct hv_vmbus_channel *channel)
-{
-	hv_device *child_dev;
-
-	/*
-	 * Allocate the new child device
-	 */
-	child_dev = malloc(sizeof(hv_device), M_DEVBUF, M_WAITOK | M_ZERO);
-
-	child_dev->channel = channel;
-	child_dev->class_id = channel->ch_guid_type;
-	child_dev->device_id = channel->ch_guid_inst;
-
-	return (child_dev);
-}
-
 int
 hv_vmbus_child_device_register(struct hv_vmbus_channel *chan)
 {
@@ -1040,8 +1000,7 @@ hv_vmbus_child_device_register(struct hv
 		error = ENXIO;
 		goto done;
 	}
-	chan->device->device = chan->ch_dev;
-	device_set_ivars(chan->ch_dev, chan->device);
+	device_set_ivars(chan->ch_dev, chan);
 
 done:
 	/* New device has been/should be added to vmbus. */



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