All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 001/117] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature
  2011-07-15 17:47 [PATCH 0000/0117] Staging: hv: Driver cleanup K. Y. Srinivasan
@ 2011-07-15 17:45   ` K. Y. Srinivasan
  2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
  2011-08-23 23:11   ` Greg KH
  2 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

VMBUS is an ACPI enumerated device, get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 1c949f5..559353d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/pci.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
@@ -754,18 +753,6 @@ static struct acpi_driver vmbus_acpi_driver = {
 	},
 };
 
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-static const struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-
 static int __init hv_acpi_init(void)
 {
 	int ret;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 001/117] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature
@ 2011-07-15 17:45   ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

VMBUS is an ACPI enumerated device, get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 1c949f5..559353d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/pci.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
@@ -754,18 +753,6 @@ static struct acpi_driver vmbus_acpi_driver = {
 	},
 };
 
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-static const struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-
 static int __init hv_acpi_init(void)
 {
 	int ret;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 002/117] Staging: hv: Replace struct hv_guid with the uuid type already defined in Linux
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Replace struct hv_guid with the uuid type already defined in Linux.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c   |   18 +++---
 drivers/staging/hv/channel.c      |    4 +-
 drivers/staging/hv/channel_mgmt.c |   50 ++++++-------
 drivers/staging/hv/hv_mouse.c     |    6 +-
 drivers/staging/hv/hyperv.h       |   24 +++----
 drivers/staging/hv/hyperv_vmbus.h |    8 +-
 drivers/staging/hv/netvsc.c       |    6 +-
 drivers/staging/hv/storvsc_drv.c  |    6 +-
 drivers/staging/hv/vmbus_drv.c    |  142 ++++++++++++++++++------------------
 9 files changed, 129 insertions(+), 135 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d286b22..018b293 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -112,8 +112,8 @@ struct block_device_context {
 static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid dev_type = {
-	.data = {
+static const uuid_le dev_type = {
+	.b = {
 		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
 	}
@@ -155,13 +155,13 @@ static int blkvsc_device_add(struct hv_device *device,
 	 * id. For IDE devices, the device instance id is formatted as
 	 * <bus id> * - <device id> - 8899 - 000000000000.
 	 */
-	device_info->path_id = device->dev_instance.data[3] << 24 |
-			     device->dev_instance.data[2] << 16 |
-			     device->dev_instance.data[1] << 8  |
-			     device->dev_instance.data[0];
+	device_info->path_id = device->dev_instance.b[3] << 24 |
+			     device->dev_instance.b[2] << 16 |
+			     device->dev_instance.b[1] << 8  |
+			     device->dev_instance.b[0];
 
-	device_info->target_id = device->dev_instance.data[5] << 8 |
-			       device->dev_instance.data[4];
+	device_info->target_id = device->dev_instance.b[5] << 8 |
+			       device->dev_instance.b[4];
 
 	return ret;
 }
@@ -829,7 +829,7 @@ static int blkvsc_drv_init(void)
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 455f47a..222adcc 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -81,10 +81,10 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
 	memcpy(&debuginfo->interfacetype,
-	       &channel->offermsg.offer.if_type, sizeof(struct hv_guid));
+	       &channel->offermsg.offer.if_type, sizeof(uuid_le));
 	memcpy(&debuginfo->interface_instance,
 	       &channel->offermsg.offer.if_instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages;
 
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index bf011f3..11beb41 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -40,12 +40,12 @@ struct vmbus_channel_message_table_entry {
 #define MAX_MSG_TYPES                    4
 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
 
-static const struct hv_guid
+static const uuid_le
 	supported_device_classes[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
 	/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
 	/* Storage - SCSI */
 	{
-		.data  = {
+		.b  = {
 			0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
 			0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
 		}
@@ -54,7 +54,7 @@ static const struct hv_guid
 	/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
 	/* Network */
 	{
-		.data = {
+		.b = {
 			0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
 			0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
 		}
@@ -63,7 +63,7 @@ static const struct hv_guid
 	/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
 	/* Input */
 	{
-		.data = {
+		.b = {
 			0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
 			0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
 		}
@@ -72,7 +72,7 @@ static const struct hv_guid
 	/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
 	/* IDE */
 	{
-		.data = {
+		.b = {
 			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
 		}
@@ -80,7 +80,7 @@ static const struct hv_guid
 	/* 0E0B6031-5213-4934-818B-38D90CED39DB */
 	/* Shutdown */
 	{
-		.data = {
+		.b = {
 			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
 			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
 		}
@@ -88,7 +88,7 @@ static const struct hv_guid
 	/* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */
 	/* TimeSync */
 	{
-		.data = {
+		.b = {
 			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
 			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
 		}
@@ -96,7 +96,7 @@ static const struct hv_guid
 	/* {57164f39-9115-4e78-ab55-382f3bd5422d} */
 	/* Heartbeat */
 	{
-		.data = {
+		.b = {
 			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
 			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
 		}
@@ -104,7 +104,7 @@ static const struct hv_guid
 	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
 	/* KVP */
 	{
-		.data = {
+		.b = {
 			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
 			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
 	}
@@ -231,7 +231,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* Shutdown */
 	{
 		.msg_type = HV_SHUTDOWN_MSG,
-		.data = {
+		.data.b = {
 			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
 			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
 		},
@@ -242,7 +242,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* TimeSync */
 	{
 		.msg_type = HV_TIMESYNC_MSG,
-		.data = {
+		.data.b = {
 			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
 			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
 		},
@@ -252,7 +252,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* Heartbeat */
 	{
 		.msg_type = HV_HEARTBEAT_MSG,
-		.data = {
+		.data.b = {
 			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
 			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
 		},
@@ -261,7 +261,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
 	/* KVP */
 	{
-		.data = {
+		.data.b = {
 			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
 			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
 		},
@@ -358,12 +358,10 @@ static void vmbus_process_offer(struct work_struct *work)
 	spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
 
 	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
-		if (!memcmp(&channel->offermsg.offer.if_type,
-			    &newchannel->offermsg.offer.if_type,
-			    sizeof(struct hv_guid)) &&
-		    !memcmp(&channel->offermsg.offer.if_instance,
-			    &newchannel->offermsg.offer.if_instance,
-			    sizeof(struct hv_guid))) {
+		if (!uuid_le_cmp(channel->offermsg.offer.if_type,
+			newchannel->offermsg.offer.if_type) &&
+			!uuid_le_cmp(channel->offermsg.offer.if_instance,
+				newchannel->offermsg.offer.if_instance)) {
 			fnew = false;
 			break;
 		}
@@ -416,9 +414,8 @@ static void vmbus_process_offer(struct work_struct *work)
 
 		/* Open IC channels */
 		for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
-			if (memcmp(&newchannel->offermsg.offer.if_type,
-				   &hv_cb_utils[cnt].data,
-				   sizeof(struct hv_guid)) == 0 &&
+			if (!uuid_le_cmp(newchannel->offermsg.offer.if_type,
+				   hv_cb_utils[cnt].data) &&
 				vmbus_open(newchannel, 2 * PAGE_SIZE,
 						 2 * PAGE_SIZE, NULL, 0,
 						 chn_cb_negotiate,
@@ -444,16 +441,15 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 {
 	struct vmbus_channel_offer_channel *offer;
 	struct vmbus_channel *newchannel;
-	struct hv_guid *guidtype;
-	struct hv_guid *guidinstance;
+	uuid_le *guidtype;
+	uuid_le *guidinstance;
 	int i;
 	int fsupported = 0;
 
 	offer = (struct vmbus_channel_offer_channel *)hdr;
 	for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
-		if (memcmp(&offer->offer.if_type,
-			&supported_device_classes[i],
-			sizeof(struct hv_guid)) == 0) {
+		if (!uuid_le_cmp(offer->offer.if_type,
+				supported_device_classes[i])) {
 			fsupported = 1;
 			break;
 		}
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b191810..6f0992a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -180,8 +180,8 @@ struct mousevsc_dev {
 static const char *driver_name = "mousevsc";
 
 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const struct hv_guid mouse_guid = {
-	.data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+static const uuid_le mouse_guid = {
+	.b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
 		 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
 };
 
@@ -933,7 +933,7 @@ static int __init mousevsc_init(void)
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
 	memcpy(&drv->dev_type, &mouse_guid,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	drv->driver.name = driver_name;
 
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 1747a24..399d9fe 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -27,6 +27,7 @@
 
 #include <linux/scatterlist.h>
 #include <linux/list.h>
+#include <linux/uuid.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
@@ -35,9 +36,6 @@
 
 #include <asm/hyperv.h>
 
-struct hv_guid {
-	unsigned char data[16];
-};
 
 #define MAX_PAGE_BUFFER_COUNT				16
 #define MAX_MULTIPAGE_BUFFER_COUNT			32 /* 128K */
@@ -156,8 +154,8 @@ struct hv_ring_buffer_debug_info {
  * struct contains the fundamental information about an offer.
  */
 struct vmbus_channel_offer {
-	struct hv_guid if_type;
-	struct hv_guid if_instance;
+	uuid_le if_type;
+	uuid_le if_instance;
 	u64 int_latency; /* in 100ns units */
 	u32 if_revision;
 	u32 server_ctx_size;	/* in bytes */
@@ -526,8 +524,8 @@ enum vmbus_channel_state {
 struct vmbus_channel_debug_info {
 	u32 relid;
 	enum vmbus_channel_state state;
-	struct hv_guid interfacetype;
-	struct hv_guid interface_instance;
+	uuid_le interfacetype;
+	uuid_le interface_instance;
 	u32 monitorid;
 	u32 servermonitor_pending;
 	u32 servermonitor_latency;
@@ -786,8 +784,8 @@ struct hv_dev_port_info {
 struct hv_device_info {
 	u32 chn_id;
 	u32 chn_state;
-	struct hv_guid chn_type;
-	struct hv_guid chn_instance;
+	uuid_le chn_type;
+	uuid_le chn_instance;
 
 	u32 monitor_id;
 	u32 server_monitor_pending;
@@ -806,7 +804,7 @@ struct hv_driver {
 	const char *name;
 
 	/* the device type supported by this driver */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	struct device_driver driver;
 
@@ -819,10 +817,10 @@ struct hv_driver {
 /* Base device object */
 struct hv_device {
 	/* the device type id of this device */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	/* the device instance id of this device */
-	struct hv_guid dev_instance;
+	uuid_le dev_instance;
 
 	struct device device;
 
@@ -935,7 +933,7 @@ struct ictimesync_data {
 struct hyperv_service_callback {
 	u8 msg_type;
 	char *log_msg;
-	unsigned char data[16];
+	uuid_le data;
 	struct vmbus_channel *channel;
 	void (*callback) (void *context);
 };
diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h
index 349ad80..16ca90d 100644
--- a/drivers/staging/hv/hyperv_vmbus.h
+++ b/drivers/staging/hv/hyperv_vmbus.h
@@ -451,8 +451,8 @@ enum {
 /* #define VMBUS_PORT_ID		11 */
 
 /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const struct hv_guid VMBUS_SERVICE_ID = {
-	.data = {
+static const uuid_le VMBUS_SERVICE_ID = {
+	.b = {
 		0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
 		0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
 	},
@@ -601,8 +601,8 @@ extern struct vmbus_connection vmbus_connection;
 
 /* General vmbus interface */
 
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-					 struct hv_guid *instance,
+struct hv_device *vmbus_child_device_create(uuid_le *type,
+					 uuid_le *instance,
 					 struct vmbus_channel *channel);
 
 int vmbus_child_device_register(struct hv_device *child_device_obj);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index dc5e5c4..1506b53 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -36,8 +36,8 @@
 static const char *driver_name = "netvsc";
 
 /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const struct hv_guid netvsc_device_type = {
-	.data = {
+static const uuid_le netvsc_device_type = {
+	.b = {
 		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
 		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
 	}
@@ -1009,7 +1009,7 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 7effaf3..e4cdbc5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -45,8 +45,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 static const char *driver_name = "storvsc";
 
 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const struct hv_guid stor_vsci_device_type = {
-	.data = {
+static const uuid_le stor_vsci_device_type = {
+	.b = {
 		0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
 		0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
 	}
@@ -765,7 +765,7 @@ static int __init storvsc_drv_init(void)
 	sizeof(u64)));
 
 	memcpy(&drv->dev_type, &stor_vsci_device_type,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 559353d..291b4e0 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -64,9 +64,9 @@ static void get_channel_info(struct hv_device *device,
 	info->chn_id = debug_info.relid;
 	info->chn_state = debug_info.state;
 	memcpy(&info->chn_type, &debug_info.interfacetype,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 	memcpy(&info->chn_instance, &debug_info.interface_instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	info->monitor_id = debug_info.monitorid;
 
@@ -116,41 +116,41 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_type.data[3],
-			       device_info.chn_type.data[2],
-			       device_info.chn_type.data[1],
-			       device_info.chn_type.data[0],
-			       device_info.chn_type.data[5],
-			       device_info.chn_type.data[4],
-			       device_info.chn_type.data[7],
-			       device_info.chn_type.data[6],
-			       device_info.chn_type.data[8],
-			       device_info.chn_type.data[9],
-			       device_info.chn_type.data[10],
-			       device_info.chn_type.data[11],
-			       device_info.chn_type.data[12],
-			       device_info.chn_type.data[13],
-			       device_info.chn_type.data[14],
-			       device_info.chn_type.data[15]);
+			       device_info.chn_type.b[3],
+			       device_info.chn_type.b[2],
+			       device_info.chn_type.b[1],
+			       device_info.chn_type.b[0],
+			       device_info.chn_type.b[5],
+			       device_info.chn_type.b[4],
+			       device_info.chn_type.b[7],
+			       device_info.chn_type.b[6],
+			       device_info.chn_type.b[8],
+			       device_info.chn_type.b[9],
+			       device_info.chn_type.b[10],
+			       device_info.chn_type.b[11],
+			       device_info.chn_type.b[12],
+			       device_info.chn_type.b[13],
+			       device_info.chn_type.b[14],
+			       device_info.chn_type.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_instance.data[3],
-			       device_info.chn_instance.data[2],
-			       device_info.chn_instance.data[1],
-			       device_info.chn_instance.data[0],
-			       device_info.chn_instance.data[5],
-			       device_info.chn_instance.data[4],
-			       device_info.chn_instance.data[7],
-			       device_info.chn_instance.data[6],
-			       device_info.chn_instance.data[8],
-			       device_info.chn_instance.data[9],
-			       device_info.chn_instance.data[10],
-			       device_info.chn_instance.data[11],
-			       device_info.chn_instance.data[12],
-			       device_info.chn_instance.data[13],
-			       device_info.chn_instance.data[14],
-			       device_info.chn_instance.data[15]);
+			       device_info.chn_instance.b[3],
+			       device_info.chn_instance.b[2],
+			       device_info.chn_instance.b[1],
+			       device_info.chn_instance.b[0],
+			       device_info.chn_instance.b[5],
+			       device_info.chn_instance.b[4],
+			       device_info.chn_instance.b[7],
+			       device_info.chn_instance.b[6],
+			       device_info.chn_instance.b[8],
+			       device_info.chn_instance.b[9],
+			       device_info.chn_instance.b[10],
+			       device_info.chn_instance.b[11],
+			       device_info.chn_instance.b[12],
+			       device_info.chn_instance.b[13],
+			       device_info.chn_instance.b[14],
+			       device_info.chn_instance.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
 		return sprintf(buf, "%d\n", device_info.chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -246,22 +246,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
 			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_type.data[3],
-			     dev->dev_type.data[2],
-			     dev->dev_type.data[1],
-			     dev->dev_type.data[0],
-			     dev->dev_type.data[5],
-			     dev->dev_type.data[4],
-			     dev->dev_type.data[7],
-			     dev->dev_type.data[6],
-			     dev->dev_type.data[8],
-			     dev->dev_type.data[9],
-			     dev->dev_type.data[10],
-			     dev->dev_type.data[11],
-			     dev->dev_type.data[12],
-			     dev->dev_type.data[13],
-			     dev->dev_type.data[14],
-			     dev->dev_type.data[15]);
+			     dev->dev_type.b[3],
+			     dev->dev_type.b[2],
+			     dev->dev_type.b[1],
+			     dev->dev_type.b[0],
+			     dev->dev_type.b[5],
+			     dev->dev_type.b[4],
+			     dev->dev_type.b[7],
+			     dev->dev_type.b[6],
+			     dev->dev_type.b[8],
+			     dev->dev_type.b[9],
+			     dev->dev_type.b[10],
+			     dev->dev_type.b[11],
+			     dev->dev_type.b[12],
+			     dev->dev_type.b[13],
+			     dev->dev_type.b[14],
+			     dev->dev_type.b[15]);
 
 	if (ret)
 		return ret;
@@ -269,22 +269,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
 			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_instance.data[3],
-			     dev->dev_instance.data[2],
-			     dev->dev_instance.data[1],
-			     dev->dev_instance.data[0],
-			     dev->dev_instance.data[5],
-			     dev->dev_instance.data[4],
-			     dev->dev_instance.data[7],
-			     dev->dev_instance.data[6],
-			     dev->dev_instance.data[8],
-			     dev->dev_instance.data[9],
-			     dev->dev_instance.data[10],
-			     dev->dev_instance.data[11],
-			     dev->dev_instance.data[12],
-			     dev->dev_instance.data[13],
-			     dev->dev_instance.data[14],
-			     dev->dev_instance.data[15]);
+			     dev->dev_instance.b[3],
+			     dev->dev_instance.b[2],
+			     dev->dev_instance.b[1],
+			     dev->dev_instance.b[0],
+			     dev->dev_instance.b[5],
+			     dev->dev_instance.b[4],
+			     dev->dev_instance.b[7],
+			     dev->dev_instance.b[6],
+			     dev->dev_instance.b[8],
+			     dev->dev_instance.b[9],
+			     dev->dev_instance.b[10],
+			     dev->dev_instance.b[11],
+			     dev->dev_instance.b[12],
+			     dev->dev_instance.b[13],
+			     dev->dev_instance.b[14],
+			     dev->dev_instance.b[15]);
 	if (ret)
 		return ret;
 
@@ -303,7 +303,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 
 	/* We found our driver ? */
 	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
-		   sizeof(struct hv_guid)) == 0)
+		   sizeof(uuid_le)) == 0)
 		match = 1;
 
 	return match;
@@ -630,8 +630,8 @@ EXPORT_SYMBOL(vmbus_child_driver_unregister);
  * vmbus_child_device_create - Creates and registers a new child device
  * on the vmbus.
  */
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-					    struct hv_guid *instance,
+struct hv_device *vmbus_child_device_create(uuid_le *type,
+					    uuid_le *instance,
 					    struct vmbus_channel *channel)
 {
 	struct hv_device *child_device_obj;
@@ -644,9 +644,9 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
 	}
 
 	child_device_obj->channel = channel;
-	memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
+	memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
 	memcpy(&child_device_obj->dev_instance, instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 
 	return child_device_obj;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 002/117] Staging: hv: Replace struct hv_guid with the uuid type already defined in Linux
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Replace struct hv_guid with the uuid type already defined in Linux.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c   |   18 +++---
 drivers/staging/hv/channel.c      |    4 +-
 drivers/staging/hv/channel_mgmt.c |   50 ++++++-------
 drivers/staging/hv/hv_mouse.c     |    6 +-
 drivers/staging/hv/hyperv.h       |   24 +++----
 drivers/staging/hv/hyperv_vmbus.h |    8 +-
 drivers/staging/hv/netvsc.c       |    6 +-
 drivers/staging/hv/storvsc_drv.c  |    6 +-
 drivers/staging/hv/vmbus_drv.c    |  142 ++++++++++++++++++------------------
 9 files changed, 129 insertions(+), 135 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d286b22..018b293 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -112,8 +112,8 @@ struct block_device_context {
 static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid dev_type = {
-	.data = {
+static const uuid_le dev_type = {
+	.b = {
 		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
 	}
@@ -155,13 +155,13 @@ static int blkvsc_device_add(struct hv_device *device,
 	 * id. For IDE devices, the device instance id is formatted as
 	 * <bus id> * - <device id> - 8899 - 000000000000.
 	 */
-	device_info->path_id = device->dev_instance.data[3] << 24 |
-			     device->dev_instance.data[2] << 16 |
-			     device->dev_instance.data[1] << 8  |
-			     device->dev_instance.data[0];
+	device_info->path_id = device->dev_instance.b[3] << 24 |
+			     device->dev_instance.b[2] << 16 |
+			     device->dev_instance.b[1] << 8  |
+			     device->dev_instance.b[0];
 
-	device_info->target_id = device->dev_instance.data[5] << 8 |
-			       device->dev_instance.data[4];
+	device_info->target_id = device->dev_instance.b[5] << 8 |
+			       device->dev_instance.b[4];
 
 	return ret;
 }
@@ -829,7 +829,7 @@ static int blkvsc_drv_init(void)
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 455f47a..222adcc 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -81,10 +81,10 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
 	memcpy(&debuginfo->interfacetype,
-	       &channel->offermsg.offer.if_type, sizeof(struct hv_guid));
+	       &channel->offermsg.offer.if_type, sizeof(uuid_le));
 	memcpy(&debuginfo->interface_instance,
 	       &channel->offermsg.offer.if_instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages;
 
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index bf011f3..11beb41 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -40,12 +40,12 @@ struct vmbus_channel_message_table_entry {
 #define MAX_MSG_TYPES                    4
 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
 
-static const struct hv_guid
+static const uuid_le
 	supported_device_classes[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
 	/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
 	/* Storage - SCSI */
 	{
-		.data  = {
+		.b  = {
 			0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
 			0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
 		}
@@ -54,7 +54,7 @@ static const struct hv_guid
 	/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
 	/* Network */
 	{
-		.data = {
+		.b = {
 			0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
 			0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
 		}
@@ -63,7 +63,7 @@ static const struct hv_guid
 	/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
 	/* Input */
 	{
-		.data = {
+		.b = {
 			0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
 			0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
 		}
@@ -72,7 +72,7 @@ static const struct hv_guid
 	/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
 	/* IDE */
 	{
-		.data = {
+		.b = {
 			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
 		}
@@ -80,7 +80,7 @@ static const struct hv_guid
 	/* 0E0B6031-5213-4934-818B-38D90CED39DB */
 	/* Shutdown */
 	{
-		.data = {
+		.b = {
 			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
 			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
 		}
@@ -88,7 +88,7 @@ static const struct hv_guid
 	/* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */
 	/* TimeSync */
 	{
-		.data = {
+		.b = {
 			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
 			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
 		}
@@ -96,7 +96,7 @@ static const struct hv_guid
 	/* {57164f39-9115-4e78-ab55-382f3bd5422d} */
 	/* Heartbeat */
 	{
-		.data = {
+		.b = {
 			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
 			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
 		}
@@ -104,7 +104,7 @@ static const struct hv_guid
 	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
 	/* KVP */
 	{
-		.data = {
+		.b = {
 			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
 			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
 	}
@@ -231,7 +231,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* Shutdown */
 	{
 		.msg_type = HV_SHUTDOWN_MSG,
-		.data = {
+		.data.b = {
 			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
 			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
 		},
@@ -242,7 +242,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* TimeSync */
 	{
 		.msg_type = HV_TIMESYNC_MSG,
-		.data = {
+		.data.b = {
 			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
 			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
 		},
@@ -252,7 +252,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* Heartbeat */
 	{
 		.msg_type = HV_HEARTBEAT_MSG,
-		.data = {
+		.data.b = {
 			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
 			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
 		},
@@ -261,7 +261,7 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
 	/* KVP */
 	{
-		.data = {
+		.data.b = {
 			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
 			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
 		},
@@ -358,12 +358,10 @@ static void vmbus_process_offer(struct work_struct *work)
 	spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
 
 	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
-		if (!memcmp(&channel->offermsg.offer.if_type,
-			    &newchannel->offermsg.offer.if_type,
-			    sizeof(struct hv_guid)) &&
-		    !memcmp(&channel->offermsg.offer.if_instance,
-			    &newchannel->offermsg.offer.if_instance,
-			    sizeof(struct hv_guid))) {
+		if (!uuid_le_cmp(channel->offermsg.offer.if_type,
+			newchannel->offermsg.offer.if_type) &&
+			!uuid_le_cmp(channel->offermsg.offer.if_instance,
+				newchannel->offermsg.offer.if_instance)) {
 			fnew = false;
 			break;
 		}
@@ -416,9 +414,8 @@ static void vmbus_process_offer(struct work_struct *work)
 
 		/* Open IC channels */
 		for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
-			if (memcmp(&newchannel->offermsg.offer.if_type,
-				   &hv_cb_utils[cnt].data,
-				   sizeof(struct hv_guid)) == 0 &&
+			if (!uuid_le_cmp(newchannel->offermsg.offer.if_type,
+				   hv_cb_utils[cnt].data) &&
 				vmbus_open(newchannel, 2 * PAGE_SIZE,
 						 2 * PAGE_SIZE, NULL, 0,
 						 chn_cb_negotiate,
@@ -444,16 +441,15 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 {
 	struct vmbus_channel_offer_channel *offer;
 	struct vmbus_channel *newchannel;
-	struct hv_guid *guidtype;
-	struct hv_guid *guidinstance;
+	uuid_le *guidtype;
+	uuid_le *guidinstance;
 	int i;
 	int fsupported = 0;
 
 	offer = (struct vmbus_channel_offer_channel *)hdr;
 	for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
-		if (memcmp(&offer->offer.if_type,
-			&supported_device_classes[i],
-			sizeof(struct hv_guid)) == 0) {
+		if (!uuid_le_cmp(offer->offer.if_type,
+				supported_device_classes[i])) {
 			fsupported = 1;
 			break;
 		}
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b191810..6f0992a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -180,8 +180,8 @@ struct mousevsc_dev {
 static const char *driver_name = "mousevsc";
 
 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const struct hv_guid mouse_guid = {
-	.data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+static const uuid_le mouse_guid = {
+	.b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
 		 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
 };
 
@@ -933,7 +933,7 @@ static int __init mousevsc_init(void)
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
 	memcpy(&drv->dev_type, &mouse_guid,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	drv->driver.name = driver_name;
 
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 1747a24..399d9fe 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -27,6 +27,7 @@
 
 #include <linux/scatterlist.h>
 #include <linux/list.h>
+#include <linux/uuid.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
@@ -35,9 +36,6 @@
 
 #include <asm/hyperv.h>
 
-struct hv_guid {
-	unsigned char data[16];
-};
 
 #define MAX_PAGE_BUFFER_COUNT				16
 #define MAX_MULTIPAGE_BUFFER_COUNT			32 /* 128K */
@@ -156,8 +154,8 @@ struct hv_ring_buffer_debug_info {
  * struct contains the fundamental information about an offer.
  */
 struct vmbus_channel_offer {
-	struct hv_guid if_type;
-	struct hv_guid if_instance;
+	uuid_le if_type;
+	uuid_le if_instance;
 	u64 int_latency; /* in 100ns units */
 	u32 if_revision;
 	u32 server_ctx_size;	/* in bytes */
@@ -526,8 +524,8 @@ enum vmbus_channel_state {
 struct vmbus_channel_debug_info {
 	u32 relid;
 	enum vmbus_channel_state state;
-	struct hv_guid interfacetype;
-	struct hv_guid interface_instance;
+	uuid_le interfacetype;
+	uuid_le interface_instance;
 	u32 monitorid;
 	u32 servermonitor_pending;
 	u32 servermonitor_latency;
@@ -786,8 +784,8 @@ struct hv_dev_port_info {
 struct hv_device_info {
 	u32 chn_id;
 	u32 chn_state;
-	struct hv_guid chn_type;
-	struct hv_guid chn_instance;
+	uuid_le chn_type;
+	uuid_le chn_instance;
 
 	u32 monitor_id;
 	u32 server_monitor_pending;
@@ -806,7 +804,7 @@ struct hv_driver {
 	const char *name;
 
 	/* the device type supported by this driver */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	struct device_driver driver;
 
@@ -819,10 +817,10 @@ struct hv_driver {
 /* Base device object */
 struct hv_device {
 	/* the device type id of this device */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	/* the device instance id of this device */
-	struct hv_guid dev_instance;
+	uuid_le dev_instance;
 
 	struct device device;
 
@@ -935,7 +933,7 @@ struct ictimesync_data {
 struct hyperv_service_callback {
 	u8 msg_type;
 	char *log_msg;
-	unsigned char data[16];
+	uuid_le data;
 	struct vmbus_channel *channel;
 	void (*callback) (void *context);
 };
diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h
index 349ad80..16ca90d 100644
--- a/drivers/staging/hv/hyperv_vmbus.h
+++ b/drivers/staging/hv/hyperv_vmbus.h
@@ -451,8 +451,8 @@ enum {
 /* #define VMBUS_PORT_ID		11 */
 
 /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const struct hv_guid VMBUS_SERVICE_ID = {
-	.data = {
+static const uuid_le VMBUS_SERVICE_ID = {
+	.b = {
 		0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
 		0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
 	},
@@ -601,8 +601,8 @@ extern struct vmbus_connection vmbus_connection;
 
 /* General vmbus interface */
 
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-					 struct hv_guid *instance,
+struct hv_device *vmbus_child_device_create(uuid_le *type,
+					 uuid_le *instance,
 					 struct vmbus_channel *channel);
 
 int vmbus_child_device_register(struct hv_device *child_device_obj);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index dc5e5c4..1506b53 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -36,8 +36,8 @@
 static const char *driver_name = "netvsc";
 
 /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const struct hv_guid netvsc_device_type = {
-	.data = {
+static const uuid_le netvsc_device_type = {
+	.b = {
 		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
 		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
 	}
@@ -1009,7 +1009,7 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 7effaf3..e4cdbc5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -45,8 +45,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 static const char *driver_name = "storvsc";
 
 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const struct hv_guid stor_vsci_device_type = {
-	.data = {
+static const uuid_le stor_vsci_device_type = {
+	.b = {
 		0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
 		0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
 	}
@@ -765,7 +765,7 @@ static int __init storvsc_drv_init(void)
 	sizeof(u64)));
 
 	memcpy(&drv->dev_type, &stor_vsci_device_type,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 559353d..291b4e0 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -64,9 +64,9 @@ static void get_channel_info(struct hv_device *device,
 	info->chn_id = debug_info.relid;
 	info->chn_state = debug_info.state;
 	memcpy(&info->chn_type, &debug_info.interfacetype,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 	memcpy(&info->chn_instance, &debug_info.interface_instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	info->monitor_id = debug_info.monitorid;
 
@@ -116,41 +116,41 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_type.data[3],
-			       device_info.chn_type.data[2],
-			       device_info.chn_type.data[1],
-			       device_info.chn_type.data[0],
-			       device_info.chn_type.data[5],
-			       device_info.chn_type.data[4],
-			       device_info.chn_type.data[7],
-			       device_info.chn_type.data[6],
-			       device_info.chn_type.data[8],
-			       device_info.chn_type.data[9],
-			       device_info.chn_type.data[10],
-			       device_info.chn_type.data[11],
-			       device_info.chn_type.data[12],
-			       device_info.chn_type.data[13],
-			       device_info.chn_type.data[14],
-			       device_info.chn_type.data[15]);
+			       device_info.chn_type.b[3],
+			       device_info.chn_type.b[2],
+			       device_info.chn_type.b[1],
+			       device_info.chn_type.b[0],
+			       device_info.chn_type.b[5],
+			       device_info.chn_type.b[4],
+			       device_info.chn_type.b[7],
+			       device_info.chn_type.b[6],
+			       device_info.chn_type.b[8],
+			       device_info.chn_type.b[9],
+			       device_info.chn_type.b[10],
+			       device_info.chn_type.b[11],
+			       device_info.chn_type.b[12],
+			       device_info.chn_type.b[13],
+			       device_info.chn_type.b[14],
+			       device_info.chn_type.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_instance.data[3],
-			       device_info.chn_instance.data[2],
-			       device_info.chn_instance.data[1],
-			       device_info.chn_instance.data[0],
-			       device_info.chn_instance.data[5],
-			       device_info.chn_instance.data[4],
-			       device_info.chn_instance.data[7],
-			       device_info.chn_instance.data[6],
-			       device_info.chn_instance.data[8],
-			       device_info.chn_instance.data[9],
-			       device_info.chn_instance.data[10],
-			       device_info.chn_instance.data[11],
-			       device_info.chn_instance.data[12],
-			       device_info.chn_instance.data[13],
-			       device_info.chn_instance.data[14],
-			       device_info.chn_instance.data[15]);
+			       device_info.chn_instance.b[3],
+			       device_info.chn_instance.b[2],
+			       device_info.chn_instance.b[1],
+			       device_info.chn_instance.b[0],
+			       device_info.chn_instance.b[5],
+			       device_info.chn_instance.b[4],
+			       device_info.chn_instance.b[7],
+			       device_info.chn_instance.b[6],
+			       device_info.chn_instance.b[8],
+			       device_info.chn_instance.b[9],
+			       device_info.chn_instance.b[10],
+			       device_info.chn_instance.b[11],
+			       device_info.chn_instance.b[12],
+			       device_info.chn_instance.b[13],
+			       device_info.chn_instance.b[14],
+			       device_info.chn_instance.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
 		return sprintf(buf, "%d\n", device_info.chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -246,22 +246,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
 			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_type.data[3],
-			     dev->dev_type.data[2],
-			     dev->dev_type.data[1],
-			     dev->dev_type.data[0],
-			     dev->dev_type.data[5],
-			     dev->dev_type.data[4],
-			     dev->dev_type.data[7],
-			     dev->dev_type.data[6],
-			     dev->dev_type.data[8],
-			     dev->dev_type.data[9],
-			     dev->dev_type.data[10],
-			     dev->dev_type.data[11],
-			     dev->dev_type.data[12],
-			     dev->dev_type.data[13],
-			     dev->dev_type.data[14],
-			     dev->dev_type.data[15]);
+			     dev->dev_type.b[3],
+			     dev->dev_type.b[2],
+			     dev->dev_type.b[1],
+			     dev->dev_type.b[0],
+			     dev->dev_type.b[5],
+			     dev->dev_type.b[4],
+			     dev->dev_type.b[7],
+			     dev->dev_type.b[6],
+			     dev->dev_type.b[8],
+			     dev->dev_type.b[9],
+			     dev->dev_type.b[10],
+			     dev->dev_type.b[11],
+			     dev->dev_type.b[12],
+			     dev->dev_type.b[13],
+			     dev->dev_type.b[14],
+			     dev->dev_type.b[15]);
 
 	if (ret)
 		return ret;
@@ -269,22 +269,22 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
 			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_instance.data[3],
-			     dev->dev_instance.data[2],
-			     dev->dev_instance.data[1],
-			     dev->dev_instance.data[0],
-			     dev->dev_instance.data[5],
-			     dev->dev_instance.data[4],
-			     dev->dev_instance.data[7],
-			     dev->dev_instance.data[6],
-			     dev->dev_instance.data[8],
-			     dev->dev_instance.data[9],
-			     dev->dev_instance.data[10],
-			     dev->dev_instance.data[11],
-			     dev->dev_instance.data[12],
-			     dev->dev_instance.data[13],
-			     dev->dev_instance.data[14],
-			     dev->dev_instance.data[15]);
+			     dev->dev_instance.b[3],
+			     dev->dev_instance.b[2],
+			     dev->dev_instance.b[1],
+			     dev->dev_instance.b[0],
+			     dev->dev_instance.b[5],
+			     dev->dev_instance.b[4],
+			     dev->dev_instance.b[7],
+			     dev->dev_instance.b[6],
+			     dev->dev_instance.b[8],
+			     dev->dev_instance.b[9],
+			     dev->dev_instance.b[10],
+			     dev->dev_instance.b[11],
+			     dev->dev_instance.b[12],
+			     dev->dev_instance.b[13],
+			     dev->dev_instance.b[14],
+			     dev->dev_instance.b[15]);
 	if (ret)
 		return ret;
 
@@ -303,7 +303,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 
 	/* We found our driver ? */
 	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
-		   sizeof(struct hv_guid)) == 0)
+		   sizeof(uuid_le)) == 0)
 		match = 1;
 
 	return match;
@@ -630,8 +630,8 @@ EXPORT_SYMBOL(vmbus_child_driver_unregister);
  * vmbus_child_device_create - Creates and registers a new child device
  * on the vmbus.
  */
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-					    struct hv_guid *instance,
+struct hv_device *vmbus_child_device_create(uuid_le *type,
+					    uuid_le *instance,
 					    struct vmbus_channel *channel)
 {
 	struct hv_device *child_device_obj;
@@ -644,9 +644,9 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
 	}
 
 	child_device_obj->channel = channel;
-	memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
+	memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
 	memcpy(&child_device_obj->dev_instance, instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 
 	return child_device_obj;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

In preparation for implementing vmbus aliases for auto-loading
Hyper-V drivers, define vmbus specific device ID.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 include/linux/mod_devicetable.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index ae28e93..5a12377 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -405,6 +405,13 @@ struct virtio_device_id {
 };
 #define VIRTIO_DEV_ANY_ID	0xffffffff
 
+/*
+ * For Hyper-V devices we use the device guid as the id.
+ */
+struct hv_vmbus_device_id {
+	__u8 guid[16];
+};
+
 /* i2c */
 
 #define I2C_NAME_SIZE	20
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

In preparation for implementing vmbus aliases for auto-loading
Hyper-V drivers, define vmbus specific device ID.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 include/linux/mod_devicetable.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index ae28e93..5a12377 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -405,6 +405,13 @@ struct virtio_device_id {
 };
 #define VIRTIO_DEV_ANY_ID	0xffffffff
 
+/*
+ * For Hyper-V devices we use the device guid as the id.
+ */
+struct hv_vmbus_device_id {
+	__u8 guid[16];
+};
+
 /* i2c */
 
 #define I2C_NAME_SIZE	20
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 004/117] Staging: hv: Add code to parse struct hv_vmbus_device_id table
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (2 preceding siblings ...)
  (?)
@ 2011-07-15 17:45   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add code to parse struct hv_vmbus_device_id table.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 scripts/mod/file2alias.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e26e2fb..b74d21a 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -735,6 +735,27 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
 	return 1;
 }
 
+/*
+ * Looks like: vmbus:guid
+ * Each byte of the guid will be represented by two hex characters
+ * in the name.
+ */
+
+static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id,
+			  char *alias)
+{
+	int i;
+	char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
+
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
+		sprintf(&guid_name[i], "%02x", id->guid[i/2]);
+
+	strcpy(alias, "vmbus:");
+	strcat(alias, guid_name);
+
+	return 1;
+}
+
 /* Looks like: i2c:S */
 static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
 			char *alias)
@@ -994,6 +1015,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 		do_table(symval, sym->st_size,
 			 sizeof(struct virtio_device_id), "virtio",
 			 do_virtio_entry, mod);
+	else if (sym_is(symname, "__mod_vmbus_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct hv_vmbus_device_id), "vmbus",
+			 do_vmbus_entry, mod);
 	else if (sym_is(symname, "__mod_i2c_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct i2c_device_id), "i2c",
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 005/117] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

In preparation for supporting auto-loading Hyper-V drivers
using vmbus specific aliases, introduce vmbus ID space in struct hv_driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 399d9fe..b8199f4 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -32,6 +32,7 @@
 #include <linux/workqueue.h>
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 
 #include <asm/hyperv.h>
@@ -805,6 +806,7 @@ struct hv_driver {
 
 	/* the device type supported by this driver */
 	uuid_le dev_type;
+	const struct hv_vmbus_device_id *id_table;
 
 	struct device_driver driver;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 005/117] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

In preparation for supporting auto-loading Hyper-V drivers
using vmbus specific aliases, introduce vmbus ID space in struct hv_driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 399d9fe..b8199f4 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -32,6 +32,7 @@
 #include <linux/workqueue.h>
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 
 #include <asm/hyperv.h>
@@ -805,6 +806,7 @@ struct hv_driver {
 
 	/* the device type supported by this driver */
 	uuid_le dev_type;
+	const struct hv_vmbus_device_id *id_table;
 
 	struct device_driver driver;
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 006/117] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced vmbus ID in the blockvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 018b293..38117d96 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -802,10 +802,26 @@ static void blkvsc_request(struct request_queue *queue)
 	}
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* IDE guid */
+		.guid = {
+			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 
 /* The one and only one */
 static  struct hv_driver blkvsc_drv = {
+	.id_table = id_table,
 	.probe =  blkvsc_probe,
 	.remove =  blkvsc_remove,
 	.shutdown = blkvsc_shutdown,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 006/117] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced vmbus ID in the blockvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 018b293..38117d96 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -802,10 +802,26 @@ static void blkvsc_request(struct request_queue *queue)
 	}
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* IDE guid */
+		.guid = {
+			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 
 /* The one and only one */
 static  struct hv_driver blkvsc_drv = {
+	.id_table = id_table,
 	.probe =  blkvsc_probe,
 	.remove =  blkvsc_remove,
 	.shutdown = blkvsc_shutdown,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 007/117] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced vmbus ID in storvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e4cdbc5..e30f11c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -646,6 +646,21 @@ static struct scsi_host_template scsi_driver = {
 	.dma_boundary =		PAGE_SIZE-1,
 };
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* SCSI guid */
+		.guid = {
+			0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
+			0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 /*
  * storvsc_probe - Add a new device for this driver
@@ -720,6 +735,7 @@ static int storvsc_probe(struct hv_device *device)
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
+	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
 };
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 007/117] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced vmbus ID in storvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e4cdbc5..e30f11c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -646,6 +646,21 @@ static struct scsi_host_template scsi_driver = {
 	.dma_boundary =		PAGE_SIZE-1,
 };
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* SCSI guid */
+		.guid = {
+			0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
+			0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 /*
  * storvsc_probe - Add a new device for this driver
@@ -720,6 +735,7 @@ static int storvsc_probe(struct hv_device *device)
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
+	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
 };
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 008/117] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced vmbus ID in netvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 61989f0..1f4b7b4 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -413,8 +413,25 @@ static int netvsc_remove(struct hv_device *dev)
 	return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Network guid */
+		.guid = {
+			0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
+			0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
+	.id_table = id_table,
 	.probe = netvsc_probe,
 	.remove = netvsc_remove,
 };
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 008/117] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced vmbus ID in netvsc driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 61989f0..1f4b7b4 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -413,8 +413,25 @@ static int netvsc_remove(struct hv_device *dev)
 	return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Network guid */
+		.guid = {
+			0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
+			0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
+	.id_table = id_table,
 	.probe = netvsc_probe,
 	.remove = netvsc_remove,
 };
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 009/117] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced vmbus ID in mouse driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6f0992a..b8514fd 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -915,8 +915,24 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 	kfree(hid_dev);
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Mouse guid */
+		.guid = {
+			0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+			0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 static struct  hv_driver mousevsc_drv = {
+	.id_table = id_table,
 	.probe = mousevsc_probe,
 	.remove = mousevsc_remove,
 };
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 009/117] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced vmbus ID in mouse driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6f0992a..b8514fd 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -915,8 +915,24 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 	kfree(hid_dev);
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Mouse guid */
+		.guid = {
+			0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+			0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
 
 static struct  hv_driver mousevsc_drv = {
+	.id_table = id_table,
 	.probe = mousevsc_probe,
 	.remove = mousevsc_remove,
 };
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 010/117] Staging: hv: util: Make hv_utils a vmbus device driver
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (8 preceding siblings ...)
  (?)
@ 2011-07-15 17:45   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Make hv_utils a vmbus device driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index c164b54..e72bfe0 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -36,6 +36,8 @@ static u8 *shut_txf_buf;
 static u8 *time_txf_buf;
 static u8 *hbeat_txf_buf;
 
+static const char *driver_name = "hv_util";
+
 static void shutdown_onchannelcallback(void *context)
 {
 	struct vmbus_channel *channel = context;
@@ -210,6 +212,27 @@ static void heartbeat_onchannelcallback(void *context)
 	}
 }
 
+/*
+ * The devices managed by the util driver don't need any additional
+ * setup.
+ */
+static int util_probe(struct hv_device *dev)
+{
+	return 0;
+}
+
+static int util_remove(struct hv_device *dev)
+{
+	return 0;
+}
+
+
+/* The one and only one */
+static  struct hv_driver util_drv = {
+	.probe =  util_probe,
+	.remove =  util_remove,
+};
+
 static const struct pci_device_id __initconst
 hv_utils_pci_table[] __maybe_unused = {
 	{ PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
@@ -264,7 +287,9 @@ static int __init init_hyperv_utils(void)
 
 	hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
 
-	return 0;
+	util_drv.driver.name = driver_name;
+
+	return vmbus_child_driver_register(&util_drv.driver);
 }
 
 static void exit_hyperv_utils(void)
@@ -296,6 +321,7 @@ static void exit_hyperv_utils(void)
 	kfree(shut_txf_buf);
 	kfree(time_txf_buf);
 	kfree(hbeat_txf_buf);
+	vmbus_child_driver_unregister(&util_drv.driver);
 }
 
 module_init(init_hyperv_utils);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 011/117] Staging: hv: util: Use the newly introduced vmbus ID in util driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced vmbus ID in util driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index e72bfe0..35540f5 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -226,9 +226,47 @@ static int util_remove(struct hv_device *dev)
 	return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Shutdown guid */
+		.guid = {
+			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
+			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
+		}
+	},
+	{
+		/* Time synch guid */
+		.guid = {
+			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
+			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
+		}
+	},
+	{
+		/* Heartbeat guid */
+		.guid = {
+			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
+			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
+		}
+	},
+	{
+		/* KVP guid */
+		.guid = {
+			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
+
 
 /* The one and only one */
 static  struct hv_driver util_drv = {
+	.id_table = id_table,
 	.probe =  util_probe,
 	.remove =  util_remove,
 };
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 011/117] Staging: hv: util: Use the newly introduced vmbus ID in util driver
@ 2011-07-15 17:45     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:45 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced vmbus ID in util driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index e72bfe0..35540f5 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -226,9 +226,47 @@ static int util_remove(struct hv_device *dev)
 	return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Shutdown guid */
+		.guid = {
+			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
+			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
+		}
+	},
+	{
+		/* Time synch guid */
+		.guid = {
+			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
+			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
+		}
+	},
+	{
+		/* Heartbeat guid */
+		.guid = {
+			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
+			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
+		}
+	},
+	{
+		/* KVP guid */
+		.guid = {
+			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
+		}
+	},
+	{
+		.guid = {
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		}
+	},
+};
+
 
 /* The one and only one */
 static  struct hv_driver util_drv = {
+	.id_table = id_table,
 	.probe =  util_probe,
 	.remove =  util_remove,
 };
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 012/117] Staging: hv: blkvsc: Add the MODULE_DEVICE_TABLE() line
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (10 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  2011-08-23 22:46     ` Greg KH
  -1 siblings, 1 reply; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line in blkvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 38117d96..8e4c206 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -818,6 +818,7 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver blkvsc_drv = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 013/117] Staging: hv: storvsc: Add MODULE_DEVICE_TABLE() line
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (11 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add MODULE_DEVICE_TABLE() line to storvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e30f11c..65679a0 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -662,6 +662,7 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 /*
  * storvsc_probe - Add a new device for this driver
  */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 014/117] Staging: hv: netvsc: Add the MODULE_DEVICE_TABLE() line
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to netvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 1f4b7b4..5847662 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -429,6 +429,8 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
 	.id_table = id_table,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 014/117] Staging: hv: netvsc: Add the MODULE_DEVICE_TABLE() line
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to netvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 1f4b7b4..5847662 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -429,6 +429,8 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
 	.id_table = id_table,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 015/117] Staging: hv: util: Add the MODULE_DEVICE_TABLE() line
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to hv_util.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 35540f5..8d327c5 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -263,6 +263,7 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver util_drv = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 015/117] Staging: hv: util: Add the MODULE_DEVICE_TABLE() line
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to hv_util.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 35540f5..8d327c5 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -263,6 +263,7 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver util_drv = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 016/117] Staging: hv: mouse: Add the MODULE_DEVICE_TABLE() line
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to hv_mouse.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b8514fd..d6441d6 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -931,6 +931,8 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 static struct  hv_driver mousevsc_drv = {
 	.id_table = id_table,
 	.probe = mousevsc_probe,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 016/117] Staging: hv: mouse: Add the MODULE_DEVICE_TABLE() line
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Add the MODULE_DEVICE_TABLE() line to hv_mouse.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b8514fd..d6441d6 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -931,6 +931,8 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 static struct  hv_driver mousevsc_drv = {
 	.id_table = id_table,
 	.probe = mousevsc_probe,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 017/117] Staging: hv: mouse: Do not auto-load the mouse driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The mouse driver is not functional and so, prevent auto-loading
of this driver. Earlier we added the MODULE_DEVICE_TABLE() line
to verify that the appropriate module alias was generated.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index d6441d6..95986fb 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -931,7 +931,10 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
-MODULE_DEVICE_TABLE(vmbus, id_table);
+/*
+ * The mouse driver is not functional; do not auto-load it.
+ */
+/* MODULE_DEVICE_TABLE(vmbus, id_table); */
 
 static struct  hv_driver mousevsc_drv = {
 	.id_table = id_table,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 017/117] Staging: hv: mouse: Do not auto-load the mouse driver
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

The mouse driver is not functional and so, prevent auto-loading
of this driver. Earlier we added the MODULE_DEVICE_TABLE() line
to verify that the appropriate module alias was generated.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index d6441d6..95986fb 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -931,7 +931,10 @@ static const struct hv_vmbus_device_id id_table[] = {
 	},
 };
 
-MODULE_DEVICE_TABLE(vmbus, id_table);
+/*
+ * The mouse driver is not functional; do not auto-load it.
+ */
+/* MODULE_DEVICE_TABLE(vmbus, id_table); */
 
 static struct  hv_driver mousevsc_drv = {
 	.id_table = id_table,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 018/117] Staging: hv: vmbus: Cleanup vmbus_match()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we are using the already defined type for guids, cleanup
vmbus_match().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 291b4e0..330cc43 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -302,8 +302,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 	struct hv_device *hv_dev = device_to_hv_device(device);
 
 	/* We found our driver ? */
-	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
-		   sizeof(uuid_le)) == 0)
+	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
 		match = 1;
 
 	return match;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 018/117] Staging: hv: vmbus: Cleanup vmbus_match()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we are using the already defined type for guids, cleanup
vmbus_match().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 291b4e0..330cc43 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -302,8 +302,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 	struct hv_device *hv_dev = device_to_hv_device(device);
 
 	/* We found our driver ? */
-	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
-		   sizeof(uuid_le)) == 0)
+	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
 		match = 1;
 
 	return match;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now generate appropriate uevent based on the modalias string. As part of this,
cleanup the existing uevent code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 330cc43..7baba62 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = {
  * This routine is invoked when a device is added or removed on the vmbus to
  * generate a uevent to udev in the userspace. The udev will then look at its
  * rule and the uevent generated here to load the appropriate driver
+ *
+ * The alias string will be of the form vmbus:guid where guid is the string
+ * representation of the device guid (each byte of the guid will be
+ * represented with two hex characters.
  */
 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 {
 	struct hv_device *dev = device_to_hv_device(device);
-	int ret;
-
-	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
-			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_type.b[3],
-			     dev->dev_type.b[2],
-			     dev->dev_type.b[1],
-			     dev->dev_type.b[0],
-			     dev->dev_type.b[5],
-			     dev->dev_type.b[4],
-			     dev->dev_type.b[7],
-			     dev->dev_type.b[6],
-			     dev->dev_type.b[8],
-			     dev->dev_type.b[9],
-			     dev->dev_type.b[10],
-			     dev->dev_type.b[11],
-			     dev->dev_type.b[12],
-			     dev->dev_type.b[13],
-			     dev->dev_type.b[14],
-			     dev->dev_type.b[15]);
-
-	if (ret)
-		return ret;
+	int i, ret;
+	char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
 
-	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
-			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_instance.b[3],
-			     dev->dev_instance.b[2],
-			     dev->dev_instance.b[1],
-			     dev->dev_instance.b[0],
-			     dev->dev_instance.b[5],
-			     dev->dev_instance.b[4],
-			     dev->dev_instance.b[7],
-			     dev->dev_instance.b[6],
-			     dev->dev_instance.b[8],
-			     dev->dev_instance.b[9],
-			     dev->dev_instance.b[10],
-			     dev->dev_instance.b[11],
-			     dev->dev_instance.b[12],
-			     dev->dev_instance.b[13],
-			     dev->dev_instance.b[14],
-			     dev->dev_instance.b[15]);
-	if (ret)
-		return ret;
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
+		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
 
-	return 0;
+	ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+	return ret;
 }
 
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now generate appropriate uevent based on the modalias string. As part of this,
cleanup the existing uevent code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 330cc43..7baba62 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = {
  * This routine is invoked when a device is added or removed on the vmbus to
  * generate a uevent to udev in the userspace. The udev will then look at its
  * rule and the uevent generated here to load the appropriate driver
+ *
+ * The alias string will be of the form vmbus:guid where guid is the string
+ * representation of the device guid (each byte of the guid will be
+ * represented with two hex characters.
  */
 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 {
 	struct hv_device *dev = device_to_hv_device(device);
-	int ret;
-
-	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
-			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_type.b[3],
-			     dev->dev_type.b[2],
-			     dev->dev_type.b[1],
-			     dev->dev_type.b[0],
-			     dev->dev_type.b[5],
-			     dev->dev_type.b[4],
-			     dev->dev_type.b[7],
-			     dev->dev_type.b[6],
-			     dev->dev_type.b[8],
-			     dev->dev_type.b[9],
-			     dev->dev_type.b[10],
-			     dev->dev_type.b[11],
-			     dev->dev_type.b[12],
-			     dev->dev_type.b[13],
-			     dev->dev_type.b[14],
-			     dev->dev_type.b[15]);
-
-	if (ret)
-		return ret;
+	int i, ret;
+	char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
 
-	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
-			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
-			     dev->dev_instance.b[3],
-			     dev->dev_instance.b[2],
-			     dev->dev_instance.b[1],
-			     dev->dev_instance.b[0],
-			     dev->dev_instance.b[5],
-			     dev->dev_instance.b[4],
-			     dev->dev_instance.b[7],
-			     dev->dev_instance.b[6],
-			     dev->dev_instance.b[8],
-			     dev->dev_instance.b[9],
-			     dev->dev_instance.b[10],
-			     dev->dev_instance.b[11],
-			     dev->dev_instance.b[12],
-			     dev->dev_instance.b[13],
-			     dev->dev_instance.b[14],
-			     dev->dev_instance.b[15]);
-	if (ret)
-		return ret;
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
+		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
 
-	return 0;
+	ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+	return ret;
 }
 
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Introduce code to handle driver specific id tables to the vmbus core
(vmbus_match). This would allow us to handle more than one device type
with a given driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 7baba62..3a8eb36 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -255,21 +255,32 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	return ret;
 }
 
+static bool is_not_null_guid(const __u8 *guid)
+{
+	int i;
+
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id)); i++)
+		if (guid[i] != 0)
+			return true;
+	return false;
+}
+
 
 /*
  * vmbus_match - Attempt to match the specified device to the specified driver
  */
 static int vmbus_match(struct device *device, struct device_driver *driver)
 {
-	int match = 0;
 	struct hv_driver *drv = drv_to_hv_drv(driver);
 	struct hv_device *hv_dev = device_to_hv_device(device);
+	const struct hv_vmbus_device_id *id_array = drv->id_table;
 
-	/* We found our driver ? */
-	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
-		match = 1;
+	for (; is_not_null_guid(id_array->guid); id_array++)
+		if (!memcmp(&id_array->guid, &hv_dev->dev_type.b,
+				sizeof(struct hv_vmbus_device_id)))
+			return 1;
 
-	return match;
+	return 0;
 }
 
 /*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Introduce code to handle driver specific id tables to the vmbus core
(vmbus_match). This would allow us to handle more than one device type
with a given driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 7baba62..3a8eb36 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -255,21 +255,32 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	return ret;
 }
 
+static bool is_not_null_guid(const __u8 *guid)
+{
+	int i;
+
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id)); i++)
+		if (guid[i] != 0)
+			return true;
+	return false;
+}
+
 
 /*
  * vmbus_match - Attempt to match the specified device to the specified driver
  */
 static int vmbus_match(struct device *device, struct device_driver *driver)
 {
-	int match = 0;
 	struct hv_driver *drv = drv_to_hv_drv(driver);
 	struct hv_device *hv_dev = device_to_hv_device(device);
+	const struct hv_vmbus_device_id *id_array = drv->id_table;
 
-	/* We found our driver ? */
-	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
-		match = 1;
+	for (; is_not_null_guid(id_array->guid); id_array++)
+		if (!memcmp(&id_array->guid, &hv_dev->dev_type.b,
+				sizeof(struct hv_vmbus_device_id)))
+			return 1;
 
-	return match;
+	return 0;
 }
 
 /*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 021/117] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of an unnecessary include line in vmbus_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 3a8eb36..9a0df2c 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 021/117] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of an unnecessary include line in vmbus_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 3a8eb36..9a0df2c 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 022/117] Staging: hv: storvsc: Get rid of the DMI signature
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 65679a0..f594ca4 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/blkdev.h>
-#include <linux/dmi.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -741,27 +740,6 @@ static struct hv_driver storvsc_drv = {
 	.remove = storvsc_remove,
 };
 
-/*
- * We use a DMI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-
-static const struct dmi_system_id __initconst
-hv_stor_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_stor_dmi_table);
-
 static int __init storvsc_drv_init(void)
 {
 	int ret;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 022/117] Staging: hv: storvsc: Get rid of the DMI signature
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 65679a0..f594ca4 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/blkdev.h>
-#include <linux/dmi.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -741,27 +740,6 @@ static struct hv_driver storvsc_drv = {
 	.remove = storvsc_remove,
 };
 
-/*
- * We use a DMI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-
-static const struct dmi_system_id __initconst
-hv_stor_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_stor_dmi_table);
-
 static int __init storvsc_drv_init(void)
 {
 	int ret;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 023/117] Staging: hv: netvsc: Get rid of the PCI signature
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 5847662..9352277 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -34,7 +34,6 @@
 #include <linux/in.h>
 #include <linux/slab.h>
 #include <linux/dmi.h>
-#include <linux/pci.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -480,13 +479,6 @@ static int __init netvsc_drv_init(void)
 	return ret;
 }
 
-static const struct pci_device_id __initconst
-hv_netvsc_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table);
-
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 023/117] Staging: hv: netvsc: Get rid of the PCI signature
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 5847662..9352277 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -34,7 +34,6 @@
 #include <linux/in.h>
 #include <linux/slab.h>
 #include <linux/dmi.h>
-#include <linux/pci.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -480,13 +479,6 @@ static int __init netvsc_drv_init(void)
 	return ret;
 }
 
-static const struct pci_device_id __initconst
-hv_netvsc_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table);
-
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 024/117] Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |   19 -------------------
 1 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 9352277..43be9db 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -33,7 +33,6 @@
 #include <linux/skbuff.h>
 #include <linux/in.h>
 #include <linux/slab.h>
-#include <linux/dmi.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -443,20 +442,6 @@ static void __exit netvsc_drv_exit(void)
 }
 
 
-static const struct dmi_system_id __initconst
-hv_netvsc_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
-
 static int __init netvsc_drv_init(void)
 {
 	struct hv_driver *drv = &netvsc_drv;
@@ -464,10 +449,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	if (!dmi_check_system(hv_netvsc_dmi_table))
-		return -ENODEV;
-
-
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 024/117] Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |   19 -------------------
 1 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 9352277..43be9db 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -33,7 +33,6 @@
 #include <linux/skbuff.h>
 #include <linux/in.h>
 #include <linux/slab.h>
-#include <linux/dmi.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -443,20 +442,6 @@ static void __exit netvsc_drv_exit(void)
 }
 
 
-static const struct dmi_system_id __initconst
-hv_netvsc_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
-
 static int __init netvsc_drv_init(void)
 {
 	struct hv_driver *drv = &netvsc_drv;
@@ -464,10 +449,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	if (!dmi_check_system(hv_netvsc_dmi_table))
-		return -ENODEV;
-
-
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 025/117] Staging: hv: util: Get rid of the DMI signature in hv_util.c
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (23 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 8d327c5..6fabc99 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
-#include <linux/dmi.h>
 #include <linux/pci.h>
 
 #include "hyperv.h"
@@ -279,22 +278,6 @@ hv_utils_pci_table[] __maybe_unused = {
 };
 MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
 
-
-static const struct dmi_system_id __initconst
-hv_utils_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
-
-
 static int __init init_hyperv_utils(void)
 {
 	pr_info("Registering HyperV Utility Driver\n");
@@ -303,9 +286,6 @@ static int __init init_hyperv_utils(void)
 		return -ENODEV;
 
 
-	if (!dmi_check_system(hv_utils_dmi_table))
-		return -ENODEV;
-
 	shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 026/117] Staging: hv: util: Get rid of the PCI signature in hv_util.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 6fabc99..26693dd 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
-#include <linux/pci.h>
 
 #include "hyperv.h"
 #include "hv_kvp.h"
@@ -271,13 +270,6 @@ static  struct hv_driver util_drv = {
 	.remove =  util_remove,
 };
 
-static const struct pci_device_id __initconst
-hv_utils_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
-
 static int __init init_hyperv_utils(void)
 {
 	pr_info("Registering HyperV Utility Driver\n");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 026/117] Staging: hv: util: Get rid of the PCI signature in hv_util.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 6fabc99..26693dd 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
-#include <linux/pci.h>
 
 #include "hyperv.h"
 #include "hv_kvp.h"
@@ -271,13 +270,6 @@ static  struct hv_driver util_drv = {
 	.remove =  util_remove,
 };
 
-static const struct pci_device_id __initconst
-hv_utils_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
-
 static int __init init_hyperv_utils(void)
 {
 	pr_info("Registering HyperV Utility Driver\n");
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 027/117] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the dev_type guid from blkvsc_drv.c as it is no longer used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 8e4c206..cb61598 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -111,14 +111,6 @@ struct block_device_context {
 
 static const char *drv_name = "blkvsc";
 
-/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const uuid_le dev_type = {
-	.b = {
-		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-	}
-};
-
 /*
  * There is a circular dependency involving blkvsc_request_completion()
  * and blkvsc_do_request().
@@ -846,7 +838,6 @@ static int blkvsc_drv_init(void)
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 027/117] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of the dev_type guid from blkvsc_drv.c as it is no longer used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 8e4c206..cb61598 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -111,14 +111,6 @@ struct block_device_context {
 
 static const char *drv_name = "blkvsc";
 
-/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const uuid_le dev_type = {
-	.b = {
-		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-	}
-};
-
 /*
  * There is a circular dependency involving blkvsc_request_completion()
  * and blkvsc_do_request().
@@ -846,7 +838,6 @@ static int blkvsc_drv_init(void)
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 028/117] Staging: hv: storvsc: Get rid of the device type guid from storvsc_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (26 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the device type guid from storvsc_drv.c as it is no longer used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index f594ca4..46cb81a 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -43,14 +43,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
 static const char *driver_name = "storvsc";
 
-/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const uuid_le stor_vsci_device_type = {
-	.b = {
-		0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
-		0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
-	}
-};
-
 struct hv_host_device {
 	struct hv_device *dev;
 	struct kmem_cache *request_pool;
@@ -759,9 +751,6 @@ static int __init storvsc_drv_init(void)
 	sizeof(struct vstor_packet) + sizeof(u64),
 	sizeof(u64)));
 
-	memcpy(&drv->dev_type, &stor_vsci_device_type,
-	       sizeof(uuid_le));
-
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 029/117] Staging: hv: netvsc: Get rid of the dev_type guid from netvsc.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the dev_type guid from netvsc.c, as it is no longer used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 1506b53..6f4541b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -35,15 +35,6 @@
 /* Globals */
 static const char *driver_name = "netvsc";
 
-/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const uuid_le netvsc_device_type = {
-	.b = {
-		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
-		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
-	}
-};
-
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -1009,7 +1000,6 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 029/117] Staging: hv: netvsc: Get rid of the dev_type guid from netvsc.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of the dev_type guid from netvsc.c, as it is no longer used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 1506b53..6f4541b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -35,15 +35,6 @@
 /* Globals */
 static const char *driver_name = "netvsc";
 
-/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const uuid_le netvsc_device_type = {
-	.b = {
-		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
-		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
-	}
-};
-
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -1009,7 +1000,6 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 030/117] Staging: hv: netvsc: Initialize the driver name directly
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Initialize the driver name directly in netvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 43be9db..dd66073 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -41,6 +41,8 @@
 #include "hyperv.h"
 #include "hyperv_net.h"
 
+static const char *driver_name = "netvsc";
+
 struct net_device_context {
 	/* point back to our device context */
 	struct hv_device *device_ctx;
@@ -452,7 +454,7 @@ static int __init netvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
-	drv->driver.name = drv->name;
+	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 030/117] Staging: hv: netvsc: Initialize the driver name directly
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Initialize the driver name directly in netvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 43be9db..dd66073 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -41,6 +41,8 @@
 #include "hyperv.h"
 #include "hyperv_net.h"
 
+static const char *driver_name = "netvsc";
+
 struct net_device_context {
 	/* point back to our device context */
 	struct hv_device *device_ctx;
@@ -452,7 +454,7 @@ static int __init netvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
-	drv->driver.name = drv->name;
+	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 031/117] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now, get rid of the driver name initialization in  int netvsc_initialize().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 6f4541b..d085018 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -32,9 +32,6 @@
 #include "hyperv_net.h"
 
 
-/* Globals */
-static const char *driver_name = "netvsc";
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -999,7 +996,5 @@ cleanup:
 int netvsc_initialize(struct hv_driver *drv)
 {
 
-	drv->name = driver_name;
-
 	return 0;
 }
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 031/117] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now, get rid of the driver name initialization in  int netvsc_initialize().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 6f4541b..d085018 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -32,9 +32,6 @@
 #include "hyperv_net.h"
 
 
-/* Globals */
-static const char *driver_name = "netvsc";
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -999,7 +996,5 @@ cleanup:
 int netvsc_initialize(struct hv_driver *drv)
 {
 
-	drv->name = driver_name;
-
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 032/117] Staging: hv: netvsc: Get rid of the empty function netvsc_initialize()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now, get rid of the empty function netvsc_initialize().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    1 -
 drivers/staging/hv/netvsc.c     |    9 ---------
 drivers/staging/hv/netvsc_drv.c |    3 ---
 3 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 27f987b..5782fea 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -96,7 +96,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
 				unsigned int status);
 int netvsc_recv_callback(struct hv_device *device_obj,
 			struct hv_netvsc_packet *packet);
-int netvsc_initialize(struct hv_driver *drv);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index d085018..cb02eed 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -989,12 +989,3 @@ cleanup:
 
 	return ret;
 }
-
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
-{
-
-	return 0;
-}
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index dd66073..11c03ae 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -451,9 +451,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	/* Callback to client driver to complete the initialization */
-	netvsc_initialize(drv);
-
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 032/117] Staging: hv: netvsc: Get rid of the empty function netvsc_initialize()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now, get rid of the empty function netvsc_initialize().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    1 -
 drivers/staging/hv/netvsc.c     |    9 ---------
 drivers/staging/hv/netvsc_drv.c |    3 ---
 3 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 27f987b..5782fea 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -96,7 +96,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
 				unsigned int status);
 int netvsc_recv_callback(struct hv_device *device_obj,
 			struct hv_netvsc_packet *packet);
-int netvsc_initialize(struct hv_driver *drv);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index d085018..cb02eed 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -989,12 +989,3 @@ cleanup:
 
 	return ret;
 }
-
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
-{
-
-	return 0;
-}
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index dd66073..11c03ae 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -451,9 +451,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	/* Callback to client driver to complete the initialization */
-	netvsc_initialize(drv);
-
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 033/117] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (31 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the unused "name" field in struct hv_driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index b8199f4..60ead66 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -802,8 +802,6 @@ struct hv_device_info {
 
 /* Base driver object */
 struct hv_driver {
-	const char *name;
-
 	/* the device type supported by this driver */
 	uuid_le dev_type;
 	const struct hv_vmbus_device_id *id_table;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 034/117] Staging: hv: mouse: Get rid of the dev_type guid in hv_mouse.c
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (32 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the dev_type guid in hv_mouse.c, as it is not used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 95986fb..e0cede3 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -179,12 +179,6 @@ struct mousevsc_dev {
 
 static const char *driver_name = "mousevsc";
 
-/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const uuid_le mouse_guid = {
-	.b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
-		 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
-};
-
 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
@@ -953,9 +947,6 @@ static int __init mousevsc_init(void)
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
-	memcpy(&drv->dev_type, &mouse_guid,
-	       sizeof(uuid_le));
-
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 035/117] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (33 preceding siblings ...)
  (?)
@ 2011-07-15 17:46   ` K. Y. Srinivasan
  2011-08-23 23:01       ` Greg KH
  -1 siblings, 1 reply; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

To support "human readable" sysfs attribute, introduce a function to map the
dev_type guid to a string.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel_mgmt.c |   36 ++++++++++++++++++++++++++++++++++++
 drivers/staging/hv/hyperv.h       |    2 +-
 2 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 11beb41..926bc87 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -112,6 +112,42 @@ static const uuid_le
 
 };
 
+static const char *blk_dev_type = "hv_block";
+static const char *net_dev_type = "hv_net";
+static const char *scsi_dev_type = "hv_scsi";
+static const char *mouse_dev_type = "hv_mouse";
+static const char *util_dev_type = "hv_util";
+
+/*
+ * Map the dev_type guid to a human readable string.
+ * The indices used in this function are based on
+ * the table defined earlier - supported_device_classes[]
+ */
+const char *hv_get_devtype_name(const uuid_le *type)
+{
+	int i;
+
+	for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
+		if (!memcmp(type, supported_device_classes[i].b,
+				sizeof(uuid_le))) {
+			switch (i) {
+			case 0:
+				return scsi_dev_type;
+			case 1:
+				return net_dev_type;
+			case 2:
+				return mouse_dev_type;
+			case 3:
+				return blk_dev_type;
+			}
+		}
+	}
+	/*
+	 * Currently the util driver is used
+	 * to handle all these devices.
+	 */
+	return util_dev_type;
+}
 
 /**
  * prep_negotiate_resp() - Create default response for Hyper-V Negotiate message
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 60ead66..c4a9f38 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -942,5 +942,5 @@ extern void prep_negotiate_resp(struct icmsg_hdr *,
 				struct icmsg_negotiate *, u8 *);
 extern void chn_cb_negotiate(void *);
 extern struct hyperv_service_callback hv_cb_utils[];
-
+const char *hv_get_devtype_name(const uuid_le *type);
 #endif /* _HYPERV_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 036/117] Staging: hv: vmbus: Make class_id attribute a human readable string
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have a human readable device_type, use that and get rid of the
guid based device type.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 9a0df2c..67415ab 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -113,24 +113,8 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	get_channel_info(hv_dev, &device_info);
 
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_type.b[3],
-			       device_info.chn_type.b[2],
-			       device_info.chn_type.b[1],
-			       device_info.chn_type.b[0],
-			       device_info.chn_type.b[5],
-			       device_info.chn_type.b[4],
-			       device_info.chn_type.b[7],
-			       device_info.chn_type.b[6],
-			       device_info.chn_type.b[8],
-			       device_info.chn_type.b[9],
-			       device_info.chn_type.b[10],
-			       device_info.chn_type.b[11],
-			       device_info.chn_type.b[12],
-			       device_info.chn_type.b[13],
-			       device_info.chn_type.b[14],
-			       device_info.chn_type.b[15]);
+		return sprintf(buf, "%s\n",
+				hv_get_devtype_name(&device_info.chn_type));
 	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 036/117] Staging: hv: vmbus: Make class_id attribute a human readable string
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have a human readable device_type, use that and get rid of the
guid based device type.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 9a0df2c..67415ab 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -113,24 +113,8 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	get_channel_info(hv_dev, &device_info);
 
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_type.b[3],
-			       device_info.chn_type.b[2],
-			       device_info.chn_type.b[1],
-			       device_info.chn_type.b[0],
-			       device_info.chn_type.b[5],
-			       device_info.chn_type.b[4],
-			       device_info.chn_type.b[7],
-			       device_info.chn_type.b[6],
-			       device_info.chn_type.b[8],
-			       device_info.chn_type.b[9],
-			       device_info.chn_type.b[10],
-			       device_info.chn_type.b[11],
-			       device_info.chn_type.b[12],
-			       device_info.chn_type.b[13],
-			       device_info.chn_type.b[14],
-			       device_info.chn_type.b[15]);
+		return sprintf(buf, "%s\n",
+				hv_get_devtype_name(&device_info.chn_type));
 	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
 		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 037/117] Staging: hv: vmbus: Get rid of the  device_id attribute
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The guid based instance data is not very useful. There is enough information
to identify the device. Get rid of this attribute.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 67415ab..1d161ba 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -115,25 +115,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
 		return sprintf(buf, "%s\n",
 				hv_get_devtype_name(&device_info.chn_type));
-	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_instance.b[3],
-			       device_info.chn_instance.b[2],
-			       device_info.chn_instance.b[1],
-			       device_info.chn_instance.b[0],
-			       device_info.chn_instance.b[5],
-			       device_info.chn_instance.b[4],
-			       device_info.chn_instance.b[7],
-			       device_info.chn_instance.b[6],
-			       device_info.chn_instance.b[8],
-			       device_info.chn_instance.b[9],
-			       device_info.chn_instance.b[10],
-			       device_info.chn_instance.b[11],
-			       device_info.chn_instance.b[12],
-			       device_info.chn_instance.b[13],
-			       device_info.chn_instance.b[14],
-			       device_info.chn_instance.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
 		return sprintf(buf, "%d\n", device_info.chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -188,7 +169,6 @@ static struct device_attribute vmbus_device_attrs[] = {
 	__ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
-	__ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
 
 	__ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 037/117] Staging: hv: vmbus: Get rid of the device_id attribute
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

The guid based instance data is not very useful. There is enough information
to identify the device. Get rid of this attribute.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 67415ab..1d161ba 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -115,25 +115,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
 		return sprintf(buf, "%s\n",
 				hv_get_devtype_name(&device_info.chn_type));
-	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_instance.b[3],
-			       device_info.chn_instance.b[2],
-			       device_info.chn_instance.b[1],
-			       device_info.chn_instance.b[0],
-			       device_info.chn_instance.b[5],
-			       device_info.chn_instance.b[4],
-			       device_info.chn_instance.b[7],
-			       device_info.chn_instance.b[6],
-			       device_info.chn_instance.b[8],
-			       device_info.chn_instance.b[9],
-			       device_info.chn_instance.b[10],
-			       device_info.chn_instance.b[11],
-			       device_info.chn_instance.b[12],
-			       device_info.chn_instance.b[13],
-			       device_info.chn_instance.b[14],
-			       device_info.chn_instance.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
 		return sprintf(buf, "%d\n", device_info.chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -188,7 +169,6 @@ static struct device_attribute vmbus_device_attrs[] = {
 	__ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
-	__ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
 
 	__ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 038/117] Staging: hv: vmbus: Get rid of some unnecessary comments
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of some unnecessary comments.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 1d161ba..ffd6066 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -44,8 +44,6 @@ static struct tasklet_struct event_dpc;
 
 unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
 EXPORT_SYMBOL(vmbus_loglevel);
-	/* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
-	/* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
 
 static struct completion probe_event;
 static int irq;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 038/117] Staging: hv: vmbus: Get rid of some unnecessary comments
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of some unnecessary comments.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 1d161ba..ffd6066 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -44,8 +44,6 @@ static struct tasklet_struct event_dpc;
 
 unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
 EXPORT_SYMBOL(vmbus_loglevel);
-	/* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
-	/* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
 
 static struct completion probe_event;
 static int irq;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 039/117] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup unnecessary comments in hv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 824f816..2f94880 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -164,11 +164,7 @@ int hv_init(void)
 		goto cleanup;
 
 	max_leaf = query_hypervisor_info();
-	/* HvQueryHypervisorFeatures(maxLeaf); */
 
-	/*
-	 * We only support running on top of Hyper-V
-	 */
 	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
 	if (hv_context.guestid != 0)
@@ -181,10 +177,6 @@ int hv_init(void)
 	/* See if the hypercall page is already set */
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-	/*
-	* Allocate the hypercall page memory
-	* virtaddr = osd_page_alloc(1);
-	*/
 	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
 	if (!virtaddr)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 039/117] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup unnecessary comments in hv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 824f816..2f94880 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -164,11 +164,7 @@ int hv_init(void)
 		goto cleanup;
 
 	max_leaf = query_hypervisor_info();
-	/* HvQueryHypervisorFeatures(maxLeaf); */
 
-	/*
-	 * We only support running on top of Hyper-V
-	 */
 	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
 	if (hv_context.guestid != 0)
@@ -181,10 +177,6 @@ int hv_init(void)
 	/* See if the hypercall page is already set */
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-	/*
-	* Allocate the hypercall page memory
-	* virtaddr = osd_page_alloc(1);
-	*/
 	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
 	if (!virtaddr)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 040/117] Staging: hv: vmbus: Cleanup error handling in hv_init()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 2f94880..e733173 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -225,8 +225,8 @@ cleanup:
 
 		vfree(virtaddr);
 	}
-	ret = -1;
-	return ret;
+
+	return -ENOTSUPP;
 }
 
 /*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 040/117] Staging: hv: vmbus: Cleanup error handling in hv_init()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 2f94880..e733173 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -225,8 +225,8 @@ cleanup:
 
 		vfree(virtaddr);
 	}
-	ret = -1;
-	return ret;
+
+	return -ENOTSUPP;
 }
 
 /*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 041/117] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of unnecessay comments in connection.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/connection.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index e6b4039..0e7efce 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -215,8 +215,6 @@ static void process_chn_event(u32 relid)
 {
 	struct vmbus_channel *channel;
 
-	/* ASSERT(relId > 0); */
-
 	/*
 	 * Find the channel based on this relid and invokes the
 	 * channel callback to process the event
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 041/117] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of unnecessay comments in connection.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/connection.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index e6b4039..0e7efce 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -215,8 +215,6 @@ static void process_chn_event(u32 relid)
 {
 	struct vmbus_channel *channel;
 
-	/* ASSERT(relId > 0); */
-
 	/*
 	 * Find the channel based on this relid and invokes the
 	 * channel callback to process the event
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 042/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_body()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the function dump_gpadl_body() since it adds no value and actually is
in the data path.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 222adcc..2d5bfac 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -239,24 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-/*
- * dump_gpadl_body - Dump the gpadl body message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
-{
-	int i;
-	int pfncount;
-
-	pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
-		   sizeof(u64);
-
-	DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
-
-	for (i = 0; i < pfncount; i++)
-		DPRINT_DBG(VMBUS, "gpadl body  - %d) pfn %llu",
-			   i, gpadl->pfn[i]);
-}
 
 /*
  * dump_gpadl_header - Dump the gpadl header message to the console for
@@ -485,8 +467,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 				CHANNELMSG_GPADL_BODY;
 			gpadl_body->gpadl = next_gpadl_handle;
 
-			dump_gpadl_body(gpadl_body, submsginfo->msgsize -
-				      sizeof(*submsginfo));
 			ret = vmbus_post_msg(gpadl_body,
 					       submsginfo->msgsize -
 					       sizeof(*submsginfo));
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 042/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_body()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of the function dump_gpadl_body() since it adds no value and actually is
in the data path.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 222adcc..2d5bfac 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -239,24 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-/*
- * dump_gpadl_body - Dump the gpadl body message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
-{
-	int i;
-	int pfncount;
-
-	pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
-		   sizeof(u64);
-
-	DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
-
-	for (i = 0; i < pfncount; i++)
-		DPRINT_DBG(VMBUS, "gpadl body  - %d) pfn %llu",
-			   i, gpadl->pfn[i]);
-}
 
 /*
  * dump_gpadl_header - Dump the gpadl header message to the console for
@@ -485,8 +467,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 				CHANNELMSG_GPADL_BODY;
 			gpadl_body->gpadl = next_gpadl_handle;
 
-			dump_gpadl_body(gpadl_body, submsginfo->msgsize -
-				      sizeof(*submsginfo));
 			ret = vmbus_post_msg(gpadl_body,
 					       submsginfo->msgsize -
 					       sizeof(*submsginfo));
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 043/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_header()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of the function dump_gpadl_header() as this adds no value.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   28 ----------------------------
 1 files changed, 0 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 2d5bfac..aa0a150 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -239,33 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-
-/*
- * dump_gpadl_header - Dump the gpadl header message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
-{
-	int i, j;
-	int pagecount;
-
-	DPRINT_DBG(VMBUS,
-		   "gpadl header - relid %d, range count %d, range buflen %d",
-		   gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
-	for (i = 0; i < gpadl->rangecount; i++) {
-		pagecount = gpadl->range[i].byte_count >> PAGE_SHIFT;
-		pagecount = (pagecount > 26) ? 26 : pagecount;
-
-		DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
-			   "page count %d", i, gpadl->range[i].byte_count,
-			   gpadl->range[i].byte_offset, pagecount);
-
-		for (j = 0; j < pagecount; j++)
-			DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
-				   gpadl->range[i].pfn_array[j]);
-	}
-}
-
 /*
  * create_gpadl_header - Creates a gpadl for the specified buffer
  */
@@ -443,7 +416,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 	gpadlmsg->child_relid = channel->offermsg.child_relid;
 	gpadlmsg->gpadl = next_gpadl_handle;
 
-	dump_gpadl_header(gpadlmsg);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&msginfo->msglistentry,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 043/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_header()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of the function dump_gpadl_header() as this adds no value.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   28 ----------------------------
 1 files changed, 0 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 2d5bfac..aa0a150 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -239,33 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-
-/*
- * dump_gpadl_header - Dump the gpadl header message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
-{
-	int i, j;
-	int pagecount;
-
-	DPRINT_DBG(VMBUS,
-		   "gpadl header - relid %d, range count %d, range buflen %d",
-		   gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
-	for (i = 0; i < gpadl->rangecount; i++) {
-		pagecount = gpadl->range[i].byte_count >> PAGE_SHIFT;
-		pagecount = (pagecount > 26) ? 26 : pagecount;
-
-		DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
-			   "page count %d", i, gpadl->range[i].byte_count,
-			   gpadl->range[i].byte_offset, pagecount);
-
-		for (j = 0; j < pagecount; j++)
-			DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
-				   gpadl->range[i].pfn_array[j]);
-	}
-}
-
 /*
  * create_gpadl_header - Creates a gpadl for the specified buffer
  */
@@ -443,7 +416,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 	gpadlmsg->child_relid = channel->offermsg.child_relid;
 	gpadlmsg->gpadl = next_gpadl_handle;
 
-	dump_gpadl_header(gpadlmsg);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&msginfo->msglistentry,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 044/117] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Rename openMsg to open_msg in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index aa0a150..ebd7552 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
 		     void (*onchannelcallback)(void *context), void *context)
 {
-	struct vmbus_channel_open_channel *openMsg;
+	struct vmbus_channel_open_channel *open_msg;
 	struct vmbus_channel_msginfo *openInfo = NULL;
 	void *in, *out;
 	unsigned long flags;
@@ -183,14 +183,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 	init_completion(&openInfo->waitevent);
 
-	openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
-	openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
-	openMsg->openid = newchannel->offermsg.child_relid;
-	openMsg->child_relid = newchannel->offermsg.child_relid;
-	openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
-	openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
+	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
+	open_msg->openid = newchannel->offermsg.child_relid;
+	open_msg->child_relid = newchannel->offermsg.child_relid;
+	open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
+	open_msg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
 						  PAGE_SHIFT;
-	openMsg->server_contextarea_gpadlhandle = 0;
+	open_msg->server_contextarea_gpadlhandle = 0;
 
 	if (userdatalen > MAX_USER_DEFINED_BYTES) {
 		err = -EINVAL;
@@ -198,14 +198,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	if (userdatalen)
-		memcpy(openMsg->userdata, userdata, userdatalen);
+		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&openInfo->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	ret = vmbus_post_msg(openMsg,
+	ret = vmbus_post_msg(open_msg,
 			       sizeof(struct vmbus_channel_open_channel));
 
 	if (ret != 0)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 044/117] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Rename openMsg to open_msg in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index aa0a150..ebd7552 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
 		     void (*onchannelcallback)(void *context), void *context)
 {
-	struct vmbus_channel_open_channel *openMsg;
+	struct vmbus_channel_open_channel *open_msg;
 	struct vmbus_channel_msginfo *openInfo = NULL;
 	void *in, *out;
 	unsigned long flags;
@@ -183,14 +183,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 	init_completion(&openInfo->waitevent);
 
-	openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
-	openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
-	openMsg->openid = newchannel->offermsg.child_relid;
-	openMsg->child_relid = newchannel->offermsg.child_relid;
-	openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
-	openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
+	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
+	open_msg->openid = newchannel->offermsg.child_relid;
+	open_msg->child_relid = newchannel->offermsg.child_relid;
+	open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
+	open_msg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
 						  PAGE_SHIFT;
-	openMsg->server_contextarea_gpadlhandle = 0;
+	open_msg->server_contextarea_gpadlhandle = 0;
 
 	if (userdatalen > MAX_USER_DEFINED_BYTES) {
 		err = -EINVAL;
@@ -198,14 +198,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	if (userdatalen)
-		memcpy(openMsg->userdata, userdata, userdatalen);
+		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&openInfo->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	ret = vmbus_post_msg(openMsg,
+	ret = vmbus_post_msg(open_msg,
 			       sizeof(struct vmbus_channel_open_channel));
 
 	if (ret != 0)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 045/117] Staging: hv: vmbus: Get rid of unnecessary comments in channel.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of unnecessary comments in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index ebd7552..e02060e 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -76,7 +76,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	struct hv_monitor_page *monitorpage;
 	u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
 	u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
-	/* u32 monitorBit	= 1 << monitorOffset; */
 
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
@@ -392,7 +391,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 {
 	struct vmbus_channel_gpadl_header *gpadlmsg;
 	struct vmbus_channel_gpadl_body *gpadl_body;
-	/* struct vmbus_channel_gpadl_created *gpadlCreated; */
 	struct vmbus_channel_msginfo *msginfo = NULL;
 	struct vmbus_channel_msginfo *submsginfo;
 	u32 msgcount;
@@ -474,8 +472,6 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	unsigned long flags;
 	int ret, t;
 
-	/* ASSERT(gpadl_handle != 0); */
-
 	info = kmalloc(sizeof(*info) +
 		       sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
 	if (!info)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 045/117] Staging: hv: vmbus: Get rid of unnecessary comments in channel.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of unnecessary comments in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index ebd7552..e02060e 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -76,7 +76,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	struct hv_monitor_page *monitorpage;
 	u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
 	u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
-	/* u32 monitorBit	= 1 << monitorOffset; */
 
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
@@ -392,7 +391,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 {
 	struct vmbus_channel_gpadl_header *gpadlmsg;
 	struct vmbus_channel_gpadl_body *gpadl_body;
-	/* struct vmbus_channel_gpadl_created *gpadlCreated; */
 	struct vmbus_channel_msginfo *msginfo = NULL;
 	struct vmbus_channel_msginfo *submsginfo;
 	u32 msgcount;
@@ -474,8 +472,6 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	unsigned long flags;
 	int ret, t;
 
-	/* ASSERT(gpadl_handle != 0); */
-
 	info = kmalloc(sizeof(*info) +
 		       sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
 	if (!info)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 046/117] Staging: hv: vmbus: Change the variable name openInfo to open_info in channel.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the variable name openInfo to open_info in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index e02060e..9eb8def 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     void (*onchannelcallback)(void *context), void *context)
 {
 	struct vmbus_channel_open_channel *open_msg;
-	struct vmbus_channel_msginfo *openInfo = NULL;
+	struct vmbus_channel_msginfo *open_info = NULL;
 	void *in, *out;
 	unsigned long flags;
 	int ret, t, err = 0;
@@ -172,17 +172,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	/* Create and init the channel open message */
-	openInfo = kmalloc(sizeof(*openInfo) +
+	open_info = kmalloc(sizeof(*open_info) +
 			   sizeof(struct vmbus_channel_open_channel),
 			   GFP_KERNEL);
-	if (!openInfo) {
+	if (!open_info) {
 		err = -ENOMEM;
 		goto errorout;
 	}
 
-	init_completion(&openInfo->waitevent);
+	init_completion(&open_info->waitevent);
 
-	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg = (struct vmbus_channel_open_channel *)open_info->msg;
 	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
 	open_msg->openid = newchannel->offermsg.child_relid;
 	open_msg->child_relid = newchannel->offermsg.child_relid;
@@ -200,7 +200,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_add_tail(&openInfo->msglistentry,
+	list_add_tail(&open_info->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
@@ -210,22 +210,22 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	if (ret != 0)
 		goto cleanup;
 
-	t = wait_for_completion_timeout(&openInfo->waitevent, 5*HZ);
+	t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
 	if (t == 0) {
 		err = -ETIMEDOUT;
 		goto errorout;
 	}
 
 
-	if (openInfo->response.open_result.status)
-		err = openInfo->response.open_result.status;
+	if (open_info->response.open_result.status)
+		err = open_info->response.open_result.status;
 
 cleanup:
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_del(&openInfo->msglistentry);
+	list_del(&open_info->msglistentry);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 
 errorout:
@@ -233,7 +233,7 @@ errorout:
 	hv_ringbuffer_cleanup(&newchannel->inbound);
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 046/117] Staging: hv: vmbus: Change the variable name openInfo to open_info in channel.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the variable name openInfo to open_info in channel.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index e02060e..9eb8def 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     void (*onchannelcallback)(void *context), void *context)
 {
 	struct vmbus_channel_open_channel *open_msg;
-	struct vmbus_channel_msginfo *openInfo = NULL;
+	struct vmbus_channel_msginfo *open_info = NULL;
 	void *in, *out;
 	unsigned long flags;
 	int ret, t, err = 0;
@@ -172,17 +172,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	/* Create and init the channel open message */
-	openInfo = kmalloc(sizeof(*openInfo) +
+	open_info = kmalloc(sizeof(*open_info) +
 			   sizeof(struct vmbus_channel_open_channel),
 			   GFP_KERNEL);
-	if (!openInfo) {
+	if (!open_info) {
 		err = -ENOMEM;
 		goto errorout;
 	}
 
-	init_completion(&openInfo->waitevent);
+	init_completion(&open_info->waitevent);
 
-	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg = (struct vmbus_channel_open_channel *)open_info->msg;
 	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
 	open_msg->openid = newchannel->offermsg.child_relid;
 	open_msg->child_relid = newchannel->offermsg.child_relid;
@@ -200,7 +200,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_add_tail(&openInfo->msglistentry,
+	list_add_tail(&open_info->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
@@ -210,22 +210,22 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	if (ret != 0)
 		goto cleanup;
 
-	t = wait_for_completion_timeout(&openInfo->waitevent, 5*HZ);
+	t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
 	if (t == 0) {
 		err = -ETIMEDOUT;
 		goto errorout;
 	}
 
 
-	if (openInfo->response.open_result.status)
-		err = openInfo->response.open_result.status;
+	if (open_info->response.open_result.status)
+		err = open_info->response.open_result.status;
 
 cleanup:
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_del(&openInfo->msglistentry);
+	list_del(&open_info->msglistentry);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 
 errorout:
@@ -233,7 +233,7 @@ errorout:
 	hv_ringbuffer_cleanup(&newchannel->inbound);
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 047/117] Staging: hv: vmbus: Cleanup error values in ringbuffer.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux errno values in ringbuffer.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/netvsc.c      |    2 +-
 drivers/staging/hv/ring_buffer.c |    6 +++---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index cb61598..eab643a 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -726,7 +726,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 		} else {
 			ret = blkvsc_submit_request(blkvsc_req,
 						    blkvsc_request_completion);
-			if (ret == -1) {
+			if (ret == -EAGAIN) {
 				pending = 1;
 				list_add_tail(&blkvsc_req->pend_entry,
 					      &blkdev->pending_list);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index cb02eed..d547ff6 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -565,7 +565,7 @@ retry_send_cmplt:
 	if (ret == 0) {
 		/* success */
 		/* no-op */
-	} else if (ret == -1) {
+	} else if (ret == -EAGAIN) {
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
 		dev_err(&device->device, "unable to send receive completion pkt"
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 42f7672..9212699 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -390,7 +390,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	/* is empty since the read index == write index */
 	if (bytes_avail_towrite <= totalbytes_towrite) {
 		spin_unlock_irqrestore(&outring_info->ring_lock, flags);
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Write to the ring buffer */
@@ -450,7 +450,7 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
 		spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Convert to byte offset */
@@ -496,7 +496,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	if (bytes_avail_toread < buflen) {
 		spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	next_read_location =
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 46cb81a..7efde7c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -580,7 +580,7 @@ retry_request:
 	/* Invokes the vsc to start an IO */
 	ret = storvsc_do_io(dev, &cmd_request->request);
 
-	if (ret == -1) {
+	if (ret == -EAGAIN) {
 		/* no more space */
 
 		if (cmd_request->bounce_sgl_count) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 047/117] Staging: hv: vmbus: Cleanup error values in ringbuffer.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux errno values in ringbuffer.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/netvsc.c      |    2 +-
 drivers/staging/hv/ring_buffer.c |    6 +++---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index cb61598..eab643a 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -726,7 +726,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 		} else {
 			ret = blkvsc_submit_request(blkvsc_req,
 						    blkvsc_request_completion);
-			if (ret == -1) {
+			if (ret == -EAGAIN) {
 				pending = 1;
 				list_add_tail(&blkvsc_req->pend_entry,
 					      &blkdev->pending_list);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index cb02eed..d547ff6 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -565,7 +565,7 @@ retry_send_cmplt:
 	if (ret == 0) {
 		/* success */
 		/* no-op */
-	} else if (ret == -1) {
+	} else if (ret == -EAGAIN) {
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
 		dev_err(&device->device, "unable to send receive completion pkt"
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 42f7672..9212699 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -390,7 +390,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	/* is empty since the read index == write index */
 	if (bytes_avail_towrite <= totalbytes_towrite) {
 		spin_unlock_irqrestore(&outring_info->ring_lock, flags);
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Write to the ring buffer */
@@ -450,7 +450,7 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
 		spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Convert to byte offset */
@@ -496,7 +496,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	if (bytes_avail_toread < buflen) {
 		spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	next_read_location =
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 46cb81a..7efde7c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -580,7 +580,7 @@ retry_request:
 	/* Invokes the vsc to start an IO */
 	ret = storvsc_do_io(dev, &cmd_request->request);
 
-	if (ret == -1) {
+	if (ret == -EAGAIN) {
 		/* no more space */
 
 		if (cmd_request->bounce_sgl_count) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 048/117] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux errno values.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c  |    2 +-
 drivers/staging/hv/hv_mouse.c |    2 +-
 drivers/staging/hv/netvsc.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 9eb8def..ac92c1f 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -811,7 +811,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 		pr_err("Buffer too small - needed %d bytes but "
 			"got space for only %d bytes\n",
 			packetlen, bufferlen);
-		return -2;
+		return -ENOBUFS;
 	}
 
 	*requestid = desc.trans_id;
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index e0cede3..30aa709 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -542,7 +542,7 @@ static void mousevsc_on_channel_callback(void *context)
 				}
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			bufferlen = bytes_recvd;
 			buffer = kzalloc(bytes_recvd, GFP_KERNEL);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index d547ff6..b89ac7e 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -884,7 +884,7 @@ static void netvsc_channel_cb(void *context)
 
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
 			if (buffer == NULL) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 048/117] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux errno values.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c  |    2 +-
 drivers/staging/hv/hv_mouse.c |    2 +-
 drivers/staging/hv/netvsc.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 9eb8def..ac92c1f 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -811,7 +811,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 		pr_err("Buffer too small - needed %d bytes but "
 			"got space for only %d bytes\n",
 			packetlen, bufferlen);
-		return -2;
+		return -ENOBUFS;
 	}
 
 	*requestid = desc.trans_id;
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index e0cede3..30aa709 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -542,7 +542,7 @@ static void mousevsc_on_channel_callback(void *context)
 				}
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			bufferlen = bytes_recvd;
 			buffer = kzalloc(bytes_recvd, GFP_KERNEL);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index d547ff6..b89ac7e 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -884,7 +884,7 @@ static void netvsc_channel_cb(void *context)
 
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
 			if (buffer == NULL) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 049/117] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of an unnecessary print statement in netvsc_probe(). Furthermore,
this fixes a bug since netdev_err is being invoked after the device has
been freed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 11c03ae..542be65 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -357,8 +357,6 @@ static int netvsc_probe(struct hv_device *dev)
 	if (ret != 0) {
 		free_netdev(net);
 		dev_set_drvdata(&dev->device, NULL);
-
-		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
 		return ret;
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 049/117] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of an unnecessary print statement in netvsc_probe(). Furthermore,
this fixes a bug since netdev_err is being invoked after the device has
been freed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 11c03ae..542be65 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -357,8 +357,6 @@ static int netvsc_probe(struct hv_device *dev)
 	if (ret != 0) {
 		free_netdev(net);
 		dev_set_drvdata(&dev->device, NULL);
-
-		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
 		return ret;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 050/117] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The function hv_post_msg() can fail because of transient resource
conditions. It may be useful to retry the operation.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/include/asm/hyperv.h   |    1 +
 drivers/staging/hv/connection.c |   18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/hyperv.h b/arch/x86/include/asm/hyperv.h
index 5df477a..b80420b 100644
--- a/arch/x86/include/asm/hyperv.h
+++ b/arch/x86/include/asm/hyperv.h
@@ -189,5 +189,6 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 #endif
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 0e7efce..a88ad70 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
+#include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
@@ -268,10 +269,25 @@ void vmbus_on_event(unsigned long data)
 int vmbus_post_msg(void *buffer, size_t buflen)
 {
 	union hv_connection_id conn_id;
+	int ret = 0;
+	int retries = 0;
 
 	conn_id.asu32 = 0;
 	conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID;
-	return hv_post_message(conn_id, 1, buffer, buflen);
+
+	/*
+	 * hv_post_message() can have transient failures because of
+	 * insufficient resources. Retry the operation a couple of
+	 * times before giving up.
+	 */
+	while (retries < 3) {
+		ret =  hv_post_message(conn_id, 1, buffer, buflen);
+		if (ret != HV_STATUS_INSUFFICIENT_BUFFERS)
+			return ret;
+		retries++;
+		msleep(100);
+	}
+	return ret;
 }
 
 /*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 050/117] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

The function hv_post_msg() can fail because of transient resource
conditions. It may be useful to retry the operation.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/include/asm/hyperv.h   |    1 +
 drivers/staging/hv/connection.c |   18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/hyperv.h b/arch/x86/include/asm/hyperv.h
index 5df477a..b80420b 100644
--- a/arch/x86/include/asm/hyperv.h
+++ b/arch/x86/include/asm/hyperv.h
@@ -189,5 +189,6 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 #endif
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 0e7efce..a88ad70 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
+#include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
@@ -268,10 +269,25 @@ void vmbus_on_event(unsigned long data)
 int vmbus_post_msg(void *buffer, size_t buflen)
 {
 	union hv_connection_id conn_id;
+	int ret = 0;
+	int retries = 0;
 
 	conn_id.asu32 = 0;
 	conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID;
-	return hv_post_message(conn_id, 1, buffer, buflen);
+
+	/*
+	 * hv_post_message() can have transient failures because of
+	 * insufficient resources. Retry the operation a couple of
+	 * times before giving up.
+	 */
+	while (retries < 3) {
+		ret =  hv_post_message(conn_id, 1, buffer, buflen);
+		if (ret != HV_STATUS_INSUFFICIENT_BUFFERS)
+			return ret;
+		retries++;
+		msleep(100);
+	}
+	return ret;
 }
 
 /*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 051/117] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error values and cleanup error handling. I would like
to acknowledge Andre Bartke (andre.bartke@gmail.com) for highlighting this
problem.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3029786..915aeee 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device,
 
 	device_info = (struct storvsc_device_info *)additional_info;
 	stor_device = alloc_stor_device(device);
-	if (!stor_device) {
-		ret = -1;
-		goto cleanup;
-	}
+	if (!stor_device)
+		return -ENOMEM;
 
 	/* Save the channel properties to our storvsc channel */
 
@@ -409,11 +407,13 @@ int storvsc_dev_add(struct hv_device *device,
 	stor_device->port_number = device_info->port_number;
 	/* Send it back up */
 	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-
+	if (ret) {
+		free_stor_device(stor_device);
+		return ret;
+	}
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
 
-cleanup:
 	return ret;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 051/117] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error values and cleanup error handling. I would like
to acknowledge Andre Bartke (andre.bartke@gmail.com) for highlighting this
problem.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3029786..915aeee 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device,
 
 	device_info = (struct storvsc_device_info *)additional_info;
 	stor_device = alloc_stor_device(device);
-	if (!stor_device) {
-		ret = -1;
-		goto cleanup;
-	}
+	if (!stor_device)
+		return -ENOMEM;
 
 	/* Save the channel properties to our storvsc channel */
 
@@ -409,11 +407,13 @@ int storvsc_dev_add(struct hv_device *device,
 	stor_device->port_number = device_info->port_number;
 	/* Send it back up */
 	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-
+	if (ret) {
+		free_stor_device(stor_device);
+		return ret;
+	}
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
 
-cleanup:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 052/117] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 915aeee..22ac6f2 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -111,7 +111,7 @@ static int storvsc_channel_init(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->init_request;
 	vstor_packet = &request->vstor_packet;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 052/117] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 915aeee..22ac6f2 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -111,7 +111,7 @@ static int storvsc_channel_init(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->init_request;
 	vstor_packet = &request->vstor_packet;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 053/117] Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup error handling in storvsc_connect_to_vsp().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 22ac6f2..2b73f72 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -376,7 +376,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 			 storvsc_on_channel_callback, device);
 
 	if (ret != 0)
-		return -1;
+		return ret;
 
 	ret = storvsc_channel_init(device);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 053/117] Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup error handling in storvsc_connect_to_vsp().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 22ac6f2..2b73f72 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -376,7 +376,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 			 storvsc_on_channel_callback, device);
 
 	if (ret != 0)
-		return -1;
+		return ret;
 
 	ret = storvsc_channel_init(device);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 054/117] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 2b73f72..2b914e4 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -454,7 +454,7 @@ int storvsc_do_io(struct hv_device *device,
 	stor_device = get_stor_device(device);
 
 	if (!stor_device)
-		return -2;
+		return -ENODEV;
 
 
 	request->device  = device;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 054/117] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 2b73f72..2b914e4 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -454,7 +454,7 @@ int storvsc_do_io(struct hv_device *device,
 	stor_device = get_stor_device(device);
 
 	if (!stor_device)
-		return -2;
+		return -ENODEV;
 
 
 	request->device  = device;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 055/117] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of some unnecessary DPRINTs from storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 2b914e4..3730f3f 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -125,8 +125,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
-	DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
-
 	ret = vmbus_sendpacket(device->channel, vstor_packet,
 			       sizeof(struct vstor_packet),
 			       (unsigned long)request,
@@ -145,7 +143,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
 
 	/* reuse the packet for version range supported */
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
@@ -174,8 +171,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	/* Query channel properties */
-	DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
 
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
@@ -207,8 +202,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	stor_device->target_id
 		= vstor_packet->storage_channel_properties.target_id;
 
-	DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
-
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -232,7 +225,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
 
 cleanup:
 	put_stor_device(device);
@@ -305,13 +297,8 @@ static void storvsc_on_receive(struct hv_device *device,
 		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
 	case VSTOR_OPERATION_REMOVE_DEVICE:
-		DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
-		/* TODO: */
-		break;
 
 	default:
-		DPRINT_INFO(STORVSC, "Unknown operation received - %d",
-			    vstor_packet->operation);
 		break;
 	}
 }
@@ -421,9 +408,6 @@ int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
-	DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
-		    device->ext);
-
 	stor_device = release_stor_device(device);
 
 	/*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 055/117] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of some unnecessary DPRINTs from storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 2b914e4..3730f3f 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -125,8 +125,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
-	DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
-
 	ret = vmbus_sendpacket(device->channel, vstor_packet,
 			       sizeof(struct vstor_packet),
 			       (unsigned long)request,
@@ -145,7 +143,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
 
 	/* reuse the packet for version range supported */
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
@@ -174,8 +171,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	/* Query channel properties */
-	DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
 
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
@@ -207,8 +202,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	stor_device->target_id
 		= vstor_packet->storage_channel_properties.target_id;
 
-	DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
-
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -232,7 +225,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
 
 cleanup:
 	put_stor_device(device);
@@ -305,13 +297,8 @@ static void storvsc_on_receive(struct hv_device *device,
 		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
 	case VSTOR_OPERATION_REMOVE_DEVICE:
-		DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
-		/* TODO: */
-		break;
 
 	default:
-		DPRINT_INFO(STORVSC, "Unknown operation received - %d",
-			    vstor_packet->operation);
 		break;
 	}
 }
@@ -421,9 +408,6 @@ int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
-	DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
-		    device->ext);
-
 	stor_device = release_stor_device(device);
 
 	/*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 056/117] Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Fix/cleanup some dated comments in storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3730f3f..827b6a3 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -166,7 +166,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -193,7 +192,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -384,11 +382,12 @@ int storvsc_dev_add(struct hv_device *device,
 
 	/* Save the channel properties to our storvsc channel */
 
-	/* FIXME: */
 	/*
 	 * If we support more than 1 scsi channel, we need to set the
 	 * port number here to the scsi channel but how do we get the
-	 * scsi channel prior to the bus scan
+	 * scsi channel prior to the bus scan.
+	 *
+	 * The host does not support this.
 	 */
 
 	stor_device->port_number = device_info->port_number;
@@ -545,4 +544,3 @@ int storvsc_get_major_info(struct storvsc_device_info *device_info,
 
 	return -ENODEV;
 }
-
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 056/117] Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Fix/cleanup some dated comments in storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3730f3f..827b6a3 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -166,7 +166,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -193,7 +192,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -384,11 +382,12 @@ int storvsc_dev_add(struct hv_device *device,
 
 	/* Save the channel properties to our storvsc channel */
 
-	/* FIXME: */
 	/*
 	 * If we support more than 1 scsi channel, we need to set the
 	 * port number here to the scsi channel but how do we get the
-	 * scsi channel prior to the bus scan
+	 * scsi channel prior to the bus scan.
+	 *
+	 * The host does not support this.
 	 */
 
 	stor_device->port_number = device_info->port_number;
@@ -545,4 +544,3 @@ int storvsc_get_major_info(struct storvsc_device_info *device_info,
 
 	return -ENODEV;
 }
-
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 057/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 7efde7c..f85ebb0 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -348,7 +348,7 @@ static int storvsc_host_reset(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->reset_request;
 	vstor_packet = &request->vstor_packet;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 057/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 7efde7c..f85ebb0 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -348,7 +348,7 @@ static int storvsc_host_reset(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->reset_request;
 	vstor_packet = &request->vstor_packet;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 058/117] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index f85ebb0..9640630 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -696,7 +696,7 @@ static int storvsc_probe(struct hv_device *device)
 	if (ret != 0) {
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	host_dev->path = device_info.path_id;
@@ -717,7 +717,7 @@ static int storvsc_probe(struct hv_device *device)
 
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	scsi_scan_host(host);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 058/117] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index f85ebb0..9640630 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -696,7 +696,7 @@ static int storvsc_probe(struct hv_device *device)
 	if (ret != 0) {
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	host_dev->path = device_info.path_id;
@@ -717,7 +717,7 @@ static int storvsc_probe(struct hv_device *device)
 
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	scsi_scan_host(host);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 059/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 9640630..bc71024 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -753,7 +753,7 @@ static int __init storvsc_drv_init(void)
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
-		return -1;
+		return -EINVAL;
 
 	drv->driver.name = driver_name;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 059/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 9640630..bc71024 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -753,7 +753,7 @@ static int __init storvsc_drv_init(void)
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
-		return -1;
+		return -EINVAL;
 
 	drv->driver.name = driver_name;
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 060/117] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 542be65..94c5abc 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -340,7 +340,7 @@ static int netvsc_probe(struct hv_device *dev)
 
 	net = alloc_etherdev(sizeof(struct net_device_context));
 	if (!net)
-		return -1;
+		return -ENOMEM;
 
 	/* Set initial state */
 	netif_carrier_off(net);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 060/117] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 542be65..94c5abc 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -340,7 +340,7 @@ static int netvsc_probe(struct hv_device *dev)
 
 	net = alloc_etherdev(sizeof(struct net_device_context));
 	if (!net)
-		return -1;
+		return -ENOMEM;
 
 	/* Set initial state */
 	netif_carrier_off(net);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 061/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup error return codes in netvsc_destroy_recv_buf().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b89ac7e..baa0c8d 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -160,7 +160,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device, "unable to send "
 				"revoke receive buffer to netvsp");
-			return -1;
+			return ret;
 		}
 	}
 
@@ -175,7 +175,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device,
 				   "unable to teardown receive buffer's gpadl");
-			return -1;
+			return -ret;
 		}
 		net_device->recv_buf_gpadl_handle = 0;
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 061/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup error return codes in netvsc_destroy_recv_buf().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b89ac7e..baa0c8d 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -160,7 +160,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device, "unable to send "
 				"revoke receive buffer to netvsp");
-			return -1;
+			return ret;
 		}
 	}
 
@@ -175,7 +175,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device,
 				   "unable to teardown receive buffer's gpadl");
-			return -1;
+			return -ret;
 		}
 		net_device->recv_buf_gpadl_handle = 0;
 	}
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 062/117] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index baa0c8d..5703fd7 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -207,7 +207,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	net_device->recv_buf =
@@ -216,7 +216,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device->recv_buf) {
 		dev_err(&device->device, "unable to allocate receive "
 			"buffer of size %d", net_device->recv_buf_size);
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -269,7 +269,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			   "initialzation with NetVsp - status %d",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -281,7 +281,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	net_device->recv_section = kmalloc(net_device->recv_section_cnt
 		* sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL);
 	if (net_device->recv_section == NULL) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -297,7 +297,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	 */
 	if (net_device->recv_section_cnt != 1 ||
 	    net_device->recv_section->offset != 0) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 062/117] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index baa0c8d..5703fd7 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -207,7 +207,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	net_device->recv_buf =
@@ -216,7 +216,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device->recv_buf) {
 		dev_err(&device->device, "unable to allocate receive "
 			"buffer of size %d", net_device->recv_buf_size);
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -269,7 +269,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			   "initialzation with NetVsp - status %d",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -281,7 +281,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	net_device->recv_section = kmalloc(net_device->recv_section_cnt
 		* sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL);
 	if (net_device->recv_section == NULL) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -297,7 +297,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	 */
 	if (net_device->recv_section_cnt != 1 ||
 	    net_device->recv_section->offset != 0) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 063/117] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 5703fd7..9cc126b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -323,7 +323,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	init_packet = &net_device->channel_init_pkt;
@@ -354,13 +354,13 @@ static int netvsc_connect_vsp(struct hv_device *device)
 
 	if (init_packet->msg.init_msg.init_complete.status !=
 	    NVSP_STAT_SUCCESS) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
 	if (init_packet->msg.init_msg.init_complete.
 	    negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
-		ret = -1;
+		ret = -EPROTO;
 		goto cleanup;
 	}
 	/* Send the ndis version */
@@ -381,10 +381,8 @@ static int netvsc_connect_vsp(struct hv_device *device)
 				sizeof(struct nvsp_message),
 				(unsigned long)init_packet,
 				VM_PKT_DATA_INBAND, 0);
-	if (ret != 0) {
-		ret = -1;
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	/* Post the big receive buffer to NetVSP */
 	ret = netvsc_init_recv_buf(device);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 063/117] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 5703fd7..9cc126b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -323,7 +323,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	init_packet = &net_device->channel_init_pkt;
@@ -354,13 +354,13 @@ static int netvsc_connect_vsp(struct hv_device *device)
 
 	if (init_packet->msg.init_msg.init_complete.status !=
 	    NVSP_STAT_SUCCESS) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
 	if (init_packet->msg.init_msg.init_complete.
 	    negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
-		ret = -1;
+		ret = -EPROTO;
 		goto cleanup;
 	}
 	/* Send the ndis version */
@@ -381,10 +381,8 @@ static int netvsc_connect_vsp(struct hv_device *device)
 				sizeof(struct nvsp_message),
 				(unsigned long)init_packet,
 				VM_PKT_DATA_INBAND, 0);
-	if (ret != 0) {
-		ret = -1;
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	/* Post the big receive buffer to NetVSP */
 	ret = netvsc_init_recv_buf(device);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 064/117] Staging: hv: netvsc: Cleanup error return values in netvsc_send()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 9cc126b..f7f4957 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -409,7 +409,7 @@ int netvsc_device_remove(struct hv_device *device)
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "No net device present!!");
-		return -1;
+		return -ENODEV;
 	}
 
 	/* Wait for all send completions */
@@ -499,7 +499,7 @@ int netvsc_send(struct hv_device *device,
 	if (!net_device) {
 		dev_err(&device->device, "net device (%p) shutting down..."
 			   "ignoring outbound packets", net_device);
-		return -2;
+		return -ENODEV;
 	}
 
 	sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 064/117] Staging: hv: netvsc: Cleanup error return values in netvsc_send()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 9cc126b..f7f4957 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -409,7 +409,7 @@ int netvsc_device_remove(struct hv_device *device)
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "No net device present!!");
-		return -1;
+		return -ENODEV;
 	}
 
 	/* Wait for all send completions */
@@ -499,7 +499,7 @@ int netvsc_send(struct hv_device *device,
 	if (!net_device) {
 		dev_err(&device->device, "net device (%p) shutting down..."
 			   "ignoring outbound packets", net_device);
-		return -2;
+		return -ENODEV;
 	}
 
 	sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 065/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index f7f4957..b6e1fb9 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -918,7 +918,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	net_device = alloc_net_device(device);
 	if (!net_device) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -947,7 +947,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	if (ret != 0) {
 		dev_err(&device->device, "unable to open channel: %d", ret);
-		ret = -1;
 		goto cleanup;
 	}
 
@@ -959,7 +958,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	if (ret != 0) {
 		dev_err(&device->device,
 			"unable to connect to NetVSP - %d", ret);
-		ret = -1;
 		goto close;
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 065/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index f7f4957..b6e1fb9 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -918,7 +918,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	net_device = alloc_net_device(device);
 	if (!net_device) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -947,7 +947,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	if (ret != 0) {
 		dev_err(&device->device, "unable to open channel: %d", ret);
-		ret = -1;
 		goto cleanup;
 	}
 
@@ -959,7 +958,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	if (ret != 0) {
 		dev_err(&device->device,
 			"unable to connect to NetVSP - %d", ret);
-		ret = -1;
 		goto close;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 066/117] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index dbb5201..8e1ef00 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -358,14 +358,14 @@ int rndis_filter_receive(struct hv_device *dev,
 	if (!net_dev->extension) {
 		dev_err(&dev->device, "got rndis message but no rndis device - "
 			  "dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
 		dev_err(&dev->device, "got rndis message but rndis device "
 			   "uninitialized...dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_hdr = (struct rndis_message *)kmap_atomic(
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 066/117] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index dbb5201..8e1ef00 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -358,14 +358,14 @@ int rndis_filter_receive(struct hv_device *dev,
 	if (!net_dev->extension) {
 		dev_err(&dev->device, "got rndis message but no rndis device - "
 			  "dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
 		dev_err(&dev->device, "got rndis message but rndis device "
 			   "uninitialized...dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_hdr = (struct rndis_message *)kmap_atomic(
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 067/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 8e1ef00..f26886d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -437,7 +437,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 067/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 8e1ef00..f26886d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -437,7 +437,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 068/117] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes and cleanup some error paths.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f26886d..f5f3052 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -511,7 +511,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
 			sizeof(u32));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -531,7 +531,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
 	if (t == 0) {
-		ret = -1;
 		dev_err(&dev->net_dev->dev->device,
 			"timeout before we got a set response...\n");
 		/*
@@ -540,8 +539,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 */
 		goto Exit;
 	} else {
-		if (ret > 0)
-			ret = 0;
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 068/117] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes and cleanup some error paths.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f26886d..f5f3052 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -511,7 +511,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
 			sizeof(u32));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -531,7 +531,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
 	if (t == 0) {
-		ret = -1;
 		dev_err(&dev->net_dev->dev->device,
 			"timeout before we got a set response...\n");
 		/*
@@ -540,8 +539,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 */
 		goto Exit;
 	} else {
-		if (ret > 0)
-			ret = 0;
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
 	}
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 069/117] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f5f3052..a71f29d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -562,7 +562,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -596,7 +596,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = 0;
 	} else {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 Cleanup:
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 069/117] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f5f3052..a71f29d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -562,7 +562,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -596,7 +596,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = 0;
 	} else {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 Cleanup:
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 070/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index a71f29d..f0d1362 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -673,7 +673,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndisDevice = get_rndis_device();
 	if (!rndisDevice)
-		return -1;
+		return -ENODEV;
 
 	/*
 	 * Let the inner driver handle this first to create the netvsc channel
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 070/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add()
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index a71f29d..f0d1362 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -673,7 +673,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndisDevice = get_rndis_device();
 	if (!rndisDevice)
-		return -1;
+		return -ENODEV;
 
 	/*
 	 * Let the inner driver handle this first to create the netvsc channel
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 071/117] Staging: hv: mouse: Change the jump label Cleanup to cleanup
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 30aa709..1c17658 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -339,7 +339,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	if (!input_device->hid_desc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
@@ -352,7 +352,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (!input_device->report_desc) {
 		pr_err("unable to allocate report descriptor - size %d",
 			   input_device->report_desc_size);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->report_desc,
@@ -379,7 +379,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (ret != 0) {
 		pr_err("unable to send synthhid device info ack - ret %d",
 			   ret);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_device->device_wait_condition = 1;
@@ -387,7 +387,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	return;
 
-Cleanup:
+cleanup:
 	kfree(input_device->hid_desc);
 	input_device->hid_desc = NULL;
 
@@ -606,7 +606,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 					VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
 		pr_err("unable to send synthhid protocol request.");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->protocol_wait_condition = 0;
@@ -614,7 +614,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	response = &input_dev->protocol_resp;
@@ -623,7 +623,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		pr_err("synthhid protocol request failed (version %d)",
 		       SYNTHHID_INPUT_VERSION);
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->device_wait_condition = 0;
@@ -631,7 +631,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->device_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/*
@@ -643,7 +643,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	else
 		ret = -1;
 
-Cleanup:
+cleanup:
 	put_input_device(device);
 
 	return ret;
@@ -661,7 +661,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	if (!input_dev) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->init_complete = false;
@@ -714,7 +714,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev->init_complete = true;
 
-Cleanup:
+cleanup:
 	return ret;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 071/117] Staging: hv: mouse: Change the jump label Cleanup to cleanup
@ 2011-07-15 17:46     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:46 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 30aa709..1c17658 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -339,7 +339,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	if (!input_device->hid_desc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
@@ -352,7 +352,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (!input_device->report_desc) {
 		pr_err("unable to allocate report descriptor - size %d",
 			   input_device->report_desc_size);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->report_desc,
@@ -379,7 +379,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (ret != 0) {
 		pr_err("unable to send synthhid device info ack - ret %d",
 			   ret);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_device->device_wait_condition = 1;
@@ -387,7 +387,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	return;
 
-Cleanup:
+cleanup:
 	kfree(input_device->hid_desc);
 	input_device->hid_desc = NULL;
 
@@ -606,7 +606,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 					VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
 		pr_err("unable to send synthhid protocol request.");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->protocol_wait_condition = 0;
@@ -614,7 +614,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	response = &input_dev->protocol_resp;
@@ -623,7 +623,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		pr_err("synthhid protocol request failed (version %d)",
 		       SYNTHHID_INPUT_VERSION);
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->device_wait_condition = 0;
@@ -631,7 +631,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->device_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/*
@@ -643,7 +643,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	else
 		ret = -1;
 
-Cleanup:
+cleanup:
 	put_input_device(device);
 
 	return ret;
@@ -661,7 +661,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	if (!input_dev) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->init_complete = false;
@@ -714,7 +714,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev->init_complete = true;
 
-Cleanup:
+cleanup:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 072/117] Staging: hv: mouse: Get rid of  the unused  PCI signature
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of  the unused  PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 1c17658..6e1c4ce 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -22,8 +22,6 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
 #include <linux/delay.h>
 
 #include "hyperv.h"
@@ -960,25 +958,6 @@ static void __exit mousevsc_exit(void)
 	mousevsc_drv_exit();
 }
 
-/*
- * We don't want to automatically load this driver just yet, it's quite
- * broken.  It's safe if you want to load it yourself manually, but
- * don't inflict it on unsuspecting users, that's just mean.
- */
-#if 0
-
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-const static struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-#endif
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 072/117] Staging: hv: mouse: Get rid of the unused PCI signature
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of  the unused  PCI signature.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 1c17658..6e1c4ce 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -22,8 +22,6 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
 #include <linux/delay.h>
 
 #include "hyperv.h"
@@ -960,25 +958,6 @@ static void __exit mousevsc_exit(void)
 	mousevsc_drv_exit();
 }
 
-/*
- * We don't want to automatically load this driver just yet, it's quite
- * broken.  It's safe if you want to load it yourself manually, but
- * don't inflict it on unsuspecting users, that's just mean.
- */
-#if 0
-
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-const static struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-#endif
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 073/117] Staging: hv: netvsc: Change the jump label Cleanup to cleanup
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f0d1362..79dfe78 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -438,7 +438,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis query */
@@ -450,12 +450,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Copy the response back */
@@ -463,7 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	if (query_complete->info_buflen > inresult_size) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(result,
@@ -473,7 +473,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	*result_size = query_complete->info_buflen;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -512,7 +512,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			sizeof(u32));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -526,7 +526,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
@@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		status = set_complete->status;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 Exit:
@@ -563,7 +563,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -578,7 +578,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0) {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 
@@ -586,7 +586,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	init_complete = &request->response_msg.msg.init_complete;
@@ -599,7 +599,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = -EINVAL;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -615,7 +615,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG,
 				RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
 	if (!request)
-		goto Cleanup;
+		goto cleanup;
 
 	/* Setup the rndis set */
 	halt = &request->request_msg.msg.halt_req;
@@ -626,7 +626,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 
 	dev->state = RNDIS_DEV_UNINITIALIZED;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 	return;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 073/117] Staging: hv: netvsc: Change the jump label Cleanup to cleanup
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f0d1362..79dfe78 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -438,7 +438,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis query */
@@ -450,12 +450,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Copy the response back */
@@ -463,7 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	if (query_complete->info_buflen > inresult_size) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(result,
@@ -473,7 +473,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	*result_size = query_complete->info_buflen;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -512,7 +512,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			sizeof(u32));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -526,7 +526,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
@@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		status = set_complete->status;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 Exit:
@@ -563,7 +563,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -578,7 +578,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0) {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 
@@ -586,7 +586,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	init_complete = &request->response_msg.msg.init_complete;
@@ -599,7 +599,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = -EINVAL;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -615,7 +615,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG,
 				RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
 	if (!request)
-		goto Cleanup;
+		goto cleanup;
 
 	/* Setup the rndis set */
 	halt = &request->request_msg.msg.halt_req;
@@ -626,7 +626,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 
 	dev->state = RNDIS_DEV_UNINITIALIZED;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 	return;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 074/117] Staging: hv: netvsc: Change the jump label Exit to exit
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the jump lable "Exit" to "exit".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 79dfe78..6db48b9 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -537,7 +537,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 * We can't deallocate the request since we may still receive a
 		 * send completion for it.
 		 */
-		goto Exit;
+		goto exit;
 	} else {
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
@@ -546,7 +546,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 cleanup:
 	if (request)
 		put_rndis_request(dev, request);
-Exit:
+exit:
 	return ret;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 074/117] Staging: hv: netvsc: Change the jump label Exit to exit
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the jump lable "Exit" to "exit".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 79dfe78..6db48b9 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -537,7 +537,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 * We can't deallocate the request since we may still receive a
 		 * send completion for it.
 		 */
-		goto Exit;
+		goto exit;
 	} else {
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
@@ -546,7 +546,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 cleanup:
 	if (request)
 		put_rndis_request(dev, request);
-Exit:
+exit:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 075/117] Staging: hv: storvsc: Inline free_stor_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Inline the code for  free_stor_device() and get rid of the function.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 827b6a3..8c62829 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -51,10 +51,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	return stor_device;
 }
 
-static inline void free_stor_device(struct storvsc_device *device)
-{
-	kfree(device);
-}
 
 /* Get the stordevice object iff exists and its refcount > 0 */
 static inline struct storvsc_device *must_get_stor_device(
@@ -394,7 +390,7 @@ int storvsc_dev_add(struct hv_device *device,
 	/* Send it back up */
 	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
 	if (ret) {
-		free_stor_device(stor_device);
+		kfree(stor_device);
 		return ret;
 	}
 	device_info->path_id = stor_device->path_id;
@@ -422,7 +418,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	/* Close the channel */
 	vmbus_close(device->channel);
 
-	free_stor_device(stor_device);
+	kfree(stor_device);
 	return 0;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 075/117] Staging: hv: storvsc: Inline free_stor_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Inline the code for  free_stor_device() and get rid of the function.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 827b6a3..8c62829 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -51,10 +51,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	return stor_device;
 }
 
-static inline void free_stor_device(struct storvsc_device *device)
-{
-	kfree(device);
-}
 
 /* Get the stordevice object iff exists and its refcount > 0 */
 static inline struct storvsc_device *must_get_stor_device(
@@ -394,7 +390,7 @@ int storvsc_dev_add(struct hv_device *device,
 	/* Send it back up */
 	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
 	if (ret) {
-		free_stor_device(stor_device);
+		kfree(stor_device);
 		return ret;
 	}
 	device_info->path_id = stor_device->path_id;
@@ -422,7 +418,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	/* Close the channel */
 	vmbus_close(device->channel);
 
-	free_stor_device(stor_device);
+	kfree(stor_device);
 	return 0;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 0000/0117] Staging: hv: Driver cleanup
@ 2011-07-15 17:47 K. Y. Srinivasan
  2011-07-15 17:45   ` K. Y. Srinivasan
                   ` (2 more replies)
  0 siblings, 3 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: K. Y. Srinivasan

Further cleanup of the hv drivers. Back in June I had sent two patch
sets to address these issues. I have addressed the comments I got from
the community on my earlier patches here:

	1) Implement code for autoloading the vmbus drivers without using PCI or DMI
	   signatures. I have implemented this based on Greg's feedback on my earlier
	   implementation.

	2) Cleanup error handling across the board and use standard Linux error codes.

	3) General cleanup

	4) Some bug fixes.

	5) Cleanup the reference counting mess for both stor and net devices.

	6) Handle all block devices using the storvsc driver. I have modified
	   the implementation here based on Christoph's feedback on my earlier
	   implementation.

	7) Accomodate some host side scsi emulation bugs.

	8) In case of scsi errors off-line the device.

This patch-set further reduces the size of Hyper-V drivers - the code is
about 10% smaller. This reduction is mainly because we have eliminated the
blkvsc driver.
	  

Regards,

K. Y 



^ permalink raw reply	[flat|nested] 294+ messages in thread

* [PATCH 076/117] Staging: hv: storvsc: Do not aquire an unnecessary reference on stor_device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

On entry into storvsc_on_io_completion() we have already acquired a reference
on the stor_device; there is no need to acquire an additional reference here.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 8c62829..cd38cd6 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -232,9 +232,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	struct storvsc_device *stor_device;
 	struct vstor_packet *stor_pkt;
 
-	stor_device = must_get_stor_device(device);
-	if (!stor_device)
-		return;
+	stor_device = (struct storvsc_device *)device->ext;
 
 	stor_pkt = &request->vstor_packet;
 
@@ -279,7 +277,6 @@ static void storvsc_on_io_completion(struct hv_device *device,
 		wake_up(&stor_device->waiting_to_drain);
 
 
-	put_stor_device(device);
 }
 
 static void storvsc_on_receive(struct hv_device *device,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 076/117] Staging: hv: storvsc: Do not aquire an unnecessary reference on stor_device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

On entry into storvsc_on_io_completion() we have already acquired a reference
on the stor_device; there is no need to acquire an additional reference here.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 8c62829..cd38cd6 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -232,9 +232,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	struct storvsc_device *stor_device;
 	struct vstor_packet *stor_pkt;
 
-	stor_device = must_get_stor_device(device);
-	if (!stor_device)
-		return;
+	stor_device = (struct storvsc_device *)device->ext;
 
 	stor_pkt = &request->vstor_packet;
 
@@ -279,7 +277,6 @@ static void storvsc_on_io_completion(struct hv_device *device,
 		wake_up(&stor_device->waiting_to_drain);
 
 
-	put_stor_device(device);
 }
 
 static void storvsc_on_receive(struct hv_device *device,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 077/117] Staging: hv: storvsc: Rename must_get_stor_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index cd38cd6..89708b1 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_stor_device() and must_get_stor_device()) to proceed. */
+	/* (ie get_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
@@ -53,7 +53,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 
 /* Get the stordevice object iff exists and its refcount > 0 */
-static inline struct storvsc_device *must_get_stor_device(
+static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -305,7 +305,7 @@ static void storvsc_on_channel_callback(void *context)
 	int ret;
 
 
-	stor_device = must_get_stor_device(device);
+	stor_device = get_in_stor_device(device);
 	if (!stor_device)
 		return;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 077/117] Staging: hv: storvsc: Rename must_get_stor_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index cd38cd6..89708b1 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_stor_device() and must_get_stor_device()) to proceed. */
+	/* (ie get_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
@@ -53,7 +53,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 
 /* Get the stordevice object iff exists and its refcount > 0 */
-static inline struct storvsc_device *must_get_stor_device(
+static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -305,7 +305,7 @@ static void storvsc_on_channel_callback(void *context)
 	int ret;
 
 
-	stor_device = must_get_stor_device(device);
+	stor_device = get_in_stor_device(device);
 	if (!stor_device)
 		return;
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 078/117] Staging: hv: storvsc: Rename get_stor_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 ++-
 drivers/staging/hv/storvsc.c        |    8 ++++----
 drivers/staging/hv/storvsc_drv.c    |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index a01f9a0..a224413 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -288,7 +288,8 @@ struct storvsc_device {
 
 
 /* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *get_stor_device(struct hv_device *device)
+static inline struct storvsc_device *get_out_stor_device(
+					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 89708b1..313a3f8 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_stor_device() and get_in_stor_device()) to proceed. */
+	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
@@ -67,7 +67,7 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 1 to effectively disable get_stor_device() */
+/* Drop ref count to 1 to effectively disable get_out_stor_device() */
 static inline struct storvsc_device *release_stor_device(
 					struct hv_device *device)
 {
@@ -105,7 +105,7 @@ static int storvsc_channel_init(struct hv_device *device)
 	struct vstor_packet *vstor_packet;
 	int ret, t;
 
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 	if (!stor_device)
 		return -ENODEV;
 
@@ -427,7 +427,7 @@ int storvsc_do_io(struct hv_device *device,
 	int ret = 0;
 
 	vstor_packet = &request->vstor_packet;
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 
 	if (!stor_device)
 		return -ENODEV;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index bc71024..0f2fc2f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -346,7 +346,7 @@ static int storvsc_host_reset(struct hv_device *device)
 	int ret, t;
 
 
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 	if (!stor_device)
 		return -ENODEV;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 078/117] Staging: hv: storvsc: Rename get_stor_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 ++-
 drivers/staging/hv/storvsc.c        |    8 ++++----
 drivers/staging/hv/storvsc_drv.c    |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index a01f9a0..a224413 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -288,7 +288,8 @@ struct storvsc_device {
 
 
 /* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *get_stor_device(struct hv_device *device)
+static inline struct storvsc_device *get_out_stor_device(
+					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 89708b1..313a3f8 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -41,7 +41,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_stor_device() and get_in_stor_device()) to proceed. */
+	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
@@ -67,7 +67,7 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 1 to effectively disable get_stor_device() */
+/* Drop ref count to 1 to effectively disable get_out_stor_device() */
 static inline struct storvsc_device *release_stor_device(
 					struct hv_device *device)
 {
@@ -105,7 +105,7 @@ static int storvsc_channel_init(struct hv_device *device)
 	struct vstor_packet *vstor_packet;
 	int ret, t;
 
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 	if (!stor_device)
 		return -ENODEV;
 
@@ -427,7 +427,7 @@ int storvsc_do_io(struct hv_device *device,
 	int ret = 0;
 
 	vstor_packet = &request->vstor_packet;
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 
 	if (!stor_device)
 		return -ENODEV;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index bc71024..0f2fc2f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -346,7 +346,7 @@ static int storvsc_host_reset(struct hv_device *device)
 	int ret, t;
 
 
-	stor_device = get_stor_device(device);
+	stor_device = get_out_stor_device(device);
 	if (!stor_device)
 		return -ENODEV;
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 079/117] Staging: hv: storvsc: Cleanup alloc_stor_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup alloc_stor_device(), we can set the ref_count directly.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 313a3f8..48bd8da 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -42,7 +42,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
+	atomic_set(&stor_device->ref_count, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 079/117] Staging: hv: storvsc: Cleanup alloc_stor_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup alloc_stor_device(), we can set the ref_count directly.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 313a3f8..48bd8da 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -42,7 +42,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
+	atomic_set(&stor_device->ref_count, 2);
 
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 080/117] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Introduce state to manage the lifecycle of stor device. This would be the
basis for managing the references on the stor object.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    2 +-
 drivers/staging/hv/storvsc.c        |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index a224413..d93bf93 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -266,7 +266,7 @@ struct storvsc_device {
 
 	/* 0 indicates the device is being destroyed */
 	atomic_t ref_count;
-
+	bool	 destroy;
 	bool	 drain_notify;
 	atomic_t num_outstanding_req;
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 48bd8da..357b08a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_set(&stor_device->ref_count, 2);
-
+	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
 	device->ext = stor_device;
@@ -401,6 +401,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	struct storvsc_device *stor_device;
 
 	stor_device = release_stor_device(device);
+	stor_device->destroy = true;
 
 	/*
 	 * At this point, all outbound traffic should be disable. We
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 080/117] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Introduce state to manage the lifecycle of stor device. This would be the
basis for managing the references on the stor object.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    2 +-
 drivers/staging/hv/storvsc.c        |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index a224413..d93bf93 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -266,7 +266,7 @@ struct storvsc_device {
 
 	/* 0 indicates the device is being destroyed */
 	atomic_t ref_count;
-
+	bool	 destroy;
 	bool	 drain_notify;
 	atomic_t num_outstanding_req;
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 48bd8da..357b08a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
 	atomic_set(&stor_device->ref_count, 2);
-
+	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
 	device->ext = stor_device;
@@ -401,6 +401,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	struct storvsc_device *stor_device;
 
 	stor_device = release_stor_device(device);
+	stor_device->destroy = true;
 
 	/*
 	 * At this point, all outbound traffic should be disable. We
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The current mechanism for handling references in broken.
Introduce a lock to protect the ext field in hv_device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h    |    3 +++
 drivers/staging/hv/vmbus_drv.c |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index c4a9f38..82ba110 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -826,6 +826,9 @@ struct hv_device {
 
 	struct vmbus_channel *channel;
 
+	/* This lock protects the device extension field */
+	spinlock_t ext_lock;
+
 	/* Device extension; */
 	void *ext;
 };
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index ffd6066..29c1712 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -578,6 +578,7 @@ struct hv_device *vmbus_child_device_create(uuid_le *type,
 		return NULL;
 	}
 
+	spin_lock_init(&child_device_obj->ext_lock);
 	child_device_obj->channel = channel;
 	memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
 	memcpy(&child_device_obj->dev_instance, instance,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

The current mechanism for handling references in broken.
Introduce a lock to protect the ext field in hv_device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h    |    3 +++
 drivers/staging/hv/vmbus_drv.c |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index c4a9f38..82ba110 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -826,6 +826,9 @@ struct hv_device {
 
 	struct vmbus_channel *channel;
 
+	/* This lock protects the device extension field */
+	spinlock_t ext_lock;
+
 	/* Device extension; */
 	void *ext;
 };
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index ffd6066..29c1712 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -578,6 +578,7 @@ struct hv_device *vmbus_child_device_create(uuid_le *type,
 		return NULL;
 	}
 
+	spin_lock_init(&child_device_obj->ext_lock);
 	child_device_obj->channel = channel;
 	memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
 	memcpy(&child_device_obj->dev_instance, instance,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 082/117] Staging: hv: storvsc: Use the newly introduced lock in accessing ext field
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced lock in accessing ext field.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    6 ++++++
 drivers/staging/hv/storvsc.c        |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index d93bf93..6b20f1d 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -292,12 +292,15 @@ static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 	if (stor_device && atomic_read(&stor_device->ref_count) > 1)
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
 }
@@ -306,10 +309,13 @@ static inline struct storvsc_device *get_out_stor_device(
 static inline void put_stor_device(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 
 	atomic_dec(&stor_device->ref_count);
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
 static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 357b08a..d1b6c4e 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -57,12 +57,15 @@ static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 	if (stor_device && atomic_read(&stor_device->ref_count))
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
 }
@@ -87,6 +90,7 @@ static inline struct storvsc_device *final_release_stor_device(
 			struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
 	stor_device = (struct storvsc_device *)device->ext;
 
@@ -94,7 +98,9 @@ static inline struct storvsc_device *final_release_stor_device(
 	while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
 		udelay(100);
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return stor_device;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 082/117] Staging: hv: storvsc: Use the newly introduced lock in accessing ext field
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced lock in accessing ext field.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    6 ++++++
 drivers/staging/hv/storvsc.c        |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index d93bf93..6b20f1d 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -292,12 +292,15 @@ static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 	if (stor_device && atomic_read(&stor_device->ref_count) > 1)
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
 }
@@ -306,10 +309,13 @@ static inline struct storvsc_device *get_out_stor_device(
 static inline void put_stor_device(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 
 	atomic_dec(&stor_device->ref_count);
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
 static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 357b08a..d1b6c4e 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -57,12 +57,15 @@ static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 	if (stor_device && atomic_read(&stor_device->ref_count))
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
 }
@@ -87,6 +90,7 @@ static inline struct storvsc_device *final_release_stor_device(
 			struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
 	stor_device = (struct storvsc_device *)device->ext;
 
@@ -94,7 +98,9 @@ static inline struct storvsc_device *final_release_stor_device(
 	while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
 		udelay(100);
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return stor_device;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 083/117] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is destroyed
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Prevent outgoing traffic when stor dev is destroyed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index 6b20f1d..53b65be 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -296,7 +296,8 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && atomic_read(&stor_device->ref_count) > 1)
+	if (stor_device && (atomic_read(&stor_device->ref_count) > 1) &&
+		!stor_device->destroy)
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 083/117] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is destroyed
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Prevent outgoing traffic when stor dev is destroyed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index 6b20f1d..53b65be 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -296,7 +296,8 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && atomic_read(&stor_device->ref_count) > 1)
+	if (stor_device && (atomic_read(&stor_device->ref_count) > 1) &&
+		!stor_device->destroy)
 		atomic_inc(&stor_device->ref_count);
 	else
 		stor_device = NULL;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 084/117] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of release_stor_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index d1b6c4e..f52e610 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -70,21 +70,6 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 1 to effectively disable get_out_stor_device() */
-static inline struct storvsc_device *release_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	/* Busy wait until the ref drop to 2, then set it to 1 */
-	while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2)
-		udelay(100);
-
-	return stor_device;
-}
-
 /* Drop ref count to 0. No one can use stor_device object. */
 static inline struct storvsc_device *final_release_stor_device(
 			struct hv_device *device)
@@ -406,7 +391,13 @@ int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
-	stor_device = release_stor_device(device);
+	/*
+	 * Since we currently hold a reference on the stor
+	 * device, it is safe to dereference the ext
+	 * pointer.
+	 */
+	stor_device = (struct storvsc_device *)device->ext;
+	atomic_dec(&stor_device->ref_count);
 	stor_device->destroy = true;
 
 	/*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 084/117] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of release_stor_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index d1b6c4e..f52e610 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -70,21 +70,6 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 1 to effectively disable get_out_stor_device() */
-static inline struct storvsc_device *release_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	/* Busy wait until the ref drop to 2, then set it to 1 */
-	while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2)
-		udelay(100);
-
-	return stor_device;
-}
-
 /* Drop ref count to 0. No one can use stor_device object. */
 static inline struct storvsc_device *final_release_stor_device(
 			struct hv_device *device)
@@ -406,7 +391,13 @@ int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
-	stor_device = release_stor_device(device);
+	/*
+	 * Since we currently hold a reference on the stor
+	 * device, it is safe to dereference the ext
+	 * pointer.
+	 */
+	stor_device = (struct storvsc_device *)device->ext;
+	atomic_dec(&stor_device->ref_count);
 	stor_device->destroy = true;
 
 	/*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 085/117] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of final_release_stor_device() by inlining code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   25 +++++--------------------
 1 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index f52e610..c4cb170 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -70,25 +70,6 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 0. No one can use stor_device object. */
-static inline struct storvsc_device *final_release_stor_device(
-			struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	/* Busy wait until the ref drop to 1, then set it to 0 */
-	while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
-		udelay(100);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	return stor_device;
-}
-
 static int storvsc_channel_init(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -390,6 +371,7 @@ int storvsc_dev_add(struct hv_device *device,
 int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
 	/*
 	 * Since we currently hold a reference on the stor
@@ -408,7 +390,10 @@ int storvsc_dev_remove(struct hv_device *device)
 
 	storvsc_wait_to_drain(stor_device);
 
-	stor_device = final_release_stor_device(device);
+	spin_lock_irqsave(&device->ext_lock, flags);
+	atomic_set(&stor_device->ref_count, 0);
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/* Close the channel */
 	vmbus_close(device->channel);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 085/117] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of final_release_stor_device() by inlining code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc.c |   25 +++++--------------------
 1 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index f52e610..c4cb170 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -70,25 +70,6 @@ static inline struct storvsc_device *get_in_stor_device(
 	return stor_device;
 }
 
-/* Drop ref count to 0. No one can use stor_device object. */
-static inline struct storvsc_device *final_release_stor_device(
-			struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	/* Busy wait until the ref drop to 1, then set it to 0 */
-	while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
-		udelay(100);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	return stor_device;
-}
-
 static int storvsc_channel_init(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -390,6 +371,7 @@ int storvsc_dev_add(struct hv_device *device,
 int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
+	unsigned long flags;
 
 	/*
 	 * Since we currently hold a reference on the stor
@@ -408,7 +390,10 @@ int storvsc_dev_remove(struct hv_device *device)
 
 	storvsc_wait_to_drain(stor_device);
 
-	stor_device = final_release_stor_device(device);
+	spin_lock_irqsave(&device->ext_lock, flags);
+	atomic_set(&stor_device->ref_count, 0);
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/* Close the channel */
 	vmbus_close(device->channel);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have a spin lock protecting access to the stor device pointer,
use it manage the reference count as well.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    8 ++++----
 drivers/staging/hv/storvsc.c        |   10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index 53b65be..d946211 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -265,7 +265,7 @@ struct storvsc_device {
 	struct hv_device *device;
 
 	/* 0 indicates the device is being destroyed */
-	atomic_t ref_count;
+	int	 ref_count;
 	bool	 destroy;
 	bool	 drain_notify;
 	atomic_t num_outstanding_req;
@@ -296,9 +296,9 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (atomic_read(&stor_device->ref_count) > 1) &&
+	if (stor_device && (stor_device->ref_count > 1) &&
 		!stor_device->destroy)
-		atomic_inc(&stor_device->ref_count);
+		stor_device->ref_count++;
 	else
 		stor_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -315,7 +315,7 @@ static inline void put_stor_device(struct hv_device *device)
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 
-	atomic_dec(&stor_device->ref_count);
+	stor_device->ref_count--;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index c4cb170..a41be2a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -42,7 +42,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	atomic_set(&stor_device->ref_count, 2);
+	stor_device->ref_count = 2;
 	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
@@ -61,8 +61,8 @@ static inline struct storvsc_device *get_in_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && atomic_read(&stor_device->ref_count))
-		atomic_inc(&stor_device->ref_count);
+	if (stor_device && stor_device->ref_count)
+		stor_device->ref_count++;
 	else
 		stor_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -379,7 +379,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	 * pointer.
 	 */
 	stor_device = (struct storvsc_device *)device->ext;
-	atomic_dec(&stor_device->ref_count);
+
 	stor_device->destroy = true;
 
 	/*
@@ -391,7 +391,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	storvsc_wait_to_drain(stor_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	atomic_set(&stor_device->ref_count, 0);
+	stor_device->ref_count = 0;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have a spin lock protecting access to the stor device pointer,
use it manage the reference count as well.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    8 ++++----
 drivers/staging/hv/storvsc.c        |   10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index 53b65be..d946211 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -265,7 +265,7 @@ struct storvsc_device {
 	struct hv_device *device;
 
 	/* 0 indicates the device is being destroyed */
-	atomic_t ref_count;
+	int	 ref_count;
 	bool	 destroy;
 	bool	 drain_notify;
 	atomic_t num_outstanding_req;
@@ -296,9 +296,9 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (atomic_read(&stor_device->ref_count) > 1) &&
+	if (stor_device && (stor_device->ref_count > 1) &&
 		!stor_device->destroy)
-		atomic_inc(&stor_device->ref_count);
+		stor_device->ref_count++;
 	else
 		stor_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -315,7 +315,7 @@ static inline void put_stor_device(struct hv_device *device)
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
 
-	atomic_dec(&stor_device->ref_count);
+	stor_device->ref_count--;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index c4cb170..a41be2a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -42,7 +42,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 	/* Set to 2 to allow both inbound and outbound traffics */
 	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	atomic_set(&stor_device->ref_count, 2);
+	stor_device->ref_count = 2;
 	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
@@ -61,8 +61,8 @@ static inline struct storvsc_device *get_in_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && atomic_read(&stor_device->ref_count))
-		atomic_inc(&stor_device->ref_count);
+	if (stor_device && stor_device->ref_count)
+		stor_device->ref_count++;
 	else
 		stor_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -379,7 +379,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	 * pointer.
 	 */
 	stor_device = (struct storvsc_device *)device->ext;
-	atomic_dec(&stor_device->ref_count);
+
 	stor_device->destroy = true;
 
 	/*
@@ -391,7 +391,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	storvsc_wait_to_drain(stor_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	atomic_set(&stor_device->ref_count, 0);
+	stor_device->ref_count = 0;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 087/117] Staging: hv: storvsc: Further cleanup reference counting of stor_device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Further cleanup reference counting of stor_device - when the device is being
destroyed, we will permit incoming traffic only to drain outstanding
requests.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 +--
 drivers/staging/hv/storvsc.c        |   22 +++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index d946211..a1f3e27 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -287,7 +287,6 @@ struct storvsc_device {
 };
 
 
-/* Get the stordevice object iff exists and its refcount > 1 */
 static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
@@ -296,7 +295,7 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (stor_device->ref_count > 1) &&
+	if (stor_device && (stor_device->ref_count) &&
 		!stor_device->destroy)
 		stor_device->ref_count++;
 	else
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index a41be2a..4d13044 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -40,9 +40,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	if (!stor_device)
 		return NULL;
 
-	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	stor_device->ref_count = 2;
+	stor_device->ref_count = 1;
 	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
@@ -51,8 +49,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	return stor_device;
 }
 
-
-/* Get the stordevice object iff exists and its refcount > 0 */
 static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
@@ -61,10 +57,18 @@ static inline struct storvsc_device *get_in_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && stor_device->ref_count)
-		stor_device->ref_count++;
-	else
-		stor_device = NULL;
+	if (!stor_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (stor_device->destroy &&
+		 (atomic_read(&stor_device->num_outstanding_req) == 0))
+		goto cleanup;
+	stor_device->ref_count++;
+cleanup:
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 087/117] Staging: hv: storvsc: Further cleanup reference counting of stor_device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Further cleanup reference counting of stor_device - when the device is being
destroyed, we will permit incoming traffic only to drain outstanding
requests.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |    3 +--
 drivers/staging/hv/storvsc.c        |   22 +++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index d946211..a1f3e27 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -287,7 +287,6 @@ struct storvsc_device {
 };
 
 
-/* Get the stordevice object iff exists and its refcount > 1 */
 static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
@@ -296,7 +295,7 @@ static inline struct storvsc_device *get_out_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (stor_device->ref_count > 1) &&
+	if (stor_device && (stor_device->ref_count) &&
 		!stor_device->destroy)
 		stor_device->ref_count++;
 	else
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index a41be2a..4d13044 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -40,9 +40,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	if (!stor_device)
 		return NULL;
 
-	/* Set to 2 to allow both inbound and outbound traffics */
-	/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-	stor_device->ref_count = 2;
+	stor_device->ref_count = 1;
 	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
@@ -51,8 +49,6 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	return stor_device;
 }
 
-
-/* Get the stordevice object iff exists and its refcount > 0 */
 static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
@@ -61,10 +57,18 @@ static inline struct storvsc_device *get_in_stor_device(
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && stor_device->ref_count)
-		stor_device->ref_count++;
-	else
-		stor_device = NULL;
+	if (!stor_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (stor_device->destroy &&
+		 (atomic_read(&stor_device->num_outstanding_req) == 0))
+		goto cleanup;
+	stor_device->ref_count++;
+cleanup:
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return stor_device;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 088/117] Staging: hv: netvsc: Inline the code for free_net_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Inline the code for free_net_device().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b6e1fb9..75c6ed7 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -49,14 +49,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	return net_device;
 }
 
-static void free_net_device(struct netvsc_device *device)
-{
-	WARN_ON(atomic_read(&device->refcnt) != 0);
-	device->dev->ext = NULL;
-	kfree(device);
-}
-
-
 /* Get the net device object iff exists and its refcount > 1 */
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
@@ -438,7 +430,7 @@ int netvsc_device_remove(struct hv_device *device)
 		kfree(netvsc_packet);
 	}
 
-	free_net_device(net_device);
+	kfree(net_device);
 	return 0;
 }
 
@@ -980,7 +972,7 @@ cleanup:
 		release_outbound_net_device(device);
 		release_inbound_net_device(device);
 
-		free_net_device(net_device);
+		kfree(net_device);
 	}
 
 	return ret;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 088/117] Staging: hv: netvsc: Inline the code for free_net_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Inline the code for free_net_device().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b6e1fb9..75c6ed7 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -49,14 +49,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	return net_device;
 }
 
-static void free_net_device(struct netvsc_device *device)
-{
-	WARN_ON(atomic_read(&device->refcnt) != 0);
-	device->dev->ext = NULL;
-	kfree(device);
-}
-
-
 /* Get the net device object iff exists and its refcount > 1 */
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
@@ -438,7 +430,7 @@ int netvsc_device_remove(struct hv_device *device)
 		kfree(netvsc_packet);
 	}
 
-	free_net_device(net_device);
+	kfree(net_device);
 	return 0;
 }
 
@@ -980,7 +972,7 @@ cleanup:
 		release_outbound_net_device(device);
 		release_inbound_net_device(device);
 
-		free_net_device(net_device);
+		kfree(net_device);
 	}
 
 	return ret;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 089/117] Staging: hv: netvsc: Cleanup alloc_net_device()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup alloc_net_device(); we can directly set the refcnt.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 75c6ed7..7722102 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -41,7 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffic */
-	atomic_cmpxchg(&net_device->refcnt, 0, 2);
+	atomic_set(&net_device->refcnt, 2);
 
 	net_device->dev = device;
 	device->ext = net_device;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 089/117] Staging: hv: netvsc: Cleanup alloc_net_device()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup alloc_net_device(); we can directly set the refcnt.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 75c6ed7..7722102 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -41,7 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffic */
-	atomic_cmpxchg(&net_device->refcnt, 0, 2);
+	atomic_set(&net_device->refcnt, 2);
 
 	net_device->dev = device;
 	device->ext = net_device;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 090/117] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Introduce state to manage the lifecycle of net device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    1 +
 drivers/staging/hv/netvsc.c     |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 5782fea..0b347c1 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -371,6 +371,7 @@ struct netvsc_device {
 
 	atomic_t refcnt;
 	atomic_t num_outstanding_sends;
+	bool destroy;
 	/*
 	 * List of free preallocated hv_netvsc_packet to represent receive
 	 * packet
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 7722102..67cf7fb 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	/* Set to 2 to allow both inbound and outbound traffic */
 	atomic_set(&net_device->refcnt, 2);
 
+	net_device->destroy = false;
 	net_device->dev = device;
 	device->ext = net_device;
 
@@ -404,6 +405,8 @@ int netvsc_device_remove(struct hv_device *device)
 		return -ENODEV;
 	}
 
+	net_device->destroy = true;
+
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
 		dev_err(&device->device,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 090/117] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Introduce state to manage the lifecycle of net device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    1 +
 drivers/staging/hv/netvsc.c     |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 5782fea..0b347c1 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -371,6 +371,7 @@ struct netvsc_device {
 
 	atomic_t refcnt;
 	atomic_t num_outstanding_sends;
+	bool destroy;
 	/*
 	 * List of free preallocated hv_netvsc_packet to represent receive
 	 * packet
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 7722102..67cf7fb 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	/* Set to 2 to allow both inbound and outbound traffic */
 	atomic_set(&net_device->refcnt, 2);
 
+	net_device->destroy = false;
 	net_device->dev = device;
 	device->ext = net_device;
 
@@ -404,6 +405,8 @@ int netvsc_device_remove(struct hv_device *device)
 		return -ENODEV;
 	}
 
+	net_device->destroy = true;
+
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
 		dev_err(&device->device,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 091/117] Staging: hv: netvsc:  Use the newly introduced lock in accessing ext field
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the newly introduced lock in accessing ext field.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 67cf7fb..c38c669 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -54,12 +54,15 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
 	if (net_device && atomic_read(&net_device->refcnt) > 1)
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return net_device;
 }
@@ -68,33 +71,46 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
 	if (net_device && atomic_read(&net_device->refcnt))
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
 
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
 
 static void put_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
 
 	net_device = device->ext;
 
 	atomic_dec(&net_device->refcnt);
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
 static struct netvsc_device *release_outbound_net_device(
 		struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device == NULL)
+	if (net_device == NULL) {
+		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return NULL;
+	}
+
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/* Busy wait until the ref drop to 2, then set it to 1 */
 	while (atomic_cmpxchg(&net_device->refcnt, 2, 1) != 2)
@@ -107,16 +123,23 @@ static struct netvsc_device *release_inbound_net_device(
 		struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device == NULL)
+	if (net_device == NULL) {
+		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return NULL;
+	}
 
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	/* Busy wait until the ref drop to 1, then set it to 0 */
 	while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1)
 		udelay(100);
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
 
@@ -397,6 +420,8 @@ int netvsc_device_remove(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *netvsc_packet, *pos;
+	unsigned long flags;
+
 
 	/* Stop outbound traffic ie sends and receives completions */
 	net_device = release_outbound_net_device(device);
@@ -404,8 +429,10 @@ int netvsc_device_remove(struct hv_device *device)
 		dev_err(&device->device, "No net device present!!");
 		return -ENODEV;
 	}
-
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device->destroy = true;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
 
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 091/117] Staging: hv: netvsc: Use the newly introduced lock in accessing ext field
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Use the newly introduced lock in accessing ext field.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 67cf7fb..c38c669 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -54,12 +54,15 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
 	if (net_device && atomic_read(&net_device->refcnt) > 1)
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	return net_device;
 }
@@ -68,33 +71,46 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
 	if (net_device && atomic_read(&net_device->refcnt))
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
 
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
 
 static void put_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
 
 	net_device = device->ext;
 
 	atomic_dec(&net_device->refcnt);
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
 static struct netvsc_device *release_outbound_net_device(
 		struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device == NULL)
+	if (net_device == NULL) {
+		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return NULL;
+	}
+
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/* Busy wait until the ref drop to 2, then set it to 1 */
 	while (atomic_cmpxchg(&net_device->refcnt, 2, 1) != 2)
@@ -107,16 +123,23 @@ static struct netvsc_device *release_inbound_net_device(
 		struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	unsigned long flags;
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device == NULL)
+	if (net_device == NULL) {
+		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return NULL;
+	}
 
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	/* Busy wait until the ref drop to 1, then set it to 0 */
 	while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1)
 		udelay(100);
 
+	spin_lock_irqsave(&device->ext_lock, flags);
 	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
 
@@ -397,6 +420,8 @@ int netvsc_device_remove(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *netvsc_packet, *pos;
+	unsigned long flags;
+
 
 	/* Stop outbound traffic ie sends and receives completions */
 	net_device = release_outbound_net_device(device);
@@ -404,8 +429,10 @@ int netvsc_device_remove(struct hv_device *device)
 		dev_err(&device->device, "No net device present!!");
 		return -ENODEV;
 	}
-
+	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device->destroy = true;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
 
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 092/117] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Prevent outgoing traffic when netvsc dev is destroyed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 2ee3f07..538259d 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -58,7 +58,8 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && atomic_read(&net_device->refcnt) > 1)
+	if (net_device && (atomic_read(&net_device->refcnt) > 1) &&
+		!net_device->destroy)
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 092/117] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Prevent outgoing traffic when netvsc dev is destroyed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 2ee3f07..538259d 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -58,7 +58,8 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && atomic_read(&net_device->refcnt) > 1)
+	if (net_device && (atomic_read(&net_device->refcnt) > 1) &&
+		!net_device->destroy)
 		atomic_inc(&net_device->refcnt);
 	else
 		net_device = NULL;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 093/117] Staging: hv: netvsc: Get rid of release_outbound_net_device() by inlining the code
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (91 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of release_outbound_net_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   45 ++++++++++++++++--------------------------
 1 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 7c3d7ac..3975219 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -98,28 +98,6 @@ static void put_net_device(struct hv_device *device)
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
-static struct netvsc_device *release_outbound_net_device(
-		struct hv_device *device)
-{
-	struct netvsc_device *net_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	net_device = device->ext;
-	if (net_device == NULL) {
-		spin_unlock_irqrestore(&device->ext_lock, flags);
-		return NULL;
-	}
-
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	/* Busy wait until the ref drop to 2, then set it to 1 */
-	while (atomic_cmpxchg(&net_device->refcnt, 2, 1) != 2)
-		udelay(100);
-
-	return net_device;
-}
-
 static struct netvsc_device *release_inbound_net_device(
 		struct hv_device *device)
 {
@@ -424,13 +402,13 @@ int netvsc_device_remove(struct hv_device *device)
 	unsigned long flags;
 
 
-	/* Stop outbound traffic ie sends and receives completions */
-	net_device = release_outbound_net_device(device);
-	if (!net_device) {
-		dev_err(&device->device, "No net device present!!");
+	spin_lock_irqsave(&device->ext_lock, flags);
+	net_device = (struct netvsc_device *)device->ext;
+	if (net_device == NULL) {
+		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return -ENODEV;
 	}
-	spin_lock_irqsave(&device->ext_lock, flags);
+	atomic_dec(&net_device->refcnt);
 	net_device->destroy = true;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
@@ -448,6 +426,18 @@ int netvsc_device_remove(struct hv_device *device)
 	/* Stop inbound traffic ie receives and sends completions */
 	net_device = release_inbound_net_device(device);
 
+	/*
+	 * Wait until the ref cnt falls to 0.
+	 * We have already stopped any new references
+	 * for outgoing traffic. Also, at this point we don't have any
+	 * incoming traffic as well. So this must be outgoing refrences
+	 * established prior to marking the device as being destroyed.
+	 * Since the send path is non-blocking, it is reasonable to busy
+	 * wait here.
+	 */
+	while (atomic_read(&net_device->refcnt))
+		udelay(100);
+
 	/* At this point, no one should be accessing netDevice except in here */
 	dev_notice(&device->device, "net device safe to remove");
 
@@ -1000,7 +990,6 @@ cleanup:
 			kfree(packet);
 		}
 
-		release_outbound_net_device(device);
 		release_inbound_net_device(device);
 
 		kfree(net_device);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 094/117] Staging: hv: netvsc: Get rid of release_inbound_net_device() by inlining the code
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of release_inbound_net_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   32 ++++----------------------------
 1 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 3975219..6805137 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -98,30 +98,6 @@ static void put_net_device(struct hv_device *device)
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
-static struct netvsc_device *release_inbound_net_device(
-		struct hv_device *device)
-{
-	struct netvsc_device *net_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	net_device = device->ext;
-	if (net_device == NULL) {
-		spin_unlock_irqrestore(&device->ext_lock, flags);
-		return NULL;
-	}
-
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	/* Busy wait until the ref drop to 1, then set it to 0 */
-	while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1)
-		udelay(100);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	return net_device;
-}
-
 static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
 	struct nvsp_message *revoke_packet;
@@ -423,8 +399,10 @@ int netvsc_device_remove(struct hv_device *device)
 
 	netvsc_disconnect_vsp(net_device);
 
-	/* Stop inbound traffic ie receives and sends completions */
-	net_device = release_inbound_net_device(device);
+	spin_lock_irqsave(&device->ext_lock, flags);
+	atomic_dec(&net_device->refcnt);
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/*
 	 * Wait until the ref cnt falls to 0.
@@ -990,8 +968,6 @@ cleanup:
 			kfree(packet);
 		}
 
-		release_inbound_net_device(device);
-
 		kfree(net_device);
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 094/117] Staging: hv: netvsc: Get rid of release_inbound_net_device() by inlining the code
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Get rid of release_inbound_net_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   32 ++++----------------------------
 1 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 3975219..6805137 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -98,30 +98,6 @@ static void put_net_device(struct hv_device *device)
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
-static struct netvsc_device *release_inbound_net_device(
-		struct hv_device *device)
-{
-	struct netvsc_device *net_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	net_device = device->ext;
-	if (net_device == NULL) {
-		spin_unlock_irqrestore(&device->ext_lock, flags);
-		return NULL;
-	}
-
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	/* Busy wait until the ref drop to 1, then set it to 0 */
-	while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1)
-		udelay(100);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-	return net_device;
-}
-
 static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
 	struct nvsp_message *revoke_packet;
@@ -423,8 +399,10 @@ int netvsc_device_remove(struct hv_device *device)
 
 	netvsc_disconnect_vsp(net_device);
 
-	/* Stop inbound traffic ie receives and sends completions */
-	net_device = release_inbound_net_device(device);
+	spin_lock_irqsave(&device->ext_lock, flags);
+	atomic_dec(&net_device->refcnt);
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
 
 	/*
 	 * Wait until the ref cnt falls to 0.
@@ -990,8 +968,6 @@ cleanup:
 			kfree(packet);
 		}
 
-		release_inbound_net_device(device);
-
 		kfree(net_device);
 	}
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 095/117] Staging: hv: netvsc: Leverage the spinlock to manage refcnt
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now that we have a spin lock protecting the device pointer, use it to also
protect the refrence count.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    2 +-
 drivers/staging/hv/netvsc.c     |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 0b347c1..5c8fc31 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -369,7 +369,7 @@ struct nvsp_message {
 struct netvsc_device {
 	struct hv_device *dev;
 
-	atomic_t refcnt;
+	int refcnt;
 	atomic_t num_outstanding_sends;
 	bool destroy;
 	/*
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 0411332..3b234a3 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -41,7 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffic */
-	atomic_set(&net_device->refcnt, 2);
+	net_device->refcnt = 2;
 
 	net_device->destroy = false;
 	net_device->dev = device;
@@ -58,9 +58,9 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && (atomic_read(&net_device->refcnt) > 1) &&
+	if (net_device && (net_device->refcnt > 1) &&
 		!net_device->destroy)
-		atomic_inc(&net_device->refcnt);
+		net_device->refcnt++;
 	else
 		net_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -76,8 +76,8 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && atomic_read(&net_device->refcnt))
-		atomic_inc(&net_device->refcnt);
+	if (net_device && net_device->refcnt)
+		net_device->refcnt++;
 	else
 		net_device = NULL;
 
@@ -94,7 +94,7 @@ static void put_net_device(struct hv_device *device)
 
 	net_device = device->ext;
 
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
@@ -385,7 +385,7 @@ int netvsc_device_remove(struct hv_device *device)
 		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return -ENODEV;
 	}
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	net_device->destroy = true;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
@@ -401,7 +401,7 @@ int netvsc_device_remove(struct hv_device *device)
 	netvsc_disconnect_vsp(net_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
@@ -414,7 +414,7 @@ int netvsc_device_remove(struct hv_device *device)
 	 * Since the send path is non-blocking, it is reasonable to busy
 	 * wait here.
 	 */
-	while (atomic_read(&net_device->refcnt))
+	while (net_device->refcnt != 0)
 		udelay(100);
 
 	/* At this point, no one should be accessing netDevice except in here */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 095/117] Staging: hv: netvsc: Leverage the spinlock to manage refcnt
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Now that we have a spin lock protecting the device pointer, use it to also
protect the refrence count.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h |    2 +-
 drivers/staging/hv/netvsc.c     |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 0b347c1..5c8fc31 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -369,7 +369,7 @@ struct nvsp_message {
 struct netvsc_device {
 	struct hv_device *dev;
 
-	atomic_t refcnt;
+	int refcnt;
 	atomic_t num_outstanding_sends;
 	bool destroy;
 	/*
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 0411332..3b234a3 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -41,7 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 		return NULL;
 
 	/* Set to 2 to allow both inbound and outbound traffic */
-	atomic_set(&net_device->refcnt, 2);
+	net_device->refcnt = 2;
 
 	net_device->destroy = false;
 	net_device->dev = device;
@@ -58,9 +58,9 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && (atomic_read(&net_device->refcnt) > 1) &&
+	if (net_device && (net_device->refcnt > 1) &&
 		!net_device->destroy)
-		atomic_inc(&net_device->refcnt);
+		net_device->refcnt++;
 	else
 		net_device = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
@@ -76,8 +76,8 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && atomic_read(&net_device->refcnt))
-		atomic_inc(&net_device->refcnt);
+	if (net_device && net_device->refcnt)
+		net_device->refcnt++;
 	else
 		net_device = NULL;
 
@@ -94,7 +94,7 @@ static void put_net_device(struct hv_device *device)
 
 	net_device = device->ext;
 
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 }
 
@@ -385,7 +385,7 @@ int netvsc_device_remove(struct hv_device *device)
 		spin_unlock_irqrestore(&device->ext_lock, flags);
 		return -ENODEV;
 	}
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	net_device->destroy = true;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
@@ -401,7 +401,7 @@ int netvsc_device_remove(struct hv_device *device)
 	netvsc_disconnect_vsp(net_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	atomic_dec(&net_device->refcnt);
+	net_device->refcnt--;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
@@ -414,7 +414,7 @@ int netvsc_device_remove(struct hv_device *device)
 	 * Since the send path is non-blocking, it is reasonable to busy
 	 * wait here.
 	 */
-	while (atomic_read(&net_device->refcnt))
+	while (net_device->refcnt != 0)
 		udelay(100);
 
 	/* At this point, no one should be accessing netDevice except in here */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 096/117] Staging: hv: netvsc: Further cleanup reference counting of netvsc_device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Further cleanup reference counting of netvsc_device. Since once the device
is marked for destruction, we only allow incoming traffic to drain out
outstanding sends, we can simplify reference counting.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 4ef17d8..16a80b1 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -17,6 +17,7 @@
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -40,8 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	if (!net_device)
 		return NULL;
 
-	/* Set to 2 to allow both inbound and outbound traffic */
-	net_device->refcnt = 2;
+	net_device->refcnt = 1;
 
 	net_device->destroy = false;
 	net_device->dev = device;
@@ -50,7 +50,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	return net_device;
 }
 
-/* Get the net device object iff exists and its refcount > 1 */
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -58,7 +57,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && (net_device->refcnt > 1) &&
+	if (net_device && (net_device->refcnt) &&
 		!net_device->destroy)
 		net_device->refcnt++;
 	else
@@ -68,7 +67,6 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 	return net_device;
 }
 
-/* Get the net device object iff exists and its refcount > 0 */
 static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -76,11 +74,23 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && net_device->refcnt)
-		net_device->refcnt++;
-	else
+
+	if (!net_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (net_device->destroy &&
+		(atomic_read(&net_device->num_outstanding_sends) == 0)) {
 		net_device = NULL;
+		goto cleanup;
+	}
 
+	net_device->refcnt++;
+
+cleanup:
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
@@ -400,7 +410,6 @@ int netvsc_device_remove(struct hv_device *device)
 	netvsc_disconnect_vsp(net_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	net_device->refcnt--;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 096/117] Staging: hv: netvsc: Further cleanup reference counting of netvsc_device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Further cleanup reference counting of netvsc_device. Since once the device
is marked for destruction, we only allow incoming traffic to drain out
outstanding sends, we can simplify reference counting.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 4ef17d8..16a80b1 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -17,6 +17,7 @@
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -40,8 +41,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	if (!net_device)
 		return NULL;
 
-	/* Set to 2 to allow both inbound and outbound traffic */
-	net_device->refcnt = 2;
+	net_device->refcnt = 1;
 
 	net_device->destroy = false;
 	net_device->dev = device;
@@ -50,7 +50,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	return net_device;
 }
 
-/* Get the net device object iff exists and its refcount > 1 */
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -58,7 +57,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && (net_device->refcnt > 1) &&
+	if (net_device && (net_device->refcnt) &&
 		!net_device->destroy)
 		net_device->refcnt++;
 	else
@@ -68,7 +67,6 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 	return net_device;
 }
 
-/* Get the net device object iff exists and its refcount > 0 */
 static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -76,11 +74,23 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 
 	spin_lock_irqsave(&device->ext_lock, flags);
 	net_device = device->ext;
-	if (net_device && net_device->refcnt)
-		net_device->refcnt++;
-	else
+
+	if (!net_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (net_device->destroy &&
+		(atomic_read(&net_device->num_outstanding_sends) == 0)) {
 		net_device = NULL;
+		goto cleanup;
+	}
 
+	net_device->refcnt++;
+
+cleanup:
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 	return net_device;
 }
@@ -400,7 +410,6 @@ int netvsc_device_remove(struct hv_device *device)
 	netvsc_disconnect_vsp(net_device);
 
 	spin_lock_irqsave(&device->ext_lock, flags);
-	net_device->refcnt--;
 	device->ext = NULL;
 	spin_unlock_irqrestore(&device->ext_lock, flags);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add code to handle IDE devices using the storvsc driver. The storvsc_probe()
is modified so that the storvsc driver can surface all disks presented to the
guest as scsi devices using generic upper level Linux scsi drivers.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   62 +++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 0f2fc2f..efbc603 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -61,6 +61,17 @@ struct storvsc_cmd_request {
 	struct hv_storvsc_request request;
 };
 
+static void storvsc_get_ide_info(struct hv_device *dev, int *target, int *path)
+{
+	*target =
+		dev->dev_instance.b[5] << 8 | dev->dev_instance.b[4];
+
+	*path =
+		dev->dev_instance.b[3] << 24 |
+		dev->dev_instance.b[2] << 16 |
+		dev->dev_instance.b[1] << 8  | dev->dev_instance.b[0];
+}
+
 
 static int storvsc_device_alloc(struct scsi_device *sdevice)
 {
@@ -654,6 +665,14 @@ static const struct hv_vmbus_device_id id_table[] = {
 };
 
 MODULE_DEVICE_TABLE(vmbus, id_table);
+
+static const uuid_le blk_guid = {
+	.b = {
+		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+	}
+};
+
 /*
  * storvsc_probe - Add a new device for this driver
  */
@@ -664,6 +683,14 @@ static int storvsc_probe(struct hv_device *device)
 	struct Scsi_Host *host;
 	struct hv_host_device *host_dev;
 	struct storvsc_device_info device_info;
+	bool dev_is_ide;
+	int path = 0;
+	int target = 0;
+
+	if (!uuid_le_cmp(device->dev_type, blk_guid))
+		dev_is_ide = true;
+	else
+		dev_is_ide = false;
 
 	host = scsi_host_alloc(&scsi_driver,
 			       sizeof(struct hv_host_device));
@@ -699,8 +726,14 @@ static int storvsc_probe(struct hv_device *device)
 		return -ENODEV;
 	}
 
-	host_dev->path = device_info.path_id;
-	host_dev->target = device_info.target_id;
+	if (dev_is_ide) {
+		storvsc_get_ide_info(device, &target, &path);
+		host_dev->path = device_info.path_id;
+		host_dev->target = device_info.target_id;
+	} else {
+		host_dev->path = device_info.path_id;
+		host_dev->target = device_info.target_id;
+	}
 
 	/* max # of devices per target */
 	host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
@@ -711,17 +744,24 @@ static int storvsc_probe(struct hv_device *device)
 
 	/* Register the HBA and start the scsi bus scan */
 	ret = scsi_add_host(host, &device->device);
-	if (ret != 0) {
-
-		storvsc_dev_remove(device);
-
-		kmem_cache_destroy(host_dev->request_pool);
-		scsi_host_put(host);
-		return -ENODEV;
-	}
+	if (ret != 0)
+		goto err_out;
 
-	scsi_scan_host(host);
+	if (dev_is_ide) {
+		ret = scsi_add_device(host, 0, target, 0);
+		if (ret) {
+			scsi_remove_host(host);
+			goto err_out;
+		}
+	} else
+		scsi_scan_host(host);
 	return ret;
+
+err_out:
+	storvsc_dev_remove(device);
+	kmem_cache_destroy(host_dev->request_pool);
+	scsi_host_put(host);
+	return -ENODEV;
 }
 
 /* The one and only one */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Add code to handle IDE devices using the storvsc driver. The storvsc_probe()
is modified so that the storvsc driver can surface all disks presented to the
guest as scsi devices using generic upper level Linux scsi drivers.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   62 +++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 0f2fc2f..efbc603 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -61,6 +61,17 @@ struct storvsc_cmd_request {
 	struct hv_storvsc_request request;
 };
 
+static void storvsc_get_ide_info(struct hv_device *dev, int *target, int *path)
+{
+	*target =
+		dev->dev_instance.b[5] << 8 | dev->dev_instance.b[4];
+
+	*path =
+		dev->dev_instance.b[3] << 24 |
+		dev->dev_instance.b[2] << 16 |
+		dev->dev_instance.b[1] << 8  | dev->dev_instance.b[0];
+}
+
 
 static int storvsc_device_alloc(struct scsi_device *sdevice)
 {
@@ -654,6 +665,14 @@ static const struct hv_vmbus_device_id id_table[] = {
 };
 
 MODULE_DEVICE_TABLE(vmbus, id_table);
+
+static const uuid_le blk_guid = {
+	.b = {
+		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+	}
+};
+
 /*
  * storvsc_probe - Add a new device for this driver
  */
@@ -664,6 +683,14 @@ static int storvsc_probe(struct hv_device *device)
 	struct Scsi_Host *host;
 	struct hv_host_device *host_dev;
 	struct storvsc_device_info device_info;
+	bool dev_is_ide;
+	int path = 0;
+	int target = 0;
+
+	if (!uuid_le_cmp(device->dev_type, blk_guid))
+		dev_is_ide = true;
+	else
+		dev_is_ide = false;
 
 	host = scsi_host_alloc(&scsi_driver,
 			       sizeof(struct hv_host_device));
@@ -699,8 +726,14 @@ static int storvsc_probe(struct hv_device *device)
 		return -ENODEV;
 	}
 
-	host_dev->path = device_info.path_id;
-	host_dev->target = device_info.target_id;
+	if (dev_is_ide) {
+		storvsc_get_ide_info(device, &target, &path);
+		host_dev->path = device_info.path_id;
+		host_dev->target = device_info.target_id;
+	} else {
+		host_dev->path = device_info.path_id;
+		host_dev->target = device_info.target_id;
+	}
 
 	/* max # of devices per target */
 	host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
@@ -711,17 +744,24 @@ static int storvsc_probe(struct hv_device *device)
 
 	/* Register the HBA and start the scsi bus scan */
 	ret = scsi_add_host(host, &device->device);
-	if (ret != 0) {
-
-		storvsc_dev_remove(device);
-
-		kmem_cache_destroy(host_dev->request_pool);
-		scsi_host_put(host);
-		return -ENODEV;
-	}
+	if (ret != 0)
+		goto err_out;
 
-	scsi_scan_host(host);
+	if (dev_is_ide) {
+		ret = scsi_add_device(host, 0, target, 0);
+		if (ret) {
+			scsi_remove_host(host);
+			goto err_out;
+		}
+	} else
+		scsi_scan_host(host);
 	return ret;
+
+err_out:
+	storvsc_dev_remove(device);
+	kmem_cache_destroy(host_dev->request_pool);
+	scsi_host_put(host);
+	return -ENODEV;
 }
 
 /* The one and only one */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 098/117] Staging: hv: storvsc: Handle IDE devices using the storvsc driver
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (96 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  2011-07-16  2:05     ` Christoph Hellwig
  -1 siblings, 1 reply; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Now, enable handling of all IDE devices by extending the storvsc
device id table to handle IDE guid. As part of this cleanup Kconfig
and Hyper-V Makefile to not build the IDE driver (blkvsc).

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/Kconfig       |    7 -------
 drivers/staging/hv/Makefile      |    2 --
 drivers/staging/hv/storvsc_drv.c |    7 +++++++
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig
index 5e0c9f6..26b5064 100644
--- a/drivers/staging/hv/Kconfig
+++ b/drivers/staging/hv/Kconfig
@@ -15,13 +15,6 @@ config HYPERV_STORAGE
 	help
 	 Select this option to enable the Hyper-V virtual storage driver.
 
-config HYPERV_BLOCK
-	tristate "Microsoft Hyper-V virtual block driver"
-	depends on BLOCK && SCSI && (LBDAF || 64BIT)
-	default HYPERV
-	help
-	  Select this option to enable the Hyper-V virtual block driver.
-
 config HYPERV_NET
 	tristate "Microsoft Hyper-V virtual network driver"
 	depends on NET
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index 3004674..bb89437 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,6 +1,5 @@
 obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
-obj-$(CONFIG_HYPERV_BLOCK)	+= hv_blkvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
 obj-$(CONFIG_HYPERV_MOUSE)	+= hv_mouse.o
@@ -9,6 +8,5 @@ hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
 		 channel_mgmt.o ring_buffer.o
 hv_storvsc-y := storvsc_drv.o storvsc.o
-hv_blkvsc-y := blkvsc_drv.o  storvsc.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index efbc603..5777482 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -657,6 +657,13 @@ static const struct hv_vmbus_device_id id_table[] = {
 		}
 	},
 	{
+		/* IDE guid */
+		.guid = {
+			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+		}
+	},
+	{
 		.guid = {
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 099/117] Staging: hv: storvsc: Optimize bounce buffer handling for the "write" case
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Optimize bounce buffer handling for the "write" case.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 5777482..e2294d5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -428,17 +428,17 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
 
+	vm_srb = &request->vstor_packet.vm_srb;
 	if (cmd_request->bounce_sgl_count) {
-
-		/* FIXME: We can optimize on writes by just skipping this */
-		copy_from_bounce_buffer(scsi_sglist(scmnd),
+		if (vm_srb->data_in == READ_TYPE) {
+			copy_from_bounce_buffer(scsi_sglist(scmnd),
 					cmd_request->bounce_sgl,
 					scsi_sg_count(scmnd));
-		destroy_bounce_buffer(cmd_request->bounce_sgl,
-				      cmd_request->bounce_sgl_count);
+			destroy_bounce_buffer(cmd_request->bounce_sgl,
+					cmd_request->bounce_sgl_count);
+		}
 	}
 
-	vm_srb = &request->vstor_packet.vm_srb;
 	scmnd->result = vm_srb->scsi_status;
 
 	if (scmnd->result) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 099/117] Staging: hv: storvsc: Optimize bounce buffer handling for the "write" case
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Optimize bounce buffer handling for the "write" case.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 5777482..e2294d5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -428,17 +428,17 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
 
+	vm_srb = &request->vstor_packet.vm_srb;
 	if (cmd_request->bounce_sgl_count) {
-
-		/* FIXME: We can optimize on writes by just skipping this */
-		copy_from_bounce_buffer(scsi_sglist(scmnd),
+		if (vm_srb->data_in == READ_TYPE) {
+			copy_from_bounce_buffer(scsi_sglist(scmnd),
 					cmd_request->bounce_sgl,
 					scsi_sg_count(scmnd));
-		destroy_bounce_buffer(cmd_request->bounce_sgl,
-				      cmd_request->bounce_sgl_count);
+			destroy_bounce_buffer(cmd_request->bounce_sgl,
+					cmd_request->bounce_sgl_count);
+		}
 	}
 
-	vm_srb = &request->vstor_packet.vm_srb;
 	scmnd->result = vm_srb->scsi_status;
 
 	if (scmnd->result) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 100/117] Staging: hv: storvsc: Optimize the bounce buffer handling in the "read" case
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Optimize the bounce buffer handling in the "read" case.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e2294d5..6e4725f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -563,12 +563,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) >>
 					PAGE_SHIFT;
 
-			/*
-			 * FIXME: We can optimize on reads by just skipping
-			 * this
-			 */
-			copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl,
-					      scsi_sg_count(scmnd));
+			if (vm_srb->data_in == WRITE_TYPE)
+				copy_to_bounce_buffer(sgl,
+					cmd_request->bounce_sgl,
+					scsi_sg_count(scmnd));
 
 			sgl = cmd_request->bounce_sgl;
 			sg_count = cmd_request->bounce_sgl_count;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 100/117] Staging: hv: storvsc: Optimize the bounce buffer handling in the "read" case
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Optimize the bounce buffer handling in the "read" case.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e2294d5..6e4725f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -563,12 +563,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) >>
 					PAGE_SHIFT;
 
-			/*
-			 * FIXME: We can optimize on reads by just skipping
-			 * this
-			 */
-			copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl,
-					      scsi_sg_count(scmnd));
+			if (vm_srb->data_in == WRITE_TYPE)
+				copy_to_bounce_buffer(sgl,
+					cmd_request->bounce_sgl,
+					scsi_sg_count(scmnd));
 
 			sgl = cmd_request->bounce_sgl;
 			sg_count = cmd_request->bounce_sgl_count;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 101/117] Staging: hv: storvsc: Include storvsc.c in storvsc_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

As part of further cleanup of our storage drivers, include the content
of storvsc.c into storvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/Makefile      |    2 +-
 drivers/staging/hv/storvsc.c     |  526 -------------------------------------
 drivers/staging/hv/storvsc_drv.c |  527 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 528 insertions(+), 527 deletions(-)
 delete mode 100644 drivers/staging/hv/storvsc.c

diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bb89437..bd176b1 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -7,6 +7,6 @@ obj-$(CONFIG_HYPERV_MOUSE)	+= hv_mouse.o
 hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
 		 channel_mgmt.o ring_buffer.o
-hv_storvsc-y := storvsc_drv.o storvsc.o
+hv_storvsc-y := storvsc_drv.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
deleted file mode 100644
index 4d13044..0000000
--- a/drivers/staging/hv/storvsc.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/completion.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-
-#include "hyperv.h"
-#include "hyperv_storage.h"
-
-
-static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-
-	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
-	if (!stor_device)
-		return NULL;
-
-	stor_device->ref_count = 1;
-	stor_device->destroy = false;
-	init_waitqueue_head(&stor_device->waiting_to_drain);
-	stor_device->device = device;
-	device->ext = stor_device;
-
-	return stor_device;
-}
-
-static inline struct storvsc_device *get_in_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-	if (!stor_device)
-		goto cleanup;
-
-	/*
-	 * If the device is being destroyed; allow incoming
-	 * traffic only to cleanup outstanding requests.
-	 */
-	if (stor_device->destroy &&
-		 (atomic_read(&stor_device->num_outstanding_req) == 0))
-		goto cleanup;
-	stor_device->ref_count++;
-cleanup:
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	return stor_device;
-}
-
-static int storvsc_channel_init(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	struct hv_storvsc_request *request;
-	struct vstor_packet *vstor_packet;
-	int ret, t;
-
-	stor_device = get_out_stor_device(device);
-	if (!stor_device)
-		return -ENODEV;
-
-	request = &stor_device->init_request;
-	vstor_packet = &request->vstor_packet;
-
-	/*
-	 * Now, initiate the vsc/vsp initialization protocol on the open
-	 * channel
-	 */
-	memset(request, 0, sizeof(struct hv_storvsc_request));
-	init_completion(&request->wait_event);
-	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-	/* reuse the packet for version range supported */
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
-	FILL_VMSTOR_REVISION(vstor_packet->version.revision);
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-	vstor_packet->storage_channel_properties.port_number =
-					stor_device->port_number;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
-	stor_device->target_id
-		= vstor_packet->storage_channel_properties.target_id;
-
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-cleanup:
-	put_stor_device(device);
-	return ret;
-}
-
-static void storvsc_on_io_completion(struct hv_device *device,
-				  struct vstor_packet *vstor_packet,
-				  struct hv_storvsc_request *request)
-{
-	struct storvsc_device *stor_device;
-	struct vstor_packet *stor_pkt;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_pkt = &request->vstor_packet;
-
-
-	/* Copy over the status...etc */
-	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
-	stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
-	stor_pkt->vm_srb.sense_info_length =
-	vstor_packet->vm_srb.sense_info_length;
-
-	if (vstor_packet->vm_srb.scsi_status != 0 ||
-		vstor_packet->vm_srb.srb_status != 1){
-		DPRINT_WARN(STORVSC,
-			    "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
-			    stor_pkt->vm_srb.cdb[0],
-			    vstor_packet->vm_srb.scsi_status,
-			    vstor_packet->vm_srb.srb_status);
-	}
-
-	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
-		/* CHECK_CONDITION */
-		if (vstor_packet->vm_srb.srb_status & 0x80) {
-			/* autosense data available */
-			DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
-				    "valid - len %d\n", request,
-				    vstor_packet->vm_srb.sense_info_length);
-
-			memcpy(request->sense_buffer,
-			       vstor_packet->vm_srb.sense_data,
-			       vstor_packet->vm_srb.sense_info_length);
-
-		}
-	}
-
-	stor_pkt->vm_srb.data_transfer_length =
-	vstor_packet->vm_srb.data_transfer_length;
-
-	request->on_io_completion(request);
-
-	if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
-		stor_device->drain_notify)
-		wake_up(&stor_device->waiting_to_drain);
-
-
-}
-
-static void storvsc_on_receive(struct hv_device *device,
-			     struct vstor_packet *vstor_packet,
-			     struct hv_storvsc_request *request)
-{
-	switch (vstor_packet->operation) {
-	case VSTOR_OPERATION_COMPLETE_IO:
-		storvsc_on_io_completion(device, vstor_packet, request);
-		break;
-	case VSTOR_OPERATION_REMOVE_DEVICE:
-
-	default:
-		break;
-	}
-}
-
-static void storvsc_on_channel_callback(void *context)
-{
-	struct hv_device *device = (struct hv_device *)context;
-	struct storvsc_device *stor_device;
-	u32 bytes_recvd;
-	u64 request_id;
-	unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
-	struct hv_storvsc_request *request;
-	int ret;
-
-
-	stor_device = get_in_stor_device(device);
-	if (!stor_device)
-		return;
-
-	do {
-		ret = vmbus_recvpacket(device->channel, packet,
-				       ALIGN(sizeof(struct vstor_packet), 8),
-				       &bytes_recvd, &request_id);
-		if (ret == 0 && bytes_recvd > 0) {
-
-			request = (struct hv_storvsc_request *)
-					(unsigned long)request_id;
-
-			if ((request == &stor_device->init_request) ||
-			    (request == &stor_device->reset_request)) {
-
-				memcpy(&request->vstor_packet, packet,
-				       sizeof(struct vstor_packet));
-				complete(&request->wait_event);
-			} else {
-				storvsc_on_receive(device,
-						(struct vstor_packet *)packet,
-						request);
-			}
-		} else {
-			break;
-		}
-	} while (1);
-
-	put_stor_device(device);
-	return;
-}
-
-static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
-{
-	struct vmstorage_channel_properties props;
-	int ret;
-
-	memset(&props, 0, sizeof(struct vmstorage_channel_properties));
-
-	/* Open the channel */
-	ret = vmbus_open(device->channel,
-			 ring_size,
-			 ring_size,
-			 (void *)&props,
-			 sizeof(struct vmstorage_channel_properties),
-			 storvsc_on_channel_callback, device);
-
-	if (ret != 0)
-		return ret;
-
-	ret = storvsc_channel_init(device);
-
-	return ret;
-}
-
-int storvsc_dev_add(struct hv_device *device,
-					void *additional_info)
-{
-	struct storvsc_device *stor_device;
-	struct storvsc_device_info *device_info;
-	int ret = 0;
-
-	device_info = (struct storvsc_device_info *)additional_info;
-	stor_device = alloc_stor_device(device);
-	if (!stor_device)
-		return -ENOMEM;
-
-	/* Save the channel properties to our storvsc channel */
-
-	/*
-	 * If we support more than 1 scsi channel, we need to set the
-	 * port number here to the scsi channel but how do we get the
-	 * scsi channel prior to the bus scan.
-	 *
-	 * The host does not support this.
-	 */
-
-	stor_device->port_number = device_info->port_number;
-	/* Send it back up */
-	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-	if (ret) {
-		kfree(stor_device);
-		return ret;
-	}
-	device_info->path_id = stor_device->path_id;
-	device_info->target_id = stor_device->target_id;
-
-	return ret;
-}
-
-int storvsc_dev_remove(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	/*
-	 * Since we currently hold a reference on the stor
-	 * device, it is safe to dereference the ext
-	 * pointer.
-	 */
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_device->destroy = true;
-
-	/*
-	 * At this point, all outbound traffic should be disable. We
-	 * only allow inbound traffic (responses) to proceed so that
-	 * outstanding requests can be completed.
-	 */
-
-	storvsc_wait_to_drain(stor_device);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device->ref_count = 0;
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	/* Close the channel */
-	vmbus_close(device->channel);
-
-	kfree(stor_device);
-	return 0;
-}
-
-int storvsc_do_io(struct hv_device *device,
-			      struct hv_storvsc_request *request)
-{
-	struct storvsc_device *stor_device;
-	struct vstor_packet *vstor_packet;
-	int ret = 0;
-
-	vstor_packet = &request->vstor_packet;
-	stor_device = get_out_stor_device(device);
-
-	if (!stor_device)
-		return -ENODEV;
-
-
-	request->device  = device;
-
-
-	vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
-
-	vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
-
-
-	vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
-
-
-	vstor_packet->vm_srb.data_transfer_length =
-	request->data_buffer.len;
-
-	vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
-
-	if (request->data_buffer.len) {
-		ret = vmbus_sendpacket_multipagebuffer(device->channel,
-				&request->data_buffer,
-				vstor_packet,
-				sizeof(struct vstor_packet),
-				(unsigned long)request);
-	} else {
-		ret = vmbus_sendpacket(device->channel, vstor_packet,
-				       sizeof(struct vstor_packet),
-				       (unsigned long)request,
-				       VM_PKT_DATA_INBAND,
-				       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	}
-
-	if (ret != 0)
-		return ret;
-
-	atomic_inc(&stor_device->num_outstanding_req);
-
-	put_stor_device(device);
-	return ret;
-}
-
-/*
- * The channel properties uniquely specify how the device is to be
- * presented to the guest. Map this information for use by the block
- * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
- * (storvsc_drv) and so scsi devices in the guest  are handled by
- * native upper level Linux drivers. Consequently, Hyper-V
- * block driver, while being a generic block driver, presently does not
- * deal with anything other than devices that would need to be presented
- * to the guest as an IDE disk.
- *
- * This function maps the channel properties as embedded in the input
- * parameter device_info onto information necessary to register the
- * corresponding block device.
- *
- * Currently, there is no way to stop the emulation of the block device
- * on the host side. And so, to prevent the native IDE drivers in Linux
- * from taking over these devices (to be managedby Hyper-V block
- * driver), we will take over if need be the major of the IDE controllers.
- *
- */
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-			    struct storvsc_major_info *major_info)
-{
-	static bool ide0_registered;
-	static bool ide1_registered;
-
-	/*
-	 * For now we only support IDE disks.
-	 */
-	major_info->devname = "ide";
-	major_info->diskname = "hd";
-
-	if (device_info->path_id) {
-		major_info->major = 22;
-		if (!ide1_registered) {
-			major_info->do_register = true;
-			ide1_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 3;
-		else
-			major_info->index = 2;
-
-		return 0;
-	} else {
-		major_info->major = 3;
-		if (!ide0_registered) {
-			major_info->do_register = true;
-			ide0_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 1;
-		else
-			major_info->index = 0;
-
-		return 0;
-	}
-
-	return -ENODEV;
-}
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 6e4725f..3ce43a3 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -36,6 +36,533 @@
 #include "hyperv.h"
 #include "hyperv_storage.h"
 
+
+/*
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/delay.h>
+
+#include "hyperv.h"
+#include "hyperv_storage.h"
+
+
+static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+
+	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
+	if (!stor_device)
+		return NULL;
+
+	stor_device->ref_count = 1;
+	stor_device->destroy = false;
+	init_waitqueue_head(&stor_device->waiting_to_drain);
+	stor_device->device = device;
+	device->ext = stor_device;
+
+	return stor_device;
+}
+
+static inline struct storvsc_device *get_in_stor_device(
+					struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+	if (!stor_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (stor_device->destroy &&
+		 (atomic_read(&stor_device->num_outstanding_req) == 0))
+		goto cleanup;
+	stor_device->ref_count++;
+cleanup:
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	return stor_device;
+}
+
+static int storvsc_channel_init(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	struct hv_storvsc_request *request;
+	struct vstor_packet *vstor_packet;
+	int ret, t;
+
+	stor_device = get_out_stor_device(device);
+	if (!stor_device)
+		return -ENODEV;
+
+	request = &stor_device->init_request;
+	vstor_packet = &request->vstor_packet;
+
+	/*
+	 * Now, initiate the vsc/vsp initialization protocol on the open
+	 * channel
+	 */
+	memset(request, 0, sizeof(struct hv_storvsc_request));
+	init_completion(&request->wait_event);
+	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+	/* reuse the packet for version range supported */
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
+	FILL_VMSTOR_REVISION(vstor_packet->version.revision);
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+	vstor_packet->storage_channel_properties.port_number =
+					stor_device->port_number;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
+	stor_device->target_id
+		= vstor_packet->storage_channel_properties.target_id;
+
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+cleanup:
+	put_stor_device(device);
+	return ret;
+}
+
+static void storvsc_on_io_completion(struct hv_device *device,
+				  struct vstor_packet *vstor_packet,
+				  struct hv_storvsc_request *request)
+{
+	struct storvsc_device *stor_device;
+	struct vstor_packet *stor_pkt;
+
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_pkt = &request->vstor_packet;
+
+
+	/* Copy over the status...etc */
+	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
+	stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
+	stor_pkt->vm_srb.sense_info_length =
+	vstor_packet->vm_srb.sense_info_length;
+
+	if (vstor_packet->vm_srb.scsi_status != 0 ||
+		vstor_packet->vm_srb.srb_status != 1){
+		DPRINT_WARN(STORVSC,
+			    "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
+			    stor_pkt->vm_srb.cdb[0],
+			    vstor_packet->vm_srb.scsi_status,
+			    vstor_packet->vm_srb.srb_status);
+	}
+
+	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
+		/* CHECK_CONDITION */
+		if (vstor_packet->vm_srb.srb_status & 0x80) {
+			/* autosense data available */
+			DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
+				    "valid - len %d\n", request,
+				    vstor_packet->vm_srb.sense_info_length);
+
+			memcpy(request->sense_buffer,
+			       vstor_packet->vm_srb.sense_data,
+			       vstor_packet->vm_srb.sense_info_length);
+
+		}
+	}
+
+	stor_pkt->vm_srb.data_transfer_length =
+	vstor_packet->vm_srb.data_transfer_length;
+
+	request->on_io_completion(request);
+
+	if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
+		stor_device->drain_notify)
+		wake_up(&stor_device->waiting_to_drain);
+
+
+}
+
+static void storvsc_on_receive(struct hv_device *device,
+			     struct vstor_packet *vstor_packet,
+			     struct hv_storvsc_request *request)
+{
+	switch (vstor_packet->operation) {
+	case VSTOR_OPERATION_COMPLETE_IO:
+		storvsc_on_io_completion(device, vstor_packet, request);
+		break;
+	case VSTOR_OPERATION_REMOVE_DEVICE:
+
+	default:
+		break;
+	}
+}
+
+static void storvsc_on_channel_callback(void *context)
+{
+	struct hv_device *device = (struct hv_device *)context;
+	struct storvsc_device *stor_device;
+	u32 bytes_recvd;
+	u64 request_id;
+	unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
+	struct hv_storvsc_request *request;
+	int ret;
+
+
+	stor_device = get_in_stor_device(device);
+	if (!stor_device)
+		return;
+
+	do {
+		ret = vmbus_recvpacket(device->channel, packet,
+				       ALIGN(sizeof(struct vstor_packet), 8),
+				       &bytes_recvd, &request_id);
+		if (ret == 0 && bytes_recvd > 0) {
+
+			request = (struct hv_storvsc_request *)
+					(unsigned long)request_id;
+
+			if ((request == &stor_device->init_request) ||
+			    (request == &stor_device->reset_request)) {
+
+				memcpy(&request->vstor_packet, packet,
+				       sizeof(struct vstor_packet));
+				complete(&request->wait_event);
+			} else {
+				storvsc_on_receive(device,
+						(struct vstor_packet *)packet,
+						request);
+			}
+		} else {
+			break;
+		}
+	} while (1);
+
+	put_stor_device(device);
+	return;
+}
+
+static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
+{
+	struct vmstorage_channel_properties props;
+	int ret;
+
+	memset(&props, 0, sizeof(struct vmstorage_channel_properties));
+
+	/* Open the channel */
+	ret = vmbus_open(device->channel,
+			 ring_size,
+			 ring_size,
+			 (void *)&props,
+			 sizeof(struct vmstorage_channel_properties),
+			 storvsc_on_channel_callback, device);
+
+	if (ret != 0)
+		return ret;
+
+	ret = storvsc_channel_init(device);
+
+	return ret;
+}
+
+int storvsc_dev_add(struct hv_device *device,
+					void *additional_info)
+{
+	struct storvsc_device *stor_device;
+	struct storvsc_device_info *device_info;
+	int ret = 0;
+
+	device_info = (struct storvsc_device_info *)additional_info;
+	stor_device = alloc_stor_device(device);
+	if (!stor_device)
+		return -ENOMEM;
+
+	/* Save the channel properties to our storvsc channel */
+
+	/*
+	 * If we support more than 1 scsi channel, we need to set the
+	 * port number here to the scsi channel but how do we get the
+	 * scsi channel prior to the bus scan.
+	 *
+	 * The host does not support this.
+	 */
+
+	stor_device->port_number = device_info->port_number;
+	/* Send it back up */
+	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
+	if (ret) {
+		kfree(stor_device);
+		return ret;
+	}
+	device_info->path_id = stor_device->path_id;
+	device_info->target_id = stor_device->target_id;
+
+	return ret;
+}
+
+int storvsc_dev_remove(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	/*
+	 * Since we currently hold a reference on the stor
+	 * device, it is safe to dereference the ext
+	 * pointer.
+	 */
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_device->destroy = true;
+
+	/*
+	 * At this point, all outbound traffic should be disable. We
+	 * only allow inbound traffic (responses) to proceed so that
+	 * outstanding requests can be completed.
+	 */
+
+	storvsc_wait_to_drain(stor_device);
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device->ref_count = 0;
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	/* Close the channel */
+	vmbus_close(device->channel);
+
+	kfree(stor_device);
+	return 0;
+}
+
+int storvsc_do_io(struct hv_device *device,
+			      struct hv_storvsc_request *request)
+{
+	struct storvsc_device *stor_device;
+	struct vstor_packet *vstor_packet;
+	int ret = 0;
+
+	vstor_packet = &request->vstor_packet;
+	stor_device = get_out_stor_device(device);
+
+	if (!stor_device)
+		return -ENODEV;
+
+
+	request->device  = device;
+
+
+	vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
+
+	vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
+
+
+	vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
+
+
+	vstor_packet->vm_srb.data_transfer_length =
+	request->data_buffer.len;
+
+	vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
+
+	if (request->data_buffer.len) {
+		ret = vmbus_sendpacket_multipagebuffer(device->channel,
+				&request->data_buffer,
+				vstor_packet,
+				sizeof(struct vstor_packet),
+				(unsigned long)request);
+	} else {
+		ret = vmbus_sendpacket(device->channel, vstor_packet,
+				       sizeof(struct vstor_packet),
+				       (unsigned long)request,
+				       VM_PKT_DATA_INBAND,
+				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	}
+
+	if (ret != 0)
+		return ret;
+
+	atomic_inc(&stor_device->num_outstanding_req);
+
+	put_stor_device(device);
+	return ret;
+}
+
+/*
+ * The channel properties uniquely specify how the device is to be
+ * presented to the guest. Map this information for use by the block
+ * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
+ * (storvsc_drv) and so scsi devices in the guest  are handled by
+ * native upper level Linux drivers. Consequently, Hyper-V
+ * block driver, while being a generic block driver, presently does not
+ * deal with anything other than devices that would need to be presented
+ * to the guest as an IDE disk.
+ *
+ * This function maps the channel properties as embedded in the input
+ * parameter device_info onto information necessary to register the
+ * corresponding block device.
+ *
+ * Currently, there is no way to stop the emulation of the block device
+ * on the host side. And so, to prevent the native IDE drivers in Linux
+ * from taking over these devices (to be managedby Hyper-V block
+ * driver), we will take over if need be the major of the IDE controllers.
+ *
+ */
+
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
+			    struct storvsc_major_info *major_info)
+{
+	static bool ide0_registered;
+	static bool ide1_registered;
+
+	/*
+	 * For now we only support IDE disks.
+	 */
+	major_info->devname = "ide";
+	major_info->diskname = "hd";
+
+	if (device_info->path_id) {
+		major_info->major = 22;
+		if (!ide1_registered) {
+			major_info->do_register = true;
+			ide1_registered = true;
+		} else
+			major_info->do_register = false;
+
+		if (device_info->target_id)
+			major_info->index = 3;
+		else
+			major_info->index = 2;
+
+		return 0;
+	} else {
+		major_info->major = 3;
+		if (!ide0_registered) {
+			major_info->do_register = true;
+			ide0_registered = true;
+		} else
+			major_info->do_register = false;
+
+		if (device_info->target_id)
+			major_info->index = 1;
+		else
+			major_info->index = 0;
+
+		return 0;
+	}
+
+	return -ENODEV;
+}
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 101/117] Staging: hv: storvsc: Include storvsc.c in storvsc_drv.c
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

As part of further cleanup of our storage drivers, include the content
of storvsc.c into storvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/Makefile      |    2 +-
 drivers/staging/hv/storvsc.c     |  526 -------------------------------------
 drivers/staging/hv/storvsc_drv.c |  527 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 528 insertions(+), 527 deletions(-)
 delete mode 100644 drivers/staging/hv/storvsc.c

diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bb89437..bd176b1 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -7,6 +7,6 @@ obj-$(CONFIG_HYPERV_MOUSE)	+= hv_mouse.o
 hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
 		 channel_mgmt.o ring_buffer.o
-hv_storvsc-y := storvsc_drv.o storvsc.o
+hv_storvsc-y := storvsc_drv.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
deleted file mode 100644
index 4d13044..0000000
--- a/drivers/staging/hv/storvsc.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/completion.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-
-#include "hyperv.h"
-#include "hyperv_storage.h"
-
-
-static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-
-	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
-	if (!stor_device)
-		return NULL;
-
-	stor_device->ref_count = 1;
-	stor_device->destroy = false;
-	init_waitqueue_head(&stor_device->waiting_to_drain);
-	stor_device->device = device;
-	device->ext = stor_device;
-
-	return stor_device;
-}
-
-static inline struct storvsc_device *get_in_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-	if (!stor_device)
-		goto cleanup;
-
-	/*
-	 * If the device is being destroyed; allow incoming
-	 * traffic only to cleanup outstanding requests.
-	 */
-	if (stor_device->destroy &&
-		 (atomic_read(&stor_device->num_outstanding_req) == 0))
-		goto cleanup;
-	stor_device->ref_count++;
-cleanup:
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	return stor_device;
-}
-
-static int storvsc_channel_init(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	struct hv_storvsc_request *request;
-	struct vstor_packet *vstor_packet;
-	int ret, t;
-
-	stor_device = get_out_stor_device(device);
-	if (!stor_device)
-		return -ENODEV;
-
-	request = &stor_device->init_request;
-	vstor_packet = &request->vstor_packet;
-
-	/*
-	 * Now, initiate the vsc/vsp initialization protocol on the open
-	 * channel
-	 */
-	memset(request, 0, sizeof(struct hv_storvsc_request));
-	init_completion(&request->wait_event);
-	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-	/* reuse the packet for version range supported */
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
-	FILL_VMSTOR_REVISION(vstor_packet->version.revision);
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-	vstor_packet->storage_channel_properties.port_number =
-					stor_device->port_number;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
-	stor_device->target_id
-		= vstor_packet->storage_channel_properties.target_id;
-
-	memset(vstor_packet, 0, sizeof(struct vstor_packet));
-	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0)
-		goto cleanup;
-
-
-cleanup:
-	put_stor_device(device);
-	return ret;
-}
-
-static void storvsc_on_io_completion(struct hv_device *device,
-				  struct vstor_packet *vstor_packet,
-				  struct hv_storvsc_request *request)
-{
-	struct storvsc_device *stor_device;
-	struct vstor_packet *stor_pkt;
-
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_pkt = &request->vstor_packet;
-
-
-	/* Copy over the status...etc */
-	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
-	stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
-	stor_pkt->vm_srb.sense_info_length =
-	vstor_packet->vm_srb.sense_info_length;
-
-	if (vstor_packet->vm_srb.scsi_status != 0 ||
-		vstor_packet->vm_srb.srb_status != 1){
-		DPRINT_WARN(STORVSC,
-			    "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
-			    stor_pkt->vm_srb.cdb[0],
-			    vstor_packet->vm_srb.scsi_status,
-			    vstor_packet->vm_srb.srb_status);
-	}
-
-	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
-		/* CHECK_CONDITION */
-		if (vstor_packet->vm_srb.srb_status & 0x80) {
-			/* autosense data available */
-			DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
-				    "valid - len %d\n", request,
-				    vstor_packet->vm_srb.sense_info_length);
-
-			memcpy(request->sense_buffer,
-			       vstor_packet->vm_srb.sense_data,
-			       vstor_packet->vm_srb.sense_info_length);
-
-		}
-	}
-
-	stor_pkt->vm_srb.data_transfer_length =
-	vstor_packet->vm_srb.data_transfer_length;
-
-	request->on_io_completion(request);
-
-	if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
-		stor_device->drain_notify)
-		wake_up(&stor_device->waiting_to_drain);
-
-
-}
-
-static void storvsc_on_receive(struct hv_device *device,
-			     struct vstor_packet *vstor_packet,
-			     struct hv_storvsc_request *request)
-{
-	switch (vstor_packet->operation) {
-	case VSTOR_OPERATION_COMPLETE_IO:
-		storvsc_on_io_completion(device, vstor_packet, request);
-		break;
-	case VSTOR_OPERATION_REMOVE_DEVICE:
-
-	default:
-		break;
-	}
-}
-
-static void storvsc_on_channel_callback(void *context)
-{
-	struct hv_device *device = (struct hv_device *)context;
-	struct storvsc_device *stor_device;
-	u32 bytes_recvd;
-	u64 request_id;
-	unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
-	struct hv_storvsc_request *request;
-	int ret;
-
-
-	stor_device = get_in_stor_device(device);
-	if (!stor_device)
-		return;
-
-	do {
-		ret = vmbus_recvpacket(device->channel, packet,
-				       ALIGN(sizeof(struct vstor_packet), 8),
-				       &bytes_recvd, &request_id);
-		if (ret == 0 && bytes_recvd > 0) {
-
-			request = (struct hv_storvsc_request *)
-					(unsigned long)request_id;
-
-			if ((request == &stor_device->init_request) ||
-			    (request == &stor_device->reset_request)) {
-
-				memcpy(&request->vstor_packet, packet,
-				       sizeof(struct vstor_packet));
-				complete(&request->wait_event);
-			} else {
-				storvsc_on_receive(device,
-						(struct vstor_packet *)packet,
-						request);
-			}
-		} else {
-			break;
-		}
-	} while (1);
-
-	put_stor_device(device);
-	return;
-}
-
-static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
-{
-	struct vmstorage_channel_properties props;
-	int ret;
-
-	memset(&props, 0, sizeof(struct vmstorage_channel_properties));
-
-	/* Open the channel */
-	ret = vmbus_open(device->channel,
-			 ring_size,
-			 ring_size,
-			 (void *)&props,
-			 sizeof(struct vmstorage_channel_properties),
-			 storvsc_on_channel_callback, device);
-
-	if (ret != 0)
-		return ret;
-
-	ret = storvsc_channel_init(device);
-
-	return ret;
-}
-
-int storvsc_dev_add(struct hv_device *device,
-					void *additional_info)
-{
-	struct storvsc_device *stor_device;
-	struct storvsc_device_info *device_info;
-	int ret = 0;
-
-	device_info = (struct storvsc_device_info *)additional_info;
-	stor_device = alloc_stor_device(device);
-	if (!stor_device)
-		return -ENOMEM;
-
-	/* Save the channel properties to our storvsc channel */
-
-	/*
-	 * If we support more than 1 scsi channel, we need to set the
-	 * port number here to the scsi channel but how do we get the
-	 * scsi channel prior to the bus scan.
-	 *
-	 * The host does not support this.
-	 */
-
-	stor_device->port_number = device_info->port_number;
-	/* Send it back up */
-	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-	if (ret) {
-		kfree(stor_device);
-		return ret;
-	}
-	device_info->path_id = stor_device->path_id;
-	device_info->target_id = stor_device->target_id;
-
-	return ret;
-}
-
-int storvsc_dev_remove(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	/*
-	 * Since we currently hold a reference on the stor
-	 * device, it is safe to dereference the ext
-	 * pointer.
-	 */
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_device->destroy = true;
-
-	/*
-	 * At this point, all outbound traffic should be disable. We
-	 * only allow inbound traffic (responses) to proceed so that
-	 * outstanding requests can be completed.
-	 */
-
-	storvsc_wait_to_drain(stor_device);
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device->ref_count = 0;
-	device->ext = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	/* Close the channel */
-	vmbus_close(device->channel);
-
-	kfree(stor_device);
-	return 0;
-}
-
-int storvsc_do_io(struct hv_device *device,
-			      struct hv_storvsc_request *request)
-{
-	struct storvsc_device *stor_device;
-	struct vstor_packet *vstor_packet;
-	int ret = 0;
-
-	vstor_packet = &request->vstor_packet;
-	stor_device = get_out_stor_device(device);
-
-	if (!stor_device)
-		return -ENODEV;
-
-
-	request->device  = device;
-
-
-	vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
-
-	vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
-
-
-	vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
-
-
-	vstor_packet->vm_srb.data_transfer_length =
-	request->data_buffer.len;
-
-	vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
-
-	if (request->data_buffer.len) {
-		ret = vmbus_sendpacket_multipagebuffer(device->channel,
-				&request->data_buffer,
-				vstor_packet,
-				sizeof(struct vstor_packet),
-				(unsigned long)request);
-	} else {
-		ret = vmbus_sendpacket(device->channel, vstor_packet,
-				       sizeof(struct vstor_packet),
-				       (unsigned long)request,
-				       VM_PKT_DATA_INBAND,
-				       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	}
-
-	if (ret != 0)
-		return ret;
-
-	atomic_inc(&stor_device->num_outstanding_req);
-
-	put_stor_device(device);
-	return ret;
-}
-
-/*
- * The channel properties uniquely specify how the device is to be
- * presented to the guest. Map this information for use by the block
- * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
- * (storvsc_drv) and so scsi devices in the guest  are handled by
- * native upper level Linux drivers. Consequently, Hyper-V
- * block driver, while being a generic block driver, presently does not
- * deal with anything other than devices that would need to be presented
- * to the guest as an IDE disk.
- *
- * This function maps the channel properties as embedded in the input
- * parameter device_info onto information necessary to register the
- * corresponding block device.
- *
- * Currently, there is no way to stop the emulation of the block device
- * on the host side. And so, to prevent the native IDE drivers in Linux
- * from taking over these devices (to be managedby Hyper-V block
- * driver), we will take over if need be the major of the IDE controllers.
- *
- */
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-			    struct storvsc_major_info *major_info)
-{
-	static bool ide0_registered;
-	static bool ide1_registered;
-
-	/*
-	 * For now we only support IDE disks.
-	 */
-	major_info->devname = "ide";
-	major_info->diskname = "hd";
-
-	if (device_info->path_id) {
-		major_info->major = 22;
-		if (!ide1_registered) {
-			major_info->do_register = true;
-			ide1_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 3;
-		else
-			major_info->index = 2;
-
-		return 0;
-	} else {
-		major_info->major = 3;
-		if (!ide0_registered) {
-			major_info->do_register = true;
-			ide0_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 1;
-		else
-			major_info->index = 0;
-
-		return 0;
-	}
-
-	return -ENODEV;
-}
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 6e4725f..3ce43a3 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -36,6 +36,533 @@
 #include "hyperv.h"
 #include "hyperv_storage.h"
 
+
+/*
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/delay.h>
+
+#include "hyperv.h"
+#include "hyperv_storage.h"
+
+
+static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+
+	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
+	if (!stor_device)
+		return NULL;
+
+	stor_device->ref_count = 1;
+	stor_device->destroy = false;
+	init_waitqueue_head(&stor_device->waiting_to_drain);
+	stor_device->device = device;
+	device->ext = stor_device;
+
+	return stor_device;
+}
+
+static inline struct storvsc_device *get_in_stor_device(
+					struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+	if (!stor_device)
+		goto cleanup;
+
+	/*
+	 * If the device is being destroyed; allow incoming
+	 * traffic only to cleanup outstanding requests.
+	 */
+	if (stor_device->destroy &&
+		 (atomic_read(&stor_device->num_outstanding_req) == 0))
+		goto cleanup;
+	stor_device->ref_count++;
+cleanup:
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	return stor_device;
+}
+
+static int storvsc_channel_init(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	struct hv_storvsc_request *request;
+	struct vstor_packet *vstor_packet;
+	int ret, t;
+
+	stor_device = get_out_stor_device(device);
+	if (!stor_device)
+		return -ENODEV;
+
+	request = &stor_device->init_request;
+	vstor_packet = &request->vstor_packet;
+
+	/*
+	 * Now, initiate the vsc/vsp initialization protocol on the open
+	 * channel
+	 */
+	memset(request, 0, sizeof(struct hv_storvsc_request));
+	init_completion(&request->wait_event);
+	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+	/* reuse the packet for version range supported */
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
+	FILL_VMSTOR_REVISION(vstor_packet->version.revision);
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+	vstor_packet->storage_channel_properties.port_number =
+					stor_device->port_number;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
+	stor_device->target_id
+		= vstor_packet->storage_channel_properties.target_id;
+
+	memset(vstor_packet, 0, sizeof(struct vstor_packet));
+	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+	    vstor_packet->status != 0)
+		goto cleanup;
+
+
+cleanup:
+	put_stor_device(device);
+	return ret;
+}
+
+static void storvsc_on_io_completion(struct hv_device *device,
+				  struct vstor_packet *vstor_packet,
+				  struct hv_storvsc_request *request)
+{
+	struct storvsc_device *stor_device;
+	struct vstor_packet *stor_pkt;
+
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_pkt = &request->vstor_packet;
+
+
+	/* Copy over the status...etc */
+	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
+	stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
+	stor_pkt->vm_srb.sense_info_length =
+	vstor_packet->vm_srb.sense_info_length;
+
+	if (vstor_packet->vm_srb.scsi_status != 0 ||
+		vstor_packet->vm_srb.srb_status != 1){
+		DPRINT_WARN(STORVSC,
+			    "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
+			    stor_pkt->vm_srb.cdb[0],
+			    vstor_packet->vm_srb.scsi_status,
+			    vstor_packet->vm_srb.srb_status);
+	}
+
+	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
+		/* CHECK_CONDITION */
+		if (vstor_packet->vm_srb.srb_status & 0x80) {
+			/* autosense data available */
+			DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
+				    "valid - len %d\n", request,
+				    vstor_packet->vm_srb.sense_info_length);
+
+			memcpy(request->sense_buffer,
+			       vstor_packet->vm_srb.sense_data,
+			       vstor_packet->vm_srb.sense_info_length);
+
+		}
+	}
+
+	stor_pkt->vm_srb.data_transfer_length =
+	vstor_packet->vm_srb.data_transfer_length;
+
+	request->on_io_completion(request);
+
+	if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
+		stor_device->drain_notify)
+		wake_up(&stor_device->waiting_to_drain);
+
+
+}
+
+static void storvsc_on_receive(struct hv_device *device,
+			     struct vstor_packet *vstor_packet,
+			     struct hv_storvsc_request *request)
+{
+	switch (vstor_packet->operation) {
+	case VSTOR_OPERATION_COMPLETE_IO:
+		storvsc_on_io_completion(device, vstor_packet, request);
+		break;
+	case VSTOR_OPERATION_REMOVE_DEVICE:
+
+	default:
+		break;
+	}
+}
+
+static void storvsc_on_channel_callback(void *context)
+{
+	struct hv_device *device = (struct hv_device *)context;
+	struct storvsc_device *stor_device;
+	u32 bytes_recvd;
+	u64 request_id;
+	unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
+	struct hv_storvsc_request *request;
+	int ret;
+
+
+	stor_device = get_in_stor_device(device);
+	if (!stor_device)
+		return;
+
+	do {
+		ret = vmbus_recvpacket(device->channel, packet,
+				       ALIGN(sizeof(struct vstor_packet), 8),
+				       &bytes_recvd, &request_id);
+		if (ret == 0 && bytes_recvd > 0) {
+
+			request = (struct hv_storvsc_request *)
+					(unsigned long)request_id;
+
+			if ((request == &stor_device->init_request) ||
+			    (request == &stor_device->reset_request)) {
+
+				memcpy(&request->vstor_packet, packet,
+				       sizeof(struct vstor_packet));
+				complete(&request->wait_event);
+			} else {
+				storvsc_on_receive(device,
+						(struct vstor_packet *)packet,
+						request);
+			}
+		} else {
+			break;
+		}
+	} while (1);
+
+	put_stor_device(device);
+	return;
+}
+
+static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
+{
+	struct vmstorage_channel_properties props;
+	int ret;
+
+	memset(&props, 0, sizeof(struct vmstorage_channel_properties));
+
+	/* Open the channel */
+	ret = vmbus_open(device->channel,
+			 ring_size,
+			 ring_size,
+			 (void *)&props,
+			 sizeof(struct vmstorage_channel_properties),
+			 storvsc_on_channel_callback, device);
+
+	if (ret != 0)
+		return ret;
+
+	ret = storvsc_channel_init(device);
+
+	return ret;
+}
+
+int storvsc_dev_add(struct hv_device *device,
+					void *additional_info)
+{
+	struct storvsc_device *stor_device;
+	struct storvsc_device_info *device_info;
+	int ret = 0;
+
+	device_info = (struct storvsc_device_info *)additional_info;
+	stor_device = alloc_stor_device(device);
+	if (!stor_device)
+		return -ENOMEM;
+
+	/* Save the channel properties to our storvsc channel */
+
+	/*
+	 * If we support more than 1 scsi channel, we need to set the
+	 * port number here to the scsi channel but how do we get the
+	 * scsi channel prior to the bus scan.
+	 *
+	 * The host does not support this.
+	 */
+
+	stor_device->port_number = device_info->port_number;
+	/* Send it back up */
+	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
+	if (ret) {
+		kfree(stor_device);
+		return ret;
+	}
+	device_info->path_id = stor_device->path_id;
+	device_info->target_id = stor_device->target_id;
+
+	return ret;
+}
+
+int storvsc_dev_remove(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	/*
+	 * Since we currently hold a reference on the stor
+	 * device, it is safe to dereference the ext
+	 * pointer.
+	 */
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_device->destroy = true;
+
+	/*
+	 * At this point, all outbound traffic should be disable. We
+	 * only allow inbound traffic (responses) to proceed so that
+	 * outstanding requests can be completed.
+	 */
+
+	storvsc_wait_to_drain(stor_device);
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device->ref_count = 0;
+	device->ext = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	/* Close the channel */
+	vmbus_close(device->channel);
+
+	kfree(stor_device);
+	return 0;
+}
+
+int storvsc_do_io(struct hv_device *device,
+			      struct hv_storvsc_request *request)
+{
+	struct storvsc_device *stor_device;
+	struct vstor_packet *vstor_packet;
+	int ret = 0;
+
+	vstor_packet = &request->vstor_packet;
+	stor_device = get_out_stor_device(device);
+
+	if (!stor_device)
+		return -ENODEV;
+
+
+	request->device  = device;
+
+
+	vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
+
+	vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
+
+
+	vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
+
+
+	vstor_packet->vm_srb.data_transfer_length =
+	request->data_buffer.len;
+
+	vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
+
+	if (request->data_buffer.len) {
+		ret = vmbus_sendpacket_multipagebuffer(device->channel,
+				&request->data_buffer,
+				vstor_packet,
+				sizeof(struct vstor_packet),
+				(unsigned long)request);
+	} else {
+		ret = vmbus_sendpacket(device->channel, vstor_packet,
+				       sizeof(struct vstor_packet),
+				       (unsigned long)request,
+				       VM_PKT_DATA_INBAND,
+				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	}
+
+	if (ret != 0)
+		return ret;
+
+	atomic_inc(&stor_device->num_outstanding_req);
+
+	put_stor_device(device);
+	return ret;
+}
+
+/*
+ * The channel properties uniquely specify how the device is to be
+ * presented to the guest. Map this information for use by the block
+ * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
+ * (storvsc_drv) and so scsi devices in the guest  are handled by
+ * native upper level Linux drivers. Consequently, Hyper-V
+ * block driver, while being a generic block driver, presently does not
+ * deal with anything other than devices that would need to be presented
+ * to the guest as an IDE disk.
+ *
+ * This function maps the channel properties as embedded in the input
+ * parameter device_info onto information necessary to register the
+ * corresponding block device.
+ *
+ * Currently, there is no way to stop the emulation of the block device
+ * on the host side. And so, to prevent the native IDE drivers in Linux
+ * from taking over these devices (to be managedby Hyper-V block
+ * driver), we will take over if need be the major of the IDE controllers.
+ *
+ */
+
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
+			    struct storvsc_major_info *major_info)
+{
+	static bool ide0_registered;
+	static bool ide1_registered;
+
+	/*
+	 * For now we only support IDE disks.
+	 */
+	major_info->devname = "ide";
+	major_info->diskname = "hd";
+
+	if (device_info->path_id) {
+		major_info->major = 22;
+		if (!ide1_registered) {
+			major_info->do_register = true;
+			ide1_registered = true;
+		} else
+			major_info->do_register = false;
+
+		if (device_info->target_id)
+			major_info->index = 3;
+		else
+			major_info->index = 2;
+
+		return 0;
+	} else {
+		major_info->major = 3;
+		if (!ide0_registered) {
+			major_info->do_register = true;
+			ide0_registered = true;
+		} else
+			major_info->do_register = false;
+
+		if (device_info->target_id)
+			major_info->index = 1;
+		else
+			major_info->index = 0;
+
+		return 0;
+	}
+
+	return -ENODEV;
+}
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 102/117] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup storvsc_drv.c after adding the contents of storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |  107 +++-----------------------------------
 1 files changed, 7 insertions(+), 100 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3ce43a3..5c06f5d 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -19,11 +19,17 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  *   K. Y. Srinivasan <kys@microsoft.com>
  */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
-#include <linux/blkdev.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -37,40 +43,6 @@
 #include "hyperv_storage.h"
 
 
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/completion.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-
-#include "hyperv.h"
-#include "hyperv_storage.h"
-
-
 static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -498,71 +470,6 @@ int storvsc_do_io(struct hv_device *device,
 	return ret;
 }
 
-/*
- * The channel properties uniquely specify how the device is to be
- * presented to the guest. Map this information for use by the block
- * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
- * (storvsc_drv) and so scsi devices in the guest  are handled by
- * native upper level Linux drivers. Consequently, Hyper-V
- * block driver, while being a generic block driver, presently does not
- * deal with anything other than devices that would need to be presented
- * to the guest as an IDE disk.
- *
- * This function maps the channel properties as embedded in the input
- * parameter device_info onto information necessary to register the
- * corresponding block device.
- *
- * Currently, there is no way to stop the emulation of the block device
- * on the host side. And so, to prevent the native IDE drivers in Linux
- * from taking over these devices (to be managedby Hyper-V block
- * driver), we will take over if need be the major of the IDE controllers.
- *
- */
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-			    struct storvsc_major_info *major_info)
-{
-	static bool ide0_registered;
-	static bool ide1_registered;
-
-	/*
-	 * For now we only support IDE disks.
-	 */
-	major_info->devname = "ide";
-	major_info->diskname = "hd";
-
-	if (device_info->path_id) {
-		major_info->major = 22;
-		if (!ide1_registered) {
-			major_info->do_register = true;
-			ide1_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 3;
-		else
-			major_info->index = 2;
-
-		return 0;
-	} else {
-		major_info->major = 3;
-		if (!ide0_registered) {
-			major_info->do_register = true;
-			ide0_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 1;
-		else
-			major_info->index = 0;
-
-		return 0;
-	}
-
-	return -ENODEV;
-}
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 102/117] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Cleanup storvsc_drv.c after adding the contents of storvsc.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |  107 +++-----------------------------------
 1 files changed, 7 insertions(+), 100 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3ce43a3..5c06f5d 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -19,11 +19,17 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  *   K. Y. Srinivasan <kys@microsoft.com>
  */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
-#include <linux/blkdev.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -37,40 +43,6 @@
 #include "hyperv_storage.h"
 
 
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/completion.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-
-#include "hyperv.h"
-#include "hyperv_storage.h"
-
-
 static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -498,71 +470,6 @@ int storvsc_do_io(struct hv_device *device,
 	return ret;
 }
 
-/*
- * The channel properties uniquely specify how the device is to be
- * presented to the guest. Map this information for use by the block
- * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
- * (storvsc_drv) and so scsi devices in the guest  are handled by
- * native upper level Linux drivers. Consequently, Hyper-V
- * block driver, while being a generic block driver, presently does not
- * deal with anything other than devices that would need to be presented
- * to the guest as an IDE disk.
- *
- * This function maps the channel properties as embedded in the input
- * parameter device_info onto information necessary to register the
- * corresponding block device.
- *
- * Currently, there is no way to stop the emulation of the block device
- * on the host side. And so, to prevent the native IDE drivers in Linux
- * from taking over these devices (to be managedby Hyper-V block
- * driver), we will take over if need be the major of the IDE controllers.
- *
- */
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-			    struct storvsc_major_info *major_info)
-{
-	static bool ide0_registered;
-	static bool ide1_registered;
-
-	/*
-	 * For now we only support IDE disks.
-	 */
-	major_info->devname = "ide";
-	major_info->diskname = "hd";
-
-	if (device_info->path_id) {
-		major_info->major = 22;
-		if (!ide1_registered) {
-			major_info->do_register = true;
-			ide1_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 3;
-		else
-			major_info->index = 2;
-
-		return 0;
-	} else {
-		major_info->major = 3;
-		if (!ide0_registered) {
-			major_info->do_register = true;
-			ide0_registered = true;
-		} else
-			major_info->do_register = false;
-
-		if (device_info->target_id)
-			major_info->index = 1;
-		else
-			major_info->index = 0;
-
-		return 0;
-	}
-
-	return -ENODEV;
-}
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 103/117] Staging: hv: storvsc: Add the contents of hyperv_storage.h to storvsc_drv.c
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

As part of further cleanup of storvsc, add the contents of hyperv_storage.h
to storvsc_drv.c.


Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |  341 -----------------------------------
 drivers/staging/hv/storvsc_drv.c    |  327 +++++++++++++++++++++++++++++++++-
 2 files changed, 326 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/staging/hv/hyperv_storage.h

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
deleted file mode 100644
index a1f3e27..0000000
--- a/drivers/staging/hv/hyperv_storage.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- *
- * Copyright (c) 2011, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-
-#ifndef _HYPERV_STORAGE_H
-#define _HYPERV_STORAGE_H
-
-
-/* vstorage.w revision number.  This is used in the case of a version match, */
-/* to alert the user that structure sizes may be mismatched even though the */
-/* protocol versions match. */
-
-
-#define REVISION_STRING(REVISION_) #REVISION_
-#define FILL_VMSTOR_REVISION(RESULT_LVALUE_)				\
-	do {								\
-		char *revision_string					\
-			= REVISION_STRING($Rev : 6 $) + 6;		\
-		RESULT_LVALUE_ = 0;					\
-		while (*revision_string >= '0'				\
-			&& *revision_string <= '9') {			\
-			RESULT_LVALUE_ *= 10;				\
-			RESULT_LVALUE_ += *revision_string - '0';	\
-			revision_string++;				\
-		}							\
-	} while (0)
-
-/* Major/minor macros.  Minor version is in LSB, meaning that earlier flat */
-/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */
-#define VMSTOR_PROTOCOL_MAJOR(VERSION_)		(((VERSION_) >> 8) & 0xff)
-#define VMSTOR_PROTOCOL_MINOR(VERSION_)		(((VERSION_))      & 0xff)
-#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
-						 (((MINOR_) & 0xff)))
-#define VMSTOR_INVALID_PROTOCOL_VERSION		(-1)
-
-/* Version history: */
-/* V1 Beta                    0.1 */
-/* V1 RC < 2008/1/31          1.0 */
-/* V1 RC > 2008/1/31          2.0 */
-#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
-
-
-
-
-/*  This will get replaced with the max transfer length that is possible on */
-/*  the host adapter. */
-/*  The max transfer length will be published when we offer a vmbus channel. */
-#define MAX_TRANSFER_LENGTH	0x40000
-#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) +	\
-			sizeof(struct vstor_packet) +		\
-			sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
-
-
-/*  Packet structure describing virtual storage requests. */
-enum vstor_packet_operation {
-	VSTOR_OPERATION_COMPLETE_IO		= 1,
-	VSTOR_OPERATION_REMOVE_DEVICE		= 2,
-	VSTOR_OPERATION_EXECUTE_SRB		= 3,
-	VSTOR_OPERATION_RESET_LUN		= 4,
-	VSTOR_OPERATION_RESET_ADAPTER		= 5,
-	VSTOR_OPERATION_RESET_BUS		= 6,
-	VSTOR_OPERATION_BEGIN_INITIALIZATION	= 7,
-	VSTOR_OPERATION_END_INITIALIZATION	= 8,
-	VSTOR_OPERATION_QUERY_PROTOCOL_VERSION	= 9,
-	VSTOR_OPERATION_QUERY_PROPERTIES	= 10,
-	VSTOR_OPERATION_MAXIMUM			= 10
-};
-
-/*
- * Platform neutral description of a scsi request -
- * this remains the same across the write regardless of 32/64 bit
- * note: it's patterned off the SCSI_PASS_THROUGH structure
- */
-#define CDB16GENERIC_LENGTH			0x10
-
-#ifndef SENSE_BUFFER_SIZE
-#define SENSE_BUFFER_SIZE			0x12
-#endif
-
-#define MAX_DATA_BUF_LEN_WITH_PADDING		0x14
-
-struct vmscsi_request {
-	unsigned short length;
-	unsigned char srb_status;
-	unsigned char scsi_status;
-
-	unsigned char port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-	unsigned char lun;
-
-	unsigned char cdb_length;
-	unsigned char sense_info_length;
-	unsigned char data_in;
-	unsigned char reserved;
-
-	unsigned int data_transfer_length;
-
-	union {
-		unsigned char cdb[CDB16GENERIC_LENGTH];
-		unsigned char sense_data[SENSE_BUFFER_SIZE];
-		unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
-	};
-} __attribute((packed));
-
-
-/*
- * This structure is sent during the intialization phase to get the different
- * properties of the channel.
- */
-struct vmstorage_channel_properties {
-	unsigned short protocol_version;
-	unsigned char path_id;
-	unsigned char target_id;
-
-	/* Note: port number is only really known on the client side */
-	unsigned int port_number;
-	unsigned int flags;
-	unsigned int max_transfer_bytes;
-
-	/*  This id is unique for each channel and will correspond with */
-	/*  vendor specific data in the inquirydata */
-	unsigned long long unique_id;
-} __packed;
-
-/*  This structure is sent during the storage protocol negotiations. */
-struct vmstorage_protocol_version {
-	/* Major (MSW) and minor (LSW) version numbers. */
-	unsigned short major_minor;
-
-	/*
-	 * Revision number is auto-incremented whenever this file is changed
-	 * (See FILL_VMSTOR_REVISION macro above).  Mismatch does not
-	 * definitely indicate incompatibility--but it does indicate mismatched
-	 * builds.
-	 */
-	unsigned short revision;
-} __packed;
-
-/* Channel Property Flags */
-#define STORAGE_CHANNEL_REMOVABLE_FLAG		0x1
-#define STORAGE_CHANNEL_EMULATED_IDE_FLAG	0x2
-
-struct vstor_packet {
-	/* Requested operation type */
-	enum vstor_packet_operation operation;
-
-	/*  Flags - see below for values */
-	unsigned int flags;
-
-	/* Status of the request returned from the server side. */
-	unsigned int status;
-
-	/* Data payload area */
-	union {
-		/*
-		 * Structure used to forward SCSI commands from the
-		 * client to the server.
-		 */
-		struct vmscsi_request vm_srb;
-
-		/* Structure used to query channel properties. */
-		struct vmstorage_channel_properties storage_channel_properties;
-
-		/* Used during version negotiations. */
-		struct vmstorage_protocol_version version;
-	};
-} __packed;
-
-/* Packet flags */
-/*
- * This flag indicates that the server should send back a completion for this
- * packet.
- */
-#define REQUEST_COMPLETION_FLAG	0x1
-
-/*  This is the set of flags that the vsc can set in any packets it sends */
-#define VSC_LEGAL_FLAGS		(REQUEST_COMPLETION_FLAG)
-
-
-#include <linux/kernel.h>
-#include <linux/wait.h>
-#include "hyperv_storage.h"
-#include "hyperv.h"
-
-/* Defines */
-#define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
-#define BLKVSC_RING_BUFFER_SIZE				(20*PAGE_SIZE)
-
-#define STORVSC_MAX_IO_REQUESTS				128
-
-/*
- * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
- * reality, the path/target is not used (ie always set to 0) so our
- * scsi host adapter essentially has 1 bus with 1 target that contains
- * up to 256 luns.
- */
-#define STORVSC_MAX_LUNS_PER_TARGET			64
-#define STORVSC_MAX_TARGETS				1
-#define STORVSC_MAX_CHANNELS				1
-
-struct hv_storvsc_request;
-
-/* Matches Windows-end */
-enum storvsc_request_type {
-	WRITE_TYPE,
-	READ_TYPE,
-	UNKNOWN_TYPE,
-};
-
-
-struct hv_storvsc_request {
-	struct hv_storvsc_request *request;
-	struct hv_device *device;
-
-	/* Synchronize the request/response if needed */
-	struct completion wait_event;
-
-	unsigned char *sense_buffer;
-	void *context;
-	void (*on_io_completion)(struct hv_storvsc_request *request);
-	struct hv_multipage_buffer data_buffer;
-
-	struct vstor_packet vstor_packet;
-};
-
-
-struct storvsc_device_info {
-	u32 ring_buffer_size;
-	unsigned int port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-};
-
-struct storvsc_major_info {
-	int major;
-	int index;
-	bool do_register;
-	char *devname;
-	char *diskname;
-};
-
-/* A storvsc device is a device object that contains a vmbus channel */
-struct storvsc_device {
-	struct hv_device *device;
-
-	/* 0 indicates the device is being destroyed */
-	int	 ref_count;
-	bool	 destroy;
-	bool	 drain_notify;
-	atomic_t num_outstanding_req;
-
-	wait_queue_head_t waiting_to_drain;
-
-	/*
-	 * Each unique Port/Path/Target represents 1 channel ie scsi
-	 * controller. In reality, the pathid, targetid is always 0
-	 * and the port is set by us
-	 */
-	unsigned int port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-
-	/* Used for vsc/vsp channel reset process */
-	struct hv_storvsc_request init_request;
-	struct hv_storvsc_request reset_request;
-};
-
-
-static inline struct storvsc_device *get_out_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (stor_device->ref_count) &&
-		!stor_device->destroy)
-		stor_device->ref_count++;
-	else
-		stor_device = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	return stor_device;
-}
-
-
-static inline void put_stor_device(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_device->ref_count--;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-}
-
-static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
-{
-	dev->drain_notify = true;
-	wait_event(dev->waiting_to_drain,
-		   atomic_read(&dev->num_outstanding_req) == 0);
-	dev->drain_notify = false;
-}
-
-/* Interface */
-
-int storvsc_dev_add(struct hv_device *device,
-				void *additional_info);
-int storvsc_dev_remove(struct hv_device *device);
-
-int storvsc_do_io(struct hv_device *device,
-				struct hv_storvsc_request *request);
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-				struct storvsc_major_info *major_info);
-
-#endif /* _HYPERV_STORAGE_H */
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 5c06f5d..463b428 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -40,7 +40,332 @@
 #include <scsi/scsi_dbg.h>
 
 #include "hyperv.h"
-#include "hyperv_storage.h"
+
+
+/*
+ *
+ * Copyright (c) 2011, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+
+
+
+/* vstorage.w revision number.  This is used in the case of a version match, */
+/* to alert the user that structure sizes may be mismatched even though the */
+/* protocol versions match. */
+
+
+#define REVISION_STRING(REVISION_) #REVISION_
+#define FILL_VMSTOR_REVISION(RESULT_LVALUE_)				\
+	do {								\
+		char *revision_string					\
+			= REVISION_STRING($Rev : 6 $) + 6;		\
+		RESULT_LVALUE_ = 0;					\
+		while (*revision_string >= '0'				\
+			&& *revision_string <= '9') {			\
+			RESULT_LVALUE_ *= 10;				\
+			RESULT_LVALUE_ += *revision_string - '0';	\
+			revision_string++;				\
+		}							\
+	} while (0)
+
+/* Major/minor macros.  Minor version is in LSB, meaning that earlier flat */
+/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */
+#define VMSTOR_PROTOCOL_MAJOR(VERSION_)		(((VERSION_) >> 8) & 0xff)
+#define VMSTOR_PROTOCOL_MINOR(VERSION_)		(((VERSION_))      & 0xff)
+#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
+						 (((MINOR_) & 0xff)))
+#define VMSTOR_INVALID_PROTOCOL_VERSION		(-1)
+
+/* Version history: */
+/* V1 Beta                    0.1 */
+/* V1 RC < 2008/1/31          1.0 */
+/* V1 RC > 2008/1/31          2.0 */
+#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
+
+
+
+
+/*  This will get replaced with the max transfer length that is possible on */
+/*  the host adapter. */
+/*  The max transfer length will be published when we offer a vmbus channel. */
+#define MAX_TRANSFER_LENGTH	0x40000
+#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) +	\
+			sizeof(struct vstor_packet) +		\
+			sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
+
+
+/*  Packet structure describing virtual storage requests. */
+enum vstor_packet_operation {
+	VSTOR_OPERATION_COMPLETE_IO		= 1,
+	VSTOR_OPERATION_REMOVE_DEVICE		= 2,
+	VSTOR_OPERATION_EXECUTE_SRB		= 3,
+	VSTOR_OPERATION_RESET_LUN		= 4,
+	VSTOR_OPERATION_RESET_ADAPTER		= 5,
+	VSTOR_OPERATION_RESET_BUS		= 6,
+	VSTOR_OPERATION_BEGIN_INITIALIZATION	= 7,
+	VSTOR_OPERATION_END_INITIALIZATION	= 8,
+	VSTOR_OPERATION_QUERY_PROTOCOL_VERSION	= 9,
+	VSTOR_OPERATION_QUERY_PROPERTIES	= 10,
+	VSTOR_OPERATION_MAXIMUM			= 10
+};
+
+/*
+ * Platform neutral description of a scsi request -
+ * this remains the same across the write regardless of 32/64 bit
+ * note: it's patterned off the SCSI_PASS_THROUGH structure
+ */
+#define CDB16GENERIC_LENGTH			0x10
+
+#ifndef SENSE_BUFFER_SIZE
+#define SENSE_BUFFER_SIZE			0x12
+#endif
+
+#define MAX_DATA_BUF_LEN_WITH_PADDING		0x14
+
+struct vmscsi_request {
+	unsigned short length;
+	unsigned char srb_status;
+	unsigned char scsi_status;
+
+	unsigned char port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+	unsigned char lun;
+
+	unsigned char cdb_length;
+	unsigned char sense_info_length;
+	unsigned char data_in;
+	unsigned char reserved;
+
+	unsigned int data_transfer_length;
+
+	union {
+		unsigned char cdb[CDB16GENERIC_LENGTH];
+		unsigned char sense_data[SENSE_BUFFER_SIZE];
+		unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
+	};
+} __attribute((packed));
+
+
+/*
+ * This structure is sent during the intialization phase to get the different
+ * properties of the channel.
+ */
+struct vmstorage_channel_properties {
+	unsigned short protocol_version;
+	unsigned char path_id;
+	unsigned char target_id;
+
+	/* Note: port number is only really known on the client side */
+	unsigned int port_number;
+	unsigned int flags;
+	unsigned int max_transfer_bytes;
+
+	/*  This id is unique for each channel and will correspond with */
+	/*  vendor specific data in the inquirydata */
+	unsigned long long unique_id;
+} __packed;
+
+/*  This structure is sent during the storage protocol negotiations. */
+struct vmstorage_protocol_version {
+	/* Major (MSW) and minor (LSW) version numbers. */
+	unsigned short major_minor;
+
+	/*
+	 * Revision number is auto-incremented whenever this file is changed
+	 * (See FILL_VMSTOR_REVISION macro above).  Mismatch does not
+	 * definitely indicate incompatibility--but it does indicate mismatched
+	 * builds.
+	 */
+	unsigned short revision;
+} __packed;
+
+/* Channel Property Flags */
+#define STORAGE_CHANNEL_REMOVABLE_FLAG		0x1
+#define STORAGE_CHANNEL_EMULATED_IDE_FLAG	0x2
+
+struct vstor_packet {
+	/* Requested operation type */
+	enum vstor_packet_operation operation;
+
+	/*  Flags - see below for values */
+	unsigned int flags;
+
+	/* Status of the request returned from the server side. */
+	unsigned int status;
+
+	/* Data payload area */
+	union {
+		/*
+		 * Structure used to forward SCSI commands from the
+		 * client to the server.
+		 */
+		struct vmscsi_request vm_srb;
+
+		/* Structure used to query channel properties. */
+		struct vmstorage_channel_properties storage_channel_properties;
+
+		/* Used during version negotiations. */
+		struct vmstorage_protocol_version version;
+	};
+} __packed;
+
+/* Packet flags */
+/*
+ * This flag indicates that the server should send back a completion for this
+ * packet.
+ */
+#define REQUEST_COMPLETION_FLAG	0x1
+
+/*  This is the set of flags that the vsc can set in any packets it sends */
+#define VSC_LEGAL_FLAGS		(REQUEST_COMPLETION_FLAG)
+
+
+#include <linux/kernel.h>
+#include <linux/wait.h>
+#include "hyperv.h"
+
+/* Defines */
+#define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
+#define BLKVSC_RING_BUFFER_SIZE				(20*PAGE_SIZE)
+
+#define STORVSC_MAX_IO_REQUESTS				128
+
+/*
+ * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
+ * reality, the path/target is not used (ie always set to 0) so our
+ * scsi host adapter essentially has 1 bus with 1 target that contains
+ * up to 256 luns.
+ */
+#define STORVSC_MAX_LUNS_PER_TARGET			64
+#define STORVSC_MAX_TARGETS				1
+#define STORVSC_MAX_CHANNELS				1
+
+struct hv_storvsc_request;
+
+/* Matches Windows-end */
+enum storvsc_request_type {
+	WRITE_TYPE,
+	READ_TYPE,
+	UNKNOWN_TYPE,
+};
+
+
+struct hv_storvsc_request {
+	struct hv_storvsc_request *request;
+	struct hv_device *device;
+
+	/* Synchronize the request/response if needed */
+	struct completion wait_event;
+
+	unsigned char *sense_buffer;
+	void *context;
+	void (*on_io_completion)(struct hv_storvsc_request *request);
+	struct hv_multipage_buffer data_buffer;
+
+	struct vstor_packet vstor_packet;
+};
+
+
+struct storvsc_device_info {
+	u32 ring_buffer_size;
+	unsigned int port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+};
+
+struct storvsc_major_info {
+	int major;
+	int index;
+	bool do_register;
+	char *devname;
+	char *diskname;
+};
+
+/* A storvsc device is a device object that contains a vmbus channel */
+struct storvsc_device {
+	struct hv_device *device;
+
+	/* 0 indicates the device is being destroyed */
+	int	 ref_count;
+	bool	 destroy;
+	bool	 drain_notify;
+	atomic_t num_outstanding_req;
+
+	wait_queue_head_t waiting_to_drain;
+
+	/*
+	 * Each unique Port/Path/Target represents 1 channel ie scsi
+	 * controller. In reality, the pathid, targetid is always 0
+	 * and the port is set by us
+	 */
+	unsigned int port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+
+	/* Used for vsc/vsp channel reset process */
+	struct hv_storvsc_request init_request;
+	struct hv_storvsc_request reset_request;
+};
+
+
+static inline struct storvsc_device *get_out_stor_device(
+					struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+	if (stor_device && (stor_device->ref_count) &&
+		!stor_device->destroy)
+		stor_device->ref_count++;
+	else
+		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	return stor_device;
+}
+
+
+static inline void put_stor_device(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_device->ref_count--;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+}
+
+static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
+{
+	dev->drain_notify = true;
+	wait_event(dev->waiting_to_drain,
+		   atomic_read(&dev->num_outstanding_req) == 0);
+	dev->drain_notify = false;
+}
 
 
 static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 103/117] Staging: hv: storvsc: Add the contents of hyperv_storage.h to storvsc_drv.c
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

As part of further cleanup of storvsc, add the contents of hyperv_storage.h
to storvsc_drv.c.


Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_storage.h |  341 -----------------------------------
 drivers/staging/hv/storvsc_drv.c    |  327 +++++++++++++++++++++++++++++++++-
 2 files changed, 326 insertions(+), 342 deletions(-)
 delete mode 100644 drivers/staging/hv/hyperv_storage.h

diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
deleted file mode 100644
index a1f3e27..0000000
--- a/drivers/staging/hv/hyperv_storage.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- *
- * Copyright (c) 2011, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-
-#ifndef _HYPERV_STORAGE_H
-#define _HYPERV_STORAGE_H
-
-
-/* vstorage.w revision number.  This is used in the case of a version match, */
-/* to alert the user that structure sizes may be mismatched even though the */
-/* protocol versions match. */
-
-
-#define REVISION_STRING(REVISION_) #REVISION_
-#define FILL_VMSTOR_REVISION(RESULT_LVALUE_)				\
-	do {								\
-		char *revision_string					\
-			= REVISION_STRING($Rev : 6 $) + 6;		\
-		RESULT_LVALUE_ = 0;					\
-		while (*revision_string >= '0'				\
-			&& *revision_string <= '9') {			\
-			RESULT_LVALUE_ *= 10;				\
-			RESULT_LVALUE_ += *revision_string - '0';	\
-			revision_string++;				\
-		}							\
-	} while (0)
-
-/* Major/minor macros.  Minor version is in LSB, meaning that earlier flat */
-/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */
-#define VMSTOR_PROTOCOL_MAJOR(VERSION_)		(((VERSION_) >> 8) & 0xff)
-#define VMSTOR_PROTOCOL_MINOR(VERSION_)		(((VERSION_))      & 0xff)
-#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
-						 (((MINOR_) & 0xff)))
-#define VMSTOR_INVALID_PROTOCOL_VERSION		(-1)
-
-/* Version history: */
-/* V1 Beta                    0.1 */
-/* V1 RC < 2008/1/31          1.0 */
-/* V1 RC > 2008/1/31          2.0 */
-#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
-
-
-
-
-/*  This will get replaced with the max transfer length that is possible on */
-/*  the host adapter. */
-/*  The max transfer length will be published when we offer a vmbus channel. */
-#define MAX_TRANSFER_LENGTH	0x40000
-#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) +	\
-			sizeof(struct vstor_packet) +		\
-			sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
-
-
-/*  Packet structure describing virtual storage requests. */
-enum vstor_packet_operation {
-	VSTOR_OPERATION_COMPLETE_IO		= 1,
-	VSTOR_OPERATION_REMOVE_DEVICE		= 2,
-	VSTOR_OPERATION_EXECUTE_SRB		= 3,
-	VSTOR_OPERATION_RESET_LUN		= 4,
-	VSTOR_OPERATION_RESET_ADAPTER		= 5,
-	VSTOR_OPERATION_RESET_BUS		= 6,
-	VSTOR_OPERATION_BEGIN_INITIALIZATION	= 7,
-	VSTOR_OPERATION_END_INITIALIZATION	= 8,
-	VSTOR_OPERATION_QUERY_PROTOCOL_VERSION	= 9,
-	VSTOR_OPERATION_QUERY_PROPERTIES	= 10,
-	VSTOR_OPERATION_MAXIMUM			= 10
-};
-
-/*
- * Platform neutral description of a scsi request -
- * this remains the same across the write regardless of 32/64 bit
- * note: it's patterned off the SCSI_PASS_THROUGH structure
- */
-#define CDB16GENERIC_LENGTH			0x10
-
-#ifndef SENSE_BUFFER_SIZE
-#define SENSE_BUFFER_SIZE			0x12
-#endif
-
-#define MAX_DATA_BUF_LEN_WITH_PADDING		0x14
-
-struct vmscsi_request {
-	unsigned short length;
-	unsigned char srb_status;
-	unsigned char scsi_status;
-
-	unsigned char port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-	unsigned char lun;
-
-	unsigned char cdb_length;
-	unsigned char sense_info_length;
-	unsigned char data_in;
-	unsigned char reserved;
-
-	unsigned int data_transfer_length;
-
-	union {
-		unsigned char cdb[CDB16GENERIC_LENGTH];
-		unsigned char sense_data[SENSE_BUFFER_SIZE];
-		unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
-	};
-} __attribute((packed));
-
-
-/*
- * This structure is sent during the intialization phase to get the different
- * properties of the channel.
- */
-struct vmstorage_channel_properties {
-	unsigned short protocol_version;
-	unsigned char path_id;
-	unsigned char target_id;
-
-	/* Note: port number is only really known on the client side */
-	unsigned int port_number;
-	unsigned int flags;
-	unsigned int max_transfer_bytes;
-
-	/*  This id is unique for each channel and will correspond with */
-	/*  vendor specific data in the inquirydata */
-	unsigned long long unique_id;
-} __packed;
-
-/*  This structure is sent during the storage protocol negotiations. */
-struct vmstorage_protocol_version {
-	/* Major (MSW) and minor (LSW) version numbers. */
-	unsigned short major_minor;
-
-	/*
-	 * Revision number is auto-incremented whenever this file is changed
-	 * (See FILL_VMSTOR_REVISION macro above).  Mismatch does not
-	 * definitely indicate incompatibility--but it does indicate mismatched
-	 * builds.
-	 */
-	unsigned short revision;
-} __packed;
-
-/* Channel Property Flags */
-#define STORAGE_CHANNEL_REMOVABLE_FLAG		0x1
-#define STORAGE_CHANNEL_EMULATED_IDE_FLAG	0x2
-
-struct vstor_packet {
-	/* Requested operation type */
-	enum vstor_packet_operation operation;
-
-	/*  Flags - see below for values */
-	unsigned int flags;
-
-	/* Status of the request returned from the server side. */
-	unsigned int status;
-
-	/* Data payload area */
-	union {
-		/*
-		 * Structure used to forward SCSI commands from the
-		 * client to the server.
-		 */
-		struct vmscsi_request vm_srb;
-
-		/* Structure used to query channel properties. */
-		struct vmstorage_channel_properties storage_channel_properties;
-
-		/* Used during version negotiations. */
-		struct vmstorage_protocol_version version;
-	};
-} __packed;
-
-/* Packet flags */
-/*
- * This flag indicates that the server should send back a completion for this
- * packet.
- */
-#define REQUEST_COMPLETION_FLAG	0x1
-
-/*  This is the set of flags that the vsc can set in any packets it sends */
-#define VSC_LEGAL_FLAGS		(REQUEST_COMPLETION_FLAG)
-
-
-#include <linux/kernel.h>
-#include <linux/wait.h>
-#include "hyperv_storage.h"
-#include "hyperv.h"
-
-/* Defines */
-#define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
-#define BLKVSC_RING_BUFFER_SIZE				(20*PAGE_SIZE)
-
-#define STORVSC_MAX_IO_REQUESTS				128
-
-/*
- * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
- * reality, the path/target is not used (ie always set to 0) so our
- * scsi host adapter essentially has 1 bus with 1 target that contains
- * up to 256 luns.
- */
-#define STORVSC_MAX_LUNS_PER_TARGET			64
-#define STORVSC_MAX_TARGETS				1
-#define STORVSC_MAX_CHANNELS				1
-
-struct hv_storvsc_request;
-
-/* Matches Windows-end */
-enum storvsc_request_type {
-	WRITE_TYPE,
-	READ_TYPE,
-	UNKNOWN_TYPE,
-};
-
-
-struct hv_storvsc_request {
-	struct hv_storvsc_request *request;
-	struct hv_device *device;
-
-	/* Synchronize the request/response if needed */
-	struct completion wait_event;
-
-	unsigned char *sense_buffer;
-	void *context;
-	void (*on_io_completion)(struct hv_storvsc_request *request);
-	struct hv_multipage_buffer data_buffer;
-
-	struct vstor_packet vstor_packet;
-};
-
-
-struct storvsc_device_info {
-	u32 ring_buffer_size;
-	unsigned int port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-};
-
-struct storvsc_major_info {
-	int major;
-	int index;
-	bool do_register;
-	char *devname;
-	char *diskname;
-};
-
-/* A storvsc device is a device object that contains a vmbus channel */
-struct storvsc_device {
-	struct hv_device *device;
-
-	/* 0 indicates the device is being destroyed */
-	int	 ref_count;
-	bool	 destroy;
-	bool	 drain_notify;
-	atomic_t num_outstanding_req;
-
-	wait_queue_head_t waiting_to_drain;
-
-	/*
-	 * Each unique Port/Path/Target represents 1 channel ie scsi
-	 * controller. In reality, the pathid, targetid is always 0
-	 * and the port is set by us
-	 */
-	unsigned int port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-
-	/* Used for vsc/vsp channel reset process */
-	struct hv_storvsc_request init_request;
-	struct hv_storvsc_request reset_request;
-};
-
-
-static inline struct storvsc_device *get_out_stor_device(
-					struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-	if (stor_device && (stor_device->ref_count) &&
-		!stor_device->destroy)
-		stor_device->ref_count++;
-	else
-		stor_device = NULL;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-
-	return stor_device;
-}
-
-
-static inline void put_stor_device(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	unsigned long flags;
-
-	spin_lock_irqsave(&device->ext_lock, flags);
-	stor_device = (struct storvsc_device *)device->ext;
-
-	stor_device->ref_count--;
-	spin_unlock_irqrestore(&device->ext_lock, flags);
-}
-
-static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
-{
-	dev->drain_notify = true;
-	wait_event(dev->waiting_to_drain,
-		   atomic_read(&dev->num_outstanding_req) == 0);
-	dev->drain_notify = false;
-}
-
-/* Interface */
-
-int storvsc_dev_add(struct hv_device *device,
-				void *additional_info);
-int storvsc_dev_remove(struct hv_device *device);
-
-int storvsc_do_io(struct hv_device *device,
-				struct hv_storvsc_request *request);
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-				struct storvsc_major_info *major_info);
-
-#endif /* _HYPERV_STORAGE_H */
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 5c06f5d..463b428 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -40,7 +40,332 @@
 #include <scsi/scsi_dbg.h>
 
 #include "hyperv.h"
-#include "hyperv_storage.h"
+
+
+/*
+ *
+ * Copyright (c) 2011, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+
+
+
+/* vstorage.w revision number.  This is used in the case of a version match, */
+/* to alert the user that structure sizes may be mismatched even though the */
+/* protocol versions match. */
+
+
+#define REVISION_STRING(REVISION_) #REVISION_
+#define FILL_VMSTOR_REVISION(RESULT_LVALUE_)				\
+	do {								\
+		char *revision_string					\
+			= REVISION_STRING($Rev : 6 $) + 6;		\
+		RESULT_LVALUE_ = 0;					\
+		while (*revision_string >= '0'				\
+			&& *revision_string <= '9') {			\
+			RESULT_LVALUE_ *= 10;				\
+			RESULT_LVALUE_ += *revision_string - '0';	\
+			revision_string++;				\
+		}							\
+	} while (0)
+
+/* Major/minor macros.  Minor version is in LSB, meaning that earlier flat */
+/* version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1). */
+#define VMSTOR_PROTOCOL_MAJOR(VERSION_)		(((VERSION_) >> 8) & 0xff)
+#define VMSTOR_PROTOCOL_MINOR(VERSION_)		(((VERSION_))      & 0xff)
+#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_)	((((MAJOR_) & 0xff) << 8) | \
+						 (((MINOR_) & 0xff)))
+#define VMSTOR_INVALID_PROTOCOL_VERSION		(-1)
+
+/* Version history: */
+/* V1 Beta                    0.1 */
+/* V1 RC < 2008/1/31          1.0 */
+/* V1 RC > 2008/1/31          2.0 */
+#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
+
+
+
+
+/*  This will get replaced with the max transfer length that is possible on */
+/*  the host adapter. */
+/*  The max transfer length will be published when we offer a vmbus channel. */
+#define MAX_TRANSFER_LENGTH	0x40000
+#define DEFAULT_PACKET_SIZE (sizeof(struct vmdata_gpa_direct) +	\
+			sizeof(struct vstor_packet) +		\
+			sizesizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
+
+
+/*  Packet structure describing virtual storage requests. */
+enum vstor_packet_operation {
+	VSTOR_OPERATION_COMPLETE_IO		= 1,
+	VSTOR_OPERATION_REMOVE_DEVICE		= 2,
+	VSTOR_OPERATION_EXECUTE_SRB		= 3,
+	VSTOR_OPERATION_RESET_LUN		= 4,
+	VSTOR_OPERATION_RESET_ADAPTER		= 5,
+	VSTOR_OPERATION_RESET_BUS		= 6,
+	VSTOR_OPERATION_BEGIN_INITIALIZATION	= 7,
+	VSTOR_OPERATION_END_INITIALIZATION	= 8,
+	VSTOR_OPERATION_QUERY_PROTOCOL_VERSION	= 9,
+	VSTOR_OPERATION_QUERY_PROPERTIES	= 10,
+	VSTOR_OPERATION_MAXIMUM			= 10
+};
+
+/*
+ * Platform neutral description of a scsi request -
+ * this remains the same across the write regardless of 32/64 bit
+ * note: it's patterned off the SCSI_PASS_THROUGH structure
+ */
+#define CDB16GENERIC_LENGTH			0x10
+
+#ifndef SENSE_BUFFER_SIZE
+#define SENSE_BUFFER_SIZE			0x12
+#endif
+
+#define MAX_DATA_BUF_LEN_WITH_PADDING		0x14
+
+struct vmscsi_request {
+	unsigned short length;
+	unsigned char srb_status;
+	unsigned char scsi_status;
+
+	unsigned char port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+	unsigned char lun;
+
+	unsigned char cdb_length;
+	unsigned char sense_info_length;
+	unsigned char data_in;
+	unsigned char reserved;
+
+	unsigned int data_transfer_length;
+
+	union {
+		unsigned char cdb[CDB16GENERIC_LENGTH];
+		unsigned char sense_data[SENSE_BUFFER_SIZE];
+		unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
+	};
+} __attribute((packed));
+
+
+/*
+ * This structure is sent during the intialization phase to get the different
+ * properties of the channel.
+ */
+struct vmstorage_channel_properties {
+	unsigned short protocol_version;
+	unsigned char path_id;
+	unsigned char target_id;
+
+	/* Note: port number is only really known on the client side */
+	unsigned int port_number;
+	unsigned int flags;
+	unsigned int max_transfer_bytes;
+
+	/*  This id is unique for each channel and will correspond with */
+	/*  vendor specific data in the inquirydata */
+	unsigned long long unique_id;
+} __packed;
+
+/*  This structure is sent during the storage protocol negotiations. */
+struct vmstorage_protocol_version {
+	/* Major (MSW) and minor (LSW) version numbers. */
+	unsigned short major_minor;
+
+	/*
+	 * Revision number is auto-incremented whenever this file is changed
+	 * (See FILL_VMSTOR_REVISION macro above).  Mismatch does not
+	 * definitely indicate incompatibility--but it does indicate mismatched
+	 * builds.
+	 */
+	unsigned short revision;
+} __packed;
+
+/* Channel Property Flags */
+#define STORAGE_CHANNEL_REMOVABLE_FLAG		0x1
+#define STORAGE_CHANNEL_EMULATED_IDE_FLAG	0x2
+
+struct vstor_packet {
+	/* Requested operation type */
+	enum vstor_packet_operation operation;
+
+	/*  Flags - see below for values */
+	unsigned int flags;
+
+	/* Status of the request returned from the server side. */
+	unsigned int status;
+
+	/* Data payload area */
+	union {
+		/*
+		 * Structure used to forward SCSI commands from the
+		 * client to the server.
+		 */
+		struct vmscsi_request vm_srb;
+
+		/* Structure used to query channel properties. */
+		struct vmstorage_channel_properties storage_channel_properties;
+
+		/* Used during version negotiations. */
+		struct vmstorage_protocol_version version;
+	};
+} __packed;
+
+/* Packet flags */
+/*
+ * This flag indicates that the server should send back a completion for this
+ * packet.
+ */
+#define REQUEST_COMPLETION_FLAG	0x1
+
+/*  This is the set of flags that the vsc can set in any packets it sends */
+#define VSC_LEGAL_FLAGS		(REQUEST_COMPLETION_FLAG)
+
+
+#include <linux/kernel.h>
+#include <linux/wait.h>
+#include "hyperv.h"
+
+/* Defines */
+#define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
+#define BLKVSC_RING_BUFFER_SIZE				(20*PAGE_SIZE)
+
+#define STORVSC_MAX_IO_REQUESTS				128
+
+/*
+ * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
+ * reality, the path/target is not used (ie always set to 0) so our
+ * scsi host adapter essentially has 1 bus with 1 target that contains
+ * up to 256 luns.
+ */
+#define STORVSC_MAX_LUNS_PER_TARGET			64
+#define STORVSC_MAX_TARGETS				1
+#define STORVSC_MAX_CHANNELS				1
+
+struct hv_storvsc_request;
+
+/* Matches Windows-end */
+enum storvsc_request_type {
+	WRITE_TYPE,
+	READ_TYPE,
+	UNKNOWN_TYPE,
+};
+
+
+struct hv_storvsc_request {
+	struct hv_storvsc_request *request;
+	struct hv_device *device;
+
+	/* Synchronize the request/response if needed */
+	struct completion wait_event;
+
+	unsigned char *sense_buffer;
+	void *context;
+	void (*on_io_completion)(struct hv_storvsc_request *request);
+	struct hv_multipage_buffer data_buffer;
+
+	struct vstor_packet vstor_packet;
+};
+
+
+struct storvsc_device_info {
+	u32 ring_buffer_size;
+	unsigned int port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+};
+
+struct storvsc_major_info {
+	int major;
+	int index;
+	bool do_register;
+	char *devname;
+	char *diskname;
+};
+
+/* A storvsc device is a device object that contains a vmbus channel */
+struct storvsc_device {
+	struct hv_device *device;
+
+	/* 0 indicates the device is being destroyed */
+	int	 ref_count;
+	bool	 destroy;
+	bool	 drain_notify;
+	atomic_t num_outstanding_req;
+
+	wait_queue_head_t waiting_to_drain;
+
+	/*
+	 * Each unique Port/Path/Target represents 1 channel ie scsi
+	 * controller. In reality, the pathid, targetid is always 0
+	 * and the port is set by us
+	 */
+	unsigned int port_number;
+	unsigned char path_id;
+	unsigned char target_id;
+
+	/* Used for vsc/vsp channel reset process */
+	struct hv_storvsc_request init_request;
+	struct hv_storvsc_request reset_request;
+};
+
+
+static inline struct storvsc_device *get_out_stor_device(
+					struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+	if (stor_device && (stor_device->ref_count) &&
+		!stor_device->destroy)
+		stor_device->ref_count++;
+	else
+		stor_device = NULL;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+
+	return stor_device;
+}
+
+
+static inline void put_stor_device(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	unsigned long flags;
+
+	spin_lock_irqsave(&device->ext_lock, flags);
+	stor_device = (struct storvsc_device *)device->ext;
+
+	stor_device->ref_count--;
+	spin_unlock_irqrestore(&device->ext_lock, flags);
+}
+
+static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
+{
+	dev->drain_notify = true;
+	wait_event(dev->waiting_to_drain,
+		   atomic_read(&dev->num_outstanding_req) == 0);
+	dev->drain_notify = false;
+}
 
 
 static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 104/117] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (102 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   30 +-----------------------------
 1 files changed, 1 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 463b428..02f9c1e 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -22,6 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/wait.h>
 #include <linux/completion.h>
 #include <linux/string.h>
 #include <linux/mm.h>
@@ -42,32 +43,6 @@
 #include "hyperv.h"
 
 
-/*
- *
- * Copyright (c) 2011, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- *
- */
-
-
-
 /* vstorage.w revision number.  This is used in the case of a version match, */
 /* to alert the user that structure sizes may be mismatched even though the */
 /* protocol versions match. */
@@ -240,9 +215,6 @@ struct vstor_packet {
 #define VSC_LEGAL_FLAGS		(REQUEST_COMPLETION_FLAG)
 
 
-#include <linux/kernel.h>
-#include <linux/wait.h>
-#include "hyperv.h"
 
 /* Defines */
 #define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 105/117] Staging: hv: storvsc: Make some non static functions, static functions
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (103 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Make some non static functions, static functions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 02f9c1e..a1e8d6a 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -645,7 +645,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 	return ret;
 }
 
-int storvsc_dev_add(struct hv_device *device,
+static int storvsc_dev_add(struct hv_device *device,
 					void *additional_info)
 {
 	struct storvsc_device *stor_device;
@@ -680,7 +680,7 @@ int storvsc_dev_add(struct hv_device *device,
 	return ret;
 }
 
-int storvsc_dev_remove(struct hv_device *device)
+static int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 	unsigned long flags;
@@ -714,7 +714,7 @@ int storvsc_dev_remove(struct hv_device *device)
 	return 0;
 }
 
-int storvsc_do_io(struct hv_device *device,
+static int storvsc_do_io(struct hv_device *device,
 			      struct hv_storvsc_request *request)
 {
 	struct storvsc_device *stor_device;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 106/117] Staging: hv: storvsc: Fixup srb and scsi status for INQUIRY and MODE_SENSE
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (104 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The current handler on the Windows Host does not correctly handle
INQUIRY and MODE_SENSE commands with some options. Fixup srb_status
in these cases since the failure is not fatal.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a1e8d6a..9c2bb56 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -520,6 +520,23 @@ static void storvsc_on_io_completion(struct hv_device *device,
 
 	stor_pkt = &request->vstor_packet;
 
+	/*
+	 * The current SCSI handling on the host side does
+	 * not correctly handle:
+	 * INQUIRY command with page code parameter set to 0x80
+	 * MODE_SENSE command with cmd[2] == 0x1c
+	 *
+	 * Setup srb and scsi status so this won't be fatal.
+	 * We do this so we can distinguish truly fatal failues
+	 * (srb status == 0x4) and off-line the device in that case.
+	 */
+
+	if ((stor_pkt->vm_srb.cdb[0] == INQUIRY) ||
+		(stor_pkt->vm_srb.cdb[0] == MODE_SENSE)) {
+		vstor_packet->vm_srb.scsi_status = 0;
+		vstor_packet->vm_srb.srb_status = 0x1;
+	}
+
 
 	/* Copy over the status...etc */
 	stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 107/117] Staging: hv: storvsc: Fix a typo
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (105 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Fix a typo in a function name.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 9c2bb56..2d7bb41 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1163,9 +1163,9 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 
 
 /*
- * storvsc_commmand_completion - Command completion processing
+ * storvsc_command_completion - Command completion processing
  */
-static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+static void storvsc_command_completion(struct hv_storvsc_request *request)
 {
 	struct storvsc_cmd_request *cmd_request =
 		(struct storvsc_cmd_request *)request->context;
@@ -1273,7 +1273,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 		break;
 	}
 
-	request->on_io_completion = storvsc_commmand_completion;
+	request->on_io_completion = storvsc_command_completion;
 	request->context = cmd_request;/* scmnd; */
 
 	vm_srb->port_number = host_dev->port;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 108/117] Staging: hv: storvsc: In case of scsi errors offline the device
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

When we do get fatal errors from the host, offline the device since the
host has already tried all possible recovery actions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 2d7bb41..8756cdf 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1187,7 +1187,15 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 		}
 	}
 
-	scmnd->result = vm_srb->scsi_status;
+	/*
+	 * If there is an error; offline the device since all
+	 * error recovery strategies would have already been
+	 * deployed on the host side.
+	 */
+	if (vm_srb->srb_status == 0x4)
+		scmnd->result = DID_TARGET_FAILURE << 16;
+	else
+		scmnd->result = vm_srb->scsi_status;
 
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 108/117] Staging: hv: storvsc: In case of scsi errors offline the device
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

When we do get fatal errors from the host, offline the device since the
host has already tried all possible recovery actions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 2d7bb41..8756cdf 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1187,7 +1187,15 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 		}
 	}
 
-	scmnd->result = vm_srb->scsi_status;
+	/*
+	 * If there is an error; offline the device since all
+	 * error recovery strategies would have already been
+	 * deployed on the host side.
+	 */
+	if (vm_srb->srb_status == 0x4)
+		scmnd->result = DID_TARGET_FAILURE << 16;
+	else
+		scmnd->result = vm_srb->scsi_status;
 
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 109/117] Staging: hv: storvsc: No need to copy from bounce buffer in case of a failure
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (107 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

No need to copy from bounce buffer in case of a failure; cleanup the code
accordingly.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 8756cdf..ba27b51 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1348,17 +1348,9 @@ retry_request:
 	if (ret == -EAGAIN) {
 		/* no more space */
 
-		if (cmd_request->bounce_sgl_count) {
-			/*
-			 * FIXME: We can optimize on writes by just skipping
-			 * this
-			 */
-			copy_from_bounce_buffer(scsi_sglist(scmnd),
-						cmd_request->bounce_sgl,
-						scsi_sg_count(scmnd));
+		if (cmd_request->bounce_sgl_count)
 			destroy_bounce_buffer(cmd_request->bounce_sgl,
-					      cmd_request->bounce_sgl_count);
-		}
+					cmd_request->bounce_sgl_count);
 
 		kmem_cache_free(host_dev->request_pool, cmd_request);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 110/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_register()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the signature of vmbus_child_driver_register() to conform to the
Linux driver model.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c    |    2 +-
 drivers/staging/hv/hv_util.c     |    2 +-
 drivers/staging/hv/hyperv.h      |    2 +-
 drivers/staging/hv/netvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 drivers/staging/hv/vmbus_drv.c   |    3 ++-
 6 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6e1c4ce..0dfaa6a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -948,7 +948,7 @@ static int __init mousevsc_init(void)
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-	vmbus_child_driver_register(&drv->driver);
+	vmbus_child_driver_register(drv);
 
 	return 0;
 }
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 26693dd..a4320dc 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -300,7 +300,7 @@ static int __init init_hyperv_utils(void)
 
 	util_drv.driver.name = driver_name;
 
-	return vmbus_child_driver_register(&util_drv.driver);
+	return vmbus_child_driver_register(&util_drv);
 }
 
 static void exit_hyperv_utils(void)
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 82ba110..a760e89 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -846,7 +846,7 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
 
 
 /* Vmbus interface */
-int vmbus_child_driver_register(struct device_driver *drv);
+int vmbus_child_driver_register(struct hv_driver *hv_drv);
 void vmbus_child_driver_unregister(struct device_driver *drv);
 
 /*
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 94c5abc..a204ea7 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -452,7 +452,7 @@ static int __init netvsc_drv_init(void)
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
+	ret = vmbus_child_driver_register(drv);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ba27b51..149ef00 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1552,7 +1552,7 @@ static int __init storvsc_drv_init(void)
 
 
 	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
+	ret = vmbus_child_driver_register(drv);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 29c1712..bd5a5a7 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -525,9 +525,10 @@ static int vmbus_bus_init(int irq)
  *
  * Mainly used by Hyper-V drivers.
  */
-int vmbus_child_driver_register(struct device_driver *drv)
+int vmbus_child_driver_register(struct hv_driver *hv_drv)
 {
 	int ret;
+	struct device_driver *drv = &hv_drv->driver;
 
 	pr_info("child driver registering - name %s\n", drv->name);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 110/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_register()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the signature of vmbus_child_driver_register() to conform to the
Linux driver model.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c    |    2 +-
 drivers/staging/hv/hv_util.c     |    2 +-
 drivers/staging/hv/hyperv.h      |    2 +-
 drivers/staging/hv/netvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 drivers/staging/hv/vmbus_drv.c   |    3 ++-
 6 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6e1c4ce..0dfaa6a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -948,7 +948,7 @@ static int __init mousevsc_init(void)
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-	vmbus_child_driver_register(&drv->driver);
+	vmbus_child_driver_register(drv);
 
 	return 0;
 }
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 26693dd..a4320dc 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -300,7 +300,7 @@ static int __init init_hyperv_utils(void)
 
 	util_drv.driver.name = driver_name;
 
-	return vmbus_child_driver_register(&util_drv.driver);
+	return vmbus_child_driver_register(&util_drv);
 }
 
 static void exit_hyperv_utils(void)
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 82ba110..a760e89 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -846,7 +846,7 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
 
 
 /* Vmbus interface */
-int vmbus_child_driver_register(struct device_driver *drv);
+int vmbus_child_driver_register(struct hv_driver *hv_drv);
 void vmbus_child_driver_unregister(struct device_driver *drv);
 
 /*
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 94c5abc..a204ea7 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -452,7 +452,7 @@ static int __init netvsc_drv_init(void)
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
+	ret = vmbus_child_driver_register(drv);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ba27b51..149ef00 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1552,7 +1552,7 @@ static int __init storvsc_drv_init(void)
 
 
 	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
+	ret = vmbus_child_driver_register(drv);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 29c1712..bd5a5a7 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -525,9 +525,10 @@ static int vmbus_bus_init(int irq)
  *
  * Mainly used by Hyper-V drivers.
  */
-int vmbus_child_driver_register(struct device_driver *drv)
+int vmbus_child_driver_register(struct hv_driver *hv_drv)
 {
 	int ret;
+	struct device_driver *drv = &hv_drv->driver;
 
 	pr_info("child driver registering - name %s\n", drv->name);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 111/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_unregister()
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Change the signature of vmbus_child_driver_unregister() to conform to the
Linux driver model.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c    |    2 +-
 drivers/staging/hv/hv_util.c     |    2 +-
 drivers/staging/hv/hyperv.h      |    2 +-
 drivers/staging/hv/netvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 drivers/staging/hv/vmbus_drv.c   |    7 ++++---
 6 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 0dfaa6a..28bd2c5 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -936,7 +936,7 @@ static struct  hv_driver mousevsc_drv = {
 
 static void mousevsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&mousevsc_drv.driver);
+	vmbus_child_driver_unregister(&mousevsc_drv);
 }
 
 static int __init mousevsc_init(void)
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index a4320dc..4712d22 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -332,7 +332,7 @@ static void exit_hyperv_utils(void)
 	kfree(shut_txf_buf);
 	kfree(time_txf_buf);
 	kfree(hbeat_txf_buf);
-	vmbus_child_driver_unregister(&util_drv.driver);
+	vmbus_child_driver_unregister(&util_drv);
 }
 
 module_init(init_hyperv_utils);
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index a760e89..9b9ff71 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -847,7 +847,7 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
 
 /* Vmbus interface */
 int vmbus_child_driver_register(struct hv_driver *hv_drv);
-void vmbus_child_driver_unregister(struct device_driver *drv);
+void vmbus_child_driver_unregister(struct hv_driver *hv_drv);
 
 /*
  * Common header for Hyper-V ICs
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index a204ea7..474c5f0 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -438,7 +438,7 @@ static struct  hv_driver netvsc_drv = {
 
 static void __exit netvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&netvsc_drv.driver);
+	vmbus_child_driver_unregister(&netvsc_drv);
 }
 
 
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 149ef00..6fbe146 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1559,7 +1559,7 @@ static int __init storvsc_drv_init(void)
 
 static void __exit storvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&storvsc_drv.driver);
+	vmbus_child_driver_unregister(&storvsc_drv);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index bd5a5a7..f271e8d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -553,11 +553,12 @@ EXPORT_SYMBOL(vmbus_child_driver_register);
  *
  * Mainly used by Hyper-V drivers.
  */
-void vmbus_child_driver_unregister(struct device_driver *drv)
+void vmbus_child_driver_unregister(struct hv_driver *hv_drv)
 {
-	pr_info("child driver unregistering - name %s\n", drv->name);
+	pr_info("child driver unregistering - name %s\n",
+		 hv_drv->driver.name);
 
-	driver_unregister(drv);
+	driver_unregister(&hv_drv->driver);
 
 }
 EXPORT_SYMBOL(vmbus_child_driver_unregister);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 111/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_unregister()
@ 2011-07-15 17:47     ` K. Y. Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang

Change the signature of vmbus_child_driver_unregister() to conform to the
Linux driver model.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c    |    2 +-
 drivers/staging/hv/hv_util.c     |    2 +-
 drivers/staging/hv/hyperv.h      |    2 +-
 drivers/staging/hv/netvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 drivers/staging/hv/vmbus_drv.c   |    7 ++++---
 6 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 0dfaa6a..28bd2c5 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -936,7 +936,7 @@ static struct  hv_driver mousevsc_drv = {
 
 static void mousevsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&mousevsc_drv.driver);
+	vmbus_child_driver_unregister(&mousevsc_drv);
 }
 
 static int __init mousevsc_init(void)
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index a4320dc..4712d22 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -332,7 +332,7 @@ static void exit_hyperv_utils(void)
 	kfree(shut_txf_buf);
 	kfree(time_txf_buf);
 	kfree(hbeat_txf_buf);
-	vmbus_child_driver_unregister(&util_drv.driver);
+	vmbus_child_driver_unregister(&util_drv);
 }
 
 module_init(init_hyperv_utils);
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index a760e89..9b9ff71 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -847,7 +847,7 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
 
 /* Vmbus interface */
 int vmbus_child_driver_register(struct hv_driver *hv_drv);
-void vmbus_child_driver_unregister(struct device_driver *drv);
+void vmbus_child_driver_unregister(struct hv_driver *hv_drv);
 
 /*
  * Common header for Hyper-V ICs
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index a204ea7..474c5f0 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -438,7 +438,7 @@ static struct  hv_driver netvsc_drv = {
 
 static void __exit netvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&netvsc_drv.driver);
+	vmbus_child_driver_unregister(&netvsc_drv);
 }
 
 
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 149ef00..6fbe146 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1559,7 +1559,7 @@ static int __init storvsc_drv_init(void)
 
 static void __exit storvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&storvsc_drv.driver);
+	vmbus_child_driver_unregister(&storvsc_drv);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index bd5a5a7..f271e8d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -553,11 +553,12 @@ EXPORT_SYMBOL(vmbus_child_driver_register);
  *
  * Mainly used by Hyper-V drivers.
  */
-void vmbus_child_driver_unregister(struct device_driver *drv)
+void vmbus_child_driver_unregister(struct hv_driver *hv_drv)
 {
-	pr_info("child driver unregistering - name %s\n", drv->name);
+	pr_info("child driver unregistering - name %s\n",
+		 hv_drv->driver.name);
 
-	driver_unregister(drv);
+	driver_unregister(&hv_drv->driver);
 
 }
 EXPORT_SYMBOL(vmbus_child_driver_unregister);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 112/117] Staging: hv: util: Forcefully shutdown when shutdown is requested
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (110 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

When the host requests a "shutdown", make sure we shutdown!

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 4712d22..070e61f 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -91,7 +91,7 @@ static void shutdown_onchannelcallback(void *context)
 	}
 
 	if (execute_shutdown == true)
-		orderly_poweroff(false);
+		orderly_poweroff(true);
 }
 
 /*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 113/117] Staging: hv: util: Adjust guest time in a process context
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (111 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The current code was adjusting guest time in interrupt context; do this
in process context since we may have to initiate cross-processor
interrupts as part of setting time.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_util.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 070e61f..d3fb017 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -109,6 +109,24 @@ static inline void do_adj_guesttime(u64 hosttime)
 }
 
 /*
+ * Set the host time in a process context.
+ */
+
+struct adj_time_work {
+	struct work_struct work;
+	u64	host_time;
+};
+
+static void hv_set_host_time(struct work_struct *work)
+{
+	struct adj_time_work	*wrk;
+
+	wrk = container_of(work, struct adj_time_work, work);
+	do_adj_guesttime(wrk->host_time);
+	kfree(wrk);
+}
+
+/*
  * Synchronize time with host after reboot, restore, etc.
  *
  * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
@@ -121,16 +139,24 @@ static inline void do_adj_guesttime(u64 hosttime)
  */
 static inline void adj_guesttime(u64 hosttime, u8 flags)
 {
+	struct adj_time_work    *wrk;
 	static s32 scnt = 50;
 
+	wrk = kmalloc(sizeof(struct adj_time_work), GFP_ATOMIC);
+	if (wrk == NULL)
+		return;
+
+	wrk->host_time = hosttime;
 	if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
-		do_adj_guesttime(hosttime);
+		INIT_WORK(&wrk->work, hv_set_host_time);
+		schedule_work(&wrk->work);
 		return;
 	}
 
 	if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
 		scnt--;
-		do_adj_guesttime(hosttime);
+		INIT_WORK(&wrk->work, hv_set_host_time);
+		schedule_work(&wrk->work);
 	}
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 114/117] Staging: hv: vmbus: Check before invoking the channel callback
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (112 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

When we close a channel, we set the corresponding callback function to NULL.
Check before invoking the channel callback.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/connection.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index a88ad70..7a3ec75 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -222,7 +222,7 @@ static void process_chn_event(u32 relid)
 	 */
 	channel = relid2channel(relid);
 
-	if (channel) {
+	if (channel && (channel->onchannel_callback != NULL)) {
 		channel->onchannel_callback(channel->channel_callback_context);
 	} else {
 		pr_err("channel not found for relid - %u\n", relid);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 115/117] Staging: hv: vmbus: Properly deal with de-registering channel callback
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (113 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Ensure that we correctly handle racing invocations of the channel callback
when the channel is being closed. We do this using the channel's inbound_lock.
A side-effect of this strategy is that we avoid repeatedly picking up this lock
as we drain the inbound ring-buffer.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/channel.c    |   20 +++++---------------
 drivers/staging/hv/connection.c |    3 +++
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index ac92c1f..b6f3d38 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -513,9 +513,12 @@ void vmbus_close(struct vmbus_channel *channel)
 {
 	struct vmbus_channel_close_channel *msg;
 	int ret;
+	unsigned long flags;
 
 	/* Stop callback and cancel the timer asap */
+	spin_lock_irqsave(&channel->inbound_lock, flags);
 	channel->onchannel_callback = NULL;
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
 	/* Send a closing message */
 
@@ -735,19 +738,15 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	u32 packetlen;
 	u32 userlen;
 	int ret;
-	unsigned long flags;
 
 	*buffer_actual_len = 0;
 	*requestid = 0;
 
-	spin_lock_irqsave(&channel->inbound_lock, flags);
 
 	ret = hv_ringbuffer_peek(&channel->inbound, &desc,
 			     sizeof(struct vmpacket_descriptor));
-	if (ret != 0) {
-		spin_unlock_irqrestore(&channel->inbound_lock, flags);
+	if (ret != 0)
 		return 0;
-	}
 
 	packetlen = desc.len8 << 3;
 	userlen = packetlen - (desc.offset8 << 3);
@@ -755,7 +754,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	*buffer_actual_len = userlen;
 
 	if (userlen > bufferlen) {
-		spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
 		pr_err("Buffer too small - got %d needs %d\n",
 			   bufferlen, userlen);
@@ -768,7 +766,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	ret = hv_ringbuffer_read(&channel->inbound, buffer, userlen,
 			     (desc.offset8 << 3));
 
-	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
 	return 0;
 }
@@ -785,19 +782,15 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	u32 packetlen;
 	u32 userlen;
 	int ret;
-	unsigned long flags;
 
 	*buffer_actual_len = 0;
 	*requestid = 0;
 
-	spin_lock_irqsave(&channel->inbound_lock, flags);
 
 	ret = hv_ringbuffer_peek(&channel->inbound, &desc,
 			     sizeof(struct vmpacket_descriptor));
-	if (ret != 0) {
-		spin_unlock_irqrestore(&channel->inbound_lock, flags);
+	if (ret != 0)
 		return 0;
-	}
 
 
 	packetlen = desc.len8 << 3;
@@ -806,8 +799,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	*buffer_actual_len = packetlen;
 
 	if (packetlen > bufferlen) {
-		spin_unlock_irqrestore(&channel->inbound_lock, flags);
-
 		pr_err("Buffer too small - needed %d bytes but "
 			"got space for only %d bytes\n",
 			packetlen, bufferlen);
@@ -819,7 +810,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	/* Copy over the entire packet to the user buffer */
 	ret = hv_ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
 
-	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 7a3ec75..6aab802 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -215,6 +215,7 @@ struct vmbus_channel *relid2channel(u32 relid)
 static void process_chn_event(u32 relid)
 {
 	struct vmbus_channel *channel;
+	unsigned long flags;
 
 	/*
 	 * Find the channel based on this relid and invokes the
@@ -222,11 +223,13 @@ static void process_chn_event(u32 relid)
 	 */
 	channel = relid2channel(relid);
 
+	spin_lock_irqsave(&channel->inbound_lock, flags);
 	if (channel && (channel->onchannel_callback != NULL)) {
 		channel->onchannel_callback(channel->channel_callback_context);
 	} else {
 		pr_err("channel not found for relid - %u\n", relid);
 	}
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 }
 
 /*
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 116/117] Staging: hv: vmbus: Add code to display modalias attribute
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (114 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Add code to display modalias attribute.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index f271e8d..433be51 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -113,6 +113,14 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
 		return sprintf(buf, "%s\n",
 				hv_get_devtype_name(&device_info.chn_type));
+	} else if (!strcmp(dev_attr->attr.name, "modalias")) {
+		int i;
+		char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
+
+		for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
+			sprintf(&alias_name[i], "%02x",
+				hv_dev->dev_type.b[i/2]);
+		return sprintf("vmbus:%s\n", alias_name);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
 		return sprintf(buf, "%d\n", device_info.chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -167,6 +175,7 @@ static struct device_attribute vmbus_device_attrs[] = {
 	__ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
+	__ATTR(modalias, S_IRUGO, vmbus_show_device_attr, NULL),
 	__ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
 
 	__ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* [PATCH 117/117] Staging: hv: blkvsc: Get rid of blkvsc_drv.c as this code is not used
  2011-07-15 17:45   ` K. Y. Srinivasan
                     ` (115 preceding siblings ...)
  (?)
@ 2011-07-15 17:47   ` K. Y. Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: K. Y. Srinivasan @ 2011-07-15 17:47 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of blkvsc_drv.c as this code is not used.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c | 1034 ---------------------------------------
 1 files changed, 0 insertions(+), 1034 deletions(-)
 delete mode 100644 drivers/staging/hv/blkvsc_drv.c

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
deleted file mode 100644
index eab643a..0000000
--- a/drivers/staging/hv/blkvsc_drv.c
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *   K. Y. Srinivasan <kys@microsoft.com>
- */
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/blkdev.h>
-#include <linux/major.h>
-#include <linux/delay.h>
-#include <linux/hdreg.h>
-#include <linux/slab.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_eh.h>
-#include <scsi/scsi_dbg.h>
-
-#include "hyperv.h"
-#include "hyperv_storage.h"
-
-
-#define BLKVSC_MINORS	64
-
-enum blkvsc_device_type {
-	UNKNOWN_DEV_TYPE,
-	HARDDISK_TYPE,
-	DVD_TYPE,
-};
-
-enum blkvsc_op_type {
-	DO_INQUIRY,
-	DO_CAPACITY,
-	DO_FLUSH,
-};
-
-/*
- * This request ties the struct request and struct
- * blkvsc_request/hv_storvsc_request together A struct request may be
- * represented by 1 or more struct blkvsc_request
- */
-struct blkvsc_request_group {
-	int outstanding;
-	int status;
-	struct list_head blkvsc_req_list;	/* list of blkvsc_requests */
-};
-
-struct blkvsc_request {
-	/* blkvsc_request_group.blkvsc_req_list */
-	struct list_head req_entry;
-
-	/* block_device_context.pending_list */
-	struct list_head pend_entry;
-
-	/* This may be null if we generate a request internally */
-	struct request *req;
-
-	struct block_device_context *dev;
-
-	/* The group this request is part of. Maybe null */
-	struct blkvsc_request_group *group;
-
-	int write;
-	sector_t sector_start;
-	unsigned long sector_count;
-
-	unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];
-	unsigned char cmd_len;
-	unsigned char cmnd[MAX_COMMAND_SIZE];
-
-	struct hv_storvsc_request request;
-};
-
-/* Per device structure */
-struct block_device_context {
-	/* point back to our device context */
-	struct hv_device *device_ctx;
-	struct kmem_cache *request_pool;
-	spinlock_t lock;
-	struct gendisk *gd;
-	enum blkvsc_device_type	device_type;
-	struct list_head pending_list;
-
-	unsigned char device_id[64];
-	unsigned int device_id_len;
-	int num_outstanding_reqs;
-	int shutting_down;
-	unsigned int sector_size;
-	sector_t capacity;
-	unsigned int port;
-	unsigned char path;
-	unsigned char target;
-	int users;
-};
-
-static const char *drv_name = "blkvsc";
-
-/*
- * There is a circular dependency involving blkvsc_request_completion()
- * and blkvsc_do_request().
- */
-static void blkvsc_request_completion(struct hv_storvsc_request *request);
-
-static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE;
-
-module_param(blkvsc_ringbuffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)");
-
-/*
- * There is a circular dependency involving blkvsc_probe()
- * and block_ops.
- */
-static int blkvsc_probe(struct hv_device *dev);
-
-static int blkvsc_device_add(struct hv_device *device,
-				void *additional_info)
-{
-	struct storvsc_device_info *device_info;
-	int ret = 0;
-
-	device_info = (struct storvsc_device_info *)additional_info;
-
-	device_info->ring_buffer_size = blkvsc_ringbuffer_size;
-
-	ret = storvsc_dev_add(device, additional_info);
-	if (ret != 0)
-		return ret;
-
-	/*
-	 * We need to use the device instance guid to set the path and target
-	 * id. For IDE devices, the device instance id is formatted as
-	 * <bus id> * - <device id> - 8899 - 000000000000.
-	 */
-	device_info->path_id = device->dev_instance.b[3] << 24 |
-			     device->dev_instance.b[2] << 16 |
-			     device->dev_instance.b[1] << 8  |
-			     device->dev_instance.b[0];
-
-	device_info->target_id = device->dev_instance.b[5] << 8 |
-			       device->dev_instance.b[4];
-
-	return ret;
-}
-
-static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
-			void (*request_completion)(struct hv_storvsc_request *))
-{
-	struct block_device_context *blkdev = blkvsc_req->dev;
-	struct hv_storvsc_request *storvsc_req;
-	struct vmscsi_request *vm_srb;
-	int ret;
-
-
-	storvsc_req = &blkvsc_req->request;
-	vm_srb = &storvsc_req->vstor_packet.vm_srb;
-
-	vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
-
-	storvsc_req->on_io_completion = request_completion;
-	storvsc_req->context = blkvsc_req;
-
-	vm_srb->port_number = blkdev->port;
-	vm_srb->path_id = blkdev->path;
-	vm_srb->target_id = blkdev->target;
-	vm_srb->lun = 0;	 /* this is not really used at all */
-
-	vm_srb->cdb_length = blkvsc_req->cmd_len;
-
-	memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length);
-
-	storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
-
-	ret =  storvsc_do_io(blkdev->device_ctx,
-					   &blkvsc_req->request);
-	if (ret == 0)
-		blkdev->num_outstanding_reqs++;
-
-	return ret;
-}
-
-
-static int blkvsc_open(struct block_device *bdev, fmode_t mode)
-{
-	struct block_device_context *blkdev = bdev->bd_disk->private_data;
-	unsigned long flags;
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	blkdev->users++;
-
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	return 0;
-}
-
-
-static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
-{
-	sector_t nsect = get_capacity(bd->bd_disk);
-	sector_t cylinders = nsect;
-
-	/*
-	 * We are making up these values; let us keep it simple.
-	 */
-	hg->heads = 0xff;
-	hg->sectors = 0x3f;
-	sector_div(cylinders, hg->heads * hg->sectors);
-	hg->cylinders = cylinders;
-	if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
-		hg->cylinders = 0xffff;
-	return 0;
-
-}
-
-
-static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
-{
-
-	blkvsc_req->cmd_len = 16;
-
-	if (rq_data_dir(blkvsc_req->req)) {
-		blkvsc_req->write = 1;
-		blkvsc_req->cmnd[0] = WRITE_16;
-	} else {
-		blkvsc_req->write = 0;
-		blkvsc_req->cmnd[0] = READ_16;
-	}
-
-	blkvsc_req->cmnd[1] |=
-	(blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
-
-	*(unsigned long long *)&blkvsc_req->cmnd[2] =
-	cpu_to_be64(blkvsc_req->sector_start);
-	*(unsigned int *)&blkvsc_req->cmnd[10] =
-	cpu_to_be32(blkvsc_req->sector_count);
-}
-
-
-static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
-			unsigned cmd, unsigned long arg)
-{
-	struct block_device_context *blkdev = bd->bd_disk->private_data;
-	int ret = 0;
-
-	switch (cmd) {
-	case HDIO_GET_IDENTITY:
-		if (copy_to_user((void __user *)arg, blkdev->device_id,
-				 blkdev->device_id_len))
-			ret = -EFAULT;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
-{
-	struct blkvsc_request *blkvsc_req =
-			(struct blkvsc_request *)request->context;
-	struct block_device_context *blkdev =
-			(struct block_device_context *)blkvsc_req->dev;
-	struct scsi_sense_hdr sense_hdr;
-	struct vmscsi_request *vm_srb;
-	unsigned long flags;
-
-
-	vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-	blkdev->num_outstanding_reqs--;
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	if (vm_srb->scsi_status)
-		if (scsi_normalize_sense(blkvsc_req->sense_buffer,
-					 SCSI_SENSE_BUFFERSIZE, &sense_hdr))
-			scsi_print_sense_hdr("blkvsc", &sense_hdr);
-
-	complete(&blkvsc_req->request.wait_event);
-}
-
-
-static int blkvsc_do_operation(struct block_device_context *blkdev,
-				enum blkvsc_op_type op)
-{
-	struct blkvsc_request *blkvsc_req;
-	struct page *page_buf;
-	unsigned char *buf;
-	unsigned char device_type;
-	struct scsi_sense_hdr sense_hdr;
-	struct vmscsi_request *vm_srb;
-	unsigned long flags;
-
-	int ret = 0;
-
-	blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
-	if (!blkvsc_req)
-		return -ENOMEM;
-
-	page_buf = alloc_page(GFP_KERNEL);
-	if (!page_buf) {
-		kmem_cache_free(blkdev->request_pool, blkvsc_req);
-		return -ENOMEM;
-	}
-
-	vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
-	init_completion(&blkvsc_req->request.wait_event);
-	blkvsc_req->dev = blkdev;
-	blkvsc_req->req = NULL;
-	blkvsc_req->write = 0;
-
-	blkvsc_req->request.data_buffer.pfn_array[0] =
-	page_to_pfn(page_buf);
-	blkvsc_req->request.data_buffer.offset = 0;
-
-	switch (op) {
-	case DO_INQUIRY:
-		blkvsc_req->cmnd[0] = INQUIRY;
-		blkvsc_req->cmnd[1] = 0x1;		/* Get product data */
-		blkvsc_req->cmnd[2] = 0x83;		/* mode page 83 */
-		blkvsc_req->cmnd[4] = 64;
-		blkvsc_req->cmd_len = 6;
-		blkvsc_req->request.data_buffer.len = 64;
-		break;
-
-	case DO_CAPACITY:
-		blkdev->sector_size = 0;
-		blkdev->capacity = 0;
-
-		blkvsc_req->cmnd[0] = READ_CAPACITY;
-		blkvsc_req->cmd_len = 16;
-		blkvsc_req->request.data_buffer.len = 8;
-		break;
-
-	case DO_FLUSH:
-		blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
-		blkvsc_req->cmd_len = 10;
-		blkvsc_req->request.data_buffer.pfn_array[0] = 0;
-		blkvsc_req->request.data_buffer.len = 0;
-		break;
-	default:
-		ret = -EINVAL;
-		goto cleanup;
-	}
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-	blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
-
-	/* check error */
-	if (vm_srb->scsi_status) {
-		scsi_normalize_sense(blkvsc_req->sense_buffer,
-				     SCSI_SENSE_BUFFERSIZE, &sense_hdr);
-
-		return 0;
-	}
-
-	buf = kmap(page_buf);
-
-	switch (op) {
-	case DO_INQUIRY:
-		device_type = buf[0] & 0x1F;
-
-		if (device_type == 0x0)
-			blkdev->device_type = HARDDISK_TYPE;
-		 else
-			blkdev->device_type = UNKNOWN_DEV_TYPE;
-
-		blkdev->device_id_len = buf[7];
-		if (blkdev->device_id_len > 64)
-			blkdev->device_id_len = 64;
-
-		memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
-		break;
-
-	case DO_CAPACITY:
-		/* be to le */
-		blkdev->capacity =
-		((buf[0] << 24) | (buf[1] << 16) |
-		(buf[2] << 8) | buf[3]) + 1;
-
-		blkdev->sector_size =
-		(buf[4] << 24) | (buf[5] << 16) |
-		(buf[6] << 8) | buf[7];
-		break;
-	default:
-		break;
-
-	}
-
-cleanup:
-
-	kunmap(page_buf);
-
-	__free_page(page_buf);
-
-	kmem_cache_free(blkdev->request_pool, blkvsc_req);
-
-	return ret;
-}
-
-
-static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
-{
-	struct blkvsc_request *pend_req, *tmp;
-	struct blkvsc_request *comp_req, *tmp2;
-	struct vmscsi_request *vm_srb;
-
-	int ret = 0;
-
-
-	/* Flush the pending list first */
-	list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
-				 pend_entry) {
-		/*
-		 * The pend_req could be part of a partially completed
-		 * request. If so, complete those req first until we
-		 * hit the pend_req
-		 */
-		list_for_each_entry_safe(comp_req, tmp2,
-					 &pend_req->group->blkvsc_req_list,
-					 req_entry) {
-
-			if (comp_req == pend_req)
-				break;
-
-			list_del(&comp_req->req_entry);
-
-			if (comp_req->req) {
-				vm_srb =
-				&comp_req->request.vstor_packet.
-				vm_srb;
-				ret = __blk_end_request(comp_req->req,
-					(!vm_srb->scsi_status ? 0 : -EIO),
-					comp_req->sector_count *
-					blkdev->sector_size);
-
-				/* FIXME: shouldn't this do more than return? */
-				if (ret)
-					goto out;
-			}
-
-			kmem_cache_free(blkdev->request_pool, comp_req);
-		}
-
-		list_del(&pend_req->pend_entry);
-
-		list_del(&pend_req->req_entry);
-
-		if (comp_req->req) {
-			if (!__blk_end_request(pend_req->req, -EIO,
-					       pend_req->sector_count *
-					       blkdev->sector_size)) {
-				/*
-				 * All the sectors have been xferred ie the
-				 * request is done
-				 */
-				kmem_cache_free(blkdev->request_pool,
-						pend_req->group);
-			}
-		}
-
-		kmem_cache_free(blkdev->request_pool, pend_req);
-	}
-
-out:
-	return ret;
-}
-
-
-/*
- * blkvsc_remove() - Callback when our device is removed
- */
-static int blkvsc_remove(struct hv_device *dev)
-{
-	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
-	unsigned long flags;
-
-
-	/* Get to a known state */
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	blkdev->shutting_down = 1;
-
-	blk_stop_queue(blkdev->gd->queue);
-
-	blkvsc_cancel_pending_reqs(blkdev);
-
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	blkvsc_do_operation(blkdev, DO_FLUSH);
-
-	if (blkdev->users == 0) {
-		del_gendisk(blkdev->gd);
-		put_disk(blkdev->gd);
-		blk_cleanup_queue(blkdev->gd->queue);
-
-		storvsc_dev_remove(blkdev->device_ctx);
-
-		kmem_cache_destroy(blkdev->request_pool);
-		kfree(blkdev);
-	}
-
-	return 0;
-}
-
-static void blkvsc_shutdown(struct hv_device *dev)
-{
-	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
-	unsigned long flags;
-
-	if (!blkdev)
-		return;
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	blkdev->shutting_down = 1;
-
-	blk_stop_queue(blkdev->gd->queue);
-
-	blkvsc_cancel_pending_reqs(blkdev);
-
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	blkvsc_do_operation(blkdev, DO_FLUSH);
-
-	/*
-	 * Now wait for all outgoing I/O to be drained.
-	 */
-	storvsc_wait_to_drain((struct storvsc_device *)dev->ext);
-
-}
-
-static int blkvsc_release(struct gendisk *disk, fmode_t mode)
-{
-	struct block_device_context *blkdev = disk->private_data;
-	unsigned long flags;
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	if ((--blkdev->users == 0) && (blkdev->shutting_down)) {
-		blk_stop_queue(blkdev->gd->queue);
-		spin_unlock_irqrestore(&blkdev->lock, flags);
-
-		blkvsc_do_operation(blkdev, DO_FLUSH);
-		del_gendisk(blkdev->gd);
-		put_disk(blkdev->gd);
-		blk_cleanup_queue(blkdev->gd->queue);
-
-		storvsc_dev_remove(blkdev->device_ctx);
-
-		kmem_cache_destroy(blkdev->request_pool);
-		kfree(blkdev);
-	} else
-		spin_unlock_irqrestore(&blkdev->lock, flags);
-
-	return 0;
-}
-
-
-/*
- * We break the request into 1 or more blkvsc_requests and submit
- * them.  If we cant submit them all, we put them on the
- * pending_list. The blkvsc_request() will work on the pending_list.
- */
-static int blkvsc_do_request(struct block_device_context *blkdev,
-			     struct request *req)
-{
-	struct bio *bio = NULL;
-	struct bio_vec *bvec = NULL;
-	struct bio_vec *prev_bvec = NULL;
-	struct blkvsc_request *blkvsc_req = NULL;
-	struct blkvsc_request *tmp;
-	int databuf_idx = 0;
-	int seg_idx = 0;
-	sector_t start_sector;
-	unsigned long num_sectors = 0;
-	int ret = 0;
-	int pending = 0;
-	struct blkvsc_request_group *group = NULL;
-
-	/* Create a group to tie req to list of blkvsc_reqs */
-	group = kmem_cache_zalloc(blkdev->request_pool, GFP_ATOMIC);
-	if (!group)
-		return -ENOMEM;
-
-	INIT_LIST_HEAD(&group->blkvsc_req_list);
-	group->outstanding = group->status = 0;
-
-	start_sector = blk_rq_pos(req);
-
-	/* foreach bio in the request */
-	if (req->bio) {
-		for (bio = req->bio; bio; bio = bio->bi_next) {
-			/*
-			 * Map this bio into an existing or new storvsc request
-			 */
-			bio_for_each_segment(bvec, bio, seg_idx) {
-				/* Get a new storvsc request */
-				/* 1st-time */
-				if ((!blkvsc_req) ||
-				    (databuf_idx >= MAX_MULTIPAGE_BUFFER_COUNT)
-				    /* hole at the begin of page */
-				    || (bvec->bv_offset != 0) ||
-				    /* hold at the end of page */
-				    (prev_bvec &&
-				     (prev_bvec->bv_len != PAGE_SIZE))) {
-					/* submit the prev one */
-					if (blkvsc_req) {
-						blkvsc_req->sector_start =
-						start_sector;
-						sector_div(
-						blkvsc_req->sector_start,
-						(blkdev->sector_size >> 9));
-
-						blkvsc_req->sector_count =
-						num_sectors /
-						(blkdev->sector_size >> 9);
-						blkvsc_init_rw(blkvsc_req);
-					}
-
-					/*
-					 * Create new blkvsc_req to represent
-					 * the current bvec
-					 */
-					blkvsc_req =
-					kmem_cache_zalloc(
-					blkdev->request_pool, GFP_ATOMIC);
-					if (!blkvsc_req) {
-						/* free up everything */
-						list_for_each_entry_safe(
-							blkvsc_req, tmp,
-							&group->blkvsc_req_list,
-							req_entry) {
-							list_del(
-							&blkvsc_req->req_entry);
-							kmem_cache_free(
-							blkdev->request_pool,
-							blkvsc_req);
-						}
-
-						kmem_cache_free(
-						blkdev->request_pool, group);
-						return -ENOMEM;
-					}
-
-					memset(blkvsc_req, 0,
-					       sizeof(struct blkvsc_request));
-
-					blkvsc_req->dev = blkdev;
-					blkvsc_req->req = req;
-					blkvsc_req->request.
-					data_buffer.offset
-					= bvec->bv_offset;
-					blkvsc_req->request.
-					data_buffer.len = 0;
-
-					/* Add to the group */
-					blkvsc_req->group = group;
-					blkvsc_req->group->outstanding++;
-					list_add_tail(&blkvsc_req->req_entry,
-					&blkvsc_req->group->blkvsc_req_list);
-
-					start_sector += num_sectors;
-					num_sectors = 0;
-					databuf_idx = 0;
-				}
-
-				/*
-				 * Add the curr bvec/segment to the curr
-				 * blkvsc_req
-				 */
-				blkvsc_req->request.data_buffer.
-					pfn_array[databuf_idx]
-						= page_to_pfn(bvec->bv_page);
-				blkvsc_req->request.data_buffer.len
-					+= bvec->bv_len;
-
-				prev_bvec = bvec;
-
-				databuf_idx++;
-				num_sectors += bvec->bv_len >> 9;
-
-			} /* bio_for_each_segment */
-
-		} /* rq_for_each_bio */
-	}
-
-	/* Handle the last one */
-	if (blkvsc_req) {
-		blkvsc_req->sector_start = start_sector;
-		sector_div(blkvsc_req->sector_start,
-			   (blkdev->sector_size >> 9));
-
-		blkvsc_req->sector_count = num_sectors /
-					   (blkdev->sector_size >> 9);
-
-		blkvsc_init_rw(blkvsc_req);
-	}
-
-	list_for_each_entry(blkvsc_req, &group->blkvsc_req_list, req_entry) {
-		if (pending) {
-
-			list_add_tail(&blkvsc_req->pend_entry,
-				      &blkdev->pending_list);
-		} else {
-			ret = blkvsc_submit_request(blkvsc_req,
-						    blkvsc_request_completion);
-			if (ret == -EAGAIN) {
-				pending = 1;
-				list_add_tail(&blkvsc_req->pend_entry,
-					      &blkdev->pending_list);
-			}
-
-		}
-	}
-
-	return pending;
-}
-
-static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
-{
-	struct blkvsc_request *pend_req, *tmp;
-	int ret = 0;
-
-	/* Flush the pending list first */
-	list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
-				 pend_entry) {
-
-		ret = blkvsc_submit_request(pend_req,
-					    blkvsc_request_completion);
-		if (ret != 0)
-			break;
-		else
-			list_del(&pend_req->pend_entry);
-	}
-
-	return ret;
-}
-
-
-static void blkvsc_request(struct request_queue *queue)
-{
-	struct block_device_context *blkdev = NULL;
-	struct request *req;
-	int ret = 0;
-
-	while ((req = blk_peek_request(queue)) != NULL) {
-
-		blkdev = req->rq_disk->private_data;
-		if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS) {
-			__blk_end_request_cur(req, 0);
-			continue;
-		}
-
-		ret = blkvsc_do_pending_reqs(blkdev);
-
-		if (ret != 0) {
-			blk_stop_queue(queue);
-			break;
-		}
-
-		blk_start_request(req);
-
-		ret = blkvsc_do_request(blkdev, req);
-		if (ret > 0) {
-			blk_stop_queue(queue);
-			break;
-		} else if (ret < 0) {
-			blk_requeue_request(queue, req);
-			blk_stop_queue(queue);
-			break;
-		}
-	}
-}
-
-static const struct hv_vmbus_device_id id_table[] = {
-	{
-		/* IDE guid */
-		.guid = {
-			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-		}
-	},
-	{
-		.guid = {
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-		}
-	},
-};
-
-MODULE_DEVICE_TABLE(vmbus, id_table);
-
-/* The one and only one */
-static  struct hv_driver blkvsc_drv = {
-	.id_table = id_table,
-	.probe =  blkvsc_probe,
-	.remove =  blkvsc_remove,
-	.shutdown = blkvsc_shutdown,
-};
-
-static const struct block_device_operations block_ops = {
-	.owner = THIS_MODULE,
-	.open = blkvsc_open,
-	.release = blkvsc_release,
-	.getgeo = blkvsc_getgeo,
-	.ioctl  = blkvsc_ioctl,
-};
-
-/*
- * blkvsc_drv_init -  BlkVsc driver initialization.
- */
-static int blkvsc_drv_init(void)
-{
-	struct hv_driver *drv = &blkvsc_drv;
-	int ret;
-
-	BUILD_BUG_ON(sizeof(sector_t) != 8);
-
-	drv->driver.name = drv_name;
-
-	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
-
-	return ret;
-}
-
-
-static void blkvsc_drv_exit(void)
-{
-
-	vmbus_child_driver_unregister(&blkvsc_drv.driver);
-}
-
-/*
- * blkvsc_probe - Add a new device for this driver
- */
-static int blkvsc_probe(struct hv_device *dev)
-{
-	struct block_device_context *blkdev = NULL;
-	struct storvsc_device_info device_info;
-	struct storvsc_major_info major_info;
-	int ret = 0;
-
-	blkdev = kzalloc(sizeof(struct block_device_context), GFP_KERNEL);
-	if (!blkdev) {
-		ret = -ENOMEM;
-		goto cleanup;
-	}
-
-	INIT_LIST_HEAD(&blkdev->pending_list);
-
-	/* Initialize what we can here */
-	spin_lock_init(&blkdev->lock);
-
-
-	blkdev->request_pool = kmem_cache_create(dev_name(&dev->device),
-					sizeof(struct blkvsc_request), 0,
-					SLAB_HWCACHE_ALIGN, NULL);
-	if (!blkdev->request_pool) {
-		ret = -ENOMEM;
-		goto cleanup;
-	}
-
-
-	ret = blkvsc_device_add(dev, &device_info);
-	if (ret != 0)
-		goto cleanup;
-
-	blkdev->device_ctx = dev;
-	/* this identified the device 0 or 1 */
-	blkdev->target = device_info.target_id;
-	/* this identified the ide ctrl 0 or 1 */
-	blkdev->path = device_info.path_id;
-
-	dev_set_drvdata(&dev->device, blkdev);
-
-	ret = storvsc_get_major_info(&device_info, &major_info);
-
-	if (ret)
-		goto cleanup;
-
-	if (major_info.do_register) {
-		ret = register_blkdev(major_info.major, major_info.devname);
-
-		if (ret != 0) {
-			DPRINT_ERR(BLKVSC_DRV,
-				   "register_blkdev() failed! ret %d", ret);
-			goto remove;
-		}
-	}
-
-	DPRINT_INFO(BLKVSC_DRV, "blkvsc registered for major %d!!",
-			major_info.major);
-
-	blkdev->gd = alloc_disk(BLKVSC_MINORS);
-	if (!blkdev->gd) {
-		ret = -1;
-		goto cleanup;
-	}
-
-	blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock);
-
-	blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE);
-	blk_queue_max_segments(blkdev->gd->queue, MAX_MULTIPAGE_BUFFER_COUNT);
-	blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1);
-	blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY);
-	blk_queue_dma_alignment(blkdev->gd->queue, 511);
-
-	blkdev->gd->major = major_info.major;
-	if (major_info.index == 1 || major_info.index == 3)
-		blkdev->gd->first_minor = BLKVSC_MINORS;
-	else
-		blkdev->gd->first_minor = 0;
-	blkdev->gd->fops = &block_ops;
-	blkdev->gd->private_data = blkdev;
-	blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
-	sprintf(blkdev->gd->disk_name, "hd%c", 'a' + major_info.index);
-
-	blkvsc_do_operation(blkdev, DO_INQUIRY);
-	blkvsc_do_operation(blkdev, DO_CAPACITY);
-
-	set_capacity(blkdev->gd, blkdev->capacity * (blkdev->sector_size/512));
-	blk_queue_logical_block_size(blkdev->gd->queue, blkdev->sector_size);
-	/* go! */
-	add_disk(blkdev->gd);
-
-	DPRINT_INFO(BLKVSC_DRV, "%s added!! capacity %lu sector_size %d",
-		    blkdev->gd->disk_name, (unsigned long)blkdev->capacity,
-		    blkdev->sector_size);
-
-	return ret;
-
-remove:
-	storvsc_dev_remove(dev);
-
-cleanup:
-	if (blkdev) {
-		if (blkdev->request_pool) {
-			kmem_cache_destroy(blkdev->request_pool);
-			blkdev->request_pool = NULL;
-		}
-		kfree(blkdev);
-		blkdev = NULL;
-	}
-
-	return ret;
-}
-
-static void blkvsc_request_completion(struct hv_storvsc_request *request)
-{
-	struct blkvsc_request *blkvsc_req =
-			(struct blkvsc_request *)request->context;
-	struct block_device_context *blkdev =
-			(struct block_device_context *)blkvsc_req->dev;
-	unsigned long flags;
-	struct blkvsc_request *comp_req, *tmp;
-	struct vmscsi_request *vm_srb;
-
-
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	blkdev->num_outstanding_reqs--;
-	blkvsc_req->group->outstanding--;
-
-	/*
-	 * Only start processing when all the blkvsc_reqs are
-	 * completed. This guarantees no out-of-order blkvsc_req
-	 * completion when calling end_that_request_first()
-	 */
-	if (blkvsc_req->group->outstanding == 0) {
-		list_for_each_entry_safe(comp_req, tmp,
-					 &blkvsc_req->group->blkvsc_req_list,
-					 req_entry) {
-
-			list_del(&comp_req->req_entry);
-
-			vm_srb =
-			&comp_req->request.vstor_packet.vm_srb;
-			if (!__blk_end_request(comp_req->req,
-				(!vm_srb->scsi_status ? 0 : -EIO),
-				comp_req->sector_count * blkdev->sector_size)) {
-				/*
-				 * All the sectors have been xferred ie the
-				 * request is done
-				 */
-				kmem_cache_free(blkdev->request_pool,
-						comp_req->group);
-			}
-
-			kmem_cache_free(blkdev->request_pool, comp_req);
-		}
-
-		if (!blkdev->shutting_down) {
-			blkvsc_do_pending_reqs(blkdev);
-			blk_start_queue(blkdev->gd->queue);
-			blkvsc_request(blkdev->gd->queue);
-		}
-	}
-
-	spin_unlock_irqrestore(&blkdev->lock, flags);
-}
-
-static void __exit blkvsc_exit(void)
-{
-	blkvsc_drv_exit();
-}
-
-MODULE_LICENSE("GPL");
-MODULE_VERSION(HV_DRV_VERSION);
-MODULE_DESCRIPTION("Microsoft Hyper-V virtual block driver");
-module_init(blkvsc_drv_init);
-module_exit(blkvsc_exit);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 294+ messages in thread

* Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 17:47 [PATCH 0000/0117] Staging: hv: Driver cleanup K. Y. Srinivasan
  2011-07-15 17:45   ` K. Y. Srinivasan
@ 2011-07-15 18:25 ` Michael Witten
  2011-07-15 18:50   ` KY Srinivasan
                     ` (2 more replies)
  2011-08-23 23:11   ` Greg KH
  2 siblings, 3 replies; 294+ messages in thread
From: Michael Witten @ 2011-07-15 18:25 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: Greg Kroah-Hartman, linux-kernel, devel, virtualization

On Fri, 15 Jul 2011 10:47:04 -0700, K. Y. Srinivasan wrote:

> Subject: [PATCH 0000/0117] Staging: hv: Driver cleanup

Now, admittedly, I'm a nobody.

However, when I had a patch series of considerable size, I noted
that Documentation/SubmittingPatches has stated the following
since 2006:

  If you cannot condense your patch set into a smaller set
  of patches, then only post say 15 or so at a time and wait
  for review and integration.

  ...

  Do not send more than 15 patches at once to the vger
  mailing lists!!!

and, accordingly, I went to the trouble of setting up a GitHub
account to host a repo from which I could issue *one* single
PULL request email; I get a little miffed every time my
inbox gets blasted with hundreds of patches when others don't
do similarly.

Surely Microsoft can host a public repo for you (and anybody
else, for that matter).

Sincerely,
Michael Witten

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: Large Patch Series in Email         (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
@ 2011-07-15 18:50   ` KY Srinivasan
  2011-07-15 21:09   ` Dan Carpenter
  2011-07-15 23:07   ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Alan Cox
  2 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-07-15 18:50 UTC (permalink / raw)
  To: Michael Witten; +Cc: Greg Kroah-Hartman, linux-kernel, devel, virtualization



> -----Original Message-----
> From: Michael Witten [mailto:mfwitten@gmail.com]
> Sent: Friday, July 15, 2011 2:26 PM
> To: KY Srinivasan
> Cc: Greg Kroah-Hartman; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org
> Subject: Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv:
> Driver cleanup)
> 
> On Fri, 15 Jul 2011 10:47:04 -0700, K. Y. Srinivasan wrote:
> 
> > Subject: [PATCH 0000/0117] Staging: hv: Driver cleanup
> 
> Now, admittedly, I'm a nobody.

You and I have something in common! I am sorry for flooding your
mailbox. In the past Greg had indicated that he could handle large
patch-sets and so, I sent out this large patch-set. Perhaps I should not have
included the vger mailing list.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
  2011-07-15 18:50   ` KY Srinivasan
@ 2011-07-15 21:09   ` Dan Carpenter
  2011-07-15 22:55     ` Michael Witten
  2011-07-15 23:07   ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Alan Cox
  2 siblings, 1 reply; 294+ messages in thread
From: Dan Carpenter @ 2011-07-15 21:09 UTC (permalink / raw)
  To: Michael Witten
  Cc: K. Y. Srinivasan, devel, Greg Kroah-Hartman, linux-kernel,
	virtualization

On Fri, Jul 15, 2011 at 06:25:55PM -0000, Michael Witten wrote:
>   Do not send more than 15 patches at once to the vger
>   mailing lists!!!

If you're using mutt just type "ESC-t ; d" to delete the entire
thread.  Don't be a whinge bucket.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 21:09   ` Dan Carpenter
@ 2011-07-15 22:55     ` Michael Witten
  2011-07-15 23:22         ` David Miller
  0 siblings, 1 reply; 294+ messages in thread
From: Michael Witten @ 2011-07-15 22:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: K. Y. Srinivasan, Greg Kroah-Hartman, linux-kernel, devel,
	virtualization

On Sat, 16 Jul 2011 00:09:03 +0300, Dan Carpenter wrote:

> On Fri, Jul 15, 2011 at 06:25:55PM -0000, Michael Witten wrote:
>>   Do not send more than 15 patches at once to the vger
>>   mailing lists!!!
>
> ... Don't be a whinge bucket.

Or be respectful of bandwidth, differing email environments, and the
official guidelines for submitting patches, which I will quote again:

    If you cannot condense your patch set into a smaller set
    of patches, then only post say 15 or so at a time and wait
    for review and integration.
    ...
    Do not send more than 15 patches at once to the vger
    mailing lists!!!

Sincerely,
Michael Witten

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email         (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
  2011-07-15 18:50   ` KY Srinivasan
  2011-07-15 21:09   ` Dan Carpenter
@ 2011-07-15 23:07   ` Alan Cox
  2011-07-17 10:47     ` Florian Mickler
  2 siblings, 1 reply; 294+ messages in thread
From: Alan Cox @ 2011-07-15 23:07 UTC (permalink / raw)
  To: Michael Witten
  Cc: K. Y. Srinivasan, Greg Kroah-Hartman, linux-kernel, devel,
	virtualization

>   Do not send more than 15 patches at once to the vger
>   mailing lists!!!
> 
> and, accordingly, I went to the trouble of setting up a GitHub
> account to host a repo from which I could issue *one* single
> PULL request email; I get a little miffed every time my
> inbox gets blasted with hundreds of patches when others don't
> do similarly.

The problem with dumping stuff that needs review into a git tree is it's
a lot of hassle to review so the advice is kind of outdated in such cases.
It's good advice for things like big new subsystems perhaps but not for
review.

As is always the case social norms evolve faster than the people who feel
compelled to attempt to document them.

There are lots of web archives of the list and it's also not hard to set
up mail tools to shuffle long emails into a folder so there are plenty of
ways to manage and read the lists without being part of it.

And someone should probably updating the CodingStyle document to reflect
reality 8)

Alan

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email
  2011-07-15 22:55     ` Michael Witten
@ 2011-07-15 23:22         ` David Miller
  0 siblings, 0 replies; 294+ messages in thread
From: David Miller @ 2011-07-15 23:22 UTC (permalink / raw)
  To: mfwitten; +Cc: error27, kys, gregkh, linux-kernel, devel, virtualization

From: Michael Witten <mfwitten@gmail.com>
Date: Fri, 15 Jul 2011 22:55:29 -0000

> On Sat, 16 Jul 2011 00:09:03 +0300, Dan Carpenter wrote:
> 
>> On Fri, Jul 15, 2011 at 06:25:55PM -0000, Michael Witten wrote:
>>>   Do not send more than 15 patches at once to the vger
>>>   mailing lists!!!
>>
>> ... Don't be a whinge bucket.
> 
> Or be respectful of bandwidth, differing email environments, and the
> official guidelines for submitting patches, which I will quote again:
> 
>     If you cannot condense your patch set into a smaller set
>     of patches, then only post say 15 or so at a time and wait
>     for review and integration.
>     ...
>     Do not send more than 15 patches at once to the vger
>     mailing lists!!!

Indeed, it really sucks when people send huge patch sets, do
not do it.

If the official SubmittingPatches document isn't convincing
enough, then maybe me (the vger postmaster) saying it will.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email
@ 2011-07-15 23:22         ` David Miller
  0 siblings, 0 replies; 294+ messages in thread
From: David Miller @ 2011-07-15 23:22 UTC (permalink / raw)
  To: mfwitten; +Cc: error27, gregkh, linux-kernel, virtualization, devel

From: Michael Witten <mfwitten@gmail.com>
Date: Fri, 15 Jul 2011 22:55:29 -0000

> On Sat, 16 Jul 2011 00:09:03 +0300, Dan Carpenter wrote:
> 
>> On Fri, Jul 15, 2011 at 06:25:55PM -0000, Michael Witten wrote:
>>>   Do not send more than 15 patches at once to the vger
>>>   mailing lists!!!
>>
>> ... Don't be a whinge bucket.
> 
> Or be respectful of bandwidth, differing email environments, and the
> official guidelines for submitting patches, which I will quote again:
> 
>     If you cannot condense your patch set into a smaller set
>     of patches, then only post say 15 or so at a time and wait
>     for review and integration.
>     ...
>     Do not send more than 15 patches at once to the vger
>     mailing lists!!!

Indeed, it really sucks when people send huge patch sets, do
not do it.

If the official SubmittingPatches document isn't convincing
enough, then maybe me (the vger postmaster) saying it will.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
  2011-07-15 17:46     ` K. Y. Srinivasan
  (?)
@ 2011-07-16  2:02     ` Christoph Hellwig
  2011-07-16 12:54       ` KY Srinivasan
  -1 siblings, 1 reply; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16  2:02 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:08AM -0700, K. Y. Srinivasan wrote:
> +static bool is_not_null_guid(const __u8 *guid)
> +{
> +	int i;
> +
> +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id)); i++)
> +		if (guid[i] != 0)
> +			return true;
> +	return false;
> +}

would be nice to add uuid_{le,be}_is_nil helpers to uuid.h.  I also
think simply using a memcpy might be more efficient than the hand-rolled
loop.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-15 17:47     ` K. Y. Srinivasan
@ 2011-07-16  2:04       ` Christoph Hellwig
  -1 siblings, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16  2:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

Thanks, this looks much cleaner than the initial variant.

> +	if (dev_is_ide) {
> +		storvsc_get_ide_info(device, &target, &path);
> +		host_dev->path = device_info.path_id;
> +		host_dev->target = device_info.target_id;
> +	} else {
> +		host_dev->path = device_info.path_id;
> +		host_dev->target = device_info.target_id;
> +	}

Is using the device_info values in both branches intentional?  If so
there's no need to have these assignments duplicated.

> +	if (dev_is_ide) {
> +		ret = scsi_add_device(host, 0, target, 0);
> +		if (ret) {
> +			scsi_remove_host(host);
> +			goto err_out;
> +		}

I'd add another goto error label for this piece of error handling.


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
@ 2011-07-16  2:04       ` Christoph Hellwig
  0 siblings, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16  2:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

Thanks, this looks much cleaner than the initial variant.

> +	if (dev_is_ide) {
> +		storvsc_get_ide_info(device, &target, &path);
> +		host_dev->path = device_info.path_id;
> +		host_dev->target = device_info.target_id;
> +	} else {
> +		host_dev->path = device_info.path_id;
> +		host_dev->target = device_info.target_id;
> +	}

Is using the device_info values in both branches intentional?  If so
there's no need to have these assignments duplicated.

> +	if (dev_is_ide) {
> +		ret = scsi_add_device(host, 0, target, 0);
> +		if (ret) {
> +			scsi_remove_host(host);
> +			goto err_out;
> +		}

I'd add another goto error label for this piece of error handling.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 098/117] Staging: hv: storvsc: Handle IDE devices using the storvsc driver
  2011-07-15 17:47   ` [PATCH 098/117] Staging: hv: storvsc: Handle " K. Y. Srinivasan
@ 2011-07-16  2:05     ` Christoph Hellwig
  0 siblings, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16  2:05 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:47:26AM -0700, K. Y. Srinivasan wrote:
> Now, enable handling of all IDE devices by extending the storvsc
> device id table to handle IDE guid. As part of this cleanup Kconfig
> and Hyper-V Makefile to not build the IDE driver (blkvsc).

I think this should be part of the previous patch.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 088/117] Staging: hv: netvsc: Inline the code for free_net_device()
  2011-07-15 17:47     ` K. Y. Srinivasan
  (?)
@ 2011-07-16 10:33     ` Dan Carpenter
  2011-07-16 13:09       ` KY Srinivasan
  -1 siblings, 1 reply; 294+ messages in thread
From: Dan Carpenter @ 2011-07-16 10:33 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:47:16AM -0700, K. Y. Srinivasan wrote:
> -static void free_net_device(struct netvsc_device *device)
> -{
> -	WARN_ON(atomic_read(&device->refcnt) != 0);
> -	device->dev->ext = NULL;

device->dev->ext points to device.  We set it NULL here to prevent
a use after free bug.  What prevents that in the new code?

> -	kfree(device);
> -}

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
  2011-07-16  2:02     ` Christoph Hellwig
@ 2011-07-16 12:54       ` KY Srinivasan
  2011-07-16 18:24         ` Christoph Hellwig
  0 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-07-16 12:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Friday, July 15, 2011 10:03 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables
> in vmbus_match()
> 
> On Fri, Jul 15, 2011 at 10:46:08AM -0700, K. Y. Srinivasan wrote:
> > +static bool is_not_null_guid(const __u8 *guid)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id)); i++)
> > +		if (guid[i] != 0)
> > +			return true;
> > +	return false;
> > +}
> 
> would be nice to add uuid_{le,be}_is_nil helpers to uuid.h.  I also
> think simply using a memcpy might be more efficient than the hand-rolled
> loop.
Having a helper function would be great. With regards to the efficiency of this loop,
this is not a performance critical path. If people feel strongly about this, I could 
change this; perhaps as a separate patch on top of this series; I don't want to send a large
patch-set like this again.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-16  2:04       ` Christoph Hellwig
@ 2011-07-16 12:57         ` KY Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-07-16 12:57 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Friday, July 15, 2011 10:05 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices
> using the storvsc driver
> 
> Thanks, this looks much cleaner than the initial variant.
> 
> > +	if (dev_is_ide) {
> > +		storvsc_get_ide_info(device, &target, &path);
> > +		host_dev->path = device_info.path_id;
> > +		host_dev->target = device_info.target_id;
> > +	} else {
> > +		host_dev->path = device_info.path_id;
> > +		host_dev->target = device_info.target_id;
> > +	}
> 
> Is using the device_info values in both branches intentional?  If so
> there's no need to have these assignments duplicated.

While we set the values in both the branches, the value set is different;
The IDE side encodes the bits differently and is appropriately parsed in the
function storvsc_get_ide_info().

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
@ 2011-07-16 12:57         ` KY Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-07-16 12:57 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization



> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Friday, July 15, 2011 10:05 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices
> using the storvsc driver
> 
> Thanks, this looks much cleaner than the initial variant.
> 
> > +	if (dev_is_ide) {
> > +		storvsc_get_ide_info(device, &target, &path);
> > +		host_dev->path = device_info.path_id;
> > +		host_dev->target = device_info.target_id;
> > +	} else {
> > +		host_dev->path = device_info.path_id;
> > +		host_dev->target = device_info.target_id;
> > +	}
> 
> Is using the device_info values in both branches intentional?  If so
> there's no need to have these assignments duplicated.

While we set the values in both the branches, the value set is different;
The IDE side encodes the bits differently and is appropriately parsed in the
function storvsc_get_ide_info().

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-16 12:57         ` KY Srinivasan
  (?)
@ 2011-07-16 13:01         ` Sasha Levin
  2011-07-16 13:12           ` KY Srinivasan
  2011-07-16 18:27             ` Christoph Hellwig
  -1 siblings, 2 replies; 294+ messages in thread
From: Sasha Levin @ 2011-07-16 13:01 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Christoph Hellwig, gregkh, linux-kernel, devel, virtualization,
	Haiyang Zhang

On Sat, 2011-07-16 at 12:57 +0000, KY Srinivasan wrote:
> 
> > -----Original Message-----
> > From: Christoph Hellwig [mailto:hch@infradead.org]
> > Sent: Friday, July 15, 2011 10:05 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices
> > using the storvsc driver
> > 
> > Thanks, this looks much cleaner than the initial variant.
> > 
> > > +	if (dev_is_ide) {
> > > +		storvsc_get_ide_info(device, &target, &path);
> > > +		host_dev->path = device_info.path_id;
> > > +		host_dev->target = device_info.target_id;
> > > +	} else {
> > > +		host_dev->path = device_info.path_id;
> > > +		host_dev->target = device_info.target_id;
> > > +	}
> > 
> > Is using the device_info values in both branches intentional?  If so
> > there's no need to have these assignments duplicated.
> 
> While we set the values in both the branches, the value set is different;
> The IDE side encodes the bits differently and is appropriately parsed in the
> function storvsc_get_ide_info().

Is think that what Christoph meant was simplifying it to:

	if (dev_is_ide)
		storvsc_get_ide_info(device, &target, &path);
	
	host_dev->path = device_info.path_id;
	host_dev->target = device_info.target_id;

-- 

Sasha.


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 088/117] Staging: hv: netvsc: Inline the code for free_net_device()
  2011-07-16 10:33     ` Dan Carpenter
@ 2011-07-16 13:09       ` KY Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-07-16 13:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Dan Carpenter [mailto:error27@gmail.com]
> Sent: Saturday, July 16, 2011 6:34 AM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 088/117] Staging: hv: netvsc: Inline the code for
> free_net_device()
> 
> On Fri, Jul 15, 2011 at 10:47:16AM -0700, K. Y. Srinivasan wrote:
> > -static void free_net_device(struct netvsc_device *device)
> > -{
> > -	WARN_ON(atomic_read(&device->refcnt) != 0);
> > -	device->dev->ext = NULL;
> 
> device->dev->ext points to device.  We set it NULL here to prevent
> a use after free bug.  What prevents that in the new code?
> 
> > -	kfree(device);
> > -}
This function is called in only two places; a) during adding a device when we have a failure
(netvsc_device_add()) and during device removal (netvsc_device_remove()). I have handled
both these cases. In any event when we are freeing the containing object via kfree(), if somebody
is accessing the ext field via freed object, we have bigger problems to deal with.

Regards,

K. Y


> 
> regards,
> dan carpenter
> 
> 


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-16 13:01         ` Sasha Levin
@ 2011-07-16 13:12           ` KY Srinivasan
  2011-07-16 18:27             ` Christoph Hellwig
  1 sibling, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-07-16 13:12 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Christoph Hellwig, gregkh, linux-kernel, devel, virtualization,
	Haiyang Zhang



> -----Original Message-----
> From: Sasha Levin [mailto:levinsasha928@gmail.com]
> Sent: Saturday, July 16, 2011 9:02 AM
> To: KY Srinivasan
> Cc: Christoph Hellwig; gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: RE: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices
> using the storvsc driver
> 
> On Sat, 2011-07-16 at 12:57 +0000, KY Srinivasan wrote:
> >
> > > -----Original Message-----
> > > From: Christoph Hellwig [mailto:hch@infradead.org]
> > > Sent: Friday, July 15, 2011 10:05 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE
> devices
> > > using the storvsc driver
> > >
> > > Thanks, this looks much cleaner than the initial variant.
> > >
> > > > +	if (dev_is_ide) {
> > > > +		storvsc_get_ide_info(device, &target, &path);
> > > > +		host_dev->path = device_info.path_id;
> > > > +		host_dev->target = device_info.target_id;
> > > > +	} else {
> > > > +		host_dev->path = device_info.path_id;
> > > > +		host_dev->target = device_info.target_id;
> > > > +	}
> > >
> > > Is using the device_info values in both branches intentional?  If so
> > > there's no need to have these assignments duplicated.
> >
> > While we set the values in both the branches, the value set is different;
> > The IDE side encodes the bits differently and is appropriately parsed in the
> > function storvsc_get_ide_info().
> 
> Is think that what Christoph meant was simplifying it to:
> 
> 	if (dev_is_ide)
> 		storvsc_get_ide_info(device, &target, &path);
> 
> 	host_dev->path = device_info.path_id;
> 	host_dev->target = device_info.target_id;

Good point! It is still too early in the morning for me. 
Greg, if it is ok with you, in the interest of keeping the patch
cops happy, I can submit a patch for this on top of this series.

Regards,

K. Y
> 
> --
> 
> Sasha.
> 


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
  2011-07-16 12:54       ` KY Srinivasan
@ 2011-07-16 18:24         ` Christoph Hellwig
  0 siblings, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16 18:24 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Christoph Hellwig, gregkh, linux-kernel, devel, virtualization,
	Haiyang Zhang

On Sat, Jul 16, 2011 at 12:54:46PM +0000, KY Srinivasan wrote:
> > would be nice to add uuid_{le,be}_is_nil helpers to uuid.h.  I also
> > think simply using a memcpy might be more efficient than the hand-rolled
> > loop.
> Having a helper function would be great. With regards to the efficiency of this loop,
> this is not a performance critical path. If people feel strongly about this, I could 
> change this; perhaps as a separate patch on top of this series; I don't want to send a large
> patch-set like this again.

I'm fine with doing it later.


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
  2011-07-16 13:01         ` Sasha Levin
@ 2011-07-16 18:27             ` Christoph Hellwig
  2011-07-16 18:27             ` Christoph Hellwig
  1 sibling, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16 18:27 UTC (permalink / raw)
  To: Sasha Levin
  Cc: KY Srinivasan, Christoph Hellwig, gregkh, linux-kernel, devel,
	virtualization, Haiyang Zhang

On Sat, Jul 16, 2011 at 04:01:39PM +0300, Sasha Levin wrote:
> Is think that what Christoph meant was simplifying it to:
> 
> 	if (dev_is_ide)
> 		storvsc_get_ide_info(device, &target, &path);
> 	
> 	host_dev->path = device_info.path_id;
> 	host_dev->target = device_info.target_id;

Indeed.  In addition path is unused and target is only used in the
second dev_is_ide conditional, so both the call and the target and path
variables can be moved into that one to further simplify the function.

But I'm fine with delaying that cleanup to a follow on patch so that
we can make progress in getting this pile merged.


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver
@ 2011-07-16 18:27             ` Christoph Hellwig
  0 siblings, 0 replies; 294+ messages in thread
From: Christoph Hellwig @ 2011-07-16 18:27 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Haiyang Zhang, gregkh, linux-kernel, Christoph Hellwig,
	virtualization, devel

On Sat, Jul 16, 2011 at 04:01:39PM +0300, Sasha Levin wrote:
> Is think that what Christoph meant was simplifying it to:
> 
> 	if (dev_is_ide)
> 		storvsc_get_ide_info(device, &target, &path);
> 	
> 	host_dev->path = device_info.path_id;
> 	host_dev->target = device_info.target_id;

Indeed.  In addition path is unused and target is only used in the
second dev_is_ide conditional, so both the call and the target and path
variables can be moved into that one to further simplify the function.

But I'm fine with delaying that cleanup to a follow on patch so that
we can make progress in getting this pile merged.

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: Large Patch Series in Email         (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup)
  2011-07-15 23:07   ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Alan Cox
@ 2011-07-17 10:47     ` Florian Mickler
  0 siblings, 0 replies; 294+ messages in thread
From: Florian Mickler @ 2011-07-17 10:47 UTC (permalink / raw)
  To: Alan Cox
  Cc: Michael Witten, K. Y. Srinivasan, Greg Kroah-Hartman,
	linux-kernel, devel, virtualization

On Sat, 16 Jul 2011 00:07:39 +0100
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> >   Do not send more than 15 patches at once to the vger
> >   mailing lists!!!
> > 
> > and, accordingly, I went to the trouble of setting up a GitHub
> > account to host a repo from which I could issue *one* single
> > PULL request email; I get a little miffed every time my
> > inbox gets blasted with hundreds of patches when others don't
> > do similarly.
> 
> The problem with dumping stuff that needs review into a git tree is it's
> a lot of hassle to review so the advice is kind of outdated in such cases.
> It's good advice for things like big new subsystems perhaps but not for
> review.
> 
> As is always the case social norms evolve faster than the people who feel
> compelled to attempt to document them.
> 
> There are lots of web archives of the list and it's also not hard to set
> up mail tools to shuffle long emails into a folder so there are plenty of
> ways to manage and read the lists without being part of it.
> 
> And someone should probably updating the CodingStyle document to reflect
> reality 8)
> 
> Alan

And while at it, maybe add some tipps on how to keep patchseries
small... (people have probably more / better suggestions, please):

- 'submit early, submit often' instead of time based submittal (like...
  oh I hacked 24/7 this week and now is friday, let's see how many
  patches I got...)
- Putting controversial stuff at the end (so at least uncontroversial
  stuff can be applied)
- try to split patchseries into stuff that can be applied independent
  of one another. 
- ...

Regards,
Flo

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-07-15 17:45     ` K. Y. Srinivasan
  (?)
@ 2011-08-23 22:41     ` Greg KH
  2011-08-24  0:44       ` KY Srinivasan
  -1 siblings, 1 reply; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:41 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> In preparation for implementing vmbus aliases for auto-loading
> Hyper-V drivers, define vmbus specific device ID.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  include/linux/mod_devicetable.h |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index ae28e93..5a12377 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -405,6 +405,13 @@ struct virtio_device_id {
>  };
>  #define VIRTIO_DEV_ANY_ID	0xffffffff
>  
> +/*
> + * For Hyper-V devices we use the device guid as the id.
> + */
> +struct hv_vmbus_device_id {
> +	__u8 guid[16];
> +};

Why do you not need a driver_data pointer here?  Are you sure you aren't
ever going to need it in the future?  Hint, I think you will...

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 006/117] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
  2011-07-15 17:45     ` K. Y. Srinivasan
@ 2011-08-23 22:45       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:45 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:45:54AM -0700, K. Y. Srinivasan wrote:
> Use the newly introduced vmbus ID in the blockvsc driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 018b293..38117d96 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -802,10 +802,26 @@ static void blkvsc_request(struct request_queue *queue)
>  	}
>  }
>  
> +static const struct hv_vmbus_device_id id_table[] = {
> +	{
> +		/* IDE guid */
> +		.guid = {
> +			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> +			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> +		}
> +	},
> +	{
> +		.guid = {
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +		}

No, just zero terminate the list with a simple { } entry, not the whole
thing spelled for every individual byte.

Same goes for the other patches that added this id_table, please fix
those.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 006/117] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
@ 2011-08-23 22:45       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:45 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:45:54AM -0700, K. Y. Srinivasan wrote:
> Use the newly introduced vmbus ID in the blockvsc driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 018b293..38117d96 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -802,10 +802,26 @@ static void blkvsc_request(struct request_queue *queue)
>  	}
>  }
>  
> +static const struct hv_vmbus_device_id id_table[] = {
> +	{
> +		/* IDE guid */
> +		.guid = {
> +			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> +			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> +		}
> +	},
> +	{
> +		.guid = {
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +		}

No, just zero terminate the list with a simple { } entry, not the whole
thing spelled for every individual byte.

Same goes for the other patches that added this id_table, please fix
those.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 012/117] Staging: hv: blkvsc: Add the MODULE_DEVICE_TABLE() line
  2011-07-15 17:46   ` [PATCH 012/117] Staging: hv: blkvsc: Add the MODULE_DEVICE_TABLE() line K. Y. Srinivasan
@ 2011-08-23 22:46     ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:46 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:00AM -0700, K. Y. Srinivasan wrote:
> Add the MODULE_DEVICE_TABLE() line in blkvsc_drv.c.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 38117d96..8e4c206 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -818,6 +818,7 @@ static const struct hv_vmbus_device_id id_table[] = {
>  	},
>  };
>  
> +MODULE_DEVICE_TABLE(vmbus, id_table);

Please merge this back into the patch that added the id_table to the
driver, having it separate like this is just ridiculous.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 011/117] Staging: hv: util: Use the newly introduced vmbus ID in util driver
  2011-07-15 17:45     ` K. Y. Srinivasan
  (?)
@ 2011-08-23 22:46     ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:46 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:45:59AM -0700, K. Y. Srinivasan wrote:
> Use the newly introduced vmbus ID in util driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hv_util.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
> index e72bfe0..35540f5 100644
> --- a/drivers/staging/hv/hv_util.c
> +++ b/drivers/staging/hv/hv_util.c
> @@ -226,9 +226,47 @@ static int util_remove(struct hv_device *dev)
>  	return 0;
>  }
>  
> +static const struct hv_vmbus_device_id id_table[] = {
> +	{
> +		/* Shutdown guid */
> +		.guid = {
> +			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
> +			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
> +		}
> +	},
> +	{
> +		/* Time synch guid */
> +		.guid = {
> +			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
> +			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
> +		}
> +	},
> +	{
> +		/* Heartbeat guid */
> +		.guid = {
> +			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
> +			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
> +		}
> +	},
> +	{
> +		/* KVP guid */
> +		.guid = {
> +			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
> +			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
> +		}
> +	},
> +	{
> +		.guid = {
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> +			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +		}
> +	},
> +};
> +

Merge this into the previous patch please.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 017/117] Staging: hv: mouse: Do not auto-load the mouse driver
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 22:47       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:47 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:05AM -0700, K. Y. Srinivasan wrote:
> The mouse driver is not functional and so, prevent auto-loading
> of this driver. Earlier we added the MODULE_DEVICE_TABLE() line
> to verify that the appropriate module alias was generated.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hv_mouse.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
> index d6441d6..95986fb 100644
> --- a/drivers/staging/hv/hv_mouse.c
> +++ b/drivers/staging/hv/hv_mouse.c
> @@ -931,7 +931,10 @@ static const struct hv_vmbus_device_id id_table[] = {
>  	},
>  };
>  
> -MODULE_DEVICE_TABLE(vmbus, id_table);
> +/*
> + * The mouse driver is not functional; do not auto-load it.
> + */
> +/* MODULE_DEVICE_TABLE(vmbus, id_table); */

Then you should not have caused it to be autoloaded on the previous
patch.  Please merge this with the previous patch, which would be merged
with the previous patch to that, smushing them all into a smaller patch
series.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 017/117] Staging: hv: mouse: Do not auto-load the mouse driver
@ 2011-08-23 22:47       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:47 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:05AM -0700, K. Y. Srinivasan wrote:
> The mouse driver is not functional and so, prevent auto-loading
> of this driver. Earlier we added the MODULE_DEVICE_TABLE() line
> to verify that the appropriate module alias was generated.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hv_mouse.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
> index d6441d6..95986fb 100644
> --- a/drivers/staging/hv/hv_mouse.c
> +++ b/drivers/staging/hv/hv_mouse.c
> @@ -931,7 +931,10 @@ static const struct hv_vmbus_device_id id_table[] = {
>  	},
>  };
>  
> -MODULE_DEVICE_TABLE(vmbus, id_table);
> +/*
> + * The mouse driver is not functional; do not auto-load it.
> + */
> +/* MODULE_DEVICE_TABLE(vmbus, id_table); */

Then you should not have caused it to be autoloaded on the previous
patch.  Please merge this with the previous patch, which would be merged
with the previous patch to that, smushing them all into a smaller patch
series.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
  2011-07-15 17:46     ` K. Y. Srinivasan
  (?)
@ 2011-08-23 22:49     ` Greg KH
  2011-08-24  0:38       ` KY Srinivasan
  -1 siblings, 1 reply; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:49 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:07AM -0700, K. Y. Srinivasan wrote:
> Now generate appropriate uevent based on the modalias string. As part of this,
> cleanup the existing uevent code.

Note, you just change the user api here, did you have tools that relied
on the old format?  If so, they just broke :(

> +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);

Don't we have a type for printing out a uuid already?

And what's with the jumping by 2 yet dividing?  What am I missing here?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 22:51       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:51 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:08AM -0700, K. Y. Srinivasan wrote:
> Introduce code to handle driver specific id tables to the vmbus core
> (vmbus_match). This would allow us to handle more than one device type
> with a given driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/vmbus_drv.c |   21 ++++++++++++++++-----
>  1 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> index 7baba62..3a8eb36 100644
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -255,21 +255,32 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
>  	return ret;
>  }
>  
> +static bool is_not_null_guid(const __u8 *guid)

Negative function names cause people's heads to get confused.

Please do "is_null_guid()" instead.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()
@ 2011-08-23 22:51       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:51 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:08AM -0700, K. Y. Srinivasan wrote:
> Introduce code to handle driver specific id tables to the vmbus core
> (vmbus_match). This would allow us to handle more than one device type
> with a given driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/vmbus_drv.c |   21 ++++++++++++++++-----
>  1 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> index 7baba62..3a8eb36 100644
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -255,21 +255,32 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
>  	return ret;
>  }
>  
> +static bool is_not_null_guid(const __u8 *guid)

Negative function names cause people's heads to get confused.

Please do "is_null_guid()" instead.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 027/117] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 22:52       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:52 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:15AM -0700, K. Y. Srinivasan wrote:
> Get rid of the dev_type guid from blkvsc_drv.c as it is no longer used.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |    9 ---------
>  1 files changed, 0 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 8e4c206..cb61598 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -111,14 +111,6 @@ struct block_device_context {
>  
>  static const char *drv_name = "blkvsc";
>  
> -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
> -static const uuid_le dev_type = {
> -	.b = {
> -		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> -		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> -	}
> -};

Could be merged with the previous patch that added the guid in the other
format, right?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 027/117] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c
@ 2011-08-23 22:52       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:52 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:15AM -0700, K. Y. Srinivasan wrote:
> Get rid of the dev_type guid from blkvsc_drv.c as it is no longer used.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |    9 ---------
>  1 files changed, 0 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 8e4c206..cb61598 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -111,14 +111,6 @@ struct block_device_context {
>  
>  static const char *drv_name = "blkvsc";
>  
> -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
> -static const uuid_le dev_type = {
> -	.b = {
> -		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> -		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> -	}
> -};

Could be merged with the previous patch that added the guid in the other
format, right?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 031/117] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 22:56       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:56 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:19AM -0700, K. Y. Srinivasan wrote:
> Now, get rid of the driver name initialization in  int netvsc_initialize().
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/netvsc.c |    5 -----
>  1 files changed, 0 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
> index 6f4541b..d085018 100644
> --- a/drivers/staging/hv/netvsc.c
> +++ b/drivers/staging/hv/netvsc.c
> @@ -32,9 +32,6 @@
>  #include "hyperv_net.h"
>  
>  
> -/* Globals */
> -static const char *driver_name = "netvsc";
> -
>  static struct netvsc_device *alloc_net_device(struct hv_device *device)
>  {
>  	struct netvsc_device *net_device;
> @@ -999,7 +996,5 @@ cleanup:
>  int netvsc_initialize(struct hv_driver *drv)
>  {
>  
> -	drv->name = driver_name;
> -

Please merge this with the previous patch.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 031/117] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c
@ 2011-08-23 22:56       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 22:56 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:19AM -0700, K. Y. Srinivasan wrote:
> Now, get rid of the driver name initialization in  int netvsc_initialize().
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/netvsc.c |    5 -----
>  1 files changed, 0 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
> index 6f4541b..d085018 100644
> --- a/drivers/staging/hv/netvsc.c
> +++ b/drivers/staging/hv/netvsc.c
> @@ -32,9 +32,6 @@
>  #include "hyperv_net.h"
>  
>  
> -/* Globals */
> -static const char *driver_name = "netvsc";
> -
>  static struct netvsc_device *alloc_net_device(struct hv_device *device)
>  {
>  	struct netvsc_device *net_device;
> @@ -999,7 +996,5 @@ cleanup:
>  int netvsc_initialize(struct hv_driver *drv)
>  {
>  
> -	drv->name = driver_name;
> -

Please merge this with the previous patch.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 035/117] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name
  2011-07-15 17:46   ` [PATCH 035/117] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name K. Y. Srinivasan
@ 2011-08-23 23:01       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:01 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:23AM -0700, K. Y. Srinivasan wrote:
> To support "human readable" sysfs attribute, introduce a function to map the
> dev_type guid to a string.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/channel_mgmt.c |   36 ++++++++++++++++++++++++++++++++++++
>  drivers/staging/hv/hyperv.h       |    2 +-
>  2 files changed, 37 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
> index 11beb41..926bc87 100644
> --- a/drivers/staging/hv/channel_mgmt.c
> +++ b/drivers/staging/hv/channel_mgmt.c
> @@ -112,6 +112,42 @@ static const uuid_le
>  
>  };
>  
> +static const char *blk_dev_type = "hv_block";
> +static const char *net_dev_type = "hv_net";
> +static const char *scsi_dev_type = "hv_scsi";
> +static const char *mouse_dev_type = "hv_mouse";
> +static const char *util_dev_type = "hv_util";

Ick, no.  There should never be any type of "central" knowledge of the
different driver names or types like this.  It should all be
self-contained within the individual drivers.

You will note that no other bus type has this type of thing, which
should have been a hint that you should not have done this...

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 035/117] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name
@ 2011-08-23 23:01       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:01 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:23AM -0700, K. Y. Srinivasan wrote:
> To support "human readable" sysfs attribute, introduce a function to map the
> dev_type guid to a string.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/channel_mgmt.c |   36 ++++++++++++++++++++++++++++++++++++
>  drivers/staging/hv/hyperv.h       |    2 +-
>  2 files changed, 37 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
> index 11beb41..926bc87 100644
> --- a/drivers/staging/hv/channel_mgmt.c
> +++ b/drivers/staging/hv/channel_mgmt.c
> @@ -112,6 +112,42 @@ static const uuid_le
>  
>  };
>  
> +static const char *blk_dev_type = "hv_block";
> +static const char *net_dev_type = "hv_net";
> +static const char *scsi_dev_type = "hv_scsi";
> +static const char *mouse_dev_type = "hv_mouse";
> +static const char *util_dev_type = "hv_util";

Ick, no.  There should never be any type of "central" knowledge of the
different driver names or types like this.  It should all be
self-contained within the individual drivers.

You will note that no other bus type has this type of thing, which
should have been a hint that you should not have done this...

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 036/117] Staging: hv: vmbus: Make class_id attribute a human readable string
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 23:02       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:02 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:24AM -0700, K. Y. Srinivasan wrote:
> Now that we have a human readable device_type, use that and get rid of the
> guid based device type.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/vmbus_drv.c |   20 ++------------------
>  1 files changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> index 9a0df2c..67415ab 100644
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -113,24 +113,8 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
>  	get_channel_info(hv_dev, &device_info);
>  
>  	if (!strcmp(dev_attr->attr.name, "class_id")) {
> -		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> -			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",

You just changed what this sysfs file contains to have something totally
different than what it used to.

What userspace tools just broke?

If you change the data in the file, shouldn't the name of the file
change as well?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 036/117] Staging: hv: vmbus: Make class_id attribute a human readable string
@ 2011-08-23 23:02       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:02 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:24AM -0700, K. Y. Srinivasan wrote:
> Now that we have a human readable device_type, use that and get rid of the
> guid based device type.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/vmbus_drv.c |   20 ++------------------
>  1 files changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> index 9a0df2c..67415ab 100644
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -113,24 +113,8 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
>  	get_channel_info(hv_dev, &device_info);
>  
>  	if (!strcmp(dev_attr->attr.name, "class_id")) {
> -		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> -			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",

You just changed what this sysfs file contains to have something totally
different than what it used to.

What userspace tools just broke?

If you change the data in the file, shouldn't the name of the file
change as well?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 037/117] Staging: hv: vmbus: Get rid of the  device_id attribute
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 23:03       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:03 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:25AM -0700, K. Y. Srinivasan wrote:
> The guid based instance data is not very useful. There is enough information
> to identify the device. Get rid of this attribute.

But userspace probably wants to see this at times, don't remove it,
someone is going to need it, especially as this is how the driver/device
is bound together.

why delete it?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 037/117] Staging: hv: vmbus: Get rid of the  device_id attribute
@ 2011-08-23 23:03       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:03 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:25AM -0700, K. Y. Srinivasan wrote:
> The guid based instance data is not very useful. There is enough information
> to identify the device. Get rid of this attribute.

But userspace probably wants to see this at times, don't remove it,
someone is going to need it, especially as this is how the driver/device
is bound together.

why delete it?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 040/117] Staging: hv: vmbus: Cleanup error handling in hv_init()
  2011-07-15 17:46     ` K. Y. Srinivasan
@ 2011-08-23 23:04       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:46:28AM -0700, K. Y. Srinivasan wrote:
> Use standard Linux error codes.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hv.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
> index 2f94880..e733173 100644
> --- a/drivers/staging/hv/hv.c
> +++ b/drivers/staging/hv/hv.c
> @@ -225,8 +225,8 @@ cleanup:
>  
>  		vfree(virtaddr);
>  	}
> -	ret = -1;
> -	return ret;
> +
> +	return -ENOTSUPP;

The ret variable is no longer needed here, so just remove it entirely in
this patch.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 040/117] Staging: hv: vmbus: Cleanup error handling in hv_init()
@ 2011-08-23 23:04       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:46:28AM -0700, K. Y. Srinivasan wrote:
> Use standard Linux error codes.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hv.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
> index 2f94880..e733173 100644
> --- a/drivers/staging/hv/hv.c
> +++ b/drivers/staging/hv/hv.c
> @@ -225,8 +225,8 @@ cleanup:
>  
>  		vfree(virtaddr);
>  	}
> -	ret = -1;
> -	return ret;
> +
> +	return -ENOTSUPP;

The ret variable is no longer needed here, so just remove it entirely in
this patch.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
  2011-07-15 17:47     ` K. Y. Srinivasan
@ 2011-08-23 23:08       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:08 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> The current mechanism for handling references in broken.
> Introduce a lock to protect the ext field in hv_device.

Why would that lock ever be needed?  How can things change to this
pointer in different ways like you are thinking it could?  Doesn't the
reference counting in the device itself handle this properly?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
@ 2011-08-23 23:08       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:08 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> The current mechanism for handling references in broken.
> Introduce a lock to protect the ext field in hv_device.

Why would that lock ever be needed?  How can things change to this
pointer in different ways like you are thinking it could?  Doesn't the
reference counting in the device itself handle this properly?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-07-15 17:47     ` K. Y. Srinivasan
@ 2011-08-23 23:10       ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:10 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> Now that we have a spin lock protecting access to the stor device pointer,
> use it manage the reference count as well.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hyperv_storage.h |    8 ++++----
>  drivers/staging/hv/storvsc.c        |   10 +++++-----
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
> index 53b65be..d946211 100644
> --- a/drivers/staging/hv/hyperv_storage.h
> +++ b/drivers/staging/hv/hyperv_storage.h
> @@ -265,7 +265,7 @@ struct storvsc_device {
>  	struct hv_device *device;
>  
>  	/* 0 indicates the device is being destroyed */
> -	atomic_t ref_count;
> +	int	 ref_count;

Is this really needed?  Can't you rely on the reference count of the
hv_device itself?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
@ 2011-08-23 23:10       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:10 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> Now that we have a spin lock protecting access to the stor device pointer,
> use it manage the reference count as well.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hyperv_storage.h |    8 ++++----
>  drivers/staging/hv/storvsc.c        |   10 +++++-----
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
> index 53b65be..d946211 100644
> --- a/drivers/staging/hv/hyperv_storage.h
> +++ b/drivers/staging/hv/hyperv_storage.h
> @@ -265,7 +265,7 @@ struct storvsc_device {
>  	struct hv_device *device;
>  
>  	/* 0 indicates the device is being destroyed */
> -	atomic_t ref_count;
> +	int	 ref_count;

Is this really needed?  Can't you rely on the reference count of the
hv_device itself?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 0000/0117] Staging: hv: Driver cleanup
  2011-07-15 17:47 [PATCH 0000/0117] Staging: hv: Driver cleanup K. Y. Srinivasan
@ 2011-08-23 23:11   ` Greg KH
  2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
  2011-08-23 23:11   ` Greg KH
  2 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:11 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization

On Fri, Jul 15, 2011 at 10:47:04AM -0700, K. Y. Srinivasan wrote:
> Further cleanup of the hv drivers. Back in June I had sent two patch
> sets to address these issues. I have addressed the comments I got from
> the community on my earlier patches here:
> 
> 	1) Implement code for autoloading the vmbus drivers without using PCI or DMI
> 	   signatures. I have implemented this based on Greg's feedback on my earlier
> 	   implementation.
> 
> 	2) Cleanup error handling across the board and use standard Linux error codes.
> 
> 	3) General cleanup
> 
> 	4) Some bug fixes.
> 
> 	5) Cleanup the reference counting mess for both stor and net devices.
> 
> 	6) Handle all block devices using the storvsc driver. I have modified
> 	   the implementation here based on Christoph's feedback on my earlier
> 	   implementation.
> 
> 	7) Accomodate some host side scsi emulation bugs.
> 
> 	8) In case of scsi errors off-line the device.

Care to respin this patch series based on my comments?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 0000/0117] Staging: hv: Driver cleanup
@ 2011-08-23 23:11   ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-23 23:11 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: devel, gregkh, linux-kernel, virtualization

On Fri, Jul 15, 2011 at 10:47:04AM -0700, K. Y. Srinivasan wrote:
> Further cleanup of the hv drivers. Back in June I had sent two patch
> sets to address these issues. I have addressed the comments I got from
> the community on my earlier patches here:
> 
> 	1) Implement code for autoloading the vmbus drivers without using PCI or DMI
> 	   signatures. I have implemented this based on Greg's feedback on my earlier
> 	   implementation.
> 
> 	2) Cleanup error handling across the board and use standard Linux error codes.
> 
> 	3) General cleanup
> 
> 	4) Some bug fixes.
> 
> 	5) Cleanup the reference counting mess for both stor and net devices.
> 
> 	6) Handle all block devices using the storvsc driver. I have modified
> 	   the implementation here based on Christoph's feedback on my earlier
> 	   implementation.
> 
> 	7) Accomodate some host side scsi emulation bugs.
> 
> 	8) In case of scsi errors off-line the device.

Care to respin this patch series based on my comments?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
  2011-08-23 22:49     ` Greg KH
@ 2011-08-24  0:38       ` KY Srinivasan
  2011-08-24  3:00           ` Greg KH
  0 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  0:38 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 6:50 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
> 
> On Fri, Jul 15, 2011 at 10:46:07AM -0700, K. Y. Srinivasan wrote:
> > Now generate appropriate uevent based on the modalias string. As part of this,
> > cleanup the existing uevent code.
> 
> Note, you just change the user api here, did you have tools that relied
> on the old format?  If so, they just broke :(

Prior to this, I don't think autoloading worked the way it should for these
modules. 

> 
> > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> > +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> 
> Don't we have a type for printing out a uuid already?

I did not see one; could you point me to the right place.
> 
> And what's with the jumping by 2 yet dividing?  What am I missing here?

Each byte of the uuid is represented by 2 bytes in the string; thus the magic with 2.

Regards,

K. Y


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-23 22:41     ` Greg KH
@ 2011-08-24  0:44       ` KY Srinivasan
  2011-08-24  2:59         ` Greg KH
  0 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  0:44 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 6:42 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> mod_devicetable.h
> 
> On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > In preparation for implementing vmbus aliases for auto-loading
> > Hyper-V drivers, define vmbus specific device ID.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  include/linux/mod_devicetable.h |    7 +++++++
> >  1 files changed, 7 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/linux/mod_devicetable.h
> b/include/linux/mod_devicetable.h
> > index ae28e93..5a12377 100644
> > --- a/include/linux/mod_devicetable.h
> > +++ b/include/linux/mod_devicetable.h
> > @@ -405,6 +405,13 @@ struct virtio_device_id {
> >  };
> >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> >
> > +/*
> > + * For Hyper-V devices we use the device guid as the id.
> > + */
> > +struct hv_vmbus_device_id {
> > +	__u8 guid[16];
> > +};
> 
> Why do you not need a driver_data pointer here?  Are you sure you aren't
> ever going to need it in the future?  Hint, I think you will...

I am not sure I am following you here; the guid is the device ID and it is 
guaranteed to remain the same. What is the driver _data pointer here 
you are referring to here.  While some device id have the _data pointer,
there are others that don't - for instance struct virtio_device_id. In 
our case, I am not sure how I would use this private pointer.

Regards,

K. Y
> 
> greg k-h


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
  2011-08-23 23:08       ` Greg KH
  (?)
@ 2011-08-24  0:55       ` KY Srinivasan
  2011-08-24  2:58           ` Greg KH
  -1 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  0:55 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 7:08 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the
> ext field in hv_device
> 
> On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> > The current mechanism for handling references in broken.
> > Introduce a lock to protect the ext field in hv_device.
> 
> Why would that lock ever be needed?  How can things change to this
> pointer in different ways like you are thinking it could?  Doesn't the
> reference counting in the device itself handle this properly?

This is to deal with a potential race condition between the driver being
unloaded and incoming traffic from the VMBUS side. The ext pointer is 
device specific (either pointing to a storage or a network device) and what
we are protecting is the pointer being set to NULL from the unload side when
we might have a racing access from the interrupt side (on the incoming vmbus
traffic).

Regards,

K. Y 


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-23 23:10       ` Greg KH
@ 2011-08-24  0:58         ` KY Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  0:58 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 7:10 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> manage ref_cnt
> 
> On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > Now that we have a spin lock protecting access to the stor device pointer,
> > use it manage the reference count as well.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> >  2 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/hv/hyperv_storage.h
> b/drivers/staging/hv/hyperv_storage.h
> > index 53b65be..d946211 100644
> > --- a/drivers/staging/hv/hyperv_storage.h
> > +++ b/drivers/staging/hv/hyperv_storage.h
> > @@ -265,7 +265,7 @@ struct storvsc_device {
> >  	struct hv_device *device;
> >
> >  	/* 0 indicates the device is being destroyed */
> > -	atomic_t ref_count;
> > +	int	 ref_count;
> 
> Is this really needed?  Can't you rely on the reference count of the
> hv_device itself?

We don't have a reference count on the hv_device and this count is taken
to deal with racing unloads and incoming traffic on the channel from the 
host. 

Regards,

K. Y


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
@ 2011-08-24  0:58         ` KY Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  0:58 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 7:10 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> manage ref_cnt
> 
> On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > Now that we have a spin lock protecting access to the stor device pointer,
> > use it manage the reference count as well.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> >  2 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/hv/hyperv_storage.h
> b/drivers/staging/hv/hyperv_storage.h
> > index 53b65be..d946211 100644
> > --- a/drivers/staging/hv/hyperv_storage.h
> > +++ b/drivers/staging/hv/hyperv_storage.h
> > @@ -265,7 +265,7 @@ struct storvsc_device {
> >  	struct hv_device *device;
> >
> >  	/* 0 indicates the device is being destroyed */
> > -	atomic_t ref_count;
> > +	int	 ref_count;
> 
> Is this really needed?  Can't you rely on the reference count of the
> hv_device itself?

We don't have a reference count on the hv_device and this count is taken
to deal with racing unloads and incoming traffic on the channel from the 
host. 

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 0000/0117] Staging: hv: Driver cleanup
  2011-08-23 23:11   ` Greg KH
  (?)
@ 2011-08-24  1:01   ` KY Srinivasan
  2011-08-24  3:08       ` Greg KH
  -1 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24  1:01 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 7:11 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org
> Subject: Re: [PATCH 0000/0117] Staging: hv: Driver cleanup
> 
> On Fri, Jul 15, 2011 at 10:47:04AM -0700, K. Y. Srinivasan wrote:
> > Further cleanup of the hv drivers. Back in June I had sent two patch
> > sets to address these issues. I have addressed the comments I got from
> > the community on my earlier patches here:
> >
> > 	1) Implement code for autoloading the vmbus drivers without using PCI
> or DMI
> > 	   signatures. I have implemented this based on Greg's feedback on my
> earlier
> > 	   implementation.
> >
> > 	2) Cleanup error handling across the board and use standard Linux error
> codes.
> >
> > 	3) General cleanup
> >
> > 	4) Some bug fixes.
> >
> > 	5) Cleanup the reference counting mess for both stor and net devices.
> >
> > 	6) Handle all block devices using the storvsc driver. I have modified
> > 	   the implementation here based on Christoph's feedback on my earlier
> > 	   implementation.
> >
> > 	7) Accomodate some host side scsi emulation bugs.
> >
> > 	8) In case of scsi errors off-line the device.
> 
> Care to respin this patch series based on my comments?

Greg,

Thank you for your comments. I will try to re-submit these patches as soon as I
possibly can. If I were to get these patches re-spun and sent to you in the next couple of 
days, can I still make this current merge window?

Regards,

K. Y
> 
> thanks,
> 
> greg k-h


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-24  0:58         ` KY Srinivasan
@ 2011-08-24  2:57           ` Greg KH
  -1 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  2:57 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 12:58:36AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 7:10 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> > manage ref_cnt
> > 
> > On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > > Now that we have a spin lock protecting access to the stor device pointer,
> > > use it manage the reference count as well.
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > ---
> > >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> > >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> > >  2 files changed, 9 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/drivers/staging/hv/hyperv_storage.h
> > b/drivers/staging/hv/hyperv_storage.h
> > > index 53b65be..d946211 100644
> > > --- a/drivers/staging/hv/hyperv_storage.h
> > > +++ b/drivers/staging/hv/hyperv_storage.h
> > > @@ -265,7 +265,7 @@ struct storvsc_device {
> > >  	struct hv_device *device;
> > >
> > >  	/* 0 indicates the device is being destroyed */
> > > -	atomic_t ref_count;
> > > +	int	 ref_count;
> > 
> > Is this really needed?  Can't you rely on the reference count of the
> > hv_device itself?
> 
> We don't have a reference count on the hv_device

Wait, why not?  You shure better have a reference count on that device
if you have a pointer to it, if not, you have a bug, and that needs to
be fixed.  Please reread Documentation/CodingStyle for details.

> and this count is taken to deal with racing unloads and incoming
> traffic on the channel from the host. 

Is this something that all other storage drivers have to do?  If not,
then you shouldn't be doing that as well.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
@ 2011-08-24  2:57           ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  2:57 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 12:58:36AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 7:10 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> > manage ref_cnt
> > 
> > On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > > Now that we have a spin lock protecting access to the stor device pointer,
> > > use it manage the reference count as well.
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > ---
> > >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> > >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> > >  2 files changed, 9 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/drivers/staging/hv/hyperv_storage.h
> > b/drivers/staging/hv/hyperv_storage.h
> > > index 53b65be..d946211 100644
> > > --- a/drivers/staging/hv/hyperv_storage.h
> > > +++ b/drivers/staging/hv/hyperv_storage.h
> > > @@ -265,7 +265,7 @@ struct storvsc_device {
> > >  	struct hv_device *device;
> > >
> > >  	/* 0 indicates the device is being destroyed */
> > > -	atomic_t ref_count;
> > > +	int	 ref_count;
> > 
> > Is this really needed?  Can't you rely on the reference count of the
> > hv_device itself?
> 
> We don't have a reference count on the hv_device

Wait, why not?  You shure better have a reference count on that device
if you have a pointer to it, if not, you have a bug, and that needs to
be fixed.  Please reread Documentation/CodingStyle for details.

> and this count is taken to deal with racing unloads and incoming
> traffic on the channel from the host. 

Is this something that all other storage drivers have to do?  If not,
then you shouldn't be doing that as well.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
  2011-08-24  0:55       ` KY Srinivasan
@ 2011-08-24  2:58           ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  2:58 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 12:55:12AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 7:08 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the
> > ext field in hv_device
> > 
> > On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> > > The current mechanism for handling references in broken.
> > > Introduce a lock to protect the ext field in hv_device.
> > 
> > Why would that lock ever be needed?  How can things change to this
> > pointer in different ways like you are thinking it could?  Doesn't the
> > reference counting in the device itself handle this properly?
> 
> This is to deal with a potential race condition between the driver being
> unloaded and incoming traffic from the VMBUS side. The ext pointer is 
> device specific (either pointing to a storage or a network device) and what
> we are protecting is the pointer being set to NULL from the unload side when
> we might have a racing access from the interrupt side (on the incoming vmbus
> traffic).

I still don't think this is needed at all, the drivers should not have
to worry about this.  Something is wrong with the design if it is, as no
other bus needs something like this, right?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
@ 2011-08-24  2:58           ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  2:58 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 12:55:12AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 7:08 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the
> > ext field in hv_device
> > 
> > On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> > > The current mechanism for handling references in broken.
> > > Introduce a lock to protect the ext field in hv_device.
> > 
> > Why would that lock ever be needed?  How can things change to this
> > pointer in different ways like you are thinking it could?  Doesn't the
> > reference counting in the device itself handle this properly?
> 
> This is to deal with a potential race condition between the driver being
> unloaded and incoming traffic from the VMBUS side. The ext pointer is 
> device specific (either pointing to a storage or a network device) and what
> we are protecting is the pointer being set to NULL from the unload side when
> we might have a racing access from the interrupt side (on the incoming vmbus
> traffic).

I still don't think this is needed at all, the drivers should not have
to worry about this.  Something is wrong with the design if it is, as no
other bus needs something like this, right?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24  0:44       ` KY Srinivasan
@ 2011-08-24  2:59         ` Greg KH
  2011-08-24 16:46           ` KY Srinivasan
  0 siblings, 1 reply; 294+ messages in thread
From: Greg KH @ 2011-08-24  2:59 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 6:42 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > mod_devicetable.h
> > 
> > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > In preparation for implementing vmbus aliases for auto-loading
> > > Hyper-V drivers, define vmbus specific device ID.
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > ---
> > >  include/linux/mod_devicetable.h |    7 +++++++
> > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/include/linux/mod_devicetable.h
> > b/include/linux/mod_devicetable.h
> > > index ae28e93..5a12377 100644
> > > --- a/include/linux/mod_devicetable.h
> > > +++ b/include/linux/mod_devicetable.h
> > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > >  };
> > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > >
> > > +/*
> > > + * For Hyper-V devices we use the device guid as the id.
> > > + */
> > > +struct hv_vmbus_device_id {
> > > +	__u8 guid[16];
> > > +};
> > 
> > Why do you not need a driver_data pointer here?  Are you sure you aren't
> > ever going to need it in the future?  Hint, I think you will...
> 
> I am not sure I am following you here; the guid is the device ID and it is 
> guaranteed to remain the same. What is the driver _data pointer here 
> you are referring to here.  While some device id have the _data pointer,
> there are others that don't - for instance struct virtio_device_id. In 
> our case, I am not sure how I would use this private pointer.

You use it like all other drivers use it, only if needed.

Hint, I think you need to use it in your hv_utils driver, it would
reduce the size of your code and simplify your logic.

And yes, not all bus types use it, but most do, for good reason.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
  2011-08-24  0:38       ` KY Srinivasan
@ 2011-08-24  3:00           ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  3:00 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 12:38:09AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 6:50 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
> > 
> > On Fri, Jul 15, 2011 at 10:46:07AM -0700, K. Y. Srinivasan wrote:
> > > Now generate appropriate uevent based on the modalias string. As part of this,
> > > cleanup the existing uevent code.
> > 
> > Note, you just change the user api here, did you have tools that relied
> > on the old format?  If so, they just broke :(
> 
> Prior to this, I don't think autoloading worked the way it should for these
> modules. 

It didn't?  How did the mouse driver get autoloaded then, through the
pci/dmi tables?

> > > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> > > +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> > 
> > Don't we have a type for printing out a uuid already?
> 
> I did not see one; could you point me to the right place.
> > 
> > And what's with the jumping by 2 yet dividing?  What am I missing here?
> 
> Each byte of the uuid is represented by 2 bytes in the string; thus the magic with 2.

Ok, wierd, but it makes sense, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
@ 2011-08-24  3:00           ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  3:00 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 12:38:09AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 6:50 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
> > 
> > On Fri, Jul 15, 2011 at 10:46:07AM -0700, K. Y. Srinivasan wrote:
> > > Now generate appropriate uevent based on the modalias string. As part of this,
> > > cleanup the existing uevent code.
> > 
> > Note, you just change the user api here, did you have tools that relied
> > on the old format?  If so, they just broke :(
> 
> Prior to this, I don't think autoloading worked the way it should for these
> modules. 

It didn't?  How did the mouse driver get autoloaded then, through the
pci/dmi tables?

> > > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> > > +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> > 
> > Don't we have a type for printing out a uuid already?
> 
> I did not see one; could you point me to the right place.
> > 
> > And what's with the jumping by 2 yet dividing?  What am I missing here?
> 
> Each byte of the uuid is represented by 2 bytes in the string; thus the magic with 2.

Ok, wierd, but it makes sense, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 0000/0117] Staging: hv: Driver cleanup
  2011-08-24  1:01   ` KY Srinivasan
@ 2011-08-24  3:08       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  3:08 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization

On Wed, Aug 24, 2011 at 01:01:26AM +0000, KY Srinivasan wrote:
> Thank you for your comments. I will try to re-submit these patches as
> soon as I possibly can. If I were to get these patches re-spun and
> sent to you in the next couple of days, can I still make this current
> merge window?

You ever sit down and write an email, pour out your frustrations and
anger in a long, detailed rant?  Smoke coming off of your keyboard as
the keys start melting in the fury of the frustration driving your rage?

And then, afterward, re-reading it, realizing that you now felt at peace
with yourself, and such a rant was only for your benefit, the recipient,
while surely knowing better than to have caused the response in the
first place, really didn't deserve the flame in the end?  So you then
delete the email before sending it, and then write a simple and concise
response instead, following the "three sentences"[1] rule?

Here's that response:

	Read Documentation/development-process/ for how Linux kernel
	development works and the merge windows happen.

	Please never ask me again.

	Ever.

	greg k-h

[1] http://three.sentenc.es/

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 0000/0117] Staging: hv: Driver cleanup
@ 2011-08-24  3:08       ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24  3:08 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 01:01:26AM +0000, KY Srinivasan wrote:
> Thank you for your comments. I will try to re-submit these patches as
> soon as I possibly can. If I were to get these patches re-spun and
> sent to you in the next couple of days, can I still make this current
> merge window?

You ever sit down and write an email, pour out your frustrations and
anger in a long, detailed rant?  Smoke coming off of your keyboard as
the keys start melting in the fury of the frustration driving your rage?

And then, afterward, re-reading it, realizing that you now felt at peace
with yourself, and such a rant was only for your benefit, the recipient,
while surely knowing better than to have caused the response in the
first place, really didn't deserve the flame in the end?  So you then
delete the email before sending it, and then write a simple and concise
response instead, following the "three sentences"[1] rule?

Here's that response:

	Read Documentation/development-process/ for how Linux kernel
	development works and the merge windows happen.

	Please never ask me again.

	Ever.

	greg k-h

[1] http://three.sentenc.es/

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
  2011-08-24  3:00           ` Greg KH
  (?)
@ 2011-08-24 14:12           ` KY Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 14:12 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 11:00 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code
> 
> On Wed, Aug 24, 2011 at 12:38:09AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 6:50 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent()
> code
> > >
> > > On Fri, Jul 15, 2011 at 10:46:07AM -0700, K. Y. Srinivasan wrote:
> > > > Now generate appropriate uevent based on the modalias string. As part of
> this,
> > > > cleanup the existing uevent code.
> > >
> > > Note, you just change the user api here, did you have tools that relied
> > > on the old format?  If so, they just broke :(
> >
> > Prior to this, I don't think autoloading worked the way it should for these
> > modules.
> 
> It didn't?  How did the mouse driver get autoloaded then, through the
> pci/dmi tables?

You are right, prior to this all drivers were loaded using pci/dmi signatures.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
  2011-08-24  2:58           ` Greg KH
@ 2011-08-24 14:29             ` KY Srinivasan
  -1 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 14:29 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 10:58 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the
> ext field in hv_device
> 
> On Wed, Aug 24, 2011 at 12:55:12AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 7:08 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect
> the
> > > ext field in hv_device
> > >
> > > On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> > > > The current mechanism for handling references in broken.
> > > > Introduce a lock to protect the ext field in hv_device.
> > >
> > > Why would that lock ever be needed?  How can things change to this
> > > pointer in different ways like you are thinking it could?  Doesn't the
> > > reference counting in the device itself handle this properly?
> >
> > This is to deal with a potential race condition between the driver being
> > unloaded and incoming traffic from the VMBUS side. The ext pointer is
> > device specific (either pointing to a storage or a network device) and what
> > we are protecting is the pointer being set to NULL from the unload side when
> > we might have a racing access from the interrupt side (on the incoming vmbus
> > traffic).
> 
> I still don't think this is needed at all, the drivers should not have
> to worry about this.  Something is wrong with the design if it is, as no
> other bus needs something like this, right?

This notion of reference counting has been in this code ever since I have been
working on this code; it just that I fixed some obvious holes/race conditions in the
logic to manage the reference counting. Firstly, this is not mandated by the vmbus and is 
used to support the protocol between the guest and host for storage, networking etc.
At least in the case of both block and networking, the client side driver code (running in the guest)
Initiates book keeping messages to the host that is not known to upper level code in Linux. So for
Instance, even though SCSI layer knows exactly what I/O's are pending and takes care of reference
counting the structures, it does not know about messages that have been sent by the lower level
storvsc driver code. If a racing unload were to happen, we could potentially dereference a NULL
ext pointer from the incoming packet processing context. The cases where this can happen are even
more prevalent on the networking side.

Regards,

K. Y


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device
@ 2011-08-24 14:29             ` KY Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 14:29 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 10:58 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the
> ext field in hv_device
> 
> On Wed, Aug 24, 2011 at 12:55:12AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 7:08 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect
> the
> > > ext field in hv_device
> > >
> > > On Fri, Jul 15, 2011 at 10:47:09AM -0700, K. Y. Srinivasan wrote:
> > > > The current mechanism for handling references in broken.
> > > > Introduce a lock to protect the ext field in hv_device.
> > >
> > > Why would that lock ever be needed?  How can things change to this
> > > pointer in different ways like you are thinking it could?  Doesn't the
> > > reference counting in the device itself handle this properly?
> >
> > This is to deal with a potential race condition between the driver being
> > unloaded and incoming traffic from the VMBUS side. The ext pointer is
> > device specific (either pointing to a storage or a network device) and what
> > we are protecting is the pointer being set to NULL from the unload side when
> > we might have a racing access from the interrupt side (on the incoming vmbus
> > traffic).
> 
> I still don't think this is needed at all, the drivers should not have
> to worry about this.  Something is wrong with the design if it is, as no
> other bus needs something like this, right?

This notion of reference counting has been in this code ever since I have been
working on this code; it just that I fixed some obvious holes/race conditions in the
logic to manage the reference counting. Firstly, this is not mandated by the vmbus and is 
used to support the protocol between the guest and host for storage, networking etc.
At least in the case of both block and networking, the client side driver code (running in the guest)
Initiates book keeping messages to the host that is not known to upper level code in Linux. So for
Instance, even though SCSI layer knows exactly what I/O's are pending and takes care of reference
counting the structures, it does not know about messages that have been sent by the lower level
storvsc driver code. If a racing unload were to happen, we could potentially dereference a NULL
ext pointer from the incoming packet processing context. The cases where this can happen are even
more prevalent on the networking side.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-24  2:57           ` Greg KH
  (?)
@ 2011-08-24 16:25           ` KY Srinivasan
  2011-08-24 20:17             ` Greg KH
  -1 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 16:25 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 10:58 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> manage ref_cnt
> 
> On Wed, Aug 24, 2011 at 12:58:36AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 7:10 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> > > manage ref_cnt
> > >
> > > On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > > > Now that we have a spin lock protecting access to the stor device pointer,
> > > > use it manage the reference count as well.
> > > >
> > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > ---
> > > >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> > > >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> > > >  2 files changed, 9 insertions(+), 9 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/hv/hyperv_storage.h
> > > b/drivers/staging/hv/hyperv_storage.h
> > > > index 53b65be..d946211 100644
> > > > --- a/drivers/staging/hv/hyperv_storage.h
> > > > +++ b/drivers/staging/hv/hyperv_storage.h
> > > > @@ -265,7 +265,7 @@ struct storvsc_device {
> > > >  	struct hv_device *device;
> > > >
> > > >  	/* 0 indicates the device is being destroyed */
> > > > -	atomic_t ref_count;
> > > > +	int	 ref_count;
> > >
> > > Is this really needed?  Can't you rely on the reference count of the
> > > hv_device itself?
> >
> > We don't have a reference count on the hv_device
> 
> Wait, why not?  You shure better have a reference count on that device
> if you have a pointer to it, if not, you have a bug, and that needs to
> be fixed.  Please reread Documentation/CodingStyle for details.

Greg,

I am confused here. The model we have is identical to other device/bus
abstractions in the kernel. For instance, neither  struct pci_dev nor struct
virtio_device have an explicit reference count. However, they both embed
struct device which  has the kobject structure embedded to manage
the object life cycle. This is exactly the model we have for the vmbus devices -
struct hv_device embeds struct device that embeds the struct kobject for
managing the lifecycle.

Like other  bus specific devices in the kernel (pci devices, virtio devices,),  
class specific vmbus devices - struct storvsc_device and struct netvsc_device 
embed a pointer to the underlying struct hv_device. Furthermore, a pointer to 
the class specific device structure is stashed in the struct hv_device (the ext pointer).
This is identical what is done in the virtio blk device - look at the priv element in struct virtio_device.

As I noted in a different email, I did not introduce this reference counting, I just fixed some gaping 
holes in the logic. The reason, I fixed the logic and kept the reference counting is because I can 
see cases where we could end up de-referencing a NULL pointer from the interrupt side that is
trying to deliver a vmbus packet to a device that is being destroyed. 

Regards,

K. Y

> 
> > and this count is taken to deal with racing unloads and incoming
> > traffic on the channel from the host.
> 
> Is this something that all other storage drivers have to do?  If not,
> then you shouldn't be doing that as well.
> 
> greg k-h


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24  2:59         ` Greg KH
@ 2011-08-24 16:46           ` KY Srinivasan
  2011-08-24 20:11               ` Greg KH
  0 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 16:46 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, August 23, 2011 10:59 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> mod_devicetable.h
> 
> On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 6:42 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > > mod_devicetable.h
> > >
> > > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > > In preparation for implementing vmbus aliases for auto-loading
> > > > Hyper-V drivers, define vmbus specific device ID.
> > > >
> > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > ---
> > > >  include/linux/mod_devicetable.h |    7 +++++++
> > > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/include/linux/mod_devicetable.h
> > > b/include/linux/mod_devicetable.h
> > > > index ae28e93..5a12377 100644
> > > > --- a/include/linux/mod_devicetable.h
> > > > +++ b/include/linux/mod_devicetable.h
> > > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > > >  };
> > > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > > >
> > > > +/*
> > > > + * For Hyper-V devices we use the device guid as the id.
> > > > + */
> > > > +struct hv_vmbus_device_id {
> > > > +	__u8 guid[16];
> > > > +};
> > >
> > > Why do you not need a driver_data pointer here?  Are you sure you aren't
> > > ever going to need it in the future?  Hint, I think you will...
> >
> > I am not sure I am following you here; the guid is the device ID and it is
> > guaranteed to remain the same. What is the driver _data pointer here
> > you are referring to here.  While some device id have the _data pointer,
> > there are others that don't - for instance struct virtio_device_id. In
> > our case, I am not sure how I would use this private pointer.
> 
> You use it like all other drivers use it, only if needed.

Fair enough; the point is I am not sure how I would use it.

> 
> Hint, I think you need to use it in your hv_utils driver, it would
> reduce the size of your code and simplify your logic.

Could you expand on this. Currently the util driver handles a bunch 
services that have their own guids - and these have been included
in the idtable. How would having the pointer simplify this code. 
I looked at the usage of this in PCI and it appears to be for supporting
dynamic  IDs for existing drivers. I am not sure if this is applicable to the util
driver. First, I am not sure if there will be additional services being 
packaged into util driver and secondly, even if I implement this scheme
of being able to dynamically add new IDs, we still would need to add the
code to the driver to handle the new service. In fact not a whole lot of 
code is shared amongst the services that are currently packaged as the
util driver. 

Regards,

K. Y


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24 16:46           ` KY Srinivasan
@ 2011-08-24 20:11               ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24 20:11 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 04:46:11PM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 10:59 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > mod_devicetable.h
> > 
> > On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Greg KH [mailto:greg@kroah.com]
> > > > Sent: Tuesday, August 23, 2011 6:42 PM
> > > > To: KY Srinivasan
> > > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > > > mod_devicetable.h
> > > >
> > > > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > > > In preparation for implementing vmbus aliases for auto-loading
> > > > > Hyper-V drivers, define vmbus specific device ID.
> > > > >
> > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > ---
> > > > >  include/linux/mod_devicetable.h |    7 +++++++
> > > > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > > > >
> > > > > diff --git a/include/linux/mod_devicetable.h
> > > > b/include/linux/mod_devicetable.h
> > > > > index ae28e93..5a12377 100644
> > > > > --- a/include/linux/mod_devicetable.h
> > > > > +++ b/include/linux/mod_devicetable.h
> > > > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > > > >  };
> > > > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > > > >
> > > > > +/*
> > > > > + * For Hyper-V devices we use the device guid as the id.
> > > > > + */
> > > > > +struct hv_vmbus_device_id {
> > > > > +	__u8 guid[16];
> > > > > +};
> > > >
> > > > Why do you not need a driver_data pointer here?  Are you sure you aren't
> > > > ever going to need it in the future?  Hint, I think you will...
> > >
> > > I am not sure I am following you here; the guid is the device ID and it is
> > > guaranteed to remain the same. What is the driver _data pointer here
> > > you are referring to here.  While some device id have the _data pointer,
> > > there are others that don't - for instance struct virtio_device_id. In
> > > our case, I am not sure how I would use this private pointer.
> > 
> > You use it like all other drivers use it, only if needed.
> 
> Fair enough; the point is I am not sure how I would use it.
> 
> > 
> > Hint, I think you need to use it in your hv_utils driver, it would
> > reduce the size of your code and simplify your logic.
> 
> Could you expand on this. Currently the util driver handles a bunch 
> services that have their own guids - and these have been included
> in the idtable. How would having the pointer simplify this code.

It would allow you, in your probe function, to do something different
depending on the guid that the probe function was matching on.  So you
would not have to check the guid again to do that, just use the data
pointed in that void pointer and away you go.

As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
variable which uses the driver_info field to contain a quirk for the
device.

> I looked at the usage of this in PCI and it appears to be for supporting
> dynamic  IDs for existing drivers.

No, that's exactly wrong.  dynamic ids play havoc with this pointer,
making some drivers not be able to handle dynamic ids because they rely
on it for some driver-specific information to be passed in it, which
dynamic ids can not handle.

Oh, have you remembered to turn off dynamic ids for these devices?  Or
do you support them properly?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
@ 2011-08-24 20:11               ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-24 20:11 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 04:46:11PM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, August 23, 2011 10:59 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > mod_devicetable.h
> > 
> > On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Greg KH [mailto:greg@kroah.com]
> > > > Sent: Tuesday, August 23, 2011 6:42 PM
> > > > To: KY Srinivasan
> > > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > > > mod_devicetable.h
> > > >
> > > > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > > > In preparation for implementing vmbus aliases for auto-loading
> > > > > Hyper-V drivers, define vmbus specific device ID.
> > > > >
> > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > ---
> > > > >  include/linux/mod_devicetable.h |    7 +++++++
> > > > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > > > >
> > > > > diff --git a/include/linux/mod_devicetable.h
> > > > b/include/linux/mod_devicetable.h
> > > > > index ae28e93..5a12377 100644
> > > > > --- a/include/linux/mod_devicetable.h
> > > > > +++ b/include/linux/mod_devicetable.h
> > > > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > > > >  };
> > > > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > > > >
> > > > > +/*
> > > > > + * For Hyper-V devices we use the device guid as the id.
> > > > > + */
> > > > > +struct hv_vmbus_device_id {
> > > > > +	__u8 guid[16];
> > > > > +};
> > > >
> > > > Why do you not need a driver_data pointer here?  Are you sure you aren't
> > > > ever going to need it in the future?  Hint, I think you will...
> > >
> > > I am not sure I am following you here; the guid is the device ID and it is
> > > guaranteed to remain the same. What is the driver _data pointer here
> > > you are referring to here.  While some device id have the _data pointer,
> > > there are others that don't - for instance struct virtio_device_id. In
> > > our case, I am not sure how I would use this private pointer.
> > 
> > You use it like all other drivers use it, only if needed.
> 
> Fair enough; the point is I am not sure how I would use it.
> 
> > 
> > Hint, I think you need to use it in your hv_utils driver, it would
> > reduce the size of your code and simplify your logic.
> 
> Could you expand on this. Currently the util driver handles a bunch 
> services that have their own guids - and these have been included
> in the idtable. How would having the pointer simplify this code.

It would allow you, in your probe function, to do something different
depending on the guid that the probe function was matching on.  So you
would not have to check the guid again to do that, just use the data
pointed in that void pointer and away you go.

As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
variable which uses the driver_info field to contain a quirk for the
device.

> I looked at the usage of this in PCI and it appears to be for supporting
> dynamic  IDs for existing drivers.

No, that's exactly wrong.  dynamic ids play havoc with this pointer,
making some drivers not be able to handle dynamic ids because they rely
on it for some driver-specific information to be passed in it, which
dynamic ids can not handle.

Oh, have you remembered to turn off dynamic ids for these devices?  Or
do you support them properly?

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-24 16:25           ` KY Srinivasan
@ 2011-08-24 20:17             ` Greg KH
  2011-08-24 22:57               ` KY Srinivasan
  0 siblings, 1 reply; 294+ messages in thread
From: Greg KH @ 2011-08-24 20:17 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 04:25:18PM +0000, KY Srinivasan wrote:
> > > > On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > > > > Now that we have a spin lock protecting access to the stor device pointer,
> > > > > use it manage the reference count as well.
> > > > >
> > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > ---
> > > > >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> > > > >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> > > > >  2 files changed, 9 insertions(+), 9 deletions(-)
> > > > >
> > > > > diff --git a/drivers/staging/hv/hyperv_storage.h
> > > > b/drivers/staging/hv/hyperv_storage.h
> > > > > index 53b65be..d946211 100644
> > > > > --- a/drivers/staging/hv/hyperv_storage.h
> > > > > +++ b/drivers/staging/hv/hyperv_storage.h
> > > > > @@ -265,7 +265,7 @@ struct storvsc_device {
> > > > >  	struct hv_device *device;
> > > > >
> > > > >  	/* 0 indicates the device is being destroyed */
> > > > > -	atomic_t ref_count;
> > > > > +	int	 ref_count;
> > > >
> > > > Is this really needed?  Can't you rely on the reference count of the
> > > > hv_device itself?
> > >
> > > We don't have a reference count on the hv_device
> > 
> > Wait, why not?  You shure better have a reference count on that device
> > if you have a pointer to it, if not, you have a bug, and that needs to
> > be fixed.  Please reread Documentation/CodingStyle for details.
> 
> Greg,
> 
> I am confused here. The model we have is identical to other device/bus
> abstractions in the kernel. For instance, neither  struct pci_dev nor struct
> virtio_device have an explicit reference count. However, they both embed
> struct device which  has the kobject structure embedded to manage
> the object life cycle. This is exactly the model we have for the vmbus devices -
> struct hv_device embeds struct device that embeds the struct kobject for
> managing the lifecycle.

Yes, that is correct.

> Like other  bus specific devices in the kernel (pci devices, virtio devices,),  
> class specific vmbus devices - struct storvsc_device and struct netvsc_device 
> embed a pointer to the underlying struct hv_device.

And when you save that pointer, you ARE incrementing the reference count
properly, right?  If not, you just caused a bug.

> Furthermore, a pointer to the class specific device structure is
> stashed in the struct hv_device (the ext pointer).
> This is identical what is done in the virtio blk device - look at the
> priv element in struct virtio_device.

Yes, but the "base" structure of virtio_device does not contain a lock
that the users of that priv pointer are using to control access to data
_within_ the priv pointer, right?

That's up to the users within the priv pointer.

Now I see how you were trying to move the lock "deeper" as it seemed
that everyone needed it, but you just moved the lock away from the thing
that it was trying to protect, which might cause problems, and at the
least, is confusing as heck because you are mixing two different layers
here, in ways that should not be mixed.

If you really need a lock to protect some private data within the priv
pointer, then put it somewhere else,like in the priv pointer, as almost
all other subsystems do.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24 20:11               ` Greg KH
  (?)
@ 2011-08-24 21:51               ` KY Srinivasan
  2011-08-25  2:27                 ` KY Srinivasan
  2011-08-25  2:38                   ` Greg KH
  -1 siblings, 2 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 21:51 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, August 24, 2011 4:12 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> mod_devicetable.h
> 
> On Wed, Aug 24, 2011 at 04:46:11PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Tuesday, August 23, 2011 10:59 PM
> > > To: KY Srinivasan
> > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > > mod_devicetable.h
> > >
> > > On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Greg KH [mailto:greg@kroah.com]
> > > > > Sent: Tuesday, August 23, 2011 6:42 PM
> > > > > To: KY Srinivasan
> > > > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id
> to
> > > > > mod_devicetable.h
> > > > >
> > > > > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > > > > In preparation for implementing vmbus aliases for auto-loading
> > > > > > Hyper-V drivers, define vmbus specific device ID.
> > > > > >
> > > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > > ---
> > > > > >  include/linux/mod_devicetable.h |    7 +++++++
> > > > > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > > > > >
> > > > > > diff --git a/include/linux/mod_devicetable.h
> > > > > b/include/linux/mod_devicetable.h
> > > > > > index ae28e93..5a12377 100644
> > > > > > --- a/include/linux/mod_devicetable.h
> > > > > > +++ b/include/linux/mod_devicetable.h
> > > > > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > > > > >  };
> > > > > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > > > > >
> > > > > > +/*
> > > > > > + * For Hyper-V devices we use the device guid as the id.
> > > > > > + */
> > > > > > +struct hv_vmbus_device_id {
> > > > > > +	__u8 guid[16];
> > > > > > +};
> > > > >
> > > > > Why do you not need a driver_data pointer here?  Are you sure you aren't
> > > > > ever going to need it in the future?  Hint, I think you will...
> > > >
> > > > I am not sure I am following you here; the guid is the device ID and it is
> > > > guaranteed to remain the same. What is the driver _data pointer here
> > > > you are referring to here.  While some device id have the _data pointer,
> > > > there are others that don't - for instance struct virtio_device_id. In
> > > > our case, I am not sure how I would use this private pointer.
> > >
> > > You use it like all other drivers use it, only if needed.
> >
> > Fair enough; the point is I am not sure how I would use it.
> >
> > >
> > > Hint, I think you need to use it in your hv_utils driver, it would
> > > reduce the size of your code and simplify your logic.
> >
> > Could you expand on this. Currently the util driver handles a bunch
> > services that have their own guids - and these have been included
> > in the idtable. How would having the pointer simplify this code.
> 
> It would allow you, in your probe function, to do something different
> depending on the guid that the probe function was matching on.  So you
> would not have to check the guid again to do that, just use the data
> pointed in that void pointer and away you go.
> 
> As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
> variable which uses the driver_info field to contain a quirk for the
> device.

Ok; this makes sense. But I currently don't have any quirks to support!
The util driver is not even a driver in the true sense. I made it a driver and
added the probe function just to support auto-loading with the vmbus ID space
that I am trying to implement here - the probe function does nothing.

So, if it is ok with you, I will not add driver_data pointer since I will not be
using it.
 
> 
> > I looked at the usage of this in PCI and it appears to be for supporting
> > dynamic  IDs for existing drivers.
> 
> No, that's exactly wrong.  dynamic ids play havoc with this pointer,
> making some drivers not be able to handle dynamic ids because they rely
> on it for some driver-specific information to be passed in it, which
> dynamic ids can not handle.
> 
> Oh, have you remembered to turn off dynamic ids for these devices?  Or
> do you support them properly?

I don't support dynamic IDs. What would I need to do to turn it off.

Regards,

K. Y

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-24 20:17             ` Greg KH
@ 2011-08-24 22:57               ` KY Srinivasan
  2011-08-25  2:45                 ` Greg KH
  0 siblings, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-24 22:57 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, August 24, 2011 4:17 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to
> manage ref_cnt
> 
> On Wed, Aug 24, 2011 at 04:25:18PM +0000, KY Srinivasan wrote:
> > > > > On Fri, Jul 15, 2011 at 10:47:14AM -0700, K. Y. Srinivasan wrote:
> > > > > > Now that we have a spin lock protecting access to the stor device
> pointer,
> > > > > > use it manage the reference count as well.
> > > > > >
> > > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > > ---
> > > > > >  drivers/staging/hv/hyperv_storage.h |    8 ++++----
> > > > > >  drivers/staging/hv/storvsc.c        |   10 +++++-----
> > > > > >  2 files changed, 9 insertions(+), 9 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/staging/hv/hyperv_storage.h
> > > > > b/drivers/staging/hv/hyperv_storage.h
> > > > > > index 53b65be..d946211 100644
> > > > > > --- a/drivers/staging/hv/hyperv_storage.h
> > > > > > +++ b/drivers/staging/hv/hyperv_storage.h
> > > > > > @@ -265,7 +265,7 @@ struct storvsc_device {
> > > > > >  	struct hv_device *device;
> > > > > >
> > > > > >  	/* 0 indicates the device is being destroyed */
> > > > > > -	atomic_t ref_count;
> > > > > > +	int	 ref_count;
> > > > >
> > > > > Is this really needed?  Can't you rely on the reference count of the
> > > > > hv_device itself?
> > > >
> > > > We don't have a reference count on the hv_device
> > >
> > > Wait, why not?  You shure better have a reference count on that device
> > > if you have a pointer to it, if not, you have a bug, and that needs to
> > > be fixed.  Please reread Documentation/CodingStyle for details.
> >
> > Greg,
> >
> > I am confused here. The model we have is identical to other device/bus
> > abstractions in the kernel. For instance, neither  struct pci_dev nor struct
> > virtio_device have an explicit reference count. However, they both embed
> > struct device which  has the kobject structure embedded to manage
> > the object life cycle. This is exactly the model we have for the vmbus devices -
> > struct hv_device embeds struct device that embeds the struct kobject for
> > managing the lifecycle.
> 
> Yes, that is correct.
> 
> > Like other  bus specific devices in the kernel (pci devices, virtio devices,),
> > class specific vmbus devices - struct storvsc_device and struct netvsc_device
> > embed a pointer to the underlying struct hv_device.
> 
> And when you save that pointer, you ARE incrementing the reference count
> properly, right?  If not, you just caused a bug.

Why do you say that. This assignment is done in the probe function where the 
driver core is invoking the driver specific probe function. In the driver specific
probe function, I allocate class specific device state and embed the bus specific
device pointer. So, I would think the driver core is taking the appropriate reference
count. What I am doing is exactly what other PCI and virtio drivers are doing. For instance,
in virtio_blk.c , virtblk_probe() function, the virtio_device pointer is stashed away in the 
virtio_blk structure in exactly the same way I am doing. I suspect the assumption here is that
if probe succeeded, then the remove() function would be called to let the driver cleanup the state.

> 
> > Furthermore, a pointer to the class specific device structure is
> > stashed in the struct hv_device (the ext pointer).
> > This is identical what is done in the virtio blk device - look at the
> > priv element in struct virtio_device.
> 
> Yes, but the "base" structure of virtio_device does not contain a lock
> that the users of that priv pointer are using to control access to data
> _within_ the priv pointer, right?

True. As I noted in an earlier email, the current hyper-v driver code has logic
to deal with the race conditions I have described. It is just that the current 
implementation is completely bogus - look at for instance the function
must_get_stor_device() in storvsc.c. This function is invoked in the channel
callback code path to process messages coming from the host. I added this lock
to close the window in getting the ext pointer. Clearly the lock protecting the 
ext pointer must be in a structure whose persistence is guaranteed and that is the reason
I put the lock in the struct hv_device.

> 
> That's up to the users within the priv pointer.
> 
> Now I see how you were trying to move the lock "deeper" as it seemed
> that everyone needed it, but you just moved the lock away from the thing
> that it was trying to protect, which might cause problems, and at the
> least, is confusing as heck because you are mixing two different layers
> here, in ways that should not be mixed.
> 
> If you really need a lock to protect some private data within the priv
> pointer, then put it somewhere else,like in the priv pointer, as almost
> all other subsystems do.

What is being protected is the ext pointer that points to the class specific device state.
This state is freed when the driver is unloaded (in the remove function). The typical access
to the class specific device structure occurs given the pointer to bus specific device structure
struct hv_device. In the current code this transformation is done in functions such as
get_stor_device() and must_get_stor_device(). As you can see the logic in these function is 
broken since there are multiple windows. The lock I introduced was to close the windows I saw in 
these functions (similar functions exist on the netvsc side as well - get_inbound_net_device()
and get_outbound_net_device() in netvsc.c). I just tried to cleanup these functions with an easy to
understand logic to ensure the stability of the ext pointer.

Regards,

K. Y


^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24 21:51               ` KY Srinivasan
@ 2011-08-25  2:27                 ` KY Srinivasan
  2011-08-25  2:40                   ` Greg KH
  2011-08-25  2:38                   ` Greg KH
  1 sibling, 1 reply; 294+ messages in thread
From: KY Srinivasan @ 2011-08-25  2:27 UTC (permalink / raw)
  To: KY Srinivasan, Greg KH
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization



> -----Original Message-----
> From: devel-bounces@linuxdriverproject.org [mailto:devel-
> bounces@linuxdriverproject.org] On Behalf Of KY Srinivasan
> Sent: Wednesday, August 24, 2011 5:51 PM
> To: Greg KH
> Cc: devel@linuxdriverproject.org; Haiyang Zhang; gregkh@suse.de; linux-
> kernel@vger.kernel.org; virtualization@lists.osdl.org
> Subject: RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> mod_devicetable.h
> 
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Wednesday, August 24, 2011 4:12 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> > mod_devicetable.h
> >
> > On Wed, Aug 24, 2011 at 04:46:11PM +0000, KY Srinivasan wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Greg KH [mailto:greg@kroah.com]
> > > > Sent: Tuesday, August 23, 2011 10:59 PM
> > > > To: KY Srinivasan
> > > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> > > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id
> to
> > > > mod_devicetable.h
> > > >
> > > > On Wed, Aug 24, 2011 at 12:44:38AM +0000, KY Srinivasan wrote:
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Greg KH [mailto:greg@kroah.com]
> > > > > > Sent: Tuesday, August 23, 2011 6:42 PM
> > > > > > To: KY Srinivasan
> > > > > > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > > > > > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang
> Zhang
> > > > > > Subject: Re: [PATCH 003/117] Staging: hv: Add struct
> hv_vmbus_device_id
> > to
> > > > > > mod_devicetable.h
> > > > > >
> > > > > > On Fri, Jul 15, 2011 at 10:45:51AM -0700, K. Y. Srinivasan wrote:
> > > > > > > In preparation for implementing vmbus aliases for auto-loading
> > > > > > > Hyper-V drivers, define vmbus specific device ID.
> > > > > > >
> > > > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > > > > ---
> > > > > > >  include/linux/mod_devicetable.h |    7 +++++++
> > > > > > >  1 files changed, 7 insertions(+), 0 deletions(-)
> > > > > > >
> > > > > > > diff --git a/include/linux/mod_devicetable.h
> > > > > > b/include/linux/mod_devicetable.h
> > > > > > > index ae28e93..5a12377 100644
> > > > > > > --- a/include/linux/mod_devicetable.h
> > > > > > > +++ b/include/linux/mod_devicetable.h
> > > > > > > @@ -405,6 +405,13 @@ struct virtio_device_id {
> > > > > > >  };
> > > > > > >  #define VIRTIO_DEV_ANY_ID	0xffffffff
> > > > > > >
> > > > > > > +/*
> > > > > > > + * For Hyper-V devices we use the device guid as the id.
> > > > > > > + */
> > > > > > > +struct hv_vmbus_device_id {
> > > > > > > +	__u8 guid[16];
> > > > > > > +};
> > > > > >
> > > > > > Why do you not need a driver_data pointer here?  Are you sure you
> aren't
> > > > > > ever going to need it in the future?  Hint, I think you will...
> > > > >
> > > > > I am not sure I am following you here; the guid is the device ID and it is
> > > > > guaranteed to remain the same. What is the driver _data pointer here
> > > > > you are referring to here.  While some device id have the _data pointer,
> > > > > there are others that don't - for instance struct virtio_device_id. In
> > > > > our case, I am not sure how I would use this private pointer.
> > > >
> > > > You use it like all other drivers use it, only if needed.
> > >
> > > Fair enough; the point is I am not sure how I would use it.
> > >
> > > >
> > > > Hint, I think you need to use it in your hv_utils driver, it would
> > > > reduce the size of your code and simplify your logic.
> > >
> > > Could you expand on this. Currently the util driver handles a bunch
> > > services that have their own guids - and these have been included
> > > in the idtable. How would having the pointer simplify this code.
> >
> > It would allow you, in your probe function, to do something different
> > depending on the guid that the probe function was matching on.  So you
> > would not have to check the guid again to do that, just use the data
> > pointed in that void pointer and away you go.
> >
> > As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
> > variable which uses the driver_info field to contain a quirk for the
> > device.
> 
> Ok; this makes sense. But I currently don't have any quirks to support!
> The util driver is not even a driver in the true sense. I made it a driver and
> added the probe function just to support auto-loading with the vmbus ID space
> that I am trying to implement here - the probe function does nothing.
> 
> So, if it is ok with you, I will not add driver_data pointer since I will not be
> using it.
> 
> >
> > > I looked at the usage of this in PCI and it appears to be for supporting
> > > dynamic  IDs for existing drivers.
> >
> > No, that's exactly wrong.  dynamic ids play havoc with this pointer,
> > making some drivers not be able to handle dynamic ids because they rely
> > on it for some driver-specific information to be passed in it, which
> > dynamic ids can not handle.
> >
> > Oh, have you remembered to turn off dynamic ids for these devices?  Or
> > do you support them properly?
> 
> I don't support dynamic IDs. What would I need to do to turn it off.

Greg,

Since I don't have any (current) use for the driver_data pointer, I have gone ahead
and cleaned up the first 74 patches without adding the driver_data. 
With the mushing of the patches   you had proposed this is about
a 60 patch series and addresses all the other comments you had in the first 74 patches.
I hope I have gotten the "right" granularity now.   If it is ok with you, I could send these 
out for your consideration.

The only unresolved issue in the remaining patches (75 - 117) is the reference counting
issue we have been debating. As I noted in my earlier emails on this topic, the reference
counting has been there for a long time and I am reluctant get rid of that code without 
additional testing/analysis. So I want to propose the following options:

1) Keep the existing code and I will skip the patches that cleaned up the reference counting

2) Take the cleanup that I have implemented

In either case, I would further test and analyze this code to see if (a) the race condition that is being
addressed is valid and (b) if there is a different mechanism that could be used to deal with it. Given
the gaping holes in the current implementation, my personal preference would be to go with the 
second option. Let me know what you want me to do here.  

Regards,

K. Y
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-24 21:51               ` KY Srinivasan
@ 2011-08-25  2:38                   ` Greg KH
  2011-08-25  2:38                   ` Greg KH
  1 sibling, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-25  2:38 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 09:51:00PM +0000, KY Srinivasan wrote:
> > It would allow you, in your probe function, to do something different
> > depending on the guid that the probe function was matching on.  So you
> > would not have to check the guid again to do that, just use the data
> > pointed in that void pointer and away you go.
> > 
> > As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
> > variable which uses the driver_info field to contain a quirk for the
> > device.
> 
> Ok; this makes sense. But I currently don't have any quirks to support!

That was just an example.

> The util driver is not even a driver in the true sense. I made it a driver and
> added the probe function just to support auto-loading with the vmbus ID space
> that I am trying to implement here - the probe function does nothing.

As you can tell, I'm trying to say that is wrong :)

the hv_util.c driver should have a pointer in each of the driver_info
that describes what it is, and then in the probe function, you use that
to hook up the correct things needed.

None of this hard-coded mess like you currently have.

Trust me, you want that pointer, put it in, and if you never use it,
I'll buy you a beer.  But if I send you a patch using it, well...

> > > I looked at the usage of this in PCI and it appears to be for supporting
> > > dynamic  IDs for existing drivers.
> > 
> > No, that's exactly wrong.  dynamic ids play havoc with this pointer,
> > making some drivers not be able to handle dynamic ids because they rely
> > on it for some driver-specific information to be passed in it, which
> > dynamic ids can not handle.
> > 
> > Oh, have you remembered to turn off dynamic ids for these devices?  Or
> > do you support them properly?
> 
> I don't support dynamic IDs. What would I need to do to turn it off.

Ah, nevermind, that is something that busses add in their core if they
want it.  I added it for PCI and USB, maybe I should move that to the
driver core so that others can get it automatically one of these days...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
@ 2011-08-25  2:38                   ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-25  2:38 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Aug 24, 2011 at 09:51:00PM +0000, KY Srinivasan wrote:
> > It would allow you, in your probe function, to do something different
> > depending on the guid that the probe function was matching on.  So you
> > would not have to check the guid again to do that, just use the data
> > pointed in that void pointer and away you go.
> > 
> > As an example, look at drivers/usb/class/cdc-acm.c, the acm_ids[]
> > variable which uses the driver_info field to contain a quirk for the
> > device.
> 
> Ok; this makes sense. But I currently don't have any quirks to support!

That was just an example.

> The util driver is not even a driver in the true sense. I made it a driver and
> added the probe function just to support auto-loading with the vmbus ID space
> that I am trying to implement here - the probe function does nothing.

As you can tell, I'm trying to say that is wrong :)

the hv_util.c driver should have a pointer in each of the driver_info
that describes what it is, and then in the probe function, you use that
to hook up the correct things needed.

None of this hard-coded mess like you currently have.

Trust me, you want that pointer, put it in, and if you never use it,
I'll buy you a beer.  But if I send you a patch using it, well...

> > > I looked at the usage of this in PCI and it appears to be for supporting
> > > dynamic  IDs for existing drivers.
> > 
> > No, that's exactly wrong.  dynamic ids play havoc with this pointer,
> > making some drivers not be able to handle dynamic ids because they rely
> > on it for some driver-specific information to be passed in it, which
> > dynamic ids can not handle.
> > 
> > Oh, have you remembered to turn off dynamic ids for these devices?  Or
> > do you support them properly?
> 
> I don't support dynamic IDs. What would I need to do to turn it off.

Ah, nevermind, that is something that busses add in their core if they
want it.  I added it for PCI and USB, maybe I should move that to the
driver core so that others can get it automatically one of these days...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-25  2:27                 ` KY Srinivasan
@ 2011-08-25  2:40                   ` Greg KH
  2011-08-25 14:14                     ` KY Srinivasan
  0 siblings, 1 reply; 294+ messages in thread
From: Greg KH @ 2011-08-25  2:40 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Thu, Aug 25, 2011 at 02:27:56AM +0000, KY Srinivasan wrote:
> Since I don't have any (current) use for the driver_data pointer, I have gone ahead
> and cleaned up the first 74 patches without adding the driver_data. 
> With the mushing of the patches   you had proposed this is about
> a 60 patch series and addresses all the other comments you had in the first 74 patches.
> I hope I have gotten the "right" granularity now.   If it is ok with you, I could send these 
> out for your consideration.

Please do.

But if you do, do you mind if I add the driver_data pointer, so you can
blame me later if no one uses it?  :)

> The only unresolved issue in the remaining patches (75 - 117) is the reference counting
> issue we have been debating. As I noted in my earlier emails on this topic, the reference
> counting has been there for a long time and I am reluctant get rid of that code without 
> additional testing/analysis. So I want to propose the following options:
> 
> 1) Keep the existing code and I will skip the patches that cleaned up the reference counting
> 
> 2) Take the cleanup that I have implemented
> 
> In either case, I would further test and analyze this code to see if (a) the race condition that is being
> addressed is valid and (b) if there is a different mechanism that could be used to deal with it. Given
> the gaping holes in the current implementation, my personal preference would be to go with the 
> second option. Let me know what you want me to do here.  

Ok, that sounds acceptable, but don't add the lock to the hv_driver, or
is that needed right now?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* Re: [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt
  2011-08-24 22:57               ` KY Srinivasan
@ 2011-08-25  2:45                 ` Greg KH
  0 siblings, 0 replies; 294+ messages in thread
From: Greg KH @ 2011-08-25  2:45 UTC (permalink / raw)
  To: KY Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Aug 24, 2011 at 10:57:18PM +0000, KY Srinivasan wrote:
> > > Like other  bus specific devices in the kernel (pci devices, virtio devices,),
> > > class specific vmbus devices - struct storvsc_device and struct netvsc_device
> > > embed a pointer to the underlying struct hv_device.
> > 
> > And when you save that pointer, you ARE incrementing the reference count
> > properly, right?  If not, you just caused a bug.
> 
> Why do you say that. This assignment is done in the probe function where the 
> driver core is invoking the driver specific probe function.

But if you save a pointer, you HAVE to increment the reference count.

> In the driver specific probe function, I allocate class specific
> device state and embed the bus specific device pointer. So, I would
> think the driver core is taking the appropriate reference count. What
> I am doing is exactly what other PCI and virtio drivers are doing. For
> instance, in virtio_blk.c , virtblk_probe() function, the
> virtio_device pointer is stashed away in the virtio_blk structure in
> exactly the same way I am doing. I suspect the assumption here is that
> if probe succeeded, then the remove() function would be called to let
> the driver cleanup the state.

Yes, but that's a bug, the pointer reference count should be
incremented.

Look at drivers/usb/usb-skeleton.c for a well-documented way to handle a
driver that works with a bus that has devices that could go away at any
point in time.  It handles the reference count, and the locking
correctly, and has been audited by lots of people.

> > > Furthermore, a pointer to the class specific device structure is
> > > stashed in the struct hv_device (the ext pointer).
> > > This is identical what is done in the virtio blk device - look at the
> > > priv element in struct virtio_device.
> > 
> > Yes, but the "base" structure of virtio_device does not contain a lock
> > that the users of that priv pointer are using to control access to data
> > _within_ the priv pointer, right?
> 
> True. As I noted in an earlier email, the current hyper-v driver code has logic
> to deal with the race conditions I have described. It is just that the current 
> implementation is completely bogus - look at for instance the function
> must_get_stor_device() in storvsc.c. This function is invoked in the channel
> callback code path to process messages coming from the host. I added this lock
> to close the window in getting the ext pointer. Clearly the lock protecting the 
> ext pointer must be in a structure whose persistence is guaranteed and that is the reason
> I put the lock in the struct hv_device.

But no, that's not the way to do it, put it in the structure that has
the data you are trying to protect.

greg k-h

^ permalink raw reply	[flat|nested] 294+ messages in thread

* RE: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h
  2011-08-25  2:40                   ` Greg KH
@ 2011-08-25 14:14                     ` KY Srinivasan
  0 siblings, 0 replies; 294+ messages in thread
From: KY Srinivasan @ 2011-08-25 14:14 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, August 24, 2011 10:40 PM
> To: KY Srinivasan
> Cc: devel@linuxdriverproject.org; Haiyang Zhang; gregkh@suse.de; linux-
> kernel@vger.kernel.org; virtualization@lists.osdl.org
> Subject: Re: [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to
> mod_devicetable.h
> 
> On Thu, Aug 25, 2011 at 02:27:56AM +0000, KY Srinivasan wrote:
> > Since I don't have any (current) use for the driver_data pointer, I have gone
> ahead
> > and cleaned up the first 74 patches without adding the driver_data.
> > With the mushing of the patches   you had proposed this is about
> > a 60 patch series and addresses all the other comments you had in the first 74
> patches.
> > I hope I have gotten the "right" granularity now.   If it is ok with you, I could
> send these
> > out for your consideration.
> 
> Please do.
> 
> But if you do, do you mind if I add the driver_data pointer, so you can
> blame me later if no one uses it?  :)

Not at all! I will go ahead and send you these patches shortly.

> 
> > The only unresolved issue in the remaining patches (75 - 117) is the reference
> counting
> > issue we have been debating. As I noted in my earlier emails on this topic, the
> reference
> > counting has been there for a long time and I am reluctant get rid of that code
> without
> > additional testing/analysis. So I want to propose the following options:
> >
> > 1) Keep the existing code and I will skip the patches that cleaned up the
> reference counting
> >
> > 2) Take the cleanup that I have implemented
> >
> > In either case, I would further test and analyze this code to see if (a) the race
> condition that is being
> > addressed is valid and (b) if there is a different mechanism that could be used
> to deal with it. Given
> > the gaping holes in the current implementation, my personal preference would
> be to go with the
> > second option. Let me know what you want me to do here.
> 
> Ok, that sounds acceptable, but don't add the lock to the hv_driver, or
> is that needed right now?

Actually, last night I spent some considerable time understanding 
how this could be addressed differently and in a potentially simpler
way. I will go ahead and implement this scheme. Hopefully, I will be able
to send you these patches soon as well.

Regards,

K. Y



^ permalink raw reply	[flat|nested] 294+ messages in thread

end of thread, other threads:[~2011-08-25 14:14 UTC | newest]

Thread overview: 294+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-15 17:47 [PATCH 0000/0117] Staging: hv: Driver cleanup K. Y. Srinivasan
2011-07-15 17:45 ` [PATCH 001/117] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature K. Y. Srinivasan
2011-07-15 17:45   ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 002/117] Staging: hv: Replace struct hv_guid with the uuid type already defined in Linux K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 003/117] Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-08-23 22:41     ` Greg KH
2011-08-24  0:44       ` KY Srinivasan
2011-08-24  2:59         ` Greg KH
2011-08-24 16:46           ` KY Srinivasan
2011-08-24 20:11             ` Greg KH
2011-08-24 20:11               ` Greg KH
2011-08-24 21:51               ` KY Srinivasan
2011-08-25  2:27                 ` KY Srinivasan
2011-08-25  2:40                   ` Greg KH
2011-08-25 14:14                     ` KY Srinivasan
2011-08-25  2:38                 ` Greg KH
2011-08-25  2:38                   ` Greg KH
2011-07-15 17:45   ` [PATCH 004/117] Staging: hv: Add code to parse struct hv_vmbus_device_id table K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 005/117] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 006/117] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-08-23 22:45     ` Greg KH
2011-08-23 22:45       ` Greg KH
2011-07-15 17:45   ` [PATCH 007/117] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 008/117] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 009/117] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 010/117] Staging: hv: util: Make hv_utils a vmbus device driver K. Y. Srinivasan
2011-07-15 17:45   ` [PATCH 011/117] Staging: hv: util: Use the newly introduced vmbus ID in util driver K. Y. Srinivasan
2011-07-15 17:45     ` K. Y. Srinivasan
2011-08-23 22:46     ` Greg KH
2011-07-15 17:46   ` [PATCH 012/117] Staging: hv: blkvsc: Add the MODULE_DEVICE_TABLE() line K. Y. Srinivasan
2011-08-23 22:46     ` Greg KH
2011-07-15 17:46   ` [PATCH 013/117] Staging: hv: storvsc: Add " K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 014/117] Staging: hv: netvsc: Add the " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 015/117] Staging: hv: util: " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 016/117] Staging: hv: mouse: " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 017/117] Staging: hv: mouse: Do not auto-load the mouse driver K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 22:47     ` Greg KH
2011-08-23 22:47       ` Greg KH
2011-07-15 17:46   ` [PATCH 018/117] Staging: hv: vmbus: Cleanup vmbus_match() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 019/117] Staging: hv: vmbus: Cleanup vmbus_uevent() code K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 22:49     ` Greg KH
2011-08-24  0:38       ` KY Srinivasan
2011-08-24  3:00         ` Greg KH
2011-08-24  3:00           ` Greg KH
2011-08-24 14:12           ` KY Srinivasan
2011-07-15 17:46   ` [PATCH 020/117] Staging: hv: vmbus: Support the notion of id tables in vmbus_match() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-16  2:02     ` Christoph Hellwig
2011-07-16 12:54       ` KY Srinivasan
2011-07-16 18:24         ` Christoph Hellwig
2011-08-23 22:51     ` Greg KH
2011-08-23 22:51       ` Greg KH
2011-07-15 17:46   ` [PATCH 021/117] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 022/117] Staging: hv: storvsc: Get rid of the DMI signature K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 023/117] Staging: hv: netvsc: Get rid of the PCI signature K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 024/117] Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 025/117] Staging: hv: util: Get rid of the DMI signature in hv_util.c K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 026/117] Staging: hv: util: Get rid of the PCI " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 027/117] Staging: hv: blkvsc: Get rid of the dev_type guid from blkvsc_drv.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 22:52     ` Greg KH
2011-08-23 22:52       ` Greg KH
2011-07-15 17:46   ` [PATCH 028/117] Staging: hv: storvsc: Get rid of the device type guid from storvsc_drv.c K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 029/117] Staging: hv: netvsc: Get rid of the dev_type guid from netvsc.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 030/117] Staging: hv: netvsc: Initialize the driver name directly K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 031/117] Staging: hv: netvsc: Get rid of the driver name initialization in netvsc.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 22:56     ` Greg KH
2011-08-23 22:56       ` Greg KH
2011-07-15 17:46   ` [PATCH 032/117] Staging: hv: netvsc: Get rid of the empty function netvsc_initialize() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 033/117] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 034/117] Staging: hv: mouse: Get rid of the dev_type guid in hv_mouse.c K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 035/117] Staging: hv: vmbus: Introduce a function to map the dev_type guid to a name K. Y. Srinivasan
2011-08-23 23:01     ` Greg KH
2011-08-23 23:01       ` Greg KH
2011-07-15 17:46   ` [PATCH 036/117] Staging: hv: vmbus: Make class_id attribute a human readable string K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 23:02     ` Greg KH
2011-08-23 23:02       ` Greg KH
2011-07-15 17:46   ` [PATCH 037/117] Staging: hv: vmbus: Get rid of the device_id attribute K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 23:03     ` Greg KH
2011-08-23 23:03       ` Greg KH
2011-07-15 17:46   ` [PATCH 038/117] Staging: hv: vmbus: Get rid of some unnecessary comments K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 039/117] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 040/117] Staging: hv: vmbus: Cleanup error handling in hv_init() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-08-23 23:04     ` Greg KH
2011-08-23 23:04       ` Greg KH
2011-07-15 17:46   ` [PATCH 041/117] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 042/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_body() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 043/117] Staging: hv: vmbus: Get rid of the function dump_gpadl_header() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 044/117] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 045/117] Staging: hv: vmbus: Get rid of unnecessary comments " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 046/117] Staging: hv: vmbus: Change the variable name openInfo to open_info " K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 047/117] Staging: hv: vmbus: Cleanup error values in ringbuffer.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 048/117] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 049/117] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 050/117] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 051/117] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 052/117] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 053/117] Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 054/117] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 055/117] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 056/117] Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 057/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 058/117] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 059/117] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 060/117] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 061/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 062/117] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 063/117] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 064/117] Staging: hv: netvsc: Cleanup error return values in netvsc_send() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 065/117] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 066/117] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 067/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 068/117] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 069/117] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 070/117] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add() K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:46   ` [PATCH 071/117] Staging: hv: mouse: Change the jump label Cleanup to cleanup K. Y. Srinivasan
2011-07-15 17:46     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 072/117] Staging: hv: mouse: Get rid of the unused PCI signature K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 073/117] Staging: hv: netvsc: Change the jump label Cleanup to cleanup K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 074/117] Staging: hv: netvsc: Change the jump label Exit to exit K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 075/117] Staging: hv: storvsc: Inline free_stor_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 076/117] Staging: hv: storvsc: Do not aquire an unnecessary reference on stor_device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 077/117] Staging: hv: storvsc: Rename must_get_stor_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 078/117] Staging: hv: storvsc: Rename get_stor_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 079/117] Staging: hv: storvsc: Cleanup alloc_stor_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 080/117] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 081/117] Staging: hv: vmbus: Introduce a lock to protect the ext field in hv_device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-08-23 23:08     ` Greg KH
2011-08-23 23:08       ` Greg KH
2011-08-24  0:55       ` KY Srinivasan
2011-08-24  2:58         ` Greg KH
2011-08-24  2:58           ` Greg KH
2011-08-24 14:29           ` KY Srinivasan
2011-08-24 14:29             ` KY Srinivasan
2011-07-15 17:47   ` [PATCH 082/117] Staging: hv: storvsc: Use the newly introduced lock in accessing ext field K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 083/117] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is destroyed K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 084/117] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 085/117] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 086/117] Staging: hv: storvsc: Leverage the spinlock to manage ref_cnt K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-08-23 23:10     ` Greg KH
2011-08-23 23:10       ` Greg KH
2011-08-24  0:58       ` KY Srinivasan
2011-08-24  0:58         ` KY Srinivasan
2011-08-24  2:57         ` Greg KH
2011-08-24  2:57           ` Greg KH
2011-08-24 16:25           ` KY Srinivasan
2011-08-24 20:17             ` Greg KH
2011-08-24 22:57               ` KY Srinivasan
2011-08-25  2:45                 ` Greg KH
2011-07-15 17:47   ` [PATCH 087/117] Staging: hv: storvsc: Further cleanup reference counting of stor_device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 088/117] Staging: hv: netvsc: Inline the code for free_net_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-16 10:33     ` Dan Carpenter
2011-07-16 13:09       ` KY Srinivasan
2011-07-15 17:47   ` [PATCH 089/117] Staging: hv: netvsc: Cleanup alloc_net_device() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 090/117] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 091/117] Staging: hv: netvsc: Use the newly introduced lock in accessing ext field K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 092/117] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 093/117] Staging: hv: netvsc: Get rid of release_outbound_net_device() by inlining the code K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 094/117] Staging: hv: netvsc: Get rid of release_inbound_net_device() " K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 095/117] Staging: hv: netvsc: Leverage the spinlock to manage refcnt K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 096/117] Staging: hv: netvsc: Further cleanup reference counting of netvsc_device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 097/117] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-16  2:04     ` Christoph Hellwig
2011-07-16  2:04       ` Christoph Hellwig
2011-07-16 12:57       ` KY Srinivasan
2011-07-16 12:57         ` KY Srinivasan
2011-07-16 13:01         ` Sasha Levin
2011-07-16 13:12           ` KY Srinivasan
2011-07-16 18:27           ` Christoph Hellwig
2011-07-16 18:27             ` Christoph Hellwig
2011-07-15 17:47   ` [PATCH 098/117] Staging: hv: storvsc: Handle " K. Y. Srinivasan
2011-07-16  2:05     ` Christoph Hellwig
2011-07-15 17:47   ` [PATCH 099/117] Staging: hv: storvsc: Optimize bounce buffer handling for the "write" case K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 100/117] Staging: hv: storvsc: Optimize the bounce buffer handling in the "read" case K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 101/117] Staging: hv: storvsc: Include storvsc.c in storvsc_drv.c K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 102/117] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 103/117] Staging: hv: storvsc: Add the contents of hyperv_storage.h to storvsc_drv.c K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 104/117] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of hyperv_storage.h K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 105/117] Staging: hv: storvsc: Make some non static functions, static functions K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 106/117] Staging: hv: storvsc: Fixup srb and scsi status for INQUIRY and MODE_SENSE K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 107/117] Staging: hv: storvsc: Fix a typo K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 108/117] Staging: hv: storvsc: In case of scsi errors offline the device K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 109/117] Staging: hv: storvsc: No need to copy from bounce buffer in case of a failure K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 110/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_register() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 111/117] Staging: hv: vmbus: Change the signature of vmbus_child_driver_unregister() K. Y. Srinivasan
2011-07-15 17:47     ` K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 112/117] Staging: hv: util: Forcefully shutdown when shutdown is requested K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 113/117] Staging: hv: util: Adjust guest time in a process context K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 114/117] Staging: hv: vmbus: Check before invoking the channel callback K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 115/117] Staging: hv: vmbus: Properly deal with de-registering " K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 116/117] Staging: hv: vmbus: Add code to display modalias attribute K. Y. Srinivasan
2011-07-15 17:47   ` [PATCH 117/117] Staging: hv: blkvsc: Get rid of blkvsc_drv.c as this code is not used K. Y. Srinivasan
2011-07-15 18:25 ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Michael Witten
2011-07-15 18:50   ` KY Srinivasan
2011-07-15 21:09   ` Dan Carpenter
2011-07-15 22:55     ` Michael Witten
2011-07-15 23:22       ` Large Patch Series in Email David Miller
2011-07-15 23:22         ` David Miller
2011-07-15 23:07   ` Large Patch Series in Email (was Re: [PATCH 0000/0117] Staging: hv: Driver cleanup) Alan Cox
2011-07-17 10:47     ` Florian Mickler
2011-08-23 23:11 ` [PATCH 0000/0117] Staging: hv: Driver cleanup Greg KH
2011-08-23 23:11   ` Greg KH
2011-08-24  1:01   ` KY Srinivasan
2011-08-24  3:08     ` Greg KH
2011-08-24  3:08       ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.