Skip to contentSkip to conversation

Staging: hv: Cleanup hv drivers

PATCH In review K. Y. Srinivasan 5 participants 217 messages May 9, 2011 – May 10, 2011 Page 1 of 2

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Staging: hv: Cleanup hv drivers

This patch-set deals with some of the architectural isues in all of the Hyper-V drivers. Specifically:

1) Fixes a number of locking issues in the block driver.

2) Eliminates all the indirection through the hv_driver abstraction.

3) Simplifies the code across the board eliminating unnecessary code and data structure layering. Prior to this restructuring there were about 11,000 lines of code in the hv directory. After this cleanup, there are about 8500 lines of code.

4) I have dealt with style and naming issues across all the drivers.

5) All the header files have been cleaned up and consolidated:
1) A single header file include/linux/hyperv.h. This file is to be included in all the drivers that attach to the vmbus.

2) A single header file that has all the defines for building the vmbus driver.
3) Consolidate header files for each device class - disk and net.

Regads,

K. Y

#1 lore raw

PATCH 1/206 Staging: hv: Get rid of blkvsc_mutex

The blkvsc_mutex is unnecessary as the state it is protecting (blkdev->users) is already protected by the spin lock.

---
 drivers/staging/hv/blkvsc_drv.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -5
index db44cf6..cfef1c0 100644
@@ -27,7 +27,6 @@
 #include <linux/major.h>
 #include <linux/delay.h>
 #include <linux/hdreg.h>
-#include <linux/mutex.h>
 #include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -113,8 +112,6 @@ struct block_device_context {
 	int users;
 };
 
-static DEFINE_MUTEX(blkvsc_mutex);
-
 static const char *g_blk_driver_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
@@ -620,7 +617,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
 {
 	struct block_device_context *blkdev = disk->private_data;
 
-	mutex_lock(&blkvsc_mutex);
 	spin_lock(&blkdev->lock);
 	if (blkdev->users == 1) {
 		spin_unlock(&blkdev->lock);
@@ -631,7 +627,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
 	blkdev->users--;
 
 	spin_unlock(&blkdev->lock);
-	mutex_unlock(&blkvsc_mutex);
 	return 0;
 }
 
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/206 Staging: hv: Cleanup spin lock usage

This spin lock is potentially acquired from interrupt context. Ensure that the interrupts are blocked whenever the lock is held. The current code was not consistent with regards to blocking interrupts - the same lock would be acquired without blocking interrupts in some instance while the interrupts would be blocked in other instances. Fix this potential deadlock problem.

---
 drivers/staging/hv/blkvsc_drv.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
drivers/staging/hv/blkvsc_drv.c +8 -6
index cfef1c0..74d51bb 100644
@@ -249,12 +249,13 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 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(&blkdev->lock);
+	spin_lock_irqsave(&blkdev->lock, flags);
 
 	blkdev->users++;
 
-	spin_unlock(&blkdev->lock);
+	spin_unlock_irqrestore(&blkdev->lock, flags);
 
 	return 0;
 }
@@ -616,17 +617,18 @@ static void blkvsc_shutdown(struct hv_device *dev)
 static int blkvsc_release(struct gendisk *disk, fmode_t mode)
 {
 	struct block_device_context *blkdev = disk->private_data;
+	unsigned long flags;
 
-	spin_lock(&blkdev->lock);
+	spin_lock_irqsave(&blkdev->lock, flags);
 	if (blkdev->users == 1) {
-		spin_unlock(&blkdev->lock);
+		spin_unlock_irqrestore(&blkdev->lock, flags);
 		blkvsc_do_operation(blkdev, DO_FLUSH);
-		spin_lock(&blkdev->lock);
+		spin_lock_irqsave(&blkdev->lock, flags);
 	}
 
 	blkdev->users--;
 
-	spin_unlock(&blkdev->lock);
+	spin_unlock_irqrestore(&blkdev->lock, flags);
 	return 0;
 }
 
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/206 Staging: hv: Fix some locking issues

In reply to K. Y. Srinivasan

Additional lock related cleanup. Properly serialize access to state even for command related operations.

---
 drivers/staging/hv/blkvsc_drv.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)
drivers/staging/hv/blkvsc_drv.c +15 -16
index 74d51bb..8a577bc 100644
@@ -331,10 +331,14 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
 			(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,
@@ -354,6 +358,7 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
 	unsigned char device_type;
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
+	unsigned long flags;
 
 	int ret = 0;
 
@@ -407,7 +412,9 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
 		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);
 
@@ -555,6 +562,8 @@ static int blkvsc_remove(struct hv_device *dev)
 
 	blk_stop_queue(blkdev->gd->queue);
 
+	blkvsc_cancel_pending_reqs(blkdev);
+
 	spin_unlock_irqrestore(&blkdev->lock, flags);
 
 	while (blkdev->num_outstanding_reqs) {
@@ -563,13 +572,8 @@ static int blkvsc_remove(struct hv_device *dev)
 		udelay(100);
 	}
 
-	blkvsc_do_operation(blkdev, DO_FLUSH);
-
-	spin_lock_irqsave(&blkdev->lock, flags);
 
-	blkvsc_cancel_pending_reqs(blkdev);
-
-	spin_unlock_irqrestore(&blkdev->lock, flags);
+	blkvsc_do_operation(blkdev, DO_FLUSH);
 
 	blk_cleanup_queue(blkdev->gd->queue);
 
@@ -597,6 +601,8 @@ static void blkvsc_shutdown(struct hv_device *dev)
 
 	blk_stop_queue(blkdev->gd->queue);
 
+	blkvsc_cancel_pending_reqs(blkdev);
+
 	spin_unlock_irqrestore(&blkdev->lock, flags);
 
 	while (blkdev->num_outstanding_reqs) {
@@ -605,13 +611,9 @@ static void blkvsc_shutdown(struct hv_device *dev)
 		udelay(100);
 	}
 
-	blkvsc_do_operation(blkdev, DO_FLUSH);
 
-	spin_lock_irqsave(&blkdev->lock, flags);
-
-	blkvsc_cancel_pending_reqs(blkdev);
+	blkvsc_do_operation(blkdev, DO_FLUSH);
 
-	spin_unlock_irqrestore(&blkdev->lock, flags);
 }
 
 static int blkvsc_release(struct gendisk *disk, fmode_t mode)
@@ -619,16 +621,14 @@ 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 == 1) {
-		spin_unlock_irqrestore(&blkdev->lock, flags);
 		blkvsc_do_operation(blkdev, DO_FLUSH);
-		spin_lock_irqsave(&blkdev->lock, flags);
 	}
 
+	spin_lock_irqsave(&blkdev->lock, flags);
 	blkdev->users--;
-
 	spin_unlock_irqrestore(&blkdev->lock, flags);
+
 	return 0;
 }
 
@@ -943,7 +943,6 @@ static int blkvsc_probe(struct hv_device *dev)
 	struct storvsc_major_info major_info;
 	int ret = 0;
 
-
 	blkdev = kzalloc(sizeof(struct block_device_context), GFP_KERNEL);
 	if (!blkdev) {
 		ret = -ENOMEM;
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 4/206 Staging: hv: Rename driver name variable

In reply to K. Y. Srinivasan

Rename the variable g_blk_driver_name.

---
 drivers/staging/hv/blkvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -2
index 8a577bc..b54130b 100644
@@ -112,7 +112,7 @@ struct block_device_context {
 	int users;
 };
 
-static const char *g_blk_driver_name = "blkvsc";
+static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
 static const struct hv_guid g_blk_device_type = {
@@ -177,7 +177,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
-	driver->name = g_blk_driver_name;
+	driver->name = drv_name;
 	memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
 
 
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 5/206 Staging: hv: Rename the device type variable

In reply to K. Y. Srinivasan

Rename the variable g_blk_device_type.

---
 drivers/staging/hv/blkvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -2
index b54130b..51d1265 100644
@@ -115,7 +115,7 @@ struct block_device_context {
 static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid g_blk_device_type = {
+static const struct hv_guid dev_type = {
 	.data = {
 		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
@@ -178,7 +178,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
 	driver->name = drv_name;
-	memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
+	memcpy(&driver->dev_type, &dev_type, sizeof(struct hv_guid));
 
 
 	/*
Signature · 1 line
1.7.4.1
#6 lore raw

Re: [PATCH 005/206] Staging: hv: Rename the device type variable

Quoted 1 line · K. Y. Srinivasan

Rename the variable g_blk_device_type.

Why?

A few of these renames could do with a bit more detail on what is wrong with the old names.

Quoted 31 lines
---
 drivers/staging/hv/blkvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -2
index b54130b..51d1265 100644
@@ -115,7 +115,7 @@ struct block_device_context {
 static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid g_blk_device_type = {
+static const struct hv_guid dev_type = {
 	.data = {
 		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
@@ -178,7 +178,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
 	driver->name = drv_name;
-	memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
+	memcpy(&driver->dev_type, &dev_type, sizeof(struct hv_guid));
 
 
 	/*
#7 lore raw

Re: [PATCH 005/206] Staging: hv: Rename the device type variable

Quoted 3 lines · Jonathan Cameron
Quoted 1 line · K. Y. Srinivasan

Rename the variable g_blk_device_type.

Why?

Because "g_blk_device_type" is in Hungarian notation, which isn't needed in the kernel.

thanks,

greg k-h

#8 lore raw

Re: [PATCH 005/206] Staging: hv: Rename the device type variable

Quoted 8 lines · Greg KH
Quoted 3 lines · Jonathan Cameron
Quoted 1 line · K. Y. Srinivasan

Rename the variable g_blk_device_type.

Why?

Because "g_blk_device_type" is in Hungarian notation, which isn't needed in the kernel.

Fair enough, I'd misunderstood what g_blk referred to. Sorry for the noise.

#9 lore raw

PATCH 6/206 Staging: hv: Change the name of struct storvsc_driver_object

In reply to K. Y. Srinivasan

Rename the struct storvsc_driver_object.

---
 drivers/staging/hv/blkvsc_drv.c  |   14 +++++++-------
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    8 ++++----
 drivers/staging/hv/storvsc_drv.c |   14 +++++++-------
 4 files changed, 19 insertions(+), 19 deletions(-)
drivers/staging/hv/blkvsc_drv.c +7 -7
index 51d1265..a80e7c1 100644
@@ -170,7 +170,7 @@ static int blk_vsc_on_device_add(struct hv_device *device,
 
 static int blk_vsc_initialize(struct hv_driver *driver)
 {
-	struct storvsc_driver_object *stor_driver;
+	struct storvsc_driver *stor_driver;
 	int ret = 0;
 
 	stor_driver = hvdr_to_stordr(driver);
@@ -211,7 +211,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 {
 	struct block_device_context *blkdev = blkvsc_req->dev;
 	struct hv_device *device_ctx = blkdev->device_ctx;
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 			drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *storvsc_req;
 	struct vmscsi_request *vm_srb;
@@ -544,7 +544,7 @@ out:
  */
 static int blkvsc_remove(struct hv_device *dev)
 {
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 				drv_to_stordrv(dev->device.driver);
 	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
 	unsigned long flags;
@@ -852,7 +852,7 @@ static void blkvsc_request(struct request_queue *queue)
 
 
 /* The one and only one */
-static  struct storvsc_driver_object g_blkvsc_drv;
+static  struct storvsc_driver g_blkvsc_drv;
 
 static const struct block_device_operations block_ops = {
 	.owner = THIS_MODULE,
@@ -867,7 +867,7 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv;
+	struct storvsc_driver *storvsc_drv_obj = &g_blkvsc_drv;
 	struct hv_driver *drv = &g_blkvsc_drv.base;
 	int ret;
 
@@ -897,7 +897,7 @@ static int blkvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void blkvsc_drv_exit(void)
 {
-	struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv;
+	struct storvsc_driver *storvsc_drv_obj = &g_blkvsc_drv;
 	struct hv_driver *drv = &g_blkvsc_drv.base;
 	struct device *current_dev;
 	int ret;
@@ -935,7 +935,7 @@ static void blkvsc_drv_exit(void)
  */
 static int blkvsc_probe(struct hv_device *dev)
 {
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 			drv_to_stordrv(dev->device.driver);
 
 	struct block_device_context *blkdev = NULL;
drivers/staging/hv/storvsc.c +1 -1
index d53aa97..6be504b 100644
@@ -411,7 +411,7 @@ static void stor_vsc_on_channel_callback(void *context)
 static int stor_vsc_connect_to_vsp(struct hv_device *device)
 {
 	struct vmstorage_channel_properties props;
-	struct storvsc_driver_object *stor_driver;
+	struct storvsc_driver *stor_driver;
 	int ret;
 
 	stor_driver = drv_to_stordrv(device->device.driver);
drivers/staging/hv/storvsc_api.h +4 -4
index b60a058..4ebf50a 100644
@@ -73,7 +73,7 @@ struct hv_storvsc_request {
 
 
 /* Represents the block vsc driver */
-struct storvsc_driver_object {
+struct storvsc_driver {
 	struct hv_driver base;
 
 	/* Set by caller (in bytes) */
@@ -149,13 +149,13 @@ static inline void put_stor_device(struct hv_device *device)
 	atomic_dec(&stor_device->ref_count);
 }
 
-static inline struct storvsc_driver_object *hvdr_to_stordr(struct hv_driver *d)
+static inline struct storvsc_driver *hvdr_to_stordr(struct hv_driver *d)
 {
-	return container_of(d, struct storvsc_driver_object, base);
+	return container_of(d, struct storvsc_driver, base);
 }
 
 static inline
-struct storvsc_driver_object *drv_to_stordrv(struct device_driver *d)
+struct storvsc_driver *drv_to_stordrv(struct device_driver *d)
 {
 	struct hv_driver *hvdrv = drv_to_hv_drv(d);
 	return hvdr_to_stordr(hvdrv);
drivers/staging/hv/storvsc_drv.c +7 -7
index e449481..1fce10e 100644
@@ -77,7 +77,7 @@ struct storvsc_cmd_request {
  */
 static int stor_vsc_initialize(struct hv_driver *driver)
 {
-	struct storvsc_driver_object *stor_driver;
+	struct storvsc_driver *stor_driver;
 
 	stor_driver = hvdr_to_stordr(driver);
 
@@ -152,7 +152,7 @@ module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
 /* The one and only one */
-static struct storvsc_driver_object g_storvsc_drv;
+static struct storvsc_driver g_storvsc_drv;
 
 /* Scsi driver */
 static struct scsi_host_template scsi_driver = {
@@ -189,7 +189,7 @@ static struct scsi_host_template scsi_driver = {
 static int storvsc_drv_init(void)
 {
 	int ret;
-	struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
+	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
 	struct hv_driver *drv = &g_storvsc_drv.base;
 
 	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
@@ -286,7 +286,7 @@ static int storvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void storvsc_drv_exit(void)
 {
-	struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
+	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
 	struct hv_driver *drv = &g_storvsc_drv.base;
 	struct device *current_dev = NULL;
 	int ret;
@@ -323,7 +323,7 @@ static void storvsc_drv_exit(void)
 static int storvsc_probe(struct hv_device *device)
 {
 	int ret;
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 		 drv_to_stordrv(device->device.driver);
 	struct Scsi_Host *host;
 	struct host_device_context *host_device_ctx;
@@ -400,7 +400,7 @@ static int storvsc_probe(struct hv_device *device)
  */
 static int storvsc_remove(struct hv_device *dev)
 {
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 			 drv_to_stordrv(dev->device.driver);
 	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
 	struct host_device_context *host_device_ctx =
@@ -686,7 +686,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	struct host_device_context *host_device_ctx =
 		(struct host_device_context *)scmnd->device->host->hostdata;
 	struct hv_device *device_ctx = host_device_ctx->device_ctx;
-	struct storvsc_driver_object *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv_obj =
 		drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *request;
 	struct storvsc_cmd_request *cmd_request;
Signature · 1 line
1.7.4.1
#10 lore raw

PATCH 7/206 Staging: hv: Change the name of blkvsc driver variable

In reply to K. Y. Srinivasan

Rename the variable g_blkvsc_drv.

---
 drivers/staging/hv/blkvsc_drv.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/blkvsc_drv.c +5 -5
index a80e7c1..a0e08de 100644
@@ -852,7 +852,7 @@ static void blkvsc_request(struct request_queue *queue)
 
 
 /* The one and only one */
-static  struct storvsc_driver g_blkvsc_drv;
+static  struct storvsc_driver blkvsc_drv;
 
 static const struct block_device_operations block_ops = {
 	.owner = THIS_MODULE,
@@ -867,8 +867,8 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &g_blkvsc_drv;
-	struct hv_driver *drv = &g_blkvsc_drv.base;
+	struct storvsc_driver *storvsc_drv_obj = &blkvsc_drv;
+	struct hv_driver *drv = &blkvsc_drv.base;
 	int ret;
 
 	storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
@@ -897,8 +897,8 @@ static int blkvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void blkvsc_drv_exit(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &g_blkvsc_drv;
-	struct hv_driver *drv = &g_blkvsc_drv.base;
+	struct storvsc_driver *storvsc_drv_obj = &blkvsc_drv;
+	struct hv_driver *drv = &blkvsc_drv.base;
 	struct device *current_dev;
 	int ret;
 
Signature · 1 line
1.7.4.1
#11 lore raw

PATCH 8/206 Staging: hv: Rename variables of type struct storvsc_driver *

In reply to K. Y. Srinivasan

Rename the variables pointing to variables of type struct storvsc_driver *.

---
 drivers/staging/hv/blkvsc_drv.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/staging/hv/blkvsc_drv.c +14 -14
index a0e08de..391666e 100644
@@ -211,7 +211,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 {
 	struct block_device_context *blkdev = blkvsc_req->dev;
 	struct hv_device *device_ctx = blkdev->device_ctx;
-	struct storvsc_driver *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv =
 			drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *storvsc_req;
 	struct vmscsi_request *vm_srb;
@@ -237,7 +237,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 
 	storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
 
-	ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx,
+	ret = storvsc_drv->on_io_request(blkdev->device_ctx,
 					   &blkvsc_req->request);
 	if (ret == 0)
 		blkdev->num_outstanding_reqs++;
@@ -544,7 +544,7 @@ out:
  */
 static int blkvsc_remove(struct hv_device *dev)
 {
-	struct storvsc_driver *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv =
 				drv_to_stordrv(dev->device.driver);
 	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
 	unsigned long flags;
@@ -553,7 +553,7 @@ static int blkvsc_remove(struct hv_device *dev)
 	 * Call to the vsc driver to let it know that the device is being
 	 * removed
 	 */
-	storvsc_drv_obj->base.dev_rm(dev);
+	storvsc_drv->base.dev_rm(dev);
 
 	/* Get to a known state */
 	spin_lock_irqsave(&blkdev->lock, flags);
@@ -867,16 +867,16 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &blkvsc_drv;
+	struct storvsc_driver *storvsc_drv = &blkvsc_drv;
 	struct hv_driver *drv = &blkvsc_drv.base;
 	int ret;
 
-	storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
+	storvsc_drv->ring_buffer_size = blkvsc_ringbuffer_size;
 
 	/* Callback to client driver to complete the initialization */
-	blk_vsc_initialize(&storvsc_drv_obj->base);
+	blk_vsc_initialize(&storvsc_drv->base);
 
-	drv->driver.name = storvsc_drv_obj->base.name;
+	drv->driver.name = storvsc_drv->base.name;
 
 	drv->probe = blkvsc_probe;
 	drv->remove = blkvsc_remove;
@@ -897,7 +897,7 @@ static int blkvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void blkvsc_drv_exit(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &blkvsc_drv;
+	struct storvsc_driver *storvsc_drv = &blkvsc_drv;
 	struct hv_driver *drv = &blkvsc_drv.base;
 	struct device *current_dev;
 	int ret;
@@ -922,8 +922,8 @@ static void blkvsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (storvsc_drv_obj->base.cleanup)
-		storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
+	if (storvsc_drv->base.cleanup)
+		storvsc_drv->base.cleanup(&storvsc_drv->base);
 
 	vmbus_child_driver_unregister(&drv->driver);
 
@@ -935,7 +935,7 @@ static void blkvsc_drv_exit(void)
  */
 static int blkvsc_probe(struct hv_device *dev)
 {
-	struct storvsc_driver *storvsc_drv_obj =
+	struct storvsc_driver *storvsc_drv =
 			drv_to_stordrv(dev->device.driver);
 
 	struct block_device_context *blkdev = NULL;
@@ -965,7 +965,7 @@ static int blkvsc_probe(struct hv_device *dev)
 
 
 	/* Call to the vsc driver to add the device */
-	ret = storvsc_drv_obj->base.dev_add(dev, &device_info);
+	ret = storvsc_drv->base.dev_add(dev, &device_info);
 	if (ret != 0)
 		goto cleanup;
 
@@ -1035,7 +1035,7 @@ static int blkvsc_probe(struct hv_device *dev)
 	return ret;
 
 remove:
-	storvsc_drv_obj->base.dev_rm(dev);
+	storvsc_drv->base.dev_rm(dev);
 
 cleanup:
 	if (blkdev) {
Signature · 1 line
1.7.4.1
#12 lore raw

PATCH 9/206 Staging: hv: Rename the function blk_vsc_on_device_add

In reply to K. Y. Srinivasan

Rename the function blk_vsc_on_device_add.

---
 drivers/staging/hv/blkvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -2
index 391666e..0005e33 100644
@@ -139,7 +139,7 @@ MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)");
  */
 static int blkvsc_probe(struct hv_device *dev);
 
-static int blk_vsc_on_device_add(struct hv_device *device,
+static int blkvsc_device_add(struct hv_device *device,
 				void *additional_info)
 {
 	struct storvsc_device_info *device_info;
@@ -197,7 +197,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.dev_add = blk_vsc_on_device_add;
+	stor_driver->base.dev_add = blkvsc_device_add;
 	stor_driver->base.dev_rm = stor_vsc_on_device_remove;
 	stor_driver->base.cleanup = stor_vsc_on_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
Signature · 1 line
1.7.4.1
#13 lore raw

PATCH 10/206 Staging: hv: Get rid of the indirection for invoking device_add

In reply to K. Y. Srinivasan

Get rid of the indirection for invoking device_add.

---
 drivers/staging/hv/blkvsc_drv.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -3
index 0005e33..434c2a9 100644
@@ -197,7 +197,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.dev_add = blkvsc_device_add;
 	stor_driver->base.dev_rm = stor_vsc_on_device_remove;
 	stor_driver->base.cleanup = stor_vsc_on_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
@@ -964,8 +963,7 @@ static int blkvsc_probe(struct hv_device *dev)
 	}
 
 
-	/* Call to the vsc driver to add the device */
-	ret = storvsc_drv->base.dev_add(dev, &device_info);
+	ret =  blkvsc_device_add(dev, &device_info);
 	if (ret != 0)
 		goto cleanup;
 
Signature · 1 line
1.7.4.1
#14 lore raw

PATCH 11/206 Staging: hv: Rename the function stor_vsc_device_add

In reply to K. Y. Srinivasan

The subject says it all.

---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index 434c2a9..908c169 100644
@@ -147,7 +147,7 @@ static int blkvsc_device_add(struct hv_device *device,
 
 	device_info = (struct storvsc_device_info *)additional_info;
 
-	ret = stor_vsc_on_device_add(device, additional_info);
+	ret = storvsc_dev_add(device, additional_info);
 	if (ret != 0)
 		return ret;
 
drivers/staging/hv/storvsc.c +1 -1
index 6be504b..503c6bf 100644
@@ -442,7 +442,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)
  * stor_vsc_on_device_add - Callback when the device belonging to this driver
  * is added
  */
-int stor_vsc_on_device_add(struct hv_device *device,
+int storvsc_dev_add(struct hv_device *device,
 					void *additional_info)
 {
 	struct storvsc_device *stor_device;
drivers/staging/hv/storvsc_api.h +1 -1
index 4ebf50a..0200154 100644
@@ -163,7 +163,7 @@ struct storvsc_driver *drv_to_stordrv(struct device_driver *d)
 
 /* Interface */
 
-int stor_vsc_on_device_add(struct hv_device *device,
+int storvsc_dev_add(struct hv_device *device,
 				void *additional_info);
 int stor_vsc_on_device_remove(struct hv_device *device);
 
drivers/staging/hv/storvsc_drv.c +1 -1
index 1fce10e..5168eb7 100644
@@ -113,7 +113,7 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 		    STORVSC_MAX_IO_REQUESTS);
 
 	/* Setup the dispatch table */
-	stor_driver->base.dev_add	= stor_vsc_on_device_add;
+	stor_driver->base.dev_add	= storvsc_dev_add;
 	stor_driver->base.dev_rm	= stor_vsc_on_device_remove;
 	stor_driver->base.cleanup	= stor_vsc_on_cleanup;
 
Signature · 1 line
1.7.4.1
#15 lore raw

PATCH 12/206 Staging: hv: Rename the function stor_vsc_on_device_remove

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index 908c169..830f257 100644
@@ -197,7 +197,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.dev_rm = stor_vsc_on_device_remove;
+	stor_driver->base.dev_rm = storvsc_dev_remove;
 	stor_driver->base.cleanup = stor_vsc_on_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
 
drivers/staging/hv/storvsc.c +1 -1
index 503c6bf..976f382 100644
@@ -483,7 +483,7 @@ cleanup:
 /*
  * stor_vsc_on_device_remove - Callback when the our device is being removed
  */
-int stor_vsc_on_device_remove(struct hv_device *device)
+int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
drivers/staging/hv/storvsc_api.h +1 -1
index 0200154..b3207a0 100644
@@ -165,7 +165,7 @@ struct storvsc_driver *drv_to_stordrv(struct device_driver *d)
 
 int storvsc_dev_add(struct hv_device *device,
 				void *additional_info);
-int stor_vsc_on_device_remove(struct hv_device *device);
+int storvsc_dev_remove(struct hv_device *device);
 
 int stor_vsc_on_io_request(struct hv_device *device,
 				struct hv_storvsc_request *request);
drivers/staging/hv/storvsc_drv.c +1 -1
index 5168eb7..903ecbe 100644
@@ -114,7 +114,7 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 
 	/* Setup the dispatch table */
 	stor_driver->base.dev_add	= storvsc_dev_add;
-	stor_driver->base.dev_rm	= stor_vsc_on_device_remove;
+	stor_driver->base.dev_rm	= storvsc_dev_remove;
 	stor_driver->base.cleanup	= stor_vsc_on_cleanup;
 
 	stor_driver->on_io_request	= stor_vsc_on_io_request;
Signature · 1 line
1.7.4.1
#16 lore raw

PATCH 13/206 Staging: hv: Get rid of the indirection for removing stor device

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -8
index 830f257..8b8d960 100644
@@ -197,7 +197,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.dev_rm = storvsc_dev_remove;
 	stor_driver->base.cleanup = stor_vsc_on_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
 
@@ -543,8 +542,6 @@ out:
  */
 static int blkvsc_remove(struct hv_device *dev)
 {
-	struct storvsc_driver *storvsc_drv =
-				drv_to_stordrv(dev->device.driver);
 	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
 	unsigned long flags;
 
@@ -552,7 +549,7 @@ static int blkvsc_remove(struct hv_device *dev)
 	 * Call to the vsc driver to let it know that the device is being
 	 * removed
 	 */
-	storvsc_drv->base.dev_rm(dev);
+	storvsc_dev_remove(dev);
 
 	/* Get to a known state */
 	spin_lock_irqsave(&blkdev->lock, flags);
@@ -934,9 +931,6 @@ static void blkvsc_drv_exit(void)
  */
 static int blkvsc_probe(struct hv_device *dev)
 {
-	struct storvsc_driver *storvsc_drv =
-			drv_to_stordrv(dev->device.driver);
-
 	struct block_device_context *blkdev = NULL;
 	struct storvsc_device_info device_info;
 	struct storvsc_major_info major_info;
@@ -1033,7 +1027,7 @@ static int blkvsc_probe(struct hv_device *dev)
 	return ret;
 
 remove:
-	storvsc_drv->base.dev_rm(dev);
+	storvsc_dev_remove(dev);
 
 cleanup:
 	if (blkdev) {
Signature · 1 line
1.7.4.1
#17 lore raw

PATCH 14/206 Staging: hv: Rename the function stor_vsc_on_cleanup

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c  |    5 ++---
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -3
index 8b8d960..1d0b6ed 100644
@@ -17,8 +17,7 @@
  * Authors:
  *   Haiyang Zhang <[email protected]>
  *   Hank Janssen  <[email protected]>
- *
- * 4/3/2011: K. Y. Srinivasan - Significant restructuring and cleanup.
+ *   K. Y. Srinivasan <[email protected]>
  */
 #include <linux/init.h>
 #include <linux/module.h>
@@ -197,7 +196,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.cleanup = stor_vsc_on_cleanup;
+	stor_driver->base.cleanup = storvsc_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
 
 	return ret;
drivers/staging/hv/storvsc.c +1 -1
index 976f382..2e276b4 100644
@@ -663,7 +663,7 @@ int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
 /*
  * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
  */
-void stor_vsc_on_cleanup(struct hv_driver *driver)
+void storvsc_cleanup(struct hv_driver *driver)
 {
 }
 
drivers/staging/hv/storvsc_api.h +1 -1
index b3207a0..3168161 100644
@@ -169,7 +169,7 @@ int storvsc_dev_remove(struct hv_device *device);
 
 int stor_vsc_on_io_request(struct hv_device *device,
 				struct hv_storvsc_request *request);
-void stor_vsc_on_cleanup(struct hv_driver *driver);
+void storvsc_cleanup(struct hv_driver *driver);
 
 int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
 				struct storvsc_major_info *major_info);
drivers/staging/hv/storvsc_drv.c +1 -1
index 903ecbe..86f2bab 100644
@@ -115,7 +115,7 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 	/* Setup the dispatch table */
 	stor_driver->base.dev_add	= storvsc_dev_add;
 	stor_driver->base.dev_rm	= storvsc_dev_remove;
-	stor_driver->base.cleanup	= stor_vsc_on_cleanup;
+	stor_driver->base.cleanup	= storvsc_cleanup;
 
 	stor_driver->on_io_request	= stor_vsc_on_io_request;
 
Signature · 1 line
1.7.4.1
#18 lore raw

PATCH 15/206 Staging: hv: Get rid of the indirection for invoking cleanup function

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -3
index 1d0b6ed..ec00a16 100644
@@ -196,7 +196,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->base.cleanup = storvsc_cleanup;
 	stor_driver->on_io_request = stor_vsc_on_io_request;
 
 	return ret;
@@ -917,8 +916,7 @@ static void blkvsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (storvsc_drv->base.cleanup)
-		storvsc_drv->base.cleanup(&storvsc_drv->base);
+	storvsc_cleanup(&storvsc_drv->base);
 
 	vmbus_child_driver_unregister(&drv->driver);
 
Signature · 1 line
1.7.4.1
#19 lore raw

PATCH 16/206 Staging: hv: Rename the function stor_vsc_on_io_request

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    2 +-
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index ec00a16..bfec15c 100644
@@ -196,7 +196,7 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel);
 
 	/* Setup the dispatch table */
-	stor_driver->on_io_request = stor_vsc_on_io_request;
+	stor_driver->on_io_request = storvsc_do_io;
 
 	return ret;
 }
drivers/staging/hv/storvsc.c +1 -1
index 2e276b4..867eba1 100644
@@ -520,7 +520,7 @@ int storvsc_dev_remove(struct hv_device *device)
 /*
  * stor_vsc_on_io_request - Callback to initiate an I/O request
  */
-int stor_vsc_on_io_request(struct hv_device *device,
+int storvsc_do_io(struct hv_device *device,
 			      struct hv_storvsc_request *request)
 {
 	struct storvsc_device *stor_device;
drivers/staging/hv/storvsc_api.h +1 -1
index 3168161..f8c724b 100644
@@ -167,7 +167,7 @@ int storvsc_dev_add(struct hv_device *device,
 				void *additional_info);
 int storvsc_dev_remove(struct hv_device *device);
 
-int stor_vsc_on_io_request(struct hv_device *device,
+int storvsc_do_io(struct hv_device *device,
 				struct hv_storvsc_request *request);
 void storvsc_cleanup(struct hv_driver *driver);
 
drivers/staging/hv/storvsc_drv.c +1 -1
index 86f2bab..799231c 100644
@@ -117,7 +117,7 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 	stor_driver->base.dev_rm	= storvsc_dev_remove;
 	stor_driver->base.cleanup	= storvsc_cleanup;
 
-	stor_driver->on_io_request	= stor_vsc_on_io_request;
+	stor_driver->on_io_request	= storvsc_do_io;
 
 	return 0;
 }
Signature · 1 line
1.7.4.1
#20 lore raw

PATCH 17/206 Staging: hv: Get rid of the indirection for invoking io request

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -6
index bfec15c..9de7df7a 100644
@@ -195,8 +195,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 	DPRINT_INFO(BLKVSC, "max io outstd %u",
 		    stor_driver->max_outstanding_req_per_channel);
 
-	/* Setup the dispatch table */
-	stor_driver->on_io_request = storvsc_do_io;
 
 	return ret;
 }
@@ -206,9 +204,6 @@ 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_device *device_ctx = blkdev->device_ctx;
-	struct storvsc_driver *storvsc_drv =
-			drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *storvsc_req;
 	struct vmscsi_request *vm_srb;
 	int ret;
@@ -233,7 +228,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 
 	storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
 
-	ret = storvsc_drv->on_io_request(blkdev->device_ctx,
+	ret =  storvsc_do_io(blkdev->device_ctx,
 					   &blkvsc_req->request);
 	if (ret == 0)
 		blkdev->num_outstanding_reqs++;
Signature · 1 line
1.7.4.1
#21 lore raw

Re: [PATCH 017/206] Staging: hv: Get rid of the indirection for invoking io request

drivers/staging/hv/blkvsc_drv.c static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, · line 232

Quoted 3 lines
drivers/staging/hv/blkvsc_drv.c +1 -1
-	ret = storvsc_drv->on_io_request(blkdev->device_ctx,
+	ret =  storvsc_do_io(blkdev->device_ctx,
 					   &blkvsc_req->request);
	ret = storvsc_do_io(blkdev->device_ctx, &blkvsc_req->request);
#22 lore raw

PATCH 18/206 Staging: hv: Statically initialize pointers for probe etc

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/blkvsc_drv.c +5 -5
index 9de7df7a..bca36b5 100644
@@ -841,7 +841,11 @@ static void blkvsc_request(struct request_queue *queue)
 
 
 /* The one and only one */
-static  struct storvsc_driver blkvsc_drv;
+static  struct storvsc_driver blkvsc_drv = {
+	.base.probe =  blkvsc_probe,
+	.base.remove =  blkvsc_remove,
+	.base.shutdown = blkvsc_shutdown,
+};
 
 static const struct block_device_operations block_ops = {
 	.owner = THIS_MODULE,
@@ -867,10 +871,6 @@ static int blkvsc_drv_init(void)
 
 	drv->driver.name = storvsc_drv->base.name;
 
-	drv->probe = blkvsc_probe;
-	drv->remove = blkvsc_remove;
-	drv->shutdown = blkvsc_shutdown;
-
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
 
Signature · 1 line
1.7.4.1
#23 lore raw

PATCH 19/206 Staging: hv: Get rid of the calls to storvsc_cleanup

In reply to K. Y. Srinivasan

The storvsc_cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/blkvsc_drv.c  |    3 ---
 drivers/staging/hv/storvsc.c     |    7 -------
 drivers/staging/hv/storvsc_api.h |    1 -
 drivers/staging/hv/storvsc_drv.c |    1 -
 4 files changed, 0 insertions(+), 12 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -3
index bca36b5..2e69af0 100644
@@ -886,7 +886,6 @@ static int blkvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void blkvsc_drv_exit(void)
 {
-	struct storvsc_driver *storvsc_drv = &blkvsc_drv;
 	struct hv_driver *drv = &blkvsc_drv.base;
 	struct device *current_dev;
 	int ret;
@@ -911,8 +910,6 @@ static void blkvsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	storvsc_cleanup(&storvsc_drv->base);
-
 	vmbus_child_driver_unregister(&drv->driver);
 
 	return;
drivers/staging/hv/storvsc.c +0 -7
index 867eba1..7074520 100644
@@ -660,10 +660,3 @@ int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
 	return -ENODEV;
 }
 
-/*
- * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
- */
-void storvsc_cleanup(struct hv_driver *driver)
-{
-}
-
drivers/staging/hv/storvsc_api.h +0 -1
index f8c724b..84ee5a9 100644
@@ -169,7 +169,6 @@ int storvsc_dev_remove(struct hv_device *device);
 
 int storvsc_do_io(struct hv_device *device,
 				struct hv_storvsc_request *request);
-void storvsc_cleanup(struct hv_driver *driver);
 
 int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
 				struct storvsc_major_info *major_info);
drivers/staging/hv/storvsc_drv.c +0 -1
index 799231c..c54a5fe 100644
@@ -115,7 +115,6 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 	/* Setup the dispatch table */
 	stor_driver->base.dev_add	= storvsc_dev_add;
 	stor_driver->base.dev_rm	= storvsc_dev_remove;
-	stor_driver->base.cleanup	= storvsc_cleanup;
 
 	stor_driver->on_io_request	= storvsc_do_io;
 
Signature · 1 line
1.7.4.1
#24 lore raw

PATCH 20/206 Staging: hv: Rename the function stor_vsc_get_major_info()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/storvsc.c     |    2 +-
 drivers/staging/hv/storvsc_api.h |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index 2e69af0..457d0bb 100644
@@ -958,7 +958,7 @@ static int blkvsc_probe(struct hv_device *dev)
 
 	dev_set_drvdata(&dev->device, blkdev);
 
-	ret = stor_vsc_get_major_info(&device_info, &major_info);
+	ret = storvsc_get_major_info(&device_info, &major_info);
 
 	if (ret)
 		goto cleanup;
drivers/staging/hv/storvsc.c +1 -1
index 7074520..8ee1ad0 100644
@@ -615,7 +615,7 @@ int storvsc_do_io(struct hv_device *device,
  *
  */
 
-int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
 			    struct storvsc_major_info *major_info)
 {
 	static bool ide0_registered;
drivers/staging/hv/storvsc_api.h +1 -1
index 84ee5a9..32228c0 100644
@@ -170,7 +170,7 @@ int storvsc_dev_remove(struct hv_device *device);
 int storvsc_do_io(struct hv_device *device,
 				struct hv_storvsc_request *request);
 
-int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
 				struct storvsc_major_info *major_info);
 
 #endif /* _STORVSC_API_H_ */
Signature · 1 line
1.7.4.1
#25 lore raw

PATCH 21/206 Staging: hv: Introduce a function to wait to drain outgoing I/O

In reply to K. Y. Srinivasan

Rather than busy loop waiting to drain I/O, introduce a function that does not burn CPU cycles waiting.

---
 drivers/staging/hv/storvsc.c     |    6 +++++-
 drivers/staging/hv/storvsc_api.h |   12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc.c +5 -1
index 8ee1ad0..36458b8 100644
@@ -47,6 +47,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 	/* (ie get_stor_device() and must_get_stor_device()) to proceed. */
 	atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
+	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
 	device->ext = stor_device;
 
@@ -332,7 +333,10 @@ static void stor_vsc_on_io_completion(struct hv_device *device,
 
 	request->on_io_completion(request);
 
-	atomic_dec(&stor_device->num_outstanding_req);
+	if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
+		stor_device->drain_notify)
+		wake_up(&stor_device->waiting_to_drain);
+
 
 	put_stor_device(device);
 }
drivers/staging/hv/storvsc_api.h +12 -0
index 32228c0..1887940 100644
@@ -26,6 +26,7 @@
 #define _STORVSC_API_H_
 
 #include <linux/kernel.h>
+#include <linux/wait.h>
 #include "vstorage.h"
 #include "vmbus_api.h"
 #include "vmbus.h"
@@ -108,8 +109,11 @@ struct storvsc_device {
 	/* 0 indicates the device is being destroyed */
 	atomic_t ref_count;
 
+	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
@@ -161,6 +165,14 @@ struct storvsc_driver *drv_to_stordrv(struct device_driver *d)
 	return hvdr_to_stordr(hvdrv);
 }
 
+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,
Signature · 1 line
1.7.4.1
#26 lore raw

PATCH 22/206 Staging: hv: Use the newly introduced I/O drain synch method

In reply to K. Y. Srinivasan

Use the newly introduced I/O drain synch method.

---
 drivers/staging/hv/storvsc.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc.c +2 -5
index 36458b8..8e529d5 100644
@@ -501,11 +501,8 @@ int storvsc_dev_remove(struct hv_device *device)
 	 * only allow inbound traffic (responses) to proceed so that
 	 * outstanding requests can be completed.
 	 */
-	while (atomic_read(&stor_device->num_outstanding_req)) {
-		DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-			    atomic_read(&stor_device->num_outstanding_req));
-		udelay(100);
-	}
+
+	storvsc_wait_to_drain(stor_device);
 
 	DPRINT_INFO(STORVSC, "removing storage device (%p)...",
 		    device->ext);
Signature · 1 line
1.7.4.1
#27 lore raw

PATCH 23/206 Staging: hv: Cleanup blkvsc_remove()

In reply to K. Y. Srinivasan

The function storvsc_dev_remove() already deals with draining of the outstanding I/O. Cleanup blkvsc_remove() keeping this in mind.

---
 drivers/staging/hv/blkvsc_drv.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)
drivers/staging/hv/blkvsc_drv.c +6 -12
index 457d0bb..217676a 100644
@@ -538,11 +538,6 @@ static int blkvsc_remove(struct hv_device *dev)
 	struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
 	unsigned long flags;
 
-	/*
-	 * Call to the vsc driver to let it know that the device is being
-	 * removed
-	 */
-	storvsc_dev_remove(dev);
 
 	/* Get to a known state */
 	spin_lock_irqsave(&blkdev->lock, flags);
@@ -555,17 +550,16 @@ static int blkvsc_remove(struct hv_device *dev)
 
 	spin_unlock_irqrestore(&blkdev->lock, flags);
 
-	while (blkdev->num_outstanding_reqs) {
-		DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-			    blkdev->num_outstanding_reqs);
-		udelay(100);
-	}
-
-
 	blkvsc_do_operation(blkdev, DO_FLUSH);
 
 	blk_cleanup_queue(blkdev->gd->queue);
 
+	/*
+	 * Call to the vsc driver to let it know that the device is being
+	 * removed
+	 */
+	storvsc_dev_remove(dev);
+
 	del_gendisk(blkdev->gd);
 
 	kmem_cache_destroy(blkdev->request_pool);
Signature · 1 line
1.7.4.1
#28 lore raw

PATCH 24/206 Staging: hv: Cleanup blkvsc_shutdown()

In reply to K. Y. Srinivasan

Use the newly introduced function to wait for draining I/Os to cleanup blkvsc_shutdown().

---
 drivers/staging/hv/blkvsc_drv.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/staging/hv/blkvsc_drv.c +5 -7
index 217676a..7fb0cf1 100644
@@ -588,15 +588,13 @@ static void blkvsc_shutdown(struct hv_device *dev)
 
 	spin_unlock_irqrestore(&blkdev->lock, flags);
 
-	while (blkdev->num_outstanding_reqs) {
-		DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-			    blkdev->num_outstanding_reqs);
-		udelay(100);
-	}
-
-
 	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)
Signature · 1 line
1.7.4.1
#29 lore raw

PATCH 25/206 Staging: hv: Rename stor_vsc_channel_init()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc.c +2 -2
index 8e529d5..50ac806 100644
@@ -105,7 +105,7 @@ static inline struct storvsc_device *final_release_stor_device(
 	return stor_device;
 }
 
-static int stor_vsc_channel_init(struct hv_device *device)
+static int storvsc_channel_init(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 	struct hv_storvsc_request *request;
@@ -437,7 +437,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)
 		return -1;
 	}
 
-	ret = stor_vsc_channel_init(device);
+	ret = storvsc_channel_init(device);
 
 	return ret;
 }
Signature · 1 line
1.7.4.1
#30 lore raw

PATCH 26/206 Staging: hv: Rename stor_vsc_on_io_completion

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc.c +2 -2
index 50ac806..ecc62e1 100644
@@ -277,7 +277,7 @@ cleanup:
 	return ret;
 }
 
-static void stor_vsc_on_io_completion(struct hv_device *device,
+static void storvsc_on_io_completion(struct hv_device *device,
 				  struct vstor_packet *vstor_packet,
 				  struct hv_storvsc_request *request)
 {
@@ -348,7 +348,7 @@ static void stor_vsc_on_receive(struct hv_device *device,
 	switch (vstor_packet->operation) {
 	case VSTOR_OPERATION_COMPLETE_IO:
 		DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
-		stor_vsc_on_io_completion(device, vstor_packet, request);
+		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
 	case VSTOR_OPERATION_REMOVE_DEVICE:
 		DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
Signature · 1 line
1.7.4.1
#31 lore raw

PATCH 27/206 Staging: hv: Rename stor_vsc_on_receive

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc.c +2 -2
index ecc62e1..ab9da5c 100644
@@ -341,7 +341,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	put_stor_device(device);
 }
 
-static void stor_vsc_on_receive(struct hv_device *device,
+static void storvsc_on_receive(struct hv_device *device,
 			     struct vstor_packet *vstor_packet,
 			     struct hv_storvsc_request *request)
 {
@@ -399,7 +399,7 @@ static void stor_vsc_on_channel_callback(void *context)
 				       sizeof(struct vstor_packet));
 				complete(&request->wait_event);
 			} else {
-				stor_vsc_on_receive(device,
+				storvsc_on_receive(device,
 						(struct vstor_packet *)packet,
 						request);
 			}
Signature · 1 line
1.7.4.1
#32 lore raw

PATCH 28/206 Staging: hv: Rename stor_vsc_on_channel_callback

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc.c +2 -2
index ab9da5c..b2ffbb7 100644
@@ -362,7 +362,7 @@ static void storvsc_on_receive(struct hv_device *device,
 	}
 }
 
-static void stor_vsc_on_channel_callback(void *context)
+static void storvsc_on_channel_callback(void *context)
 {
 	struct hv_device *device = (struct hv_device *)context;
 	struct storvsc_device *stor_device;
@@ -427,7 +427,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)
 			 stor_driver->ring_buffer_size,
 			 (void *)&props,
 			 sizeof(struct vmstorage_channel_properties),
-			 stor_vsc_on_channel_callback, device);
+			 storvsc_on_channel_callback, device);
 
 	DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d",
 		   props.path_id, props.target_id, props.max_transfer_bytes);
Signature · 1 line
1.7.4.1
#33 lore raw

PATCH 29/206 Staging: hv: Rename stor_vsc_connect_to_vsp

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc.c +2 -2
index b2ffbb7..234ce8b 100644
@@ -412,7 +412,7 @@ static void storvsc_on_channel_callback(void *context)
 	return;
 }
 
-static int stor_vsc_connect_to_vsp(struct hv_device *device)
+static int storvsc_connect_to_vsp(struct hv_device *device)
 {
 	struct vmstorage_channel_properties props;
 	struct storvsc_driver *stor_driver;
@@ -471,7 +471,7 @@ int storvsc_dev_add(struct hv_device *device,
 
 	stor_device->port_number = device_info->port_number;
 	/* Send it back up */
-	ret = stor_vsc_connect_to_vsp(device);
+	ret = storvsc_connect_to_vsp(device);
 
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
Signature · 1 line
1.7.4.1
#34 lore raw

PATCH 30/206 Staging: hv: Get rid of/change some dated comments

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)
drivers/staging/hv/storvsc.c +1 -11
index 234ce8b..5d5aec3 100644
@@ -17,8 +17,8 @@
  * Authors:
  *   Haiyang Zhang <[email protected]>
  *   Hank Janssen  <[email protected]>
+ *   K. Y. Srinivasan <[email protected]>
  *
- * 4/3/2011: K. Y. Srinivasan - Significant restructuring and cleanup.
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -442,10 +442,6 @@ static int storvsc_connect_to_vsp(struct hv_device *device)
 	return ret;
 }
 
-/*
- * stor_vsc_on_device_add - Callback when the device belonging to this driver
- * is added
- */
 int storvsc_dev_add(struct hv_device *device,
 					void *additional_info)
 {
@@ -484,9 +480,6 @@ cleanup:
 	return ret;
 }
 
-/*
- * stor_vsc_on_device_remove - Callback when the our device is being removed
- */
 int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
@@ -518,9 +511,6 @@ int storvsc_dev_remove(struct hv_device *device)
 	return 0;
 }
 
-/*
- * stor_vsc_on_io_request - Callback to initiate an I/O request
- */
 int storvsc_do_io(struct hv_device *device,
 			      struct hv_storvsc_request *request)
 {
Signature · 1 line
1.7.4.1
#35 lore raw

PATCH 31/206 Staging: hv: Get rid of some unnecessary DPRINTS

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc.c |  116 ++++++------------------------------------
 1 files changed, 16 insertions(+), 100 deletions(-)
drivers/staging/hv/storvsc.c +16 -100
index 5d5aec3..41361f5 100644
@@ -113,11 +113,8 @@ static int storvsc_channel_init(struct hv_device *device)
 	int ret, t;
 
 	stor_device = get_stor_device(device);
-	if (!stor_device) {
-		DPRINT_ERR(STORVSC, "unable to get stor device..."
-			   "device being destroyed?");
+	if (!stor_device)
 		return -1;
-	}
 
 	request = &stor_device->init_request;
 	vstor_packet = &request->vstor_packet;
@@ -138,11 +135,8 @@ static int storvsc_channel_init(struct hv_device *device)
 			       (unsigned long)request,
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC,
-			   "unable to send BEGIN_INITIALIZATION_OPERATION");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&request->wait_event, HZ);
 	if (t == 0) {
@@ -151,12 +145,8 @@ static int storvsc_channel_init(struct hv_device *device)
 	}
 
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0) {
-		DPRINT_ERR(STORVSC, "BEGIN_INITIALIZATION_OPERATION failed "
-			   "(op %d status 0x%x)",
-			   vstor_packet->operation, vstor_packet->status);
+	    vstor_packet->status != 0)
 		goto cleanup;
-	}
 
 	DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
 
@@ -173,11 +163,8 @@ static int storvsc_channel_init(struct hv_device *device)
 			       (unsigned long)request,
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC,
-			   "unable to send BEGIN_INITIALIZATION_OPERATION");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&request->wait_event, HZ);
 	if (t == 0) {
@@ -187,12 +174,8 @@ static int storvsc_channel_init(struct hv_device *device)
 
 	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0) {
-		DPRINT_ERR(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION failed "
-			   "(op %d status 0x%x)",
-			   vstor_packet->operation, vstor_packet->status);
+	    vstor_packet->status != 0)
 		goto cleanup;
-	}
 
 	/* Query channel properties */
 	DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
@@ -209,11 +192,8 @@ static int storvsc_channel_init(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC,
-			   "unable to send QUERY_PROPERTIES_OPERATION");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&request->wait_event, HZ);
 	if (t == 0) {
@@ -223,21 +203,13 @@ static int storvsc_channel_init(struct hv_device *device)
 
 	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0) {
-		DPRINT_ERR(STORVSC, "QUERY_PROPERTIES_OPERATION failed "
-			   "(op %d status 0x%x)",
-			   vstor_packet->operation, vstor_packet->status);
+	    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;
 
-	DPRINT_DBG(STORVSC, "channel flag 0x%x, max xfer len 0x%x",
-		   vstor_packet->storage_channel_properties.flags,
-		   vstor_packet->storage_channel_properties.max_transfer_bytes);
-
 	DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
 
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
@@ -250,11 +222,8 @@ static int storvsc_channel_init(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC,
-			   "unable to send END_INITIALIZATION_OPERATION");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&request->wait_event, HZ);
 	if (t == 0) {
@@ -263,12 +232,8 @@ static int storvsc_channel_init(struct hv_device *device)
 	}
 
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-	    vstor_packet->status != 0) {
-		DPRINT_ERR(STORVSC, "END_INITIALIZATION_OPERATION failed "
-			   "(op %d status 0x%x)",
-			   vstor_packet->operation, vstor_packet->status);
+	    vstor_packet->status != 0)
 		goto cleanup;
-	}
 
 	DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
 
@@ -285,15 +250,8 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	struct vstor_packet *stor_pkt;
 
 	stor_device = must_get_stor_device(device);
-	if (!stor_device) {
-		DPRINT_ERR(STORVSC, "unable to get stor device..."
-			   "device being destroyed?");
+	if (!stor_device)
 		return;
-	}
-
-	DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request %p "
-		   "completed bytes xfer %u", request,
-		   vstor_packet->vm_srb.data_transfer_length);
 
 	stor_pkt = &request->vstor_packet;
 
@@ -305,7 +263,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	vstor_packet->vm_srb.sense_info_length;
 
 	if (vstor_packet->vm_srb.scsi_status != 0 ||
-		vstor_packet->vm_srb.srb_status != 1) {
+		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],
@@ -347,7 +305,6 @@ static void storvsc_on_receive(struct hv_device *device,
 {
 	switch (vstor_packet->operation) {
 	case VSTOR_OPERATION_COMPLETE_IO:
-		DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
 		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
 	case VSTOR_OPERATION_REMOVE_DEVICE:
@@ -374,20 +331,14 @@ static void storvsc_on_channel_callback(void *context)
 
 
 	stor_device = must_get_stor_device(device);
-	if (!stor_device) {
-		DPRINT_ERR(STORVSC, "unable to get stor device..."
-			   "device being destroyed?");
+	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) {
-			DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
-				   bytes_recvd, request_id);
-
 
 			request = (struct hv_storvsc_request *)
 					(unsigned long)request_id;
@@ -429,13 +380,8 @@ static int storvsc_connect_to_vsp(struct hv_device *device)
 			 sizeof(struct vmstorage_channel_properties),
 			 storvsc_on_channel_callback, device);
 
-	DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d",
-		   props.path_id, props.target_id, props.max_transfer_bytes);
-
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC, "unable to open channel: %d", ret);
+	if (ret != 0)
 		return -1;
-	}
 
 	ret = storvsc_channel_init(device);
 
@@ -472,10 +418,6 @@ int storvsc_dev_add(struct hv_device *device,
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
 
-	DPRINT_DBG(STORVSC, "assigned port %u, path %u target %u\n",
-		   stor_device->port_number, stor_device->path_id,
-		   stor_device->target_id);
-
 cleanup:
 	return ret;
 }
@@ -497,13 +439,8 @@ int storvsc_dev_remove(struct hv_device *device)
 
 	storvsc_wait_to_drain(stor_device);
 
-	DPRINT_INFO(STORVSC, "removing storage device (%p)...",
-		    device->ext);
-
 	stor_device = final_release_stor_device(device);
 
-	DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", stor_device);
-
 	/* Close the channel */
 	vmbus_close(device->channel);
 
@@ -521,17 +458,8 @@ int storvsc_do_io(struct hv_device *device,
 	vstor_packet = &request->vstor_packet;
 	stor_device = get_stor_device(device);
 
-	DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
-		   , device, stor_device, request);
-
-	DPRINT_DBG(STORVSC, "req %p len %d",
-		   request, request->data_buffer.len);
-
-	if (!stor_device) {
-		DPRINT_ERR(STORVSC, "unable to get stor device..."
-			   "device being destroyed?");
+	if (!stor_device)
 		return -2;
-	}
 
 
 	request->device  = device;
@@ -550,16 +478,6 @@ int storvsc_do_io(struct hv_device *device,
 
 	vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
 
-	DPRINT_DBG(STORVSC, "srb - len %d port %d, path %d, target %d, "
-		   "lun %d senselen %d cdblen %d",
-		   vstor_packet->vm_srb.length,
-		   vstor_packet->vm_srb.port_number,
-		   vstor_packet->vm_srb.path_id,
-		   vstor_packet->vm_srb.target_id,
-		   vstor_packet->vm_srb.lun,
-		   vstor_packet->vm_srb.sense_info_length,
-		   vstor_packet->vm_srb.cdb_length);
-
 	if (request->data_buffer.len) {
 		ret = vmbus_sendpacket_multipagebuffer(device->channel,
 				&request->data_buffer,
@@ -574,10 +492,8 @@ int storvsc_do_io(struct hv_device *device,
 				       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	}
 
-	if (ret != 0) {
-		DPRINT_DBG(STORVSC, "Unable to send packet %p ret %d",
-			   vstor_packet, ret);
-	}
+	if (ret != 0)
+		return ret;
 
 	atomic_inc(&stor_device->num_outstanding_req);
 
Signature · 1 line
1.7.4.1
#36 lore raw

PATCH 32/206 Staging: hv: Rename g_driver_name

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_drv.c +2 -2
index c54a5fe..d19df02 100644
@@ -40,7 +40,7 @@
 #include "channel.h"
 
 
-static const char *g_driver_name = "storvsc";
+static const char *driver_name = "storvsc";
 
 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
 static const struct hv_guid gStorVscDeviceType = {
@@ -91,7 +91,7 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
-	driver->name = g_driver_name;
+	driver->name = driver_name;
 	memcpy(&driver->dev_type, &gStorVscDeviceType,
 	       sizeof(struct hv_guid));
 
Signature · 1 line
1.7.4.1
#37 lore raw

PATCH 33/206 Staging: hv: Rename struct host_device_context

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
drivers/staging/hv/storvsc_drv.c +14 -13
index d19df02..2411f53 100644
@@ -17,6 +17,7 @@
  * Authors:
  *   Haiyang Zhang <[email protected]>
  *   Hank Janssen  <[email protected]>
+ *   K. Y. Srinivasan <[email protected]>
  */
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -50,7 +51,7 @@ static const struct hv_guid gStorVscDeviceType = {
 	}
 };
 
-struct host_device_context {
+struct hv_host_device {
 	/* must be 1st field
 	 * FIXME this is a bug */
 	/* point back to our device context */
@@ -325,14 +326,14 @@ static int storvsc_probe(struct hv_device *device)
 	struct storvsc_driver *storvsc_drv_obj =
 		 drv_to_stordrv(device->device.driver);
 	struct Scsi_Host *host;
-	struct host_device_context *host_device_ctx;
+	struct hv_host_device *host_device_ctx;
 	struct storvsc_device_info device_info;
 
 	if (!storvsc_drv_obj->base.dev_add)
 		return -1;
 
 	host = scsi_host_alloc(&scsi_driver,
-			       sizeof(struct host_device_context));
+			       sizeof(struct hv_host_device));
 	if (!host) {
 		DPRINT_ERR(STORVSC_DRV, "unable to allocate scsi host object");
 		return -ENOMEM;
@@ -340,8 +341,8 @@ static int storvsc_probe(struct hv_device *device)
 
 	dev_set_drvdata(&device->device, host);
 
-	host_device_ctx = (struct host_device_context *)host->hostdata;
-	memset(host_device_ctx, 0, sizeof(struct host_device_context));
+	host_device_ctx = (struct hv_host_device *)host->hostdata;
+	memset(host_device_ctx, 0, sizeof(struct hv_host_device));
 
 	host_device_ctx->port = host->host_no;
 	host_device_ctx->device_ctx = device;
@@ -402,8 +403,8 @@ static int storvsc_remove(struct hv_device *dev)
 	struct storvsc_driver *storvsc_drv_obj =
 			 drv_to_stordrv(dev->device.driver);
 	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
-	struct host_device_context *host_device_ctx =
-			(struct host_device_context *)host->hostdata;
+	struct hv_host_device *host_device_ctx =
+			(struct hv_host_device *)host->hostdata;
 
 	/*
 	 * Call to the vsc driver to let it know that the device is being
@@ -432,8 +433,8 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	struct storvsc_cmd_request *cmd_request =
 		(struct storvsc_cmd_request *)request->context;
 	struct scsi_cmnd *scmnd = cmd_request->cmd;
-	struct host_device_context *host_device_ctx =
-		(struct host_device_context *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_device_ctx =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
 	void (*scsi_done_fn)(struct scsi_cmnd *);
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
@@ -682,8 +683,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				void (*done)(struct scsi_cmnd *))
 {
 	int ret;
-	struct host_device_context *host_device_ctx =
-		(struct host_device_context *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_device_ctx =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
 	struct hv_device *device_ctx = host_device_ctx->device_ctx;
 	struct storvsc_driver *storvsc_drv_obj =
 		drv_to_stordrv(device_ctx->device.driver);
@@ -915,8 +916,8 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
 	int ret;
-	struct host_device_context *host_device_ctx =
-		(struct host_device_context *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_device_ctx =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
 	struct hv_device *device_ctx = host_device_ctx->device_ctx;
 
 	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
Signature · 1 line
1.7.4.1
#38 lore raw

PATCH 34/206 Staging: hv: Rename variables pointing to struct hv_host_device

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   50 +++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 25 deletions(-)
drivers/staging/hv/storvsc_drv.c +25 -25
index 2411f53..2e2e004 100644
@@ -326,7 +326,7 @@ static int storvsc_probe(struct hv_device *device)
 	struct storvsc_driver *storvsc_drv_obj =
 		 drv_to_stordrv(device->device.driver);
 	struct Scsi_Host *host;
-	struct hv_host_device *host_device_ctx;
+	struct hv_host_device *host_dev;
 	struct storvsc_device_info device_info;
 
 	if (!storvsc_drv_obj->base.dev_add)
@@ -341,18 +341,18 @@ static int storvsc_probe(struct hv_device *device)
 
 	dev_set_drvdata(&device->device, host);
 
-	host_device_ctx = (struct hv_host_device *)host->hostdata;
-	memset(host_device_ctx, 0, sizeof(struct hv_host_device));
+	host_dev = (struct hv_host_device *)host->hostdata;
+	memset(host_dev, 0, sizeof(struct hv_host_device));
 
-	host_device_ctx->port = host->host_no;
-	host_device_ctx->device_ctx = device;
+	host_dev->port = host->host_no;
+	host_dev->device_ctx = device;
 
-	host_device_ctx->request_pool =
+	host_dev->request_pool =
 				kmem_cache_create(dev_name(&device->device),
 					sizeof(struct storvsc_cmd_request), 0,
 					SLAB_HWCACHE_ALIGN, NULL);
 
-	if (!host_device_ctx->request_pool) {
+	if (!host_dev->request_pool) {
 		scsi_host_put(host);
 		return -ENOMEM;
 	}
@@ -363,14 +363,14 @@ static int storvsc_probe(struct hv_device *device)
 
 	if (ret != 0) {
 		DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
-		kmem_cache_destroy(host_device_ctx->request_pool);
+		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		return -1;
 	}
 
 	/* host_device_ctx->port = device_info.PortNumber; */
-	host_device_ctx->path = device_info.path_id;
-	host_device_ctx->target = device_info.target_id;
+	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;
@@ -386,7 +386,7 @@ static int storvsc_probe(struct hv_device *device)
 
 		storvsc_drv_obj->base.dev_rm(device);
 
-		kmem_cache_destroy(host_device_ctx->request_pool);
+		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		return -1;
 	}
@@ -403,7 +403,7 @@ static int storvsc_remove(struct hv_device *dev)
 	struct storvsc_driver *storvsc_drv_obj =
 			 drv_to_stordrv(dev->device.driver);
 	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
-	struct hv_host_device *host_device_ctx =
+	struct hv_host_device *host_dev =
 			(struct hv_host_device *)host->hostdata;
 
 	/*
@@ -412,9 +412,9 @@ static int storvsc_remove(struct hv_device *dev)
 	 */
 	storvsc_drv_obj->base.dev_rm(dev);
 
-	if (host_device_ctx->request_pool) {
-		kmem_cache_destroy(host_device_ctx->request_pool);
-		host_device_ctx->request_pool = NULL;
+	if (host_dev->request_pool) {
+		kmem_cache_destroy(host_dev->request_pool);
+		host_dev->request_pool = NULL;
 	}
 
 	DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
@@ -433,7 +433,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	struct storvsc_cmd_request *cmd_request =
 		(struct storvsc_cmd_request *)request->context;
 	struct scsi_cmnd *scmnd = cmd_request->cmd;
-	struct hv_host_device *host_device_ctx =
+	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
 	void (*scsi_done_fn)(struct scsi_cmnd *);
 	struct scsi_sense_hdr sense_hdr;
@@ -479,7 +479,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	/* !!DO NOT MODIFY the scmnd after this call */
 	scsi_done_fn(scmnd);
 
-	kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+	kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
 static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
@@ -683,9 +683,9 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				void (*done)(struct scsi_cmnd *))
 {
 	int ret;
-	struct hv_host_device *host_device_ctx =
+	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_device_ctx->device_ctx;
+	struct hv_device *device_ctx = host_dev->device_ctx;
 	struct storvsc_driver *storvsc_drv_obj =
 		drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *request;
@@ -721,7 +721,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 	request_size = sizeof(struct storvsc_cmd_request);
 
-	cmd_request = kmem_cache_zalloc(host_device_ctx->request_pool,
+	cmd_request = kmem_cache_zalloc(host_dev->request_pool,
 				       GFP_ATOMIC);
 	if (!cmd_request) {
 		DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
@@ -759,7 +759,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	request->context = cmd_request;/* scmnd; */
 
 	/* request->PortId = scmnd->device->channel; */
-	vm_srb->port_number = host_device_ctx->port;
+	vm_srb->port_number = host_dev->port;
 	vm_srb->path_id = scmnd->device->channel;
 	vm_srb->target_id = scmnd->device->id;
 	vm_srb->lun = scmnd->device->lun;
@@ -792,7 +792,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 				scmnd->scsi_done = NULL;
 				scmnd->host_scribble = NULL;
-				kmem_cache_free(host_device_ctx->request_pool,
+				kmem_cache_free(host_dev->request_pool,
 						cmd_request);
 
 				return SCSI_MLQUEUE_HOST_BUSY;
@@ -851,7 +851,7 @@ retry_request:
 					      cmd_request->bounce_sgl_count);
 		}
 
-		kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+		kmem_cache_free(host_dev->request_pool, cmd_request);
 
 		scmnd->scsi_done = NULL;
 		scmnd->host_scribble = NULL;
@@ -916,9 +916,9 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
 	int ret;
-	struct hv_host_device *host_device_ctx =
+	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_device_ctx->device_ctx;
+	struct hv_device *device_ctx = host_dev->device_ctx;
 
 	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
 		    scmnd->device, device_ctx);
Signature · 1 line
1.7.4.1
#39 lore raw

PATCH 35/206 Staging: hv: Rename the struct hv_device * element of struct hv_host_device

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/storvsc_drv.c +4 -4
index 2e2e004..c183220 100644
@@ -55,7 +55,7 @@ struct hv_host_device {
 	/* must be 1st field
 	 * FIXME this is a bug */
 	/* point back to our device context */
-	struct hv_device *device_ctx;
+	struct hv_device *dev;
 	struct kmem_cache *request_pool;
 	unsigned int port;
 	unsigned char path;
@@ -345,7 +345,7 @@ static int storvsc_probe(struct hv_device *device)
 	memset(host_dev, 0, sizeof(struct hv_host_device));
 
 	host_dev->port = host->host_no;
-	host_dev->device_ctx = device;
+	host_dev->dev = device;
 
 	host_dev->request_pool =
 				kmem_cache_create(dev_name(&device->device),
@@ -685,7 +685,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	int ret;
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_dev->device_ctx;
+	struct hv_device *device_ctx = host_dev->dev;
 	struct storvsc_driver *storvsc_drv_obj =
 		drv_to_stordrv(device_ctx->device.driver);
 	struct hv_storvsc_request *request;
@@ -918,7 +918,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 	int ret;
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_dev->device_ctx;
+	struct hv_device *device_ctx = host_dev->dev;
 
 	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
 		    scmnd->device, device_ctx);
Signature · 1 line
1.7.4.1
#40 lore raw

PATCH 36/206 Staging: hv: Rename variables pointing to struct hv_device

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
drivers/staging/hv/storvsc_drv.c +7 -8
index c183220..c654172 100644
@@ -368,7 +368,6 @@ static int storvsc_probe(struct hv_device *device)
 		return -1;
 	}
 
-	/* host_device_ctx->port = device_info.PortNumber; */
 	host_dev->path = device_info.path_id;
 	host_dev->target = device_info.target_id;
 
@@ -685,9 +684,9 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	int ret;
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_dev->dev;
+	struct hv_device *dev = host_dev->dev;
 	struct storvsc_driver *storvsc_drv_obj =
-		drv_to_stordrv(device_ctx->device.driver);
+		drv_to_stordrv(dev->device.driver);
 	struct hv_storvsc_request *request;
 	struct storvsc_cmd_request *cmd_request;
 	unsigned int request_size = 0;
@@ -831,7 +830,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 retry_request:
 	/* Invokes the vsc to start an IO */
-	ret = storvsc_drv_obj->on_io_request(device_ctx,
+	ret = storvsc_drv_obj->on_io_request(dev,
 					   &cmd_request->request);
 	if (ret == -1) {
 		/* no more space */
@@ -918,18 +917,18 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 	int ret;
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *device_ctx = host_dev->dev;
+	struct hv_device *dev = host_dev->dev;
 
 	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
-		    scmnd->device, device_ctx);
+		    scmnd->device, dev);
 
 	/* Invokes the vsc to reset the host/bus */
-	ret = stor_vsc_on_host_reset(device_ctx);
+	ret = stor_vsc_on_host_reset(dev);
 	if (ret != 0)
 		return ret;
 
 	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
-		    scmnd->device, device_ctx);
+		    scmnd->device, dev);
 
 	return ret;
 }
Signature · 1 line
1.7.4.1
#41 lore raw

PATCH 37/206 Staging: hv: Get rid of some dated comments

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -3
index c654172..2f252ea 100644
@@ -52,9 +52,6 @@ static const struct hv_guid gStorVscDeviceType = {
 };
 
 struct hv_host_device {
-	/* must be 1st field
-	 * FIXME this is a bug */
-	/* point back to our device context */
 	struct hv_device *dev;
 	struct kmem_cache *request_pool;
 	unsigned int port;
Signature · 1 line
1.7.4.1
#42 lore raw

PATCH 38/206 Staging: hv: Get rid of some DPRINTS

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   65 +++----------------------------------
 1 files changed, 6 insertions(+), 59 deletions(-)
drivers/staging/hv/storvsc_drv.c +6 -59
index 2f252ea..52d8974 100644
@@ -79,13 +79,6 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 
 	stor_driver = hvdr_to_stordr(driver);
 
-	DPRINT_DBG(STORVSC,
-		   "sizeof(struct hv_storvsc_request)=%zd "
-		   "sizeof(struct vstor_packet)=%zd, "
-		   "sizeof(struct vmscsi_request)=%zd",
-		   sizeof(struct hv_storvsc_request),
-		   sizeof(struct vstor_packet),
-		   sizeof(struct vmscsi_request));
 
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
@@ -199,14 +192,8 @@ static int storvsc_drv_init(void)
 		    storvsc_drv_obj->max_outstanding_req_per_channel);
 
 	if (storvsc_drv_obj->max_outstanding_req_per_channel <
-	    STORVSC_MAX_IO_REQUESTS) {
-		DPRINT_ERR(STORVSC_DRV,
-			   "The number of outstanding io requests (%d) "
-			   "is larger than that supported (%d) internally.",
-			   STORVSC_MAX_IO_REQUESTS,
-			   storvsc_drv_obj->max_outstanding_req_per_channel);
+	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
-	}
 
 	drv->driver.name = storvsc_drv_obj->base.name;
 
@@ -230,11 +217,8 @@ static int stor_vsc_on_host_reset(struct hv_device *device)
 	DPRINT_INFO(STORVSC, "resetting host adapter...");
 
 	stor_device = get_stor_device(device);
-	if (!stor_device) {
-		DPRINT_ERR(STORVSC, "unable to get stor device..."
-			   "device being destroyed?");
+	if (!stor_device)
 		return -1;
-	}
 
 	request = &stor_device->reset_request;
 	vstor_packet = &request->vstor_packet;
@@ -250,11 +234,8 @@ static int stor_vsc_on_host_reset(struct hv_device *device)
 			       (unsigned long)&stor_device->reset_request,
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0) {
-		DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
-			   vstor_packet, ret);
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&request->wait_event, HZ);
 	if (t == 0) {
@@ -296,9 +277,6 @@ static void storvsc_drv_exit(void)
 					     (void *) &current_dev,
 					     storvsc_drv_exit_cb);
 
-		if (ret)
-			DPRINT_WARN(STORVSC_DRV,
-				    "driver_for_each_device returned %d", ret);
 
 		if (current_dev == NULL)
 			break;
@@ -331,10 +309,8 @@ static int storvsc_probe(struct hv_device *device)
 
 	host = scsi_host_alloc(&scsi_driver,
 			       sizeof(struct hv_host_device));
-	if (!host) {
-		DPRINT_ERR(STORVSC_DRV, "unable to allocate scsi host object");
+	if (!host)
 		return -ENOMEM;
-	}
 
 	dev_set_drvdata(&device->device, host);
 
@@ -359,7 +335,6 @@ static int storvsc_probe(struct hv_device *device)
 	ret = storvsc_drv_obj->base.dev_add(device, (void *)&device_info);
 
 	if (ret != 0) {
-		DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		return -1;
@@ -378,7 +353,6 @@ 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) {
-		DPRINT_ERR(STORVSC_DRV, "unable to add scsi host device");
 
 		storvsc_drv_obj->base.dev_rm(device);
 
@@ -692,11 +666,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	unsigned int sg_count = 0;
 	struct vmscsi_request *vm_srb;
 
-	DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d "
-		   "queue depth %d tagged %d", scmnd, scmnd->sc_data_direction,
-		   scsi_sg_count(scmnd), scsi_sglist(scmnd),
-		   scsi_bufflen(scmnd), scmnd->device->queue_depth,
-		   scmnd->device->tagged_supported);
 
 	/* If retrying, no need to prep the cmd */
 	if (scmnd->host_scribble) {
@@ -720,8 +689,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	cmd_request = kmem_cache_zalloc(host_dev->request_pool,
 				       GFP_ATOMIC);
 	if (!cmd_request) {
-		DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
-			   "storvsc_cmd_request...marking queue busy", scmnd);
 		scmnd->scsi_done = NULL;
 		return SCSI_MLQUEUE_DEVICE_BUSY;
 	}
@@ -736,7 +703,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	request = &cmd_request->request;
 	vm_srb = &request->vstor_packet.vm_srb;
 
-	DPRINT_DBG(STORVSC_DRV, "req %p size %d", request, request_size);
 
 	/* Build the SRB */
 	switch (scmnd->sc_data_direction) {
@@ -775,17 +741,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 		/* check if we need to bounce the sgl */
 		if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
-			DPRINT_INFO(STORVSC_DRV,
-				    "need to bounce buffer for this scmnd %p",
-				    scmnd);
 			cmd_request->bounce_sgl =
 				create_bounce_buffer(sgl, scsi_sg_count(scmnd),
 						     scsi_bufflen(scmnd));
 			if (!cmd_request->bounce_sgl) {
-				DPRINT_ERR(STORVSC_DRV,
-					   "unable to create bounce buffer for "
-					   "this scmnd %p", scmnd);
-
 				scmnd->scsi_done = NULL;
 				scmnd->host_scribble = NULL;
 				kmem_cache_free(host_dev->request_pool,
@@ -811,12 +770,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 		request->data_buffer.offset = sgl[0].offset;
 
-		for (i = 0; i < sg_count; i++) {
-			DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n",
-				   i, sgl[i].length, sgl[i].offset);
+		for (i = 0; i < sg_count; i++)
 			request->data_buffer.pfn_array[i] =
 				page_to_pfn(sg_page((&sgl[i])));
-		}
+
 	} else if (scsi_sglist(scmnd)) {
 		/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
 		request->data_buffer.offset =
@@ -831,9 +788,6 @@ retry_request:
 					   &cmd_request->request);
 	if (ret == -1) {
 		/* no more space */
-		DPRINT_ERR(STORVSC_DRV,
-			   "scmnd (%p) - queue FULL...marking queue busy",
-			   scmnd);
 
 		if (cmd_request->bounce_sgl_count) {
 			/*
@@ -872,8 +826,6 @@ static int storvsc_merge_bvec(struct request_queue *q,
  */
 static int storvsc_device_alloc(struct scsi_device *sdevice)
 {
-	DPRINT_DBG(STORVSC_DRV, "sdev (%p) - setting device flag to %d",
-		   sdevice, BLIST_SPARSELUN);
 	/*
 	 * This enables luns to be located sparsely. Otherwise, we may not
 	 * discovered them.
@@ -884,11 +836,6 @@ static int storvsc_device_alloc(struct scsi_device *sdevice)
 
 static int storvsc_device_configure(struct scsi_device *sdevice)
 {
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - curr queue depth %d", sdevice,
-		    sdevice->queue_depth);
-
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting queue depth to %d",
-		    sdevice, STORVSC_MAX_IO_REQUESTS);
 	scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
 				STORVSC_MAX_IO_REQUESTS);
 
Signature · 1 line
1.7.4.1
#43 lore raw

PATCH 39/206 Staging: hv: Get rid of the forward declaration for storvsc_device_alloc()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)
drivers/staging/hv/storvsc_drv.c +10 -14
index 52d8974..2bd9c09 100644
@@ -112,10 +112,19 @@ static int stor_vsc_initialize(struct hv_driver *driver)
 	return 0;
 }
 
+static int storvsc_device_alloc(struct scsi_device *sdevice)
+{
+	/*
+	 * This enables luns to be located sparsely. Otherwise, we may not
+	 * discovered them.
+	 */
+	sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
+	return 0;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
-static int storvsc_device_alloc(struct scsi_device *);
 static int storvsc_device_configure(struct scsi_device *);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 static int storvsc_remove(struct hv_device *dev);
@@ -821,19 +830,6 @@ static int storvsc_merge_bvec(struct request_queue *q,
 	return bvec->bv_len;
 }
 
-/*
- * storvsc_device_configure - Configure the specified scsi device
- */
-static int storvsc_device_alloc(struct scsi_device *sdevice)
-{
-	/*
-	 * This enables luns to be located sparsely. Otherwise, we may not
-	 * discovered them.
-	 */
-	sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
-	return 0;
-}
-
 static int storvsc_device_configure(struct scsi_device *sdevice)
 {
 	scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
Signature · 1 line
1.7.4.1
#44 lore raw

PATCH 40/206 Staging: hv: Move the function storvsc_merge_bvec() to earlier in the file

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/hv/storvsc_drv.c +7 -7
index 2bd9c09..44dbaae 100644
@@ -122,6 +122,13 @@ static int storvsc_device_alloc(struct scsi_device *sdevice)
 	return 0;
 }
 
+static int storvsc_merge_bvec(struct request_queue *q,
+			      struct bvec_merge_data *bmd, struct bio_vec *bvec)
+{
+	/* checking done by caller. */
+	return bvec->bv_len;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
@@ -823,13 +830,6 @@ retry_request:
 
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
-static int storvsc_merge_bvec(struct request_queue *q,
-			      struct bvec_merge_data *bmd, struct bio_vec *bvec)
-{
-	/* checking done by caller. */
-	return bvec->bv_len;
-}
-
 static int storvsc_device_configure(struct scsi_device *sdevice)
 {
 	scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
Signature · 1 line
1.7.4.1
#45 lore raw

PATCH 41/206 Staging: hv: Get rid of the forward declaration for storvsc_device_configure()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   39 ++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 20 deletions(-)
drivers/staging/hv/storvsc_drv.c +19 -20
index 44dbaae..4196d6a 100644
@@ -129,10 +129,28 @@ static int storvsc_merge_bvec(struct request_queue *q,
 	return bvec->bv_len;
 }
 
+static int storvsc_device_configure(struct scsi_device *sdevice)
+{
+	scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
+				STORVSC_MAX_IO_REQUESTS);
+
+	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
+		    sdevice, PAGE_SIZE);
+	blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
+
+	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
+		    sdevice);
+	blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
+
+	blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
+	/* sdevice->timeout = (2000 * HZ);//(75 * HZ); */
+
+	return 0;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
-static int storvsc_device_configure(struct scsi_device *);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 static int storvsc_remove(struct hv_device *dev);
 
@@ -830,25 +848,6 @@ retry_request:
 
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
-static int storvsc_device_configure(struct scsi_device *sdevice)
-{
-	scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
-				STORVSC_MAX_IO_REQUESTS);
-
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
-		    sdevice, PAGE_SIZE);
-	blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
-
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
-		    sdevice);
-	blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
-
-	blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
-	/* sdevice->timeout = (2000 * HZ);//(75 * HZ); */
-
-	return 0;
-}
-
 /*
  * storvsc_host_reset_handler - Reset the scsi HBA
  */
Signature · 1 line
1.7.4.1
#46 lore raw

PATCH 42/206 Staging: hv: Get rid of the forwrd declaration of destroy_bounce_buffer

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)
drivers/staging/hv/storvsc_drv.c +15 -17
index 4196d6a..bf5b138 100644
@@ -148,6 +148,21 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 	return 0;
 }
 
+static void destroy_bounce_buffer(struct scatterlist *sgl,
+				  unsigned int sg_count)
+{
+	int i;
+	struct page *page_buf;
+
+	for (i = 0; i < sg_count; i++) {
+		page_buf = sg_page((&sgl[i]));
+		if (page_buf != NULL)
+			__free_page(page_buf);
+	}
+
+	kfree(sgl);
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
@@ -157,8 +172,6 @@ static int storvsc_remove(struct hv_device *dev);
 static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
 						unsigned int sg_count,
 						unsigned int len);
-static void destroy_bounce_buffer(struct scatterlist *sgl,
-				  unsigned int sg_count);
 static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
 static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
 					    struct scatterlist *bounce_sgl,
@@ -542,21 +555,6 @@ cleanup:
 	return NULL;
 }
 
-static void destroy_bounce_buffer(struct scatterlist *sgl,
-				  unsigned int sg_count)
-{
-	int i;
-	struct page *page_buf;
-
-	for (i = 0; i < sg_count; i++) {
-		page_buf = sg_page((&sgl[i]));
-		if (page_buf != NULL)
-			__free_page(page_buf);
-	}
-
-	kfree(sgl);
-}
-
 /* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
 static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 					  struct scatterlist *bounce_sgl,
Signature · 1 line
1.7.4.1
#47 lore raw

PATCH 43/206 Staging: hv: Get rid of the forward declaration for do_bounce_buffer()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   55 ++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 28 deletions(-)
drivers/staging/hv/storvsc_drv.c +27 -28
index bf5b138..9380866 100644
@@ -163,6 +163,33 @@ static void destroy_bounce_buffer(struct scatterlist *sgl,
 	kfree(sgl);
 }
 
+static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
+{
+	int i;
+
+	/* No need to check */
+	if (sg_count < 2)
+		return -1;
+
+	/* We have at least 2 sg entries */
+	for (i = 0; i < sg_count; i++) {
+		if (i == 0) {
+			/* make sure 1st one does not have hole */
+			if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
+				return i;
+		} else if (i == sg_count - 1) {
+			/* make sure last one does not have hole */
+			if (sgl[i].offset != 0)
+				return i;
+		} else {
+			/* make sure no hole in the middle */
+			if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
+				return i;
+		}
+	}
+	return -1;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
@@ -172,7 +199,6 @@ static int storvsc_remove(struct hv_device *dev);
 static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
 						unsigned int sg_count,
 						unsigned int len);
-static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
 static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
 					    struct scatterlist *bounce_sgl,
 					    unsigned int orig_sgl_count);
@@ -499,33 +525,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
-static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
-{
-	int i;
-
-	/* No need to check */
-	if (sg_count < 2)
-		return -1;
-
-	/* We have at least 2 sg entries */
-	for (i = 0; i < sg_count; i++) {
-		if (i == 0) {
-			/* make sure 1st one does not have hole */
-			if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
-				return i;
-		} else if (i == sg_count - 1) {
-			/* make sure last one does not have hole */
-			if (sgl[i].offset != 0)
-				return i;
-		} else {
-			/* make sure no hole in the middle */
-			if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
-				return i;
-		}
-	}
-	return -1;
-}
-
 static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
 						unsigned int sg_count,
 						unsigned int len)
Signature · 1 line
1.7.4.1
#48 lore raw

PATCH 44/206 Staging: hv: Get rid of the forward declaration for create_bounce_buffer()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   61 ++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 32 deletions(-)
drivers/staging/hv/storvsc_drv.c +29 -32
index 9380866..551c48c 100644
@@ -190,15 +190,41 @@ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
 	return -1;
 }
 
+static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
+						unsigned int sg_count,
+						unsigned int len)
+{
+	int i;
+	int num_pages;
+	struct scatterlist *bounce_sgl;
+	struct page *page_buf;
+
+	num_pages = ALIGN(len, PAGE_SIZE) >> PAGE_SHIFT;
+
+	bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
+	if (!bounce_sgl)
+		return NULL;
+
+	for (i = 0; i < num_pages; i++) {
+		page_buf = alloc_page(GFP_ATOMIC);
+		if (!page_buf)
+			goto cleanup;
+		sg_set_page(&bounce_sgl[i], page_buf, 0, 0);
+	}
+
+	return bounce_sgl;
+
+cleanup:
+	destroy_bounce_buffer(bounce_sgl, num_pages);
+	return NULL;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 static int storvsc_remove(struct hv_device *dev);
 
-static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
-						unsigned int sg_count,
-						unsigned int len);
 static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
 					    struct scatterlist *bounce_sgl,
 					    unsigned int orig_sgl_count);
@@ -525,35 +551,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
-static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
-						unsigned int sg_count,
-						unsigned int len)
-{
-	int i;
-	int num_pages;
-	struct scatterlist *bounce_sgl;
-	struct page *page_buf;
-
-	num_pages = ALIGN(len, PAGE_SIZE) >> PAGE_SHIFT;
-
-	bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
-	if (!bounce_sgl)
-		return NULL;
-
-	for (i = 0; i < num_pages; i++) {
-		page_buf = alloc_page(GFP_ATOMIC);
-		if (!page_buf)
-			goto cleanup;
-		sg_set_page(&bounce_sgl[i], page_buf, 0, 0);
-	}
-
-	return bounce_sgl;
-
-cleanup:
-	destroy_bounce_buffer(bounce_sgl, num_pages);
-	return NULL;
-}
-
 /* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
 static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 					  struct scatterlist *bounce_sgl,
Signature · 1 line
1.7.4.1
#49 lore raw

PATCH 45/206 Staging: hv: Get rid of the forward declaration of copy_from_bounce_buffer()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |  129 +++++++++++++++++++-------------------
 1 files changed, 65 insertions(+), 64 deletions(-)
drivers/staging/hv/storvsc_drv.c +65 -64
index 551c48c..4e3e9ca 100644
@@ -219,15 +219,77 @@ cleanup:
 	return NULL;
 }
 
+
+/* Assume the original sgl has enough room */
+static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
+					    struct scatterlist *bounce_sgl,
+					    unsigned int orig_sgl_count)
+{
+	int i;
+	int j = 0;
+	unsigned long src, dest;
+	unsigned int srclen, destlen, copylen;
+	unsigned int total_copied = 0;
+	unsigned long bounce_addr = 0;
+	unsigned long dest_addr = 0;
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	for (i = 0; i < orig_sgl_count; i++) {
+		dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
+					KM_IRQ0) + orig_sgl[i].offset;
+		dest = dest_addr;
+		destlen = orig_sgl[i].length;
+
+		if (bounce_addr == 0)
+			bounce_addr =
+			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
+							KM_IRQ0);
+
+		while (destlen) {
+			src = bounce_addr + bounce_sgl[j].offset;
+			srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
+
+			copylen = min(srclen, destlen);
+			memcpy((void *)dest, (void *)src, copylen);
+
+			total_copied += copylen;
+			bounce_sgl[j].offset += copylen;
+			destlen -= copylen;
+			dest += copylen;
+
+			if (bounce_sgl[j].offset == bounce_sgl[j].length) {
+				/* full */
+				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+				j++;
+
+				/* if we need to use another bounce buffer */
+				if (destlen || i != orig_sgl_count - 1)
+					bounce_addr =
+					(unsigned long)kmap_atomic(
+					sg_page((&bounce_sgl[j])), KM_IRQ0);
+			} else if (destlen == 0 && i == orig_sgl_count - 1) {
+				/* unmap the last bounce that is < PAGE_SIZE */
+				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+			}
+		}
+
+		kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
+			      KM_IRQ0);
+	}
+
+	local_irq_restore(flags);
+
+	return total_copied;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 static int storvsc_remove(struct hv_device *dev);
 
-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
-					    struct scatterlist *bounce_sgl,
-					    unsigned int orig_sgl_count);
 static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 					  struct scatterlist *bounce_sgl,
 					  unsigned int orig_sgl_count);
@@ -613,67 +675,6 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 	return total_copied;
 }
 
-/* Assume the original sgl has enough room */
-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
-					    struct scatterlist *bounce_sgl,
-					    unsigned int orig_sgl_count)
-{
-	int i;
-	int j = 0;
-	unsigned long src, dest;
-	unsigned int srclen, destlen, copylen;
-	unsigned int total_copied = 0;
-	unsigned long bounce_addr = 0;
-	unsigned long dest_addr = 0;
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	for (i = 0; i < orig_sgl_count; i++) {
-		dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
-					KM_IRQ0) + orig_sgl[i].offset;
-		dest = dest_addr;
-		destlen = orig_sgl[i].length;
-		/* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
-
-		if (bounce_addr == 0)
-			bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-
-		while (destlen) {
-			src = bounce_addr + bounce_sgl[j].offset;
-			srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
-
-			copylen = min(srclen, destlen);
-			memcpy((void *)dest, (void *)src, copylen);
-
-			total_copied += copylen;
-			bounce_sgl[j].offset += copylen;
-			destlen -= copylen;
-			dest += copylen;
-
-			if (bounce_sgl[j].offset == bounce_sgl[j].length) {
-				/* full */
-				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-				j++;
-
-				/* if we need to use another bounce buffer */
-				if (destlen || i != orig_sgl_count - 1)
-					bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-			} else if (destlen == 0 && i == orig_sgl_count - 1) {
-				/* unmap the last bounce that is < PAGE_SIZE */
-				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-			}
-		}
-
-		kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
-			      KM_IRQ0);
-	}
-
-	local_irq_restore(flags);
-
-	return total_copied;
-}
-
 /*
  * storvsc_queuecommand - Initiate command processing
  */
Signature · 1 line
1.7.4.1
#50 lore raw

PATCH 46/206 Staging: hv: Get rid of the forward declaration for copy_to_bounce_buffer()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |  132 +++++++++++++++++++-------------------
 1 files changed, 66 insertions(+), 66 deletions(-)
drivers/staging/hv/storvsc_drv.c +66 -66
index 4e3e9ca..807ba89 100644
@@ -284,16 +284,78 @@ static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
 	return total_copied;
 }
 
+
+/* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
+static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
+					  struct scatterlist *bounce_sgl,
+					  unsigned int orig_sgl_count)
+{
+	int i;
+	int j = 0;
+	unsigned long src, dest;
+	unsigned int srclen, destlen, copylen;
+	unsigned int total_copied = 0;
+	unsigned long bounce_addr = 0;
+	unsigned long src_addr = 0;
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	for (i = 0; i < orig_sgl_count; i++) {
+		src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
+				KM_IRQ0) + orig_sgl[i].offset;
+		src = src_addr;
+		srclen = orig_sgl[i].length;
+
+		if (bounce_addr == 0)
+			bounce_addr =
+			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
+						KM_IRQ0);
+
+		while (srclen) {
+			/* assume bounce offset always == 0 */
+			dest = bounce_addr + bounce_sgl[j].length;
+			destlen = PAGE_SIZE - bounce_sgl[j].length;
+
+			copylen = min(srclen, destlen);
+			memcpy((void *)dest, (void *)src, copylen);
+
+			total_copied += copylen;
+			bounce_sgl[j].length += copylen;
+			srclen -= copylen;
+			src += copylen;
+
+			if (bounce_sgl[j].length == PAGE_SIZE) {
+				/* full..move to next entry */
+				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+				j++;
+
+				/* if we need to use another bounce buffer */
+				if (srclen || i != orig_sgl_count - 1)
+					bounce_addr =
+					(unsigned long)kmap_atomic(
+					sg_page((&bounce_sgl[j])), KM_IRQ0);
+
+			} else if (srclen == 0 && i == orig_sgl_count - 1) {
+				/* unmap the last bounce that is < PAGE_SIZE */
+				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+			}
+		}
+
+		kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
+	}
+
+	local_irq_restore(flags);
+
+	return total_copied;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 static int storvsc_remove(struct hv_device *dev);
 
-static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
-					  struct scatterlist *bounce_sgl,
-					  unsigned int orig_sgl_count);
-
 static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
 			   sector_t capacity, int *info);
 
@@ -613,68 +675,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
-/* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
-static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
-					  struct scatterlist *bounce_sgl,
-					  unsigned int orig_sgl_count)
-{
-	int i;
-	int j = 0;
-	unsigned long src, dest;
-	unsigned int srclen, destlen, copylen;
-	unsigned int total_copied = 0;
-	unsigned long bounce_addr = 0;
-	unsigned long src_addr = 0;
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	for (i = 0; i < orig_sgl_count; i++) {
-		src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
-				KM_IRQ0) + orig_sgl[i].offset;
-		src = src_addr;
-		srclen = orig_sgl[i].length;
-
-		/* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
-
-		if (bounce_addr == 0)
-			bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-
-		while (srclen) {
-			/* assume bounce offset always == 0 */
-			dest = bounce_addr + bounce_sgl[j].length;
-			destlen = PAGE_SIZE - bounce_sgl[j].length;
-
-			copylen = min(srclen, destlen);
-			memcpy((void *)dest, (void *)src, copylen);
-
-			total_copied += copylen;
-			bounce_sgl[j].length += copylen;
-			srclen -= copylen;
-			src += copylen;
-
-			if (bounce_sgl[j].length == PAGE_SIZE) {
-				/* full..move to next entry */
-				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-				j++;
-
-				/* if we need to use another bounce buffer */
-				if (srclen || i != orig_sgl_count - 1)
-					bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-			} else if (srclen == 0 && i == orig_sgl_count - 1) {
-				/* unmap the last bounce that is < PAGE_SIZE */
-				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-			}
-		}
-
-		kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
-	}
-
-	local_irq_restore(flags);
-
-	return total_copied;
-}
-
 /*
  * storvsc_queuecommand - Initiate command processing
  */
Signature · 1 line
1.7.4.1
#51 lore raw

PATCH 47/206 Staging: hv: Get rid of the forward declaration of storvsc_remove()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   62 +++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 31 deletions(-)
drivers/staging/hv/storvsc_drv.c +31 -31
index 807ba89..6f23f52 100644
@@ -350,11 +350,41 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 	return total_copied;
 }
 
+
+/*
+ * storvsc_remove - Callback when our device is removed
+ */
+static int storvsc_remove(struct hv_device *dev)
+{
+	struct storvsc_driver *storvsc_drv_obj =
+			 drv_to_stordrv(dev->device.driver);
+	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
+	struct hv_host_device *host_dev =
+			(struct hv_host_device *)host->hostdata;
+
+	/*
+	 * Call to the vsc driver to let it know that the device is being
+	 * removed
+	 */
+	storvsc_drv_obj->base.dev_rm(dev);
+
+	if (host_dev->request_pool) {
+		kmem_cache_destroy(host_dev->request_pool);
+		host_dev->request_pool = NULL;
+	}
+
+	DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
+	scsi_remove_host(host);
+
+	DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
+	scsi_host_put(host);
+	return 0;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
-static int storvsc_remove(struct hv_device *dev);
 
 static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
 			   sector_t capacity, int *info);
@@ -589,36 +619,6 @@ static int storvsc_probe(struct hv_device *device)
 }
 
 /*
- * storvsc_remove - Callback when our device is removed
- */
-static int storvsc_remove(struct hv_device *dev)
-{
-	struct storvsc_driver *storvsc_drv_obj =
-			 drv_to_stordrv(dev->device.driver);
-	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
-	struct hv_host_device *host_dev =
-			(struct hv_host_device *)host->hostdata;
-
-	/*
-	 * Call to the vsc driver to let it know that the device is being
-	 * removed
-	 */
-	storvsc_drv_obj->base.dev_rm(dev);
-
-	if (host_dev->request_pool) {
-		kmem_cache_destroy(host_dev->request_pool);
-		host_dev->request_pool = NULL;
-	}
-
-	DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
-	scsi_remove_host(host);
-
-	DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
-	scsi_host_put(host);
-	return 0;
-}
-
-/*
  * storvsc_commmand_completion - Command completion processing
  */
 static void storvsc_commmand_completion(struct hv_storvsc_request *request)
Signature · 1 line
1.7.4.1
#52 lore raw

PATCH 48/206 Staging: hv: Get rid of the forward declaration of storvsc_get_chs()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |  164 ++++++++++++++++++-------------------
 1 files changed, 80 insertions(+), 84 deletions(-)
drivers/staging/hv/storvsc_drv.c +80 -84
index 6f23f52..4c08328 100644
@@ -381,15 +381,91 @@ static int storvsc_remove(struct hv_device *dev)
 	return 0;
 }
 
+
+static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
+			   sector_t capacity, int *info)
+{
+	sector_t total_sectors = capacity;
+	sector_t cylinder_times_heads = 0;
+	sector_t temp = 0;
+
+	int sectors_per_track = 0;
+	int heads = 0;
+	int cylinders = 0;
+	int rem = 0;
+
+	if (total_sectors > (65535 * 16 * 255))
+		total_sectors = (65535 * 16 * 255);
+
+	if (total_sectors >= (65535 * 16 * 63)) {
+		sectors_per_track = 255;
+		heads = 16;
+
+		cylinder_times_heads = total_sectors;
+		/* sector_div stores the quotient in cylinder_times_heads */
+		rem = sector_div(cylinder_times_heads, sectors_per_track);
+	} else {
+		sectors_per_track = 17;
+
+		cylinder_times_heads = total_sectors;
+		/* sector_div stores the quotient in cylinder_times_heads */
+		rem = sector_div(cylinder_times_heads, sectors_per_track);
+
+		temp = cylinder_times_heads + 1023;
+		/* sector_div stores the quotient in temp */
+		rem = sector_div(temp, 1024);
+
+		heads = temp;
+
+		if (heads < 4)
+			heads = 4;
+
+		if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
+			sectors_per_track = 31;
+			heads = 16;
+
+			cylinder_times_heads = total_sectors;
+			/*
+			 * sector_div stores the quotient in
+			 * cylinder_times_heads
+			 */
+			rem = sector_div(cylinder_times_heads,
+					 sectors_per_track);
+		}
+
+		if (cylinder_times_heads >= (heads * 1024)) {
+			sectors_per_track = 63;
+			heads = 16;
+
+			cylinder_times_heads = total_sectors;
+			/*
+			 * sector_div stores the quotient in
+			 * cylinder_times_heads
+			 */
+			rem = sector_div(cylinder_times_heads,
+					 sectors_per_track);
+		}
+	}
+
+	temp = cylinder_times_heads;
+	/* sector_div stores the quotient in temp */
+	rem = sector_div(temp, heads);
+	cylinders = temp;
+
+	info[0] = heads;
+	info[1] = sectors_per_track;
+	info[2] = cylinders;
+
+	DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
+		    sectors_per_track);
+
+	return 0;
+}
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 
-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
-			   sector_t capacity, int *info);
-
-
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
@@ -867,86 +943,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 	return ret;
 }
 
-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
-			   sector_t capacity, int *info)
-{
-	sector_t total_sectors = capacity;
-	sector_t cylinder_times_heads = 0;
-	sector_t temp = 0;
-
-	int sectors_per_track = 0;
-	int heads = 0;
-	int cylinders = 0;
-	int rem = 0;
-
-	if (total_sectors > (65535 * 16 * 255))
-		total_sectors = (65535 * 16 * 255);
-
-	if (total_sectors >= (65535 * 16 * 63)) {
-		sectors_per_track = 255;
-		heads = 16;
-
-		cylinder_times_heads = total_sectors;
-		/* sector_div stores the quotient in cylinder_times_heads */
-		rem = sector_div(cylinder_times_heads, sectors_per_track);
-	} else {
-		sectors_per_track = 17;
-
-		cylinder_times_heads = total_sectors;
-		/* sector_div stores the quotient in cylinder_times_heads */
-		rem = sector_div(cylinder_times_heads, sectors_per_track);
-
-		temp = cylinder_times_heads + 1023;
-		/* sector_div stores the quotient in temp */
-		rem = sector_div(temp, 1024);
-
-		heads = temp;
-
-		if (heads < 4)
-			heads = 4;
-
-		if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
-			sectors_per_track = 31;
-			heads = 16;
-
-			cylinder_times_heads = total_sectors;
-			/*
-			 * sector_div stores the quotient in
-			 * cylinder_times_heads
-			 */
-			rem = sector_div(cylinder_times_heads,
-					 sectors_per_track);
-		}
-
-		if (cylinder_times_heads >= (heads * 1024)) {
-			sectors_per_track = 63;
-			heads = 16;
-
-			cylinder_times_heads = total_sectors;
-			/*
-			 * sector_div stores the quotient in
-			 * cylinder_times_heads
-			 */
-			rem = sector_div(cylinder_times_heads,
-					 sectors_per_track);
-		}
-	}
-
-	temp = cylinder_times_heads;
-	/* sector_div stores the quotient in temp */
-	rem = sector_div(temp, heads);
-	cylinders = temp;
-
-	info[0] = heads;
-	info[1] = sectors_per_track;
-	info[2] = cylinders;
-
-	DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
-		    sectors_per_track);
-
-    return 0;
-}
-
 static int __init storvsc_init(void)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#53 lore raw

PATCH 49/206 Staging: hv: Staging: hv: Rename the function stor_vsc_on_host_reset()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_drv.c +2 -2
index 4c08328..d8ce28e 100644
@@ -536,7 +536,7 @@ static int storvsc_drv_init(void)
 }
 
 
-static int stor_vsc_on_host_reset(struct hv_device *device)
+static int storvsc_host_reset(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 	struct hv_storvsc_request *request;
@@ -933,7 +933,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 		    scmnd->device, dev);
 
 	/* Invokes the vsc to reset the host/bus */
-	ret = stor_vsc_on_host_reset(dev);
+	ret = storvsc_host_reset(dev);
 	if (ret != 0)
 		return ret;
 
Signature · 1 line
1.7.4.1
#54 lore raw

PATCH 50/206 Staging: hv: Rename stor_vsc_initialize()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +3 -3
index d8ce28e..28b8569 100644
@@ -71,9 +71,9 @@ struct storvsc_cmd_request {
 
 
 /*
- * stor_vsc_initialize - Main entry point
+ * storvsc_initialize - Main entry point
  */
-static int stor_vsc_initialize(struct hv_driver *driver)
+static int storvsc_initialize(struct hv_driver *driver)
 {
 	struct storvsc_driver *stor_driver;
 
@@ -514,7 +514,7 @@ static int storvsc_drv_init(void)
 	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
 
 	/* Callback to client driver to complete the initialization */
-	stor_vsc_initialize(&storvsc_drv_obj->base);
+	storvsc_initialize(&storvsc_drv_obj->base);
 
 	DPRINT_INFO(STORVSC_DRV,
 		    "max outstanding reqs %u",
Signature · 1 line
1.7.4.1
#55 lore raw

PATCH 51/206 Staging: hv: Move the definition of storvsc_host_reset() to earlier in the file

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   99 +++++++++++++++++++-------------------
 1 files changed, 50 insertions(+), 49 deletions(-)
drivers/staging/hv/storvsc_drv.c +50 -49
index 28b8569..3b2917e 100644
@@ -461,6 +461,56 @@ static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
 
 	return 0;
 }
+
+static int storvsc_host_reset(struct hv_device *device)
+{
+	struct storvsc_device *stor_device;
+	struct hv_storvsc_request *request;
+	struct vstor_packet *vstor_packet;
+	int ret, t;
+
+	DPRINT_INFO(STORVSC, "resetting host adapter...");
+
+	stor_device = get_stor_device(device);
+	if (!stor_device)
+		return -1;
+
+	request = &stor_device->reset_request;
+	vstor_packet = &request->vstor_packet;
+
+	init_completion(&request->wait_event);
+
+	vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
+	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+	vstor_packet->vm_srb.path_id = stor_device->path_id;
+
+	ret = vmbus_sendpacket(device->channel, vstor_packet,
+			       sizeof(struct vstor_packet),
+			       (unsigned long)&stor_device->reset_request,
+			       VM_PKT_DATA_INBAND,
+			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+	if (ret != 0)
+		goto cleanup;
+
+	t = wait_for_completion_timeout(&request->wait_event, HZ);
+	if (t == 0) {
+		ret = -ETIMEDOUT;
+		goto cleanup;
+	}
+
+	DPRINT_INFO(STORVSC, "host adapter reset completed");
+
+	/*
+	 * At this point, all outstanding requests in the adapter
+	 * should have been flushed out and return to us
+	 */
+
+cleanup:
+	put_stor_device(device);
+	return ret;
+}
+
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
@@ -535,55 +585,6 @@ static int storvsc_drv_init(void)
 	return ret;
 }
 
-
-static int storvsc_host_reset(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-	struct hv_storvsc_request *request;
-	struct vstor_packet *vstor_packet;
-	int ret, t;
-
-	DPRINT_INFO(STORVSC, "resetting host adapter...");
-
-	stor_device = get_stor_device(device);
-	if (!stor_device)
-		return -1;
-
-	request = &stor_device->reset_request;
-	vstor_packet = &request->vstor_packet;
-
-	init_completion(&request->wait_event);
-
-	vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
-	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-	vstor_packet->vm_srb.path_id = stor_device->path_id;
-
-	ret = vmbus_sendpacket(device->channel, vstor_packet,
-			       sizeof(struct vstor_packet),
-			       (unsigned long)&stor_device->reset_request,
-			       VM_PKT_DATA_INBAND,
-			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0)
-		goto cleanup;
-
-	t = wait_for_completion_timeout(&request->wait_event, HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
-
-	DPRINT_INFO(STORVSC, "host adapter reset completed");
-
-	/*
-	 * At this point, all outstanding requests in the adapter
-	 * should have been flushed out and return to us
-	 */
-
-cleanup:
-	put_stor_device(device);
-	return ret;
-}
-
 static int storvsc_drv_exit_cb(struct device *dev, void *data)
 {
 	struct device **curr = (struct device **)data;
Signature · 1 line
1.7.4.1
#56 lore raw

PATCH 52/206 Staging: hv: Get rid of the forward declaration for storvsc_host_reset_handler()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |   49 ++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 25 deletions(-)
drivers/staging/hv/storvsc_drv.c +24 -25
index 3b2917e..462aaa5 100644
@@ -511,10 +511,33 @@ cleanup:
 }
 
 
+/*
+ * storvsc_host_reset_handler - Reset the scsi HBA
+ */
+static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
+{
+	int ret;
+	struct hv_host_device *host_dev =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
+	struct hv_device *dev = host_dev->dev;
+
+	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
+		    scmnd->device, dev);
+
+	/* Invokes the vsc to reset the host/bus */
+	ret = storvsc_host_reset(dev);
+	if (ret != 0)
+		return ret;
+
+	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
+		    scmnd->device, dev);
+
+	return ret;
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
-static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
 
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
@@ -920,30 +943,6 @@ retry_request:
 
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
-/*
- * storvsc_host_reset_handler - Reset the scsi HBA
- */
-static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
-{
-	int ret;
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *dev = host_dev->dev;
-
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
-		    scmnd->device, dev);
-
-	/* Invokes the vsc to reset the host/bus */
-	ret = storvsc_host_reset(dev);
-	if (ret != 0)
-		return ret;
-
-	DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
-		    scmnd->device, dev);
-
-	return ret;
-}
-
 static int __init storvsc_init(void)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#57 lore raw

PATCH 53/206 Staging: hv: Move the definition of storvsc_ringbuffer_size to earlier in the file

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -1
index 462aaa5..6bb35c4 100644
@@ -40,6 +40,7 @@
 #include "vstorage.h"
 #include "channel.h"
 
+static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
 static const char *driver_name = "storvsc";
 
@@ -539,7 +540,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 
-static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
Signature · 1 line
1.7.4.1
#58 lore raw

PATCH 54/206 Staging: hv: Move module parameters to earlier in the file

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +3 -3
index 6bb35c4..0d9ce56 100644
@@ -42,6 +42,9 @@
 
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
+module_param(storvsc_ringbuffer_size, int, S_IRUGO);
+MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
+
 static const char *driver_name = "storvsc";
 
 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
@@ -540,9 +543,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 
-module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
-
 /* The one and only one */
 static struct storvsc_driver g_storvsc_drv;
 
Signature · 1 line
1.7.4.1
#59 lore raw

PATCH 55/206 Staging: hv: Move the function storvsc_commmand_completion() to earlier in the file

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |  115 +++++++++++++++++++-------------------
 1 files changed, 58 insertions(+), 57 deletions(-)
drivers/staging/hv/storvsc_drv.c +58 -57
index 0d9ce56..d10e533 100644
@@ -539,6 +539,64 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 	return ret;
 }
 
+
+/*
+ * storvsc_commmand_completion - Command completion processing
+ */
+static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+{
+	struct storvsc_cmd_request *cmd_request =
+		(struct storvsc_cmd_request *)request->context;
+	struct scsi_cmnd *scmnd = cmd_request->cmd;
+	struct hv_host_device *host_dev =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
+	void (*scsi_done_fn)(struct scsi_cmnd *);
+	struct scsi_sense_hdr sense_hdr;
+	struct vmscsi_request *vm_srb;
+
+	/* ASSERT(request == &cmd_request->request); */
+	/* ASSERT(scmnd); */
+	/* ASSERT((unsigned long)scmnd->host_scribble == */
+	/*        (unsigned long)cmd_request); */
+	/* ASSERT(scmnd->scsi_done); */
+
+	if (cmd_request->bounce_sgl_count) {
+		/* using bounce buffer */
+		/* printk("copy_from_bounce_buffer\n"); */
+
+		/* 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));
+		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) {
+		if (scsi_normalize_sense(scmnd->sense_buffer,
+				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+			scsi_print_sense_hdr("storvsc", &sense_hdr);
+	}
+
+	/* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
+	scsi_set_resid(scmnd,
+		request->data_buffer.len -
+		vm_srb->data_transfer_length);
+
+	scsi_done_fn = scmnd->scsi_done;
+
+	scmnd->host_scribble = NULL;
+	scmnd->scsi_done = NULL;
+
+	/* !!DO NOT MODIFY the scmnd after this call */
+	scsi_done_fn(scmnd);
+
+	kmem_cache_free(host_dev->request_pool, cmd_request);
+}
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
 static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
@@ -719,63 +777,6 @@ static int storvsc_probe(struct hv_device *device)
 }
 
 /*
- * storvsc_commmand_completion - Command completion processing
- */
-static void storvsc_commmand_completion(struct hv_storvsc_request *request)
-{
-	struct storvsc_cmd_request *cmd_request =
-		(struct storvsc_cmd_request *)request->context;
-	struct scsi_cmnd *scmnd = cmd_request->cmd;
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
-	void (*scsi_done_fn)(struct scsi_cmnd *);
-	struct scsi_sense_hdr sense_hdr;
-	struct vmscsi_request *vm_srb;
-
-	/* ASSERT(request == &cmd_request->request); */
-	/* ASSERT(scmnd); */
-	/* ASSERT((unsigned long)scmnd->host_scribble == */
-	/*        (unsigned long)cmd_request); */
-	/* ASSERT(scmnd->scsi_done); */
-
-	if (cmd_request->bounce_sgl_count) {
-		/* using bounce buffer */
-		/* printk("copy_from_bounce_buffer\n"); */
-
-		/* 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));
-		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) {
-		if (scsi_normalize_sense(scmnd->sense_buffer,
-				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
-			scsi_print_sense_hdr("storvsc", &sense_hdr);
-	}
-
-	/* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
-	scsi_set_resid(scmnd,
-		request->data_buffer.len -
-		vm_srb->data_transfer_length);
-
-	scsi_done_fn = scmnd->scsi_done;
-
-	scmnd->host_scribble = NULL;
-	scmnd->scsi_done = NULL;
-
-	/* !!DO NOT MODIFY the scmnd after this call */
-	scsi_done_fn(scmnd);
-
-	kmem_cache_free(host_dev->request_pool, cmd_request);
-}
-
-/*
  * storvsc_queuecommand - Initiate command processing
  */
 static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
Signature · 1 line
1.7.4.1
#60 lore raw

PATCH 56/206 Staging: hv: Get rid of the forward declaration of storvsc_queuecommand()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |  338 +++++++++++++++++++-------------------
 1 files changed, 169 insertions(+), 169 deletions(-)
drivers/staging/hv/storvsc_drv.c +169 -169
index d10e533..4d4226a 100644
@@ -597,9 +597,177 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
+
+/*
+ * storvsc_queuecommand - Initiate command processing
+ */
+static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
+				void (*done)(struct scsi_cmnd *))
+{
+	int ret;
+	struct hv_host_device *host_dev =
+		(struct hv_host_device *)scmnd->device->host->hostdata;
+	struct hv_device *dev = host_dev->dev;
+	struct storvsc_driver *storvsc_drv_obj =
+		drv_to_stordrv(dev->device.driver);
+	struct hv_storvsc_request *request;
+	struct storvsc_cmd_request *cmd_request;
+	unsigned int request_size = 0;
+	int i;
+	struct scatterlist *sgl;
+	unsigned int sg_count = 0;
+	struct vmscsi_request *vm_srb;
+
+
+	/* If retrying, no need to prep the cmd */
+	if (scmnd->host_scribble) {
+		/* ASSERT(scmnd->scsi_done != NULL); */
+
+		cmd_request =
+			(struct storvsc_cmd_request *)scmnd->host_scribble;
+		DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p",
+			    scmnd, cmd_request);
+
+		goto retry_request;
+	}
+
+	/* ASSERT(scmnd->scsi_done == NULL); */
+	/* ASSERT(scmnd->host_scribble == NULL); */
+
+	scmnd->scsi_done = done;
+
+	request_size = sizeof(struct storvsc_cmd_request);
+
+	cmd_request = kmem_cache_zalloc(host_dev->request_pool,
+				       GFP_ATOMIC);
+	if (!cmd_request) {
+		scmnd->scsi_done = NULL;
+		return SCSI_MLQUEUE_DEVICE_BUSY;
+	}
+
+	/* Setup the cmd request */
+	cmd_request->bounce_sgl_count = 0;
+	cmd_request->bounce_sgl = NULL;
+	cmd_request->cmd = scmnd;
+
+	scmnd->host_scribble = (unsigned char *)cmd_request;
+
+	request = &cmd_request->request;
+	vm_srb = &request->vstor_packet.vm_srb;
+
+
+	/* Build the SRB */
+	switch (scmnd->sc_data_direction) {
+	case DMA_TO_DEVICE:
+		vm_srb->data_in = WRITE_TYPE;
+		break;
+	case DMA_FROM_DEVICE:
+		vm_srb->data_in = READ_TYPE;
+		break;
+	default:
+		vm_srb->data_in = UNKNOWN_TYPE;
+		break;
+	}
+
+	request->on_io_completion = storvsc_commmand_completion;
+	request->context = cmd_request;/* scmnd; */
+
+	/* request->PortId = scmnd->device->channel; */
+	vm_srb->port_number = host_dev->port;
+	vm_srb->path_id = scmnd->device->channel;
+	vm_srb->target_id = scmnd->device->id;
+	vm_srb->lun = scmnd->device->lun;
+
+	/* ASSERT(scmnd->cmd_len <= 16); */
+	vm_srb->cdb_length = scmnd->cmd_len;
+
+	memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
+
+	request->sense_buffer = scmnd->sense_buffer;
+
+
+	request->data_buffer.len = scsi_bufflen(scmnd);
+	if (scsi_sg_count(scmnd)) {
+		sgl = (struct scatterlist *)scsi_sglist(scmnd);
+		sg_count = scsi_sg_count(scmnd);
+
+		/* check if we need to bounce the sgl */
+		if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
+			cmd_request->bounce_sgl =
+				create_bounce_buffer(sgl, scsi_sg_count(scmnd),
+						     scsi_bufflen(scmnd));
+			if (!cmd_request->bounce_sgl) {
+				scmnd->scsi_done = NULL;
+				scmnd->host_scribble = NULL;
+				kmem_cache_free(host_dev->request_pool,
+						cmd_request);
+
+				return SCSI_MLQUEUE_HOST_BUSY;
+			}
+
+			cmd_request->bounce_sgl_count =
+				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));
+
+			sgl = cmd_request->bounce_sgl;
+			sg_count = cmd_request->bounce_sgl_count;
+		}
+
+		request->data_buffer.offset = sgl[0].offset;
+
+		for (i = 0; i < sg_count; i++)
+			request->data_buffer.pfn_array[i] =
+				page_to_pfn(sg_page((&sgl[i])));
+
+	} else if (scsi_sglist(scmnd)) {
+		/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
+		request->data_buffer.offset =
+			virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
+		request->data_buffer.pfn_array[0] =
+			virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
+	}
+
+retry_request:
+	/* Invokes the vsc to start an IO */
+	ret = storvsc_drv_obj->on_io_request(dev,
+					   &cmd_request->request);
+	if (ret == -1) {
+		/* 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));
+			destroy_bounce_buffer(cmd_request->bounce_sgl,
+					      cmd_request->bounce_sgl_count);
+		}
+
+		kmem_cache_free(host_dev->request_pool, cmd_request);
+
+		scmnd->scsi_done = NULL;
+		scmnd->host_scribble = NULL;
+
+		ret = SCSI_MLQUEUE_DEVICE_BUSY;
+	}
+
+	return ret;
+}
+
+static DEF_SCSI_QCMD(storvsc_queuecommand)
+
 /* Static decl */
 static int storvsc_probe(struct hv_device *dev);
-static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
 
 /* The one and only one */
 static struct storvsc_driver g_storvsc_drv;
@@ -776,174 +944,6 @@ static int storvsc_probe(struct hv_device *device)
 	return ret;
 }
 
-/*
- * storvsc_queuecommand - Initiate command processing
- */
-static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
-				void (*done)(struct scsi_cmnd *))
-{
-	int ret;
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
-	struct hv_device *dev = host_dev->dev;
-	struct storvsc_driver *storvsc_drv_obj =
-		drv_to_stordrv(dev->device.driver);
-	struct hv_storvsc_request *request;
-	struct storvsc_cmd_request *cmd_request;
-	unsigned int request_size = 0;
-	int i;
-	struct scatterlist *sgl;
-	unsigned int sg_count = 0;
-	struct vmscsi_request *vm_srb;
-
-
-	/* If retrying, no need to prep the cmd */
-	if (scmnd->host_scribble) {
-		/* ASSERT(scmnd->scsi_done != NULL); */
-
-		cmd_request =
-			(struct storvsc_cmd_request *)scmnd->host_scribble;
-		DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p",
-			    scmnd, cmd_request);
-
-		goto retry_request;
-	}
-
-	/* ASSERT(scmnd->scsi_done == NULL); */
-	/* ASSERT(scmnd->host_scribble == NULL); */
-
-	scmnd->scsi_done = done;
-
-	request_size = sizeof(struct storvsc_cmd_request);
-
-	cmd_request = kmem_cache_zalloc(host_dev->request_pool,
-				       GFP_ATOMIC);
-	if (!cmd_request) {
-		scmnd->scsi_done = NULL;
-		return SCSI_MLQUEUE_DEVICE_BUSY;
-	}
-
-	/* Setup the cmd request */
-	cmd_request->bounce_sgl_count = 0;
-	cmd_request->bounce_sgl = NULL;
-	cmd_request->cmd = scmnd;
-
-	scmnd->host_scribble = (unsigned char *)cmd_request;
-
-	request = &cmd_request->request;
-	vm_srb = &request->vstor_packet.vm_srb;
-
-
-	/* Build the SRB */
-	switch (scmnd->sc_data_direction) {
-	case DMA_TO_DEVICE:
-		vm_srb->data_in = WRITE_TYPE;
-		break;
-	case DMA_FROM_DEVICE:
-		vm_srb->data_in = READ_TYPE;
-		break;
-	default:
-		vm_srb->data_in = UNKNOWN_TYPE;
-		break;
-	}
-
-	request->on_io_completion = storvsc_commmand_completion;
-	request->context = cmd_request;/* scmnd; */
-
-	/* request->PortId = scmnd->device->channel; */
-	vm_srb->port_number = host_dev->port;
-	vm_srb->path_id = scmnd->device->channel;
-	vm_srb->target_id = scmnd->device->id;
-	vm_srb->lun = scmnd->device->lun;
-
-	/* ASSERT(scmnd->cmd_len <= 16); */
-	vm_srb->cdb_length = scmnd->cmd_len;
-
-	memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
-
-	request->sense_buffer = scmnd->sense_buffer;
-
-
-	request->data_buffer.len = scsi_bufflen(scmnd);
-	if (scsi_sg_count(scmnd)) {
-		sgl = (struct scatterlist *)scsi_sglist(scmnd);
-		sg_count = scsi_sg_count(scmnd);
-
-		/* check if we need to bounce the sgl */
-		if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
-			cmd_request->bounce_sgl =
-				create_bounce_buffer(sgl, scsi_sg_count(scmnd),
-						     scsi_bufflen(scmnd));
-			if (!cmd_request->bounce_sgl) {
-				scmnd->scsi_done = NULL;
-				scmnd->host_scribble = NULL;
-				kmem_cache_free(host_dev->request_pool,
-						cmd_request);
-
-				return SCSI_MLQUEUE_HOST_BUSY;
-			}
-
-			cmd_request->bounce_sgl_count =
-				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));
-
-			sgl = cmd_request->bounce_sgl;
-			sg_count = cmd_request->bounce_sgl_count;
-		}
-
-		request->data_buffer.offset = sgl[0].offset;
-
-		for (i = 0; i < sg_count; i++)
-			request->data_buffer.pfn_array[i] =
-				page_to_pfn(sg_page((&sgl[i])));
-
-	} else if (scsi_sglist(scmnd)) {
-		/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
-		request->data_buffer.offset =
-			virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
-		request->data_buffer.pfn_array[0] =
-			virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
-	}
-
-retry_request:
-	/* Invokes the vsc to start an IO */
-	ret = storvsc_drv_obj->on_io_request(dev,
-					   &cmd_request->request);
-	if (ret == -1) {
-		/* 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));
-			destroy_bounce_buffer(cmd_request->bounce_sgl,
-					      cmd_request->bounce_sgl_count);
-		}
-
-		kmem_cache_free(host_dev->request_pool, cmd_request);
-
-		scmnd->scsi_done = NULL;
-		scmnd->host_scribble = NULL;
-
-		ret = SCSI_MLQUEUE_DEVICE_BUSY;
-	}
-
-	return ret;
-}
-
-static DEF_SCSI_QCMD(storvsc_queuecommand)
-
 static int __init storvsc_init(void)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#61 lore raw

PATCH 57/206 Staging: hv: Get rid of the forward declaration of storvsc_probe()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/storvsc_drv.c |  143 +++++++++++++++++++-------------------
 1 files changed, 71 insertions(+), 72 deletions(-)
drivers/staging/hv/storvsc_drv.c +71 -72
index 4d4226a..37bc4dd 100644
@@ -766,8 +766,6 @@ retry_request:
 
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
-/* Static decl */
-static int storvsc_probe(struct hv_device *dev);
 
 /* The one and only one */
 static struct storvsc_driver g_storvsc_drv;
@@ -802,78 +800,9 @@ static struct scsi_host_template scsi_driver = {
 
 
 /*
- * storvsc_drv_init - StorVsc driver initialization.
- */
-static int storvsc_drv_init(void)
-{
-	int ret;
-	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
-	struct hv_driver *drv = &g_storvsc_drv.base;
-
-	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
-
-	/* Callback to client driver to complete the initialization */
-	storvsc_initialize(&storvsc_drv_obj->base);
-
-	DPRINT_INFO(STORVSC_DRV,
-		    "max outstanding reqs %u",
-		    storvsc_drv_obj->max_outstanding_req_per_channel);
-
-	if (storvsc_drv_obj->max_outstanding_req_per_channel <
-	    STORVSC_MAX_IO_REQUESTS)
-		return -1;
-
-	drv->driver.name = storvsc_drv_obj->base.name;
-
-	drv->probe = storvsc_probe;
-	drv->remove = storvsc_remove;
-
-	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
-
-	return ret;
-}
-
-static int storvsc_drv_exit_cb(struct device *dev, void *data)
-{
-	struct device **curr = (struct device **)data;
-	*curr = dev;
-	return 1; /* stop iterating */
-}
-
-static void storvsc_drv_exit(void)
-{
-	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
-	struct hv_driver *drv = &g_storvsc_drv.base;
-	struct device *current_dev = NULL;
-	int ret;
-
-	while (1) {
-		current_dev = NULL;
-
-		/* Get the device */
-		ret = driver_for_each_device(&drv->driver, NULL,
-					     (void *) &current_dev,
-					     storvsc_drv_exit_cb);
-
-
-		if (current_dev == NULL)
-			break;
-
-		/* Initiate removal from the top-down */
-		device_unregister(current_dev);
-	}
-
-	if (storvsc_drv_obj->base.cleanup)
-		storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
-
-	vmbus_child_driver_unregister(&drv->driver);
-	return;
-}
-
-/*
  * storvsc_probe - Add a new device for this driver
  */
+
 static int storvsc_probe(struct hv_device *device)
 {
 	int ret;
@@ -944,6 +873,76 @@ static int storvsc_probe(struct hv_device *device)
 	return ret;
 }
 
+/*
+ * storvsc_drv_init - StorVsc driver initialization.
+ */
+static int storvsc_drv_init(void)
+{
+	int ret;
+	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
+	struct hv_driver *drv = &g_storvsc_drv.base;
+
+	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
+
+	/* Callback to client driver to complete the initialization */
+	storvsc_initialize(&storvsc_drv_obj->base);
+
+	DPRINT_INFO(STORVSC_DRV,
+		    "max outstanding reqs %u",
+		    storvsc_drv_obj->max_outstanding_req_per_channel);
+
+	if (storvsc_drv_obj->max_outstanding_req_per_channel <
+	    STORVSC_MAX_IO_REQUESTS)
+		return -1;
+
+	drv->driver.name = storvsc_drv_obj->base.name;
+
+	drv->probe = storvsc_probe;
+	drv->remove = storvsc_remove;
+
+	/* The driver belongs to vmbus */
+	ret = vmbus_child_driver_register(&drv->driver);
+
+	return ret;
+}
+
+static int storvsc_drv_exit_cb(struct device *dev, void *data)
+{
+	struct device **curr = (struct device **)data;
+	*curr = dev;
+	return 1; /* stop iterating */
+}
+
+static void storvsc_drv_exit(void)
+{
+	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
+	struct hv_driver *drv = &g_storvsc_drv.base;
+	struct device *current_dev = NULL;
+	int ret;
+
+	while (1) {
+		current_dev = NULL;
+
+		/* Get the device */
+		ret = driver_for_each_device(&drv->driver, NULL,
+					     (void *) &current_dev,
+					     storvsc_drv_exit_cb);
+
+
+		if (current_dev == NULL)
+			break;
+
+		/* Initiate removal from the top-down */
+		device_unregister(current_dev);
+	}
+
+	if (storvsc_drv_obj->base.cleanup)
+		storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
+
+	vmbus_child_driver_unregister(&drv->driver);
+	return;
+}
+
 static int __init storvsc_init(void)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#62 lore raw

PATCH 58/206 Staging: hv: Rename the driver variable

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc_drv.c +5 -5
index 37bc4dd..d246678 100644
@@ -768,7 +768,7 @@ static DEF_SCSI_QCMD(storvsc_queuecommand)
 
 
 /* The one and only one */
-static struct storvsc_driver g_storvsc_drv;
+static struct storvsc_driver storvsc_drv;
 
 /* Scsi driver */
 static struct scsi_host_template scsi_driver = {
@@ -879,8 +879,8 @@ static int storvsc_probe(struct hv_device *device)
 static int storvsc_drv_init(void)
 {
 	int ret;
-	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
-	struct hv_driver *drv = &g_storvsc_drv.base;
+	struct storvsc_driver *storvsc_drv_obj = &storvsc_drv;
+	struct hv_driver *drv = &storvsc_drv.base;
 
 	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
 
@@ -915,8 +915,8 @@ static int storvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void storvsc_drv_exit(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &g_storvsc_drv;
-	struct hv_driver *drv = &g_storvsc_drv.base;
+	struct storvsc_driver *storvsc_drv_obj = &storvsc_drv;
+	struct hv_driver *drv = &storvsc_drv.base;
 	struct device *current_dev = NULL;
 	int ret;
 
Signature · 1 line
1.7.4.1
#63 lore raw

PATCH 59/206 Staging: hv: Move the declaration of the driver variable

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +5 -3
index d246678..570d563 100644
@@ -767,9 +767,6 @@ retry_request:
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
 
-/* The one and only one */
-static struct storvsc_driver storvsc_drv;
-
 /* Scsi driver */
 static struct scsi_host_template scsi_driver = {
 	.module	=		THIS_MODULE,
@@ -873,6 +870,11 @@ static int storvsc_probe(struct hv_device *device)
 	return ret;
 }
 
+/* The one and only one */
+
+static struct storvsc_driver storvsc_drv;
+
+
 /*
  * storvsc_drv_init - StorVsc driver initialization.
  */
Signature · 1 line
1.7.4.1
#64 lore raw

PATCH 60/206 Staging: hv: Statically initialize probe/remove elements of the driver

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_drv.c +4 -3
index 570d563..89a0b05 100644
@@ -872,7 +872,10 @@ static int storvsc_probe(struct hv_device *device)
 
 /* The one and only one */
 
-static struct storvsc_driver storvsc_drv;
+static struct storvsc_driver storvsc_drv = {
+	.base.probe = storvsc_probe,
+	.base.remove = storvsc_remove,
+};
 
 
 /*
@@ -899,8 +902,6 @@ static int storvsc_drv_init(void)
 
 	drv->driver.name = storvsc_drv_obj->base.name;
 
-	drv->probe = storvsc_probe;
-	drv->remove = storvsc_remove;
 
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
Signature · 1 line
1.7.4.1
#65 lore raw

PATCH 61/206 Staging: hv: Get rid of unnecessary comments/dead code

In reply to K. Y. Srinivasan

Get rid of unnecessary comments/dead code.

---
 drivers/staging/hv/storvsc_drv.c |   17 -----------------
 1 files changed, 0 insertions(+), 17 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -17
index 89a0b05..650e11f 100644
@@ -147,7 +147,6 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 	blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
 
 	blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
-	/* sdevice->timeout = (2000 * HZ);//(75 * HZ); */
 
 	return 0;
 }
@@ -554,15 +553,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
 
-	/* ASSERT(request == &cmd_request->request); */
-	/* ASSERT(scmnd); */
-	/* ASSERT((unsigned long)scmnd->host_scribble == */
-	/*        (unsigned long)cmd_request); */
-	/* ASSERT(scmnd->scsi_done); */
-
 	if (cmd_request->bounce_sgl_count) {
-		/* using bounce buffer */
-		/* printk("copy_from_bounce_buffer\n"); */
 
 		/* FIXME: We can optimize on writes by just skipping this */
 		copy_from_bounce_buffer(scsi_sglist(scmnd),
@@ -581,7 +572,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
 			scsi_print_sense_hdr("storvsc", &sense_hdr);
 	}
 
-	/* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
 	scsi_set_resid(scmnd,
 		request->data_buffer.len -
 		vm_srb->data_transfer_length);
@@ -621,7 +611,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 	/* If retrying, no need to prep the cmd */
 	if (scmnd->host_scribble) {
-		/* ASSERT(scmnd->scsi_done != NULL); */
 
 		cmd_request =
 			(struct storvsc_cmd_request *)scmnd->host_scribble;
@@ -631,9 +620,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 		goto retry_request;
 	}
 
-	/* ASSERT(scmnd->scsi_done == NULL); */
-	/* ASSERT(scmnd->host_scribble == NULL); */
-
 	scmnd->scsi_done = done;
 
 	request_size = sizeof(struct storvsc_cmd_request);
@@ -672,13 +658,11 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	request->on_io_completion = storvsc_commmand_completion;
 	request->context = cmd_request;/* scmnd; */
 
-	/* request->PortId = scmnd->device->channel; */
 	vm_srb->port_number = host_dev->port;
 	vm_srb->path_id = scmnd->device->channel;
 	vm_srb->target_id = scmnd->device->id;
 	vm_srb->lun = scmnd->device->lun;
 
-	/* ASSERT(scmnd->cmd_len <= 16); */
 	vm_srb->cdb_length = scmnd->cmd_len;
 
 	memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
@@ -727,7 +711,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				page_to_pfn(sg_page((&sgl[i])));
 
 	} else if (scsi_sglist(scmnd)) {
-		/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
 		request->data_buffer.offset =
 			virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
 		request->data_buffer.pfn_array[0] =
Signature · 1 line
1.7.4.1
#66 lore raw

PATCH 62/206 Staging: hv: Get rid of the indirection in invoking storvsc_dev_remove()

In reply to K. Y. Srinivasan

Get rid of the indirection in invoking storvsc_dev_remove()

---
 drivers/staging/hv/storvsc_drv.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/hv/storvsc_drv.c +2 -4
index 650e11f..233aa4c 100644
@@ -359,8 +359,6 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
  */
 static int storvsc_remove(struct hv_device *dev)
 {
-	struct storvsc_driver *storvsc_drv_obj =
-			 drv_to_stordrv(dev->device.driver);
 	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
 	struct hv_host_device *host_dev =
 			(struct hv_host_device *)host->hostdata;
@@ -369,7 +367,7 @@ static int storvsc_remove(struct hv_device *dev)
 	 * Call to the vsc driver to let it know that the device is being
 	 * removed
 	 */
-	storvsc_drv_obj->base.dev_rm(dev);
+	storvsc_dev_remove(dev);
 
 	if (host_dev->request_pool) {
 		kmem_cache_destroy(host_dev->request_pool);
@@ -842,7 +840,7 @@ static int storvsc_probe(struct hv_device *device)
 	ret = scsi_add_host(host, &device->device);
 	if (ret != 0) {
 
-		storvsc_drv_obj->base.dev_rm(device);
+		storvsc_dev_remove(device);
 
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
Signature · 1 line
1.7.4.1
#67 lore raw

PATCH 63/206 Staging: hv: Get rid of the indirection in invoking storvsc_dev_add()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -6
index 233aa4c..599b5d2 100644
@@ -784,15 +784,10 @@ static struct scsi_host_template scsi_driver = {
 static int storvsc_probe(struct hv_device *device)
 {
 	int ret;
-	struct storvsc_driver *storvsc_drv_obj =
-		 drv_to_stordrv(device->device.driver);
 	struct Scsi_Host *host;
 	struct hv_host_device *host_dev;
 	struct storvsc_device_info device_info;
 
-	if (!storvsc_drv_obj->base.dev_add)
-		return -1;
-
 	host = scsi_host_alloc(&scsi_driver,
 			       sizeof(struct hv_host_device));
 	if (!host)
@@ -818,7 +813,7 @@ static int storvsc_probe(struct hv_device *device)
 
 	device_info.port_number = host->host_no;
 	/* Call to the vsc driver to add the device */
-	ret = storvsc_drv_obj->base.dev_add(device, (void *)&device_info);
+	ret = storvsc_dev_add(device, (void *)&device_info);
 
 	if (ret != 0) {
 		kmem_cache_destroy(host_dev->request_pool);
Signature · 1 line
1.7.4.1
#68 lore raw

PATCH 64/206 Staging: hv: Get rid of the indirection in invoking storvsc_do_io()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/hv/storvsc_drv.c +2 -4
index 599b5d2..6300b79 100644
@@ -596,8 +596,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
 	struct hv_device *dev = host_dev->dev;
-	struct storvsc_driver *storvsc_drv_obj =
-		drv_to_stordrv(dev->device.driver);
 	struct hv_storvsc_request *request;
 	struct storvsc_cmd_request *cmd_request;
 	unsigned int request_size = 0;
@@ -717,8 +715,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 retry_request:
 	/* Invokes the vsc to start an IO */
-	ret = storvsc_drv_obj->on_io_request(dev,
-					   &cmd_request->request);
+	ret = storvsc_do_io(dev, &cmd_request->request);
+
 	if (ret == -1) {
 		/* no more space */
 
Signature · 1 line
1.7.4.1
#69 lore raw

PATCH 65/206 Staging: hv: Get rid of the code initializing the dispatch table

In reply to K. Y. Srinivasan

Now that we have eliminated the indirection, we can get rid of the code to initialize the dispatch table.

---
 drivers/staging/hv/storvsc_drv.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -5
index 6300b79..caa1f36 100644
@@ -107,11 +107,6 @@ static int storvsc_initialize(struct hv_driver *driver)
 		    stor_driver->max_outstanding_req_per_channel,
 		    STORVSC_MAX_IO_REQUESTS);
 
-	/* Setup the dispatch table */
-	stor_driver->base.dev_add	= storvsc_dev_add;
-	stor_driver->base.dev_rm	= storvsc_dev_remove;
-
-	stor_driver->on_io_request	= storvsc_do_io;
 
 	return 0;
 }
Signature · 1 line
1.7.4.1
#70 lore raw

PATCH 66/206 Staging: hv: Simplify the code for getting the drive parameters

In reply to K. Y. Srinivasan

We are making up the drive parameters; simplify the code.

---
 drivers/staging/hv/storvsc_drv.c |   84 +++++++-------------------------------
 1 files changed, 15 insertions(+), 69 deletions(-)
drivers/staging/hv/storvsc_drv.c +15 -69
index caa1f36..5624d26 100644
@@ -381,79 +381,25 @@ static int storvsc_remove(struct hv_device *dev)
 static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
 			   sector_t capacity, int *info)
 {
-	sector_t total_sectors = capacity;
-	sector_t cylinder_times_heads = 0;
-	sector_t temp = 0;
+	sector_t nsect = capacity;
+	sector_t cylinders = nsect;
+	int heads, sectors_pt;
 
-	int sectors_per_track = 0;
-	int heads = 0;
-	int cylinders = 0;
-	int rem = 0;
-
-	if (total_sectors > (65535 * 16 * 255))
-		total_sectors = (65535 * 16 * 255);
-
-	if (total_sectors >= (65535 * 16 * 63)) {
-		sectors_per_track = 255;
-		heads = 16;
-
-		cylinder_times_heads = total_sectors;
-		/* sector_div stores the quotient in cylinder_times_heads */
-		rem = sector_div(cylinder_times_heads, sectors_per_track);
-	} else {
-		sectors_per_track = 17;
-
-		cylinder_times_heads = total_sectors;
-		/* sector_div stores the quotient in cylinder_times_heads */
-		rem = sector_div(cylinder_times_heads, sectors_per_track);
-
-		temp = cylinder_times_heads + 1023;
-		/* sector_div stores the quotient in temp */
-		rem = sector_div(temp, 1024);
-
-		heads = temp;
-
-		if (heads < 4)
-			heads = 4;
-
-		if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
-			sectors_per_track = 31;
-			heads = 16;
-
-			cylinder_times_heads = total_sectors;
-			/*
-			 * sector_div stores the quotient in
-			 * cylinder_times_heads
-			 */
-			rem = sector_div(cylinder_times_heads,
-					 sectors_per_track);
-		}
-
-		if (cylinder_times_heads >= (heads * 1024)) {
-			sectors_per_track = 63;
-			heads = 16;
-
-			cylinder_times_heads = total_sectors;
-			/*
-			 * sector_div stores the quotient in
-			 * cylinder_times_heads
-			 */
-			rem = sector_div(cylinder_times_heads,
-					 sectors_per_track);
-		}
-	}
-
-	temp = cylinder_times_heads;
-	/* sector_div stores the quotient in temp */
-	rem = sector_div(temp, heads);
-	cylinders = temp;
+	/*
+	 * We are making up these values; let us keep it simple.
+	 */
+	heads = 0xff;
+	sectors_pt = 0x3f;      /* Sectors per track */
+	sector_div(cylinders, heads * sectors_pt);
+	if ((sector_t)(cylinders + 1) * heads * sectors_pt < nsect)
+		cylinders = 0xffff;
 
 	info[0] = heads;
-	info[1] = sectors_per_track;
-	info[2] = cylinders;
+	info[1] = sectors_pt;
+	info[2] = (int)cylinders;
 
-	DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
-		    sectors_per_track);
+	DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", (int)cylinders, heads,
+			sectors_pt);
 
 	return 0;
 }
Signature · 1 line
1.7.4.1
#71 lore raw

PATCH 67/206 Staging: hv: Make the function netvsc_device_add() non static

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc.c     |    2 +-
 drivers/staging/hv/netvsc_api.h |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc.c +1 -1
index 27c7449..7cd3f0b 100644
@@ -1097,7 +1097,7 @@ out:
  * netvsc_device_add - Callback when the device belonging to this
  * driver is added
  */
-static int netvsc_device_add(struct hv_device *device, void *additional_info)
+int netvsc_device_add(struct hv_device *device, void *additional_info)
 {
 	int ret = 0;
 	int i;
drivers/staging/hv/netvsc_api.h +1 -0
index 48b512b..d09d6eb 100644
@@ -117,6 +117,7 @@ struct netvsc_device_info {
 };
 
 /* Interface */
+int netvsc_device_add(struct hv_device *device, void *additional_info);
 int netvsc_initialize(struct hv_driver *drv);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
Signature · 1 line
1.7.4.1
#72 lore raw

PATCH 68/206 Staging: hv: Make netvsc_device_remove non static

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc.c     |    2 +-
 drivers/staging/hv/netvsc_api.h |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc.c +1 -1
index 7cd3f0b..8790f0f 100644
@@ -580,7 +580,7 @@ static void netvsc_disconnect_vsp(struct netvsc_device *net_device)
 /*
  * netvsc_device_remove - Callback when the root bus device is removed
  */
-static int netvsc_device_remove(struct hv_device *device)
+int netvsc_device_remove(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *netvsc_packet, *pos;
drivers/staging/hv/netvsc_api.h +1 -0
index d09d6eb..d8d77c0 100644
@@ -118,6 +118,7 @@ struct netvsc_device_info {
 
 /* Interface */
 int netvsc_device_add(struct hv_device *device, void *additional_info);
+int netvsc_device_remove(struct hv_device *device);
 int netvsc_initialize(struct hv_driver *drv);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
Signature · 1 line
1.7.4.1
#73 lore raw

PATCH 69/206 Staging: hv: Get rid of netvsc_cleanup()

In reply to K. Y. Srinivasan

netvsc_cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/netvsc.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/hv/netvsc.c +0 -8
index 8790f0f..34828c4 100644
@@ -622,13 +622,6 @@ int netvsc_device_remove(struct hv_device *device)
 	return 0;
 }
 
-/*
- * netvsc_cleanup - Perform any cleanup when the driver is removed
- */
-static void netvsc_cleanup(struct hv_driver *drv)
-{
-}
-
 static void netvsc_send_completion(struct hv_device *device,
 				   struct vmpacket_descriptor *packet)
 {
@@ -1194,7 +1187,6 @@ int netvsc_initialize(struct hv_driver *drv)
 	/* Setup the dispatch table */
 	driver->base.dev_add	= netvsc_device_add;
 	driver->base.dev_rm	= netvsc_device_remove;
-	driver->base.cleanup		= netvsc_cleanup;
 
 	driver->send			= netvsc_send;
 
Signature · 1 line
1.7.4.1
#74 lore raw

PATCH 70/206 Staging: hv: Make rndis_filte_device_add() non static

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_api.h   |    3 +++
 drivers/staging/hv/rndis_filter.c |    5 +----
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/netvsc_api.h +3 -0
index d8d77c0..64625e3 100644
@@ -122,5 +122,8 @@ int netvsc_device_remove(struct hv_device *device);
 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_filte_device_add(struct hv_device *dev,
+			void *additional_info);
+
 
 #endif /* _NETVSC_API_H_ */
drivers/staging/hv/rndis_filter.c +1 -4
index 6305050..09118b8 100644
@@ -84,9 +84,6 @@ struct rndis_filter_packet {
 };
 
 
-static int rndis_filte_device_add(struct hv_device *dev,
-				  void *additional_info);
-
 static int rndis_filter_device_remove(struct hv_device *dev);
 
 static void rndis_filter_cleanup(struct hv_driver *drv);
@@ -746,7 +743,7 @@ static int rndis_filter_close_device(struct rndis_device *dev)
 	return ret;
 }
 
-static int rndis_filte_device_add(struct hv_device *dev,
+int rndis_filte_device_add(struct hv_device *dev,
 				  void *additional_info)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#75 lore raw

PATCH 71/206 Staging: hv: Make rndis_filter_device_remove() non static

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_api.h   |    1 +
 drivers/staging/hv/rndis_filter.c |    4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc_api.h +1 -0
index 64625e3..b385c9d 100644
@@ -124,6 +124,7 @@ int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filte_device_add(struct hv_device *dev,
 			void *additional_info);
+int rndis_filter_device_remove(struct hv_device *dev);
 
 
 #endif /* _NETVSC_API_H_ */
drivers/staging/hv/rndis_filter.c +1 -3
index 09118b8..455d440 100644
@@ -84,8 +84,6 @@ struct rndis_filter_packet {
 };
 
 
-static int rndis_filter_device_remove(struct hv_device *dev);
-
 static void rndis_filter_cleanup(struct hv_driver *drv);
 
 static int rndis_filter_send(struct hv_device *dev,
@@ -803,7 +801,7 @@ int rndis_filte_device_add(struct hv_device *dev,
 	return ret;
 }
 
-static int rndis_filter_device_remove(struct hv_device *dev)
+int rndis_filter_device_remove(struct hv_device *dev)
 {
 	struct netvsc_device *net_dev = dev->ext;
 	struct rndis_device *rndis_dev = net_dev->extension;
Signature · 1 line
1.7.4.1
#76 lore raw

PATCH 72/206 Staging: hv: Get rid of rndis_filter_cleanup()

In reply to K. Y. Srinivasan

rndis_filter_cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/rndis_filter.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/staging/hv/rndis_filter.c +0 -6
index 455d440..b0c888e 100644
@@ -84,8 +84,6 @@ struct rndis_filter_packet {
 };
 
 
-static void rndis_filter_cleanup(struct hv_driver *drv);
-
 static int rndis_filter_send(struct hv_device *dev,
 			     struct hv_netvsc_packet *pkt);
 
@@ -621,7 +619,6 @@ int rndis_filter_init(struct netvsc_driver *drv)
 	/* Override */
 	drv->base.dev_add = rndis_filte_device_add;
 	drv->base.dev_rm = rndis_filter_device_remove;
-	drv->base.cleanup = rndis_filter_cleanup;
 	drv->send = rndis_filter_send;
 	drv->recv_cb = rndis_filter_receive;
 
@@ -818,9 +815,6 @@ int rndis_filter_device_remove(struct hv_device *dev)
 	return 0;
 }
 
-static void rndis_filter_cleanup(struct hv_driver *drv)
-{
-}
 
 int rndis_filter_open(struct hv_device *dev)
 {
Signature · 1 line
1.7.4.1
#77 lore raw

PATCH 73/206 Staging: hv: Get rid of the indirection to invoke rndis_filte_device_add()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_drv.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/staging/hv/netvsc_drv.c +1 -4
index f4c6000..d962308 100644
@@ -349,9 +349,6 @@ static int netvsc_probe(struct hv_device *dev)
 	struct netvsc_device_info device_info;
 	int ret;
 
-	if (!net_drv_obj->base.dev_add)
-		return -1;
-
 	net = alloc_etherdev(sizeof(struct net_device_context));
 	if (!net)
 		return -1;
@@ -366,7 +363,7 @@ static int netvsc_probe(struct hv_device *dev)
 	INIT_WORK(&net_device_ctx->work, netvsc_send_garp);
 
 	/* Notify the netvsc driver of the new device */
-	ret = net_drv_obj->base.dev_add(dev, &device_info);
+	ret = rndis_filte_device_add(dev, &device_info);
 	if (ret != 0) {
 		free_netdev(net);
 		dev_set_drvdata(&dev->device, NULL);
Signature · 1 line
1.7.4.1
#78 lore raw

PATCH 74/206 Staging: hv: Get rid of the indirection to invoke netvsc_device_add()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -1
index b0c888e..299b14e 100644
@@ -755,7 +755,7 @@ int rndis_filte_device_add(struct hv_device *dev,
 	 * NOTE! Once the channel is created, we may get a receive callback
 	 * (RndisFilterOnReceive()) before this call is completed
 	 */
-	ret = rndis_filter.inner_drv.base.dev_add(dev, additional_info);
+	ret = netvsc_device_add(dev, additional_info);
 	if (ret != 0) {
 		kfree(rndisDevice);
 		return ret;
Signature · 1 line
1.7.4.1
#79 lore raw

PATCH 75/206 Staging: hv: Get rid of the indirection in invoking rndis_filter_device_remove()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_drv.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
drivers/staging/hv/netvsc_drv.c +2 -9
index d962308..3fc39cd 100644
@@ -342,8 +342,6 @@ static void netvsc_send_garp(struct work_struct *w)
 
 static int netvsc_probe(struct hv_device *dev)
 {
-	struct netvsc_driver *net_drv_obj =
-		drv_to_netvscdrv(dev->device.driver);
 	struct net_device *net = NULL;
 	struct net_device_context *net_device_ctx;
 	struct netvsc_device_info device_info;
@@ -398,7 +396,7 @@ static int netvsc_probe(struct hv_device *dev)
 	ret = register_netdev(net);
 	if (ret != 0) {
 		/* Remove the device and release the resource */
-		net_drv_obj->base.dev_rm(dev);
+		rndis_filter_device_remove(dev);
 		free_netdev(net);
 	}
 
@@ -407,8 +405,6 @@ static int netvsc_probe(struct hv_device *dev)
 
 static int netvsc_remove(struct hv_device *dev)
 {
-	struct netvsc_driver *net_drv_obj =
-		drv_to_netvscdrv(dev->device.driver);
 	struct net_device *net = dev_get_drvdata(&dev->device);
 	int ret;
 
@@ -417,9 +413,6 @@ static int netvsc_remove(struct hv_device *dev)
 		return 0;
 	}
 
-	if (!net_drv_obj->base.dev_rm)
-		return -1;
-
 	/* Stop outbound asap */
 	netif_stop_queue(net);
 	/* netif_carrier_off(net); */
@@ -430,7 +423,7 @@ static int netvsc_remove(struct hv_device *dev)
 	 * Call to the vsc driver to let it know that the device is being
 	 * removed
 	 */
-	ret = net_drv_obj->base.dev_rm(dev);
+	ret = rndis_filter_device_remove(dev);
 	if (ret != 0) {
 		/* TODO: */
 		netdev_err(net, "unable to remove vsc device (ret %d)\n", ret);
Signature · 1 line
1.7.4.1
#80 lore raw

PATCH 76/206 Staging: hv: Get rid of the indirection in invoking netvsc_device_remove()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/rndis_filter.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -2
index 299b14e..f9c18fa 100644
@@ -809,8 +809,7 @@ int rndis_filter_device_remove(struct hv_device *dev)
 	kfree(rndis_dev);
 	net_dev->extension = NULL;
 
-	/* Pass control to inner driver to remove the device */
-	rndis_filter.inner_drv.base.dev_rm(dev);
+	netvsc_device_remove(dev);
 
 	return 0;
 }
Signature · 1 line
1.7.4.1
#81 lore raw

PATCH 77/206 Staging: hv: Get rid of call to cleanup()

In reply to K. Y. Srinivasan

cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/netvsc_drv.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/netvsc_drv.c +0 -4
index 3fc39cd..0e81a93 100644
@@ -444,7 +444,6 @@ static int netvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void netvsc_drv_exit(void)
 {
-	struct netvsc_driver *netvsc_drv_obj = &g_netvsc_drv;
 	struct hv_driver *drv = &g_netvsc_drv.base;
 	struct device *current_dev;
 	int ret;
@@ -466,9 +465,6 @@ static void netvsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (netvsc_drv_obj->base.cleanup)
-		netvsc_drv_obj->base.cleanup(&netvsc_drv_obj->base);
-
 	vmbus_child_driver_unregister(&drv->driver);
 
 	return;
Signature · 1 line
1.7.4.1
#82 lore raw

Re: [PATCH 077/206] Staging: hv: Get rid of call to cleanup()

Quoted 8 lines · K. Y. Srinivasan

cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/netvsc_drv.c |    4 ----

Just picking a random patch out of this series (which, I only received the first 132, not all 206).

You need to specify a better changelog entry as you didn't say what code you are changing in the Subject:.

How about:
Staging: hv: netvsc_drv: Get rid of call to cleanup()

Otherwise I would think (and I did) that you got rid of a global function called cleanup() in all of the hv code.

Care to fix the names of your patches?

Note, I wouldn't recommend sending that many patches to lkml, it's not needed, just stick to the [email protected] list as I really doubt anyone else cares about this code at the moment.

thanks,

greg k-h

#83 lore raw

RE: [PATCH 077/206] Staging: hv: Get rid of call to cleanup()

Quoted 27 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, May 09, 2011 6:53 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang; Abhishek Kane (Mindtree Consulting PVT LTD); Hank Janssen
Subject: Re: [PATCH 077/206] Staging: hv: Get rid of call to cleanup()

Quoted 8 lines · K. Y. Srinivasan

cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/netvsc_drv.c |    4 ----

Just picking a random patch out of this series (which, I only received the first 132, not all 206).

You need to specify a better changelog entry as you didn't say what code you are changing in the Subject:.

Quoted 7 lines

How about:
Staging: hv: netvsc_drv: Get rid of call to cleanup()

Otherwise I would think (and I did) that you got rid of a global function called cleanup() in all of the hv code.

Care to fix the names of your patches?

Good point; I will fix up the names.

Quoted 4 lines

Note, I wouldn't recommend sending that many patches to lkml, it's not needed, just stick to the [email protected] list as I really doubt anyone else cares about this code at the moment.

Agreed; I will do that. Shall I go ahead and fix the names and send the patches just to you or do you want me to send them to the devel list as well.

Regards,

K. Y

Quoted 4 lines

thanks,

greg k-h

#84 lore raw

Re: [PATCH 077/206] Staging: hv: Get rid of call to cleanup()

Quoted 6 lines · KY Srinivasan
Quoted 3 lines

Note, I wouldn't recommend sending that many patches to lkml, it's not needed, just stick to the [email protected] list as I really doubt anyone else cares about this code at the moment.

Agreed; I will do that. Shall I go ahead and fix the names and send the patches just to you or do you want me to send them to the devel list as well.

As they have all failed to show up to the list, it can't hurt to send them all again there as well as to me.

thanks,

greg k-h

#85 lore raw

PATCH 78/206 Staging: hv: Get rid of unnecessary code in netvsc.c

In reply to K. Y. Srinivasan

Now that we had gotten rid of the indirection; get rid of some unnecessary code.

---
 drivers/staging/hv/netvsc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc.c +0 -3
index 34828c4..832f62e 100644
@@ -1184,9 +1184,6 @@ int netvsc_initialize(struct hv_driver *drv)
 	drv->name = driver_name;
 	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
 
-	/* Setup the dispatch table */
-	driver->base.dev_add	= netvsc_device_add;
-	driver->base.dev_rm	= netvsc_device_remove;
 
 	driver->send			= netvsc_send;
 
Signature · 1 line
1.7.4.1
#86 lore raw

PATCH 79/206 Staging: hv: Get rid of some unnecessary code in rndis_filter.c

In reply to K. Y. Srinivasan

Now that we have gotten rid of the indirection; get rid of some unnecessary code.

---
 drivers/staging/hv/rndis_filter.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/staging/hv/rndis_filter.c +0 -7
index f9c18fa..ee74cd1 100644
@@ -606,19 +606,12 @@ int rndis_filter_init(struct netvsc_driver *drv)
 	rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
 
 	/* Save the original dispatch handlers before we override it */
-	rndis_filter.inner_drv.base.dev_add = drv->base.dev_add;
-	rndis_filter.inner_drv.base.dev_rm =
-					drv->base.dev_rm;
-	rndis_filter.inner_drv.base.cleanup = drv->base.cleanup;
-
 	rndis_filter.inner_drv.send = drv->send;
 	rndis_filter.inner_drv.recv_cb = drv->recv_cb;
 	rndis_filter.inner_drv.link_status_change =
 					drv->link_status_change;
 
 	/* Override */
-	drv->base.dev_add = rndis_filte_device_add;
-	drv->base.dev_rm = rndis_filter_device_remove;
 	drv->send = rndis_filter_send;
 	drv->recv_cb = rndis_filter_receive;
 
Signature · 1 line
1.7.4.1
#87 lore raw

PATCH 80/206 Staging: hv: Get rid of the indirection to invoke mousevsc_on_device_add()

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/hv_mouse.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/staging/hv/hv_mouse.c +1 -4
index d49a51e..43f5158 100644
@@ -836,9 +836,6 @@ static int mousevsc_probe(struct hv_device *dev)
 {
 	int ret = 0;
 
-	struct mousevsc_drv_obj *mousevsc_drv_obj =
-		drv_to_mousedrv(dev->device.driver);
-
 	struct input_device_context *input_dev_ctx;
 
 	input_dev_ctx = kmalloc(sizeof(struct input_device_context),
@@ -847,7 +844,7 @@ static int mousevsc_probe(struct hv_device *dev)
 	dev_set_drvdata(&dev->device, input_dev_ctx);
 
 	/* Call to the vsc driver to add the device */
-	ret = mousevsc_drv_obj->base.dev_add(dev, NULL);
+	ret = mousevsc_on_device_add(dev, NULL);
 
 	if (ret != 0) {
 		DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
Signature · 1 line
1.7.4.1
#88 lore raw

PATCH 81/206 Staging: hv: Get rid of the indirection to invoke mousevsc_on_device_remove

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/hv_mouse.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/staging/hv/hv_mouse.c +1 -7
index 43f5158..b7016e2 100644
@@ -859,9 +859,6 @@ static int mousevsc_remove(struct hv_device *dev)
 {
 	int ret = 0;
 
-	struct mousevsc_drv_obj *mousevsc_drv_obj =
-		drv_to_mousedrv(dev->device.driver);
-
 	struct input_device_context *input_dev_ctx;
 
 	input_dev_ctx = kmalloc(sizeof(struct input_device_context),
@@ -874,14 +871,11 @@ static int mousevsc_remove(struct hv_device *dev)
 		input_dev_ctx->connected = 0;
 	}
 
-	if (!mousevsc_drv_obj->base.dev_rm)
-		return -1;
-
 	/*
 	 * Call to the vsc driver to let it know that the device
 	 * is being removed
 	 */
-	ret = mousevsc_drv_obj->base.dev_rm(dev);
+	ret = mousevsc_on_device_remove(dev);
 
 	if (ret != 0) {
 		DPRINT_ERR(INPUTVSC_DRV,
Signature · 1 line
1.7.4.1
#89 lore raw

PATCH 82/206 Staging: hv: Get rid of the mouse cleanup() function

In reply to K. Y. Srinivasan

mousevsc_on_cleanup() is an empty function; get rid of it.

---
 drivers/staging/hv/hv_mouse.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/hv_mouse.c +0 -4
index b7016e2..41bfa3f 100644
@@ -782,9 +782,6 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	return ret;
 }
 
-static void mousevsc_on_cleanup(struct hv_driver *drv)
-{
-}
 
 /*
  * Data types
@@ -994,7 +991,6 @@ static int mouse_vsc_initialize(struct hv_driver *driver)
 	/* Setup the dispatch table */
 	input_drv->base.dev_add = mousevsc_on_device_add;
 	input_drv->base.dev_rm = mousevsc_on_device_remove;
-	input_drv->base.cleanup = mousevsc_on_cleanup;
 
 	return ret;
 }
Signature · 1 line
1.7.4.1
#90 lore raw

PATCH 83/206 Staging: hv: Cleanup mouse_vsc_initialize()

In reply to K. Y. Srinivasan

Now that we have gotten rid of the indirection, cleanup mouse_vsc_initialize().

---
 drivers/staging/hv/hv_mouse.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
drivers/staging/hv/hv_mouse.c +1 -9
index 41bfa3f..523c428 100644
@@ -980,19 +980,11 @@ static void mousevsc_drv_exit(void)
 
 static int mouse_vsc_initialize(struct hv_driver *driver)
 {
-	struct mousevsc_drv_obj *input_drv =
-		(struct mousevsc_drv_obj *)driver;
-	int ret = 0;
-
 	driver->name = driver_name;
 	memcpy(&driver->dev_type, &mouse_guid,
 	       sizeof(struct hv_guid));
 
-	/* Setup the dispatch table */
-	input_drv->base.dev_add = mousevsc_on_device_add;
-	input_drv->base.dev_rm = mousevsc_on_device_remove;
-
-	return ret;
+	return 0;
 }
 
 
Signature · 1 line
1.7.4.1
#91 lore raw

PATCH 84/206 Staging: hv: Get rid of dev_add from struct hv_driver

In reply to K. Y. Srinivasan

Now that we have gotten rid of the indirection, get rid of the unnecessary state struct hv_driver.

---
 drivers/staging/hv/vmbus_api.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/hv/vmbus_api.h +0 -1
index 50fbeb5..b1a7e88 100644
@@ -96,7 +96,6 @@ struct hv_driver {
 
 	struct device_driver driver;
 
-	int (*dev_add)(struct hv_device *device, void *data);
 	int (*dev_rm)(struct hv_device *device);
 	void (*cleanup)(struct hv_driver *driver);
 
Signature · 1 line
1.7.4.1
#92 lore raw

PATCH 85/206 Staging: hv: Get rid of dev_rm from struct hv_driver

In reply to K. Y. Srinivasan

Now that we have gotten rid of the indirection for invoking dev_rm, get rid of this.

---
 drivers/staging/hv/vmbus_api.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/hv/vmbus_api.h +0 -1
index b1a7e88..568ff09 100644
@@ -96,7 +96,6 @@ struct hv_driver {
 
 	struct device_driver driver;
 
-	int (*dev_rm)(struct hv_device *device);
 	void (*cleanup)(struct hv_driver *driver);
 
 	int (*probe)(struct hv_device *);
Signature · 1 line
1.7.4.1
#93 lore raw

PATCH 86/206 Staging: hv: Cleanup calls to cleanup in storvsc_drv.c

In reply to K. Y. Srinivasan

cleanup() is an empty function; get rid of calls to this.

---
 drivers/staging/hv/storvsc_drv.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -4
index 5624d26..0d7e43b 100644
@@ -833,7 +833,6 @@ static int storvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void storvsc_drv_exit(void)
 {
-	struct storvsc_driver *storvsc_drv_obj = &storvsc_drv;
 	struct hv_driver *drv = &storvsc_drv.base;
 	struct device *current_dev = NULL;
 	int ret;
@@ -854,9 +853,6 @@ static void storvsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (storvsc_drv_obj->base.cleanup)
-		storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
-
 	vmbus_child_driver_unregister(&drv->driver);
 	return;
 }
Signature · 1 line
1.7.4.1
#94 lore raw

PATCH 87/206 Staging: hv: Cleanup calls to cleanup() in hv_mouse.c

In reply to K. Y. Srinivasan

Cleanup calls to cleanup() in hv_mouse.c as this is an empty function.

---
 drivers/staging/hv/hv_mouse.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/hv_mouse.c +0 -4
index 523c428..b708663 100644
@@ -947,7 +947,6 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 
 static void mousevsc_drv_exit(void)
 {
-	struct mousevsc_drv_obj *mousevsc_drv_obj = &g_mousevsc_drv;
 	struct hv_driver *drv = &g_mousevsc_drv.base;
 	int ret;
 
@@ -970,9 +969,6 @@ static void mousevsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (mousevsc_drv_obj->base.cleanup)
-		mousevsc_drv_obj->base.cleanup(&mousevsc_drv_obj->base);
-
 	vmbus_child_driver_unregister(&drv->driver);
 
 	return;
Signature · 1 line
1.7.4.1
#95 lore raw

PATCH 88/206 Staging: hv: Get rid of cleanup from struct hv_driver

In reply to K. Y. Srinivasan

Now that we have removed calls to this empty function, get rid of the unnecessary state in struct hv_driver.

---
 drivers/staging/hv/vmbus_api.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/vmbus_api.h +0 -2
index 568ff09..5845436 100644
@@ -96,8 +96,6 @@ struct hv_driver {
 
 	struct device_driver driver;
 
-	void (*cleanup)(struct hv_driver *driver);
-
 	int (*probe)(struct hv_device *);
 	int (*remove)(struct hv_device *);
 	void (*shutdown)(struct hv_device *);
Signature · 1 line
1.7.4.1
#96 lore raw

PATCH 89/206 Staging: hv: Rename the variable g_netvsc_drv

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_drv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/netvsc_drv.c +4 -4
index 0e81a93..25883ca 100644
@@ -61,7 +61,7 @@ module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
 /* The one and only one */
-static struct  netvsc_driver g_netvsc_drv;
+static struct  netvsc_driver netvsc_drv;
 
 /* no-op so the netdev core doesn't return -EINVAL when modifying the the
  * multicast address list in SIOCADDMULTI. hv is setup to get all multicast
@@ -444,7 +444,7 @@ static int netvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void netvsc_drv_exit(void)
 {
-	struct hv_driver *drv = &g_netvsc_drv.base;
+	struct hv_driver *drv = &netvsc_drv.base;
 	struct device *current_dev;
 	int ret;
 
@@ -472,8 +472,8 @@ static void netvsc_drv_exit(void)
 
 static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 {
-	struct netvsc_driver *net_drv_obj = &g_netvsc_drv;
-	struct hv_driver *drv = &g_netvsc_drv.base;
+	struct netvsc_driver *net_drv_obj = &netvsc_drv;
+	struct hv_driver *drv = &netvsc_drv.base;
 	int ret;
 
 	net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
Signature · 1 line
1.7.4.1
#97 lore raw

PATCH 90/206 Staging: hv: Move the declaration of the variable netvsc_drv

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/netvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc_drv.c +3 -3
index 25883ca..566865f 100644
@@ -60,9 +60,6 @@ static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
-/* The one and only one */
-static struct  netvsc_driver netvsc_drv;
-
 /* no-op so the netdev core doesn't return -EINVAL when modifying the the
  * multicast address list in SIOCADDMULTI. hv is setup to get all multicast
  * when it calls RndisFilterOnOpen() */
@@ -442,6 +439,9 @@ static int netvsc_drv_exit_cb(struct device *dev, void *data)
 	return 1;
 }
 
+/* The one and only one */
+static struct  netvsc_driver netvsc_drv;
+
 static void netvsc_drv_exit(void)
 {
 	struct hv_driver *drv = &netvsc_drv.base;
Signature · 1 line
1.7.4.1
#98 lore raw

PATCH 91/206 Staging: hv: Statically initialize probe/remove

In reply to K. Y. Srinivasan

Statically initialize probe/remove.

---
 drivers/staging/hv/netvsc_drv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/netvsc_drv.c +4 -4
index 566865f..c5e7b93 100644
@@ -440,7 +440,10 @@ static int netvsc_drv_exit_cb(struct device *dev, void *data)
 }
 
 /* The one and only one */
-static struct  netvsc_driver netvsc_drv;
+static struct  netvsc_driver netvsc_drv = {
+	.base.probe = netvsc_probe,
+	.base.remove = netvsc_remove,
+};
 
 static void netvsc_drv_exit(void)
 {
@@ -485,9 +488,6 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 
 	drv->driver.name = net_drv_obj->base.name;
 
-	drv->probe = netvsc_probe;
-	drv->remove = netvsc_remove;
-
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
 
Signature · 1 line
1.7.4.1
#99 lore raw

PATCH 92/206 Staging: hv: Rename the variable g_mousevsc_drv

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/hv_mouse.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/hv_mouse.c +4 -4
index b708663..cc3c1d4 100644
@@ -794,7 +794,7 @@ struct input_device_context {
 };
 
 
-static struct  mousevsc_drv_obj g_mousevsc_drv;
+static struct  mousevsc_drv_obj mousevsc_drv;
 
 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
 {
@@ -947,7 +947,7 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 
 static void mousevsc_drv_exit(void)
 {
-	struct hv_driver *drv = &g_mousevsc_drv.base;
+	struct hv_driver *drv = &mousevsc_drv.base;
 	int ret;
 
 	struct device *current_dev = NULL;
@@ -986,8 +986,8 @@ static int mouse_vsc_initialize(struct hv_driver *driver)
 
 static int __init mousevsc_init(void)
 {
-	struct mousevsc_drv_obj *input_drv_obj = &g_mousevsc_drv;
-	struct hv_driver *drv = &g_mousevsc_drv.base;
+	struct mousevsc_drv_obj *input_drv_obj = &mousevsc_drv;
+	struct hv_driver *drv = &mousevsc_drv.base;
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
Signature · 1 line
1.7.4.1
#100 lore raw

PATCH 93/206 Staging: hv: Move the declaration of the variable mousevsc_drv

In reply to K. Y. Srinivasan

Move the declaration of the variable mousevsc_drv.

---
 drivers/staging/hv/hv_mouse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/hv_mouse.c +2 -2
index cc3c1d4..c5e50b4 100644
@@ -794,8 +794,6 @@ struct input_device_context {
 };
 
 
-static struct  mousevsc_drv_obj mousevsc_drv;
-
 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
 {
 	struct input_device_context *input_device_ctx =
@@ -945,6 +943,8 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 	return 1;
 }
 
+static struct  mousevsc_drv_obj mousevsc_drv;
+
 static void mousevsc_drv_exit(void)
 {
 	struct hv_driver *drv = &mousevsc_drv.base;
Signature · 1 line
1.7.4.1
#101 lore raw

PATCH 94/206 Staging: hv: Statically initialize probe/remove

In reply to K. Y. Srinivasan

Statically initialize probe/remove.

---
 drivers/staging/hv/hv_mouse.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/hv_mouse.c +4 -4
index c5e50b4..4475534 100644
@@ -943,7 +943,10 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 	return 1;
 }
 
-static struct  mousevsc_drv_obj mousevsc_drv;
+static struct  mousevsc_drv_obj mousevsc_drv = {
+	.base.probe = mousevsc_probe,
+	.base.remove = mousevsc_remove,
+};
 
 static void mousevsc_drv_exit(void)
 {
@@ -996,9 +999,6 @@ static int __init mousevsc_init(void)
 
 	drv->driver.name = input_drv_obj->base.name;
 
-	drv->probe = mousevsc_probe;
-	drv->remove = mousevsc_remove;
-
 	/* The driver belongs to vmbus */
 	vmbus_child_driver_register(&drv->driver);
 
Signature · 1 line
1.7.4.1
#102 lore raw

PATCH 95/206 Staging: hv: Rename the function ringbuffer_init

In reply to K. Y. Srinivasan

Rename the function ringbuffer_init to not pollute the namespace.

---
 drivers/staging/hv/channel.c     |    7 +++++--
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    3 ++-
 3 files changed, 9 insertions(+), 5 deletions(-)
drivers/staging/hv/channel.c +5 -2
index b53be58..43e54b5 100644
@@ -201,13 +201,16 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
 					   recv_ringbuffer_size) >> PAGE_SHIFT;
 
-	ret = ringbuffer_init(&newchannel->outbound, out, send_ringbuffer_size);
+	ret = hv_ringbuffer_init(
+		&newchannel->outbound, out, send_ringbuffer_size);
+
 	if (ret != 0) {
 		err = ret;
 		goto errorout;
 	}
 
-	ret = ringbuffer_init(&newchannel->inbound, in, recv_ringbuffer_size);
+	ret = hv_ringbuffer_init(
+		&newchannel->inbound, in, recv_ringbuffer_size);
 	if (ret != 0) {
 		err = ret;
 		goto errorout;
drivers/staging/hv/ring_buffer.c +2 -2
index 66e1b3f..9653ab5 100644
@@ -299,13 +299,13 @@ u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
 /*++
 
 Name:
-	ringbuffer_init()
+	hv_ringbuffer_init()
 
 Description:
 	Initialize the ring buffer
 
 --*/
-int ringbuffer_init(struct hv_ring_buffer_info *ring_info,
+int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
 		   void *buffer, u32 buflen)
 {
 	if (sizeof(struct hv_ring_buffer) != PAGE_SIZE)
drivers/staging/hv/ring_buffer.h +2 -1
index 7bf20d6..3c66dc0 100644
@@ -18,6 +18,7 @@
  * Authors:
  *   Haiyang Zhang <[email protected]>
  *   Hank Janssen  <[email protected]>
+ *   K. Y. Srinivasan <[email protected]>
  *
  */
 
@@ -75,7 +76,7 @@ struct hv_ring_buffer_debug_info {
 /* Interface */
 
 
-int ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
+int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
 		   u32 buflen);
 
 void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
Signature · 1 line
1.7.4.1
#103 lore raw

PATCH 96/206 Staging: hv: Rename ringbuffer_cleanup

In reply to K. Y. Srinivasan

Rename ringbuffer_cleanup.

---
 drivers/staging/hv/channel.c     |    8 ++++----
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/hv/channel.c +4 -4
index 43e54b5..44b81e8 100644
@@ -292,8 +292,8 @@ Cleanup:
 	return err;
 
 errorout:
-	ringbuffer_cleanup(&newchannel->outbound);
-	ringbuffer_cleanup(&newchannel->inbound);
+	hv_ringbuffer_cleanup(&newchannel->outbound);
+	hv_ringbuffer_cleanup(&newchannel->inbound);
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
 	kfree(openInfo);
@@ -651,8 +651,8 @@ void vmbus_close(struct vmbus_channel *channel)
 	/* TODO: Send a msg to release the childRelId */
 
 	/* Cleanup the ring buffers for this channel */
-	ringbuffer_cleanup(&channel->outbound);
-	ringbuffer_cleanup(&channel->inbound);
+	hv_ringbuffer_cleanup(&channel->outbound);
+	hv_ringbuffer_cleanup(&channel->inbound);
 
 	free_pages((unsigned long)channel->ringbuffer_pages,
 		get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
drivers/staging/hv/ring_buffer.c +2 -2
index 9653ab5..9bab40c 100644
@@ -328,13 +328,13 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
 /*++
 
 Name:
-	ringbuffer_cleanup()
+	hv_ringbuffer_cleanup()
 
 Description:
 	Cleanup the ring buffer
 
 --*/
-void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
+void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
 {
 }
 
drivers/staging/hv/ring_buffer.h +1 -1
index 3c66dc0..66d9a2d 100644
@@ -79,7 +79,7 @@ struct hv_ring_buffer_debug_info {
 int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
 		   u32 buflen);
 
-void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
+void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
 
 int ringbuffer_write(struct hv_ring_buffer_info *ring_info,
 		    struct scatterlist *sglist,
Signature · 1 line
1.7.4.1
#104 lore raw

PATCH 97/206 Staging: hv: Rename ringbuffer_write

In reply to K. Y. Srinivasan

Rename ringbuffer_write.

---
 drivers/staging/hv/channel.c     |    6 +++---
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/hv/channel.c +3 -3
index 44b81e8..859771c 100644
@@ -718,7 +718,7 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
 	sg_set_buf(&bufferlist[2], &aligned_data,
 		   packetlen_aligned - packetlen);
 
-	ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
@@ -783,7 +783,7 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
 	sg_set_buf(&bufferlist[2], &aligned_data,
 		packetlen_aligned - packetlen);
 
-	ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
@@ -848,7 +848,7 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 	sg_set_buf(&bufferlist[2], &aligned_data,
 		packetlen_aligned - packetlen);
 
-	ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
drivers/staging/hv/ring_buffer.c +2 -2
index 9bab40c..483678c 100644
@@ -341,13 +341,13 @@ void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	ringbuffer_write()
+	hv_ringbuffer_write()
 
 Description:
 	Write to the ring buffer
 
 --*/
-int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
+int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 		    struct scatterlist *sglist, u32 sgcount)
 {
 	int i = 0;
drivers/staging/hv/ring_buffer.h +1 -1
index 66d9a2d..5c17288 100644
@@ -81,7 +81,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
 
 void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
 
-int ringbuffer_write(struct hv_ring_buffer_info *ring_info,
+int hv_ringbuffer_write(struct hv_ring_buffer_info *ring_info,
 		    struct scatterlist *sglist,
 		    u32 sgcount);
 
Signature · 1 line
1.7.4.1
#105 lore raw

PATCH 98/206 Staging: hv: Rename ringbuffer_peek

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c     |    4 ++--
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/channel.c +2 -2
index 859771c..d625517 100644
@@ -885,7 +885,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 
 	spin_lock_irqsave(&channel->inbound_lock, flags);
 
-	ret = ringbuffer_peek(&channel->inbound, &desc,
+	ret = hv_ringbuffer_peek(&channel->inbound, &desc,
 			     sizeof(struct vmpacket_descriptor));
 	if (ret != 0) {
 		spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -938,7 +938,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 
 	spin_lock_irqsave(&channel->inbound_lock, flags);
 
-	ret = ringbuffer_peek(&channel->inbound, &desc,
+	ret = hv_ringbuffer_peek(&channel->inbound, &desc,
 			     sizeof(struct vmpacket_descriptor));
 	if (ret != 0) {
 		spin_unlock_irqrestore(&channel->inbound_lock, flags);
drivers/staging/hv/ring_buffer.c +2 -2
index 483678c..bf04397 100644
@@ -418,13 +418,13 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 /*++
 
 Name:
-	ringbuffer_peek()
+	hv_ringbuffer_peek()
 
 Description:
 	Read without advancing the read index
 
 --*/
-int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
+int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 		   void *Buffer, u32 buflen)
 {
 	u32 bytes_avail_towrite;
drivers/staging/hv/ring_buffer.h +1 -1
index 5c17288..c684d97 100644
@@ -85,7 +85,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *ring_info,
 		    struct scatterlist *sglist,
 		    u32 sgcount);
 
-int ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
+int hv_ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
 		   u32 buflen);
 
 int ringbuffer_read(struct hv_ring_buffer_info *ring_info,
Signature · 1 line
1.7.4.1
#106 lore raw

PATCH 99/206 Staging: hv: Rename ringbuffer_read

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c     |    4 ++--
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/channel.c +2 -2
index d625517..9f8bed2 100644
@@ -911,7 +911,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	*requestid = desc.trans_id;
 
 	/* Copy over the packet to the user buffer */
-	ret = ringbuffer_read(&channel->inbound, buffer, userlen,
+	ret = hv_ringbuffer_read(&channel->inbound, buffer, userlen,
 			     (desc.offset8 << 3));
 
 	spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -964,7 +964,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	*requestid = desc.trans_id;
 
 	/* Copy over the entire packet to the user buffer */
-	ret = ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
+	ret = hv_ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
 
 	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 	return 0;
drivers/staging/hv/ring_buffer.c +2 -2
index bf04397..2a05059 100644
@@ -468,13 +468,13 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 /*++
 
 Name:
-	ringbuffer_read()
+	hv_ringbuffer_read()
 
 Description:
 	Read and advance the read index
 
 --*/
-int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
+int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 		   u32 buflen, u32 offset)
 {
 	u32 bytes_avail_towrite;
drivers/staging/hv/ring_buffer.h +1 -1
index c684d97..0ebf3be 100644
@@ -88,7 +88,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *ring_info,
 int hv_ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
 		   u32 buflen);
 
-int ringbuffer_read(struct hv_ring_buffer_info *ring_info,
+int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info,
 		   void *buffer,
 		   u32 buflen,
 		   u32 offset);
Signature · 1 line
1.7.4.1
#107 lore raw

PATCH 100/206 Staging: hv: Rename get_ringbuffer_interrupt_mask

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c     |    6 +++---
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/hv/channel.c +3 -3
index 9f8bed2..3274b29 100644
@@ -721,7 +721,7 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
 	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+	if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
 		vmbus_setevent(channel);
 
 	return ret;
@@ -786,7 +786,7 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
 	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+	if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
 		vmbus_setevent(channel);
 
 	return ret;
@@ -851,7 +851,7 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+	if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
 		vmbus_setevent(channel);
 
 	return ret;
drivers/staging/hv/ring_buffer.c +2 -2
index 2a05059..013b7a5 100644
@@ -285,13 +285,13 @@ void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 /*++
 
 Name:
-	get_ringbuffer_interrupt_mask()
+	hv_get_ringbuffer_interrupt_mask()
 
 Description:
 	Get the interrupt mask for the specified ring buffer
 
 --*/
-u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
+u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
 {
 	return rbi->ring_buffer->interrupt_mask;
 }
drivers/staging/hv/ring_buffer.h +1 -1
index 0ebf3be..6454105 100644
@@ -93,7 +93,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info,
 		   u32 buflen,
 		   u32 offset);
 
-u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
+u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
 
 void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
 
Signature · 1 line
1.7.4.1
#108 lore raw

PATCH 101/206 Staging: hv: Rename dump_ring_info

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c     |    4 ++--
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/channel.c +2 -2
index 3274b29..be4e004 100644
@@ -1001,6 +1001,6 @@ void vmbus_ontimer(unsigned long data)
 static void dump_vmbus_channel(struct vmbus_channel *channel)
 {
 	DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
-	dump_ring_info(&channel->outbound, "Outbound ");
-	dump_ring_info(&channel->inbound, "Inbound ");
+	hv_dump_ring_info(&channel->outbound, "Outbound ");
+	hv_dump_ring_info(&channel->inbound, "Inbound ");
 }
drivers/staging/hv/ring_buffer.c +2 -2
index 013b7a5..abf0091 100644
@@ -203,13 +203,13 @@ get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	dump_ring_info()
+	hv_dump_ring_info()
 
 Description:
 	Dump out to console the ring buffer info
 
 --*/
-void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
+void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 {
 	u32 bytes_avail_towrite;
 	u32 bytes_avail_toread;
drivers/staging/hv/ring_buffer.h +1 -1
index 6454105..61470a3 100644
@@ -95,7 +95,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info,
 
 u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
 
-void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
+void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
 
 void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 			    struct hv_ring_buffer_debug_info *debug_info);
Signature · 1 line
1.7.4.1
#109 lore raw

PATCH 102/206 Staging: hv: Rename ringbuffer_get_debuginfo

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c     |    4 ++--
 drivers/staging/hv/ring_buffer.c |    4 ++--
 drivers/staging/hv/ring_buffer.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/channel.c +2 -2
index be4e004..5fcf9d3 100644
@@ -162,8 +162,8 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 			monitorpage->parameter[monitor_group]
 					[monitor_offset].connectionid.u.id;
 
-	ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
-	ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
+	hv_ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
+	hv_ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
 }
 
 /*
drivers/staging/hv/ring_buffer.c +2 -2
index abf0091..7fbadb1 100644
@@ -253,13 +253,13 @@ copyfrom_ringbuffer(
 /*++
 
 Name:
-	ringbuffer_get_debuginfo()
+	hv_ringbuffer_get_debuginfo()
 
 Description:
 	Get various debug metrics for the specified ring buffer
 
 --*/
-void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
+void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 			    struct hv_ring_buffer_debug_info *debug_info)
 {
 	u32 bytes_avail_towrite;
drivers/staging/hv/ring_buffer.h +1 -1
index 61470a3..1bc0b8a 100644
@@ -97,7 +97,7 @@ u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
 
 void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
 
-void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
+void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 			    struct hv_ring_buffer_debug_info *debug_info);
 
 #endif /* _RING_BUFFER_H_ */
Signature · 1 line
1.7.4.1
#110 lore raw

PATCH 103/206 Staging: hv: Rename all static functions in ring_buffer.c

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/ring_buffer.c |   88 +++++++++++++++++++-------------------
 1 files changed, 44 insertions(+), 44 deletions(-)
drivers/staging/hv/ring_buffer.c +44 -44
index 7fbadb1..f4707f8 100644
@@ -38,7 +38,7 @@
 /*++
 
 Name:
-	get_ringbuffer_availbytes()
+	hv_get_ringbuffer_availbytes()
 
 Description:
 	Get number of bytes available to read and to write to
@@ -46,7 +46,7 @@ Description:
 
 --*/
 static inline void
-get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
+hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
 			  u32 *read, u32 *write)
 {
 	u32 read_loc, write_loc;
@@ -62,14 +62,14 @@ get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
 /*++
 
 Name:
-	get_next_write_location()
+	hv_get_next_write_location()
 
 Description:
 	Get the next write location for the specified ring buffer
 
 --*/
 static inline u32
-get_next_write_location(struct hv_ring_buffer_info *ring_info)
+hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
 {
 	u32 next = ring_info->ring_buffer->write_index;
 
@@ -81,14 +81,14 @@ get_next_write_location(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	set_next_write_location()
+	hv_set_next_write_location()
 
 Description:
 	Set the next write location for the specified ring buffer
 
 --*/
 static inline void
-set_next_write_location(struct hv_ring_buffer_info *ring_info,
+hv_set_next_write_location(struct hv_ring_buffer_info *ring_info,
 		     u32 next_write_location)
 {
 	ring_info->ring_buffer->write_index = next_write_location;
@@ -97,14 +97,14 @@ set_next_write_location(struct hv_ring_buffer_info *ring_info,
 /*++
 
 Name:
-	get_next_read_location()
+	hv_get_next_read_location()
 
 Description:
 	Get the next read location for the specified ring buffer
 
 --*/
 static inline u32
-get_next_read_location(struct hv_ring_buffer_info *ring_info)
+hv_get_next_read_location(struct hv_ring_buffer_info *ring_info)
 {
 	u32 next = ring_info->ring_buffer->read_index;
 
@@ -116,7 +116,7 @@ get_next_read_location(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	get_next_readlocation_withoffset()
+	hv_get_next_readlocation_withoffset()
 
 Description:
 	Get the next read location + offset for the specified ring buffer.
@@ -124,7 +124,7 @@ Description:
 
 --*/
 static inline u32
-get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
+hv_get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
 				 u32 offset)
 {
 	u32 next = ring_info->ring_buffer->read_index;
@@ -139,14 +139,14 @@ get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
 /*++
 
 Name:
-	set_next_read_location()
+	hv_set_next_read_location()
 
 Description:
 	Set the next read location for the specified ring buffer
 
 --*/
 static inline void
-set_next_read_location(struct hv_ring_buffer_info *ring_info,
+hv_set_next_read_location(struct hv_ring_buffer_info *ring_info,
 		    u32 next_read_location)
 {
 	ring_info->ring_buffer->read_index = next_read_location;
@@ -156,14 +156,14 @@ set_next_read_location(struct hv_ring_buffer_info *ring_info,
 /*++
 
 Name:
-	get_ring_buffer()
+	hv_get_ring_buffer()
 
 Description:
 	Get the start of the ring buffer
 
 --*/
 static inline void *
-get_ring_buffer(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
 {
 	return (void *)ring_info->ring_buffer->buffer;
 }
@@ -172,14 +172,14 @@ get_ring_buffer(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	get_ring_buffersize()
+	hv_get_ring_buffersize()
 
 Description:
 	Get the size of the ring buffer
 
 --*/
 static inline u32
-get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
 {
 	return ring_info->ring_datasize;
 }
@@ -187,14 +187,14 @@ get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
 /*++
 
 Name:
-	get_ring_bufferindices()
+	hv_get_ring_bufferindices()
 
 Description:
 	Get the read and write indices as u64 of the specified ring buffer
 
 --*/
 static inline u64
-get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
 {
 	return (u64)ring_info->ring_buffer->write_index << 32;
 }
@@ -214,7 +214,7 @@ void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 	u32 bytes_avail_towrite;
 	u32 bytes_avail_toread;
 
-	get_ringbuffer_availbytes(ring_info,
+	hv_get_ringbuffer_availbytes(ring_info,
 	&bytes_avail_toread,
 	&bytes_avail_towrite);
 
@@ -235,14 +235,14 @@ void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 /* Internal routines */
 
 static u32
-copyto_ringbuffer(
+hv_copyto_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
 	u32				start_write_offset,
 	void				*src,
 	u32				srclen);
 
 static u32
-copyfrom_ringbuffer(
+hv_copyfrom_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
 	void				*dest,
 	u32				destlen,
@@ -266,7 +266,7 @@ void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 	u32 bytes_avail_toread;
 
 	if (ring_info->ring_buffer) {
-		get_ringbuffer_availbytes(ring_info,
+		hv_get_ringbuffer_availbytes(ring_info,
 					&bytes_avail_toread,
 					&bytes_avail_towrite);
 
@@ -369,7 +369,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 
 	spin_lock_irqsave(&outring_info->ring_lock, flags);
 
-	get_ringbuffer_availbytes(outring_info,
+	hv_get_ringbuffer_availbytes(outring_info,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
@@ -384,20 +384,20 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	}
 
 	/* Write to the ring buffer */
-	next_write_location = get_next_write_location(outring_info);
+	next_write_location = hv_get_next_write_location(outring_info);
 
 	for_each_sg(sglist, sg, sgcount, i)
 	{
-		next_write_location = copyto_ringbuffer(outring_info,
+		next_write_location = hv_copyto_ringbuffer(outring_info,
 						     next_write_location,
 						     sg_virt(sg),
 						     sg->length);
 	}
 
 	/* Set previous packet start */
-	prev_indices = get_ring_bufferindices(outring_info);
+	prev_indices = hv_get_ring_bufferindices(outring_info);
 
-	next_write_location = copyto_ringbuffer(outring_info,
+	next_write_location = hv_copyto_ringbuffer(outring_info,
 					     next_write_location,
 					     &prev_indices,
 					     sizeof(u64));
@@ -406,7 +406,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	mb();
 
 	/* Now, update the write location */
-	set_next_write_location(outring_info, next_write_location);
+	hv_set_next_write_location(outring_info, next_write_location);
 
 	/* Dumpring_info(Outring_info, "AFTER "); */
 
@@ -434,7 +434,7 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
 	spin_lock_irqsave(&Inring_info->ring_lock, flags);
 
-	get_ringbuffer_availbytes(Inring_info,
+	hv_get_ringbuffer_availbytes(Inring_info,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
@@ -452,9 +452,9 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 	}
 
 	/* Convert to byte offset */
-	next_read_location = get_next_read_location(Inring_info);
+	next_read_location = hv_get_next_read_location(Inring_info);
 
-	next_read_location = copyfrom_ringbuffer(Inring_info,
+	next_read_location = hv_copyfrom_ringbuffer(Inring_info,
 						Buffer,
 						buflen,
 						next_read_location);
@@ -488,7 +488,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 
 	spin_lock_irqsave(&inring_info->ring_lock, flags);
 
-	get_ringbuffer_availbytes(inring_info,
+	hv_get_ringbuffer_availbytes(inring_info,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
@@ -502,14 +502,14 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	}
 
 	next_read_location =
-		get_next_readlocation_withoffset(inring_info, offset);
+		hv_get_next_readlocation_withoffset(inring_info, offset);
 
-	next_read_location = copyfrom_ringbuffer(inring_info,
+	next_read_location = hv_copyfrom_ringbuffer(inring_info,
 						buffer,
 						buflen,
 						next_read_location);
 
-	next_read_location = copyfrom_ringbuffer(inring_info,
+	next_read_location = hv_copyfrom_ringbuffer(inring_info,
 						&prev_indices,
 						sizeof(u64),
 						next_read_location);
@@ -520,7 +520,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	mb();
 
 	/* Update the read index */
-	set_next_read_location(inring_info, next_read_location);
+	hv_set_next_read_location(inring_info, next_read_location);
 
 	/* Dumpring_info(Inring_info, "AFTER "); */
 
@@ -533,7 +533,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 /*++
 
 Name:
-	copyto_ringbuffer()
+	hv_copyto_ringbuffer()
 
 Description:
 	Helper routine to copy from source to ring buffer.
@@ -541,14 +541,14 @@ Description:
 
 --*/
 static u32
-copyto_ringbuffer(
+hv_copyto_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
 	u32				start_write_offset,
 	void				*src,
 	u32				srclen)
 {
-	void *ring_buffer = get_ring_buffer(ring_info);
-	u32 ring_buffer_size = get_ring_buffersize(ring_info);
+	void *ring_buffer = hv_get_ring_buffer(ring_info);
+	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
 	u32 frag_len;
 
 	/* wrap-around detected! */
@@ -569,7 +569,7 @@ copyto_ringbuffer(
 /*++
 
 Name:
-	copyfrom_ringbuffer()
+	hv_copyfrom_ringbuffer()
 
 Description:
 	Helper routine to copy to source from ring buffer.
@@ -577,14 +577,14 @@ Description:
 
 --*/
 static u32
-copyfrom_ringbuffer(
+hv_copyfrom_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
 	void				*dest,
 	u32				destlen,
 	u32				start_read_offset)
 {
-	void *ring_buffer = get_ring_buffer(ring_info);
-	u32 ring_buffer_size = get_ring_buffersize(ring_info);
+	void *ring_buffer = hv_get_ring_buffer(ring_info);
+	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
 
 	u32 frag_len;
 
Signature · 1 line
1.7.4.1
#111 lore raw

PATCH 104/206 Staging: hv: Cleanup comments in ring_buffer.c

In reply to K. Y. Srinivasan

Cleanup comments in ring_buffer.c

---
 drivers/staging/hv/ring_buffer.c |  323 +++++++++++++++-----------------------
 1 files changed, 129 insertions(+), 194 deletions(-)
drivers/staging/hv/ring_buffer.c +129 -194
index f4707f8..8544516 100644
@@ -18,6 +18,7 @@
  * Authors:
  *   Haiyang Zhang <[email protected]>
  *   Hank Janssen  <[email protected]>
+ *   K. Y. Srinivasan <[email protected]>
  *
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -35,16 +36,13 @@
 #define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))
 
 
-/*++
-
-Name:
-	hv_get_ringbuffer_availbytes()
-
-Description:
-	Get number of bytes available to read and to write to
-	for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_get_ringbuffer_availbytes()
+ *
+ * Get number of bytes available to read and to write to
+ * for the specified ring buffer
+ */
 static inline void
 hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
 			  u32 *read, u32 *write)
@@ -59,34 +57,26 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
 	*read = rbi->ring_datasize - *write;
 }
 
-/*++
-
-Name:
-	hv_get_next_write_location()
-
-Description:
-	Get the next write location for the specified ring buffer
-
---*/
+/*
+ * hv_get_next_write_location()
+ *
+ * Get the next write location for the specified ring buffer
+ *
+ */
 static inline u32
 hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
 {
 	u32 next = ring_info->ring_buffer->write_index;
 
-	/* ASSERT(next < ring_info->RingDataSize); */
-
 	return next;
 }
 
-/*++
-
-Name:
-	hv_set_next_write_location()
-
-Description:
-	Set the next write location for the specified ring buffer
-
---*/
+/*
+ * hv_set_next_write_location()
+ *
+ * Set the next write location for the specified ring buffer
+ *
+ */
 static inline void
 hv_set_next_write_location(struct hv_ring_buffer_info *ring_info,
 		     u32 next_write_location)
@@ -94,57 +84,44 @@ hv_set_next_write_location(struct hv_ring_buffer_info *ring_info,
 	ring_info->ring_buffer->write_index = next_write_location;
 }
 
-/*++
-
-Name:
-	hv_get_next_read_location()
-
-Description:
-	Get the next read location for the specified ring buffer
-
---*/
+/*
+ * hv_get_next_read_location()
+ *
+ * Get the next read location for the specified ring buffer
+ */
 static inline u32
 hv_get_next_read_location(struct hv_ring_buffer_info *ring_info)
 {
 	u32 next = ring_info->ring_buffer->read_index;
 
-	/* ASSERT(next < ring_info->RingDataSize); */
-
 	return next;
 }
 
-/*++
-
-Name:
-	hv_get_next_readlocation_withoffset()
-
-Description:
-	Get the next read location + offset for the specified ring buffer.
-	This allows the caller to skip
-
---*/
+/*
+ * hv_get_next_readlocation_withoffset()
+ *
+ * Get the next read location + offset for the specified ring buffer.
+ * This allows the caller to skip
+ */
 static inline u32
 hv_get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
 				 u32 offset)
 {
 	u32 next = ring_info->ring_buffer->read_index;
 
-	/* ASSERT(next < ring_info->RingDataSize); */
 	next += offset;
 	next %= ring_info->ring_datasize;
 
 	return next;
 }
 
-/*++
-
-Name:
-	hv_set_next_read_location()
-
-Description:
-	Set the next read location for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_set_next_read_location()
+ *
+ * Set the next read location for the specified ring buffer
+ *
+ */
 static inline void
 hv_set_next_read_location(struct hv_ring_buffer_info *ring_info,
 		    u32 next_read_location)
@@ -153,15 +130,12 @@ hv_set_next_read_location(struct hv_ring_buffer_info *ring_info,
 }
 
 
-/*++
-
-Name:
-	hv_get_ring_buffer()
-
-Description:
-	Get the start of the ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_buffer()
+ *
+ * Get the start of the ring buffer
+ */
 static inline void *
 hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
 {
@@ -169,30 +143,25 @@ hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
 }
 
 
-/*++
-
-Name:
-	hv_get_ring_buffersize()
-
-Description:
-	Get the size of the ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_buffersize()
+ *
+ * Get the size of the ring buffer
+ */
 static inline u32
 hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
 {
 	return ring_info->ring_datasize;
 }
 
-/*++
-
-Name:
-	hv_get_ring_bufferindices()
-
-Description:
-	Get the read and write indices as u64 of the specified ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_bufferindices()
+ *
+ * Get the read and write indices as u64 of the specified ring buffer
+ *
+ */
 static inline u64
 hv_get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
 {
@@ -200,15 +169,13 @@ hv_get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
 }
 
 
-/*++
-
-Name:
-	hv_dump_ring_info()
-
-Description:
-	Dump out to console the ring buffer info
-
---*/
+/*
+ *
+ * hv_dump_ring_info()
+ *
+ * Dump out to console the ring buffer info
+ *
+ */
 void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 {
 	u32 bytes_avail_towrite;
@@ -232,7 +199,6 @@ void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 }
 
 
-/* Internal routines */
 
 static u32
 hv_copyto_ringbuffer(
@@ -250,15 +216,13 @@ hv_copyfrom_ringbuffer(
 
 
 
-/*++
-
-Name:
-	hv_ringbuffer_get_debuginfo()
-
-Description:
-	Get various debug metrics for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_ringbuffer_get_debuginfo()
+ *
+ * Get various debug metrics for the specified ring buffer
+ *
+ */
 void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 			    struct hv_ring_buffer_debug_info *debug_info)
 {
@@ -282,29 +246,25 @@ void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 }
 
 
-/*++
-
-Name:
-	hv_get_ringbuffer_interrupt_mask()
-
-Description:
-	Get the interrupt mask for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_get_ringbuffer_interrupt_mask()
+ *
+ * Get the interrupt mask for the specified ring buffer
+ *
+ */
 u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
 {
 	return rbi->ring_buffer->interrupt_mask;
 }
 
-/*++
-
-Name:
-	hv_ringbuffer_init()
-
-Description:
-	Initialize the ring buffer
-
---*/
+/*
+ *
+ * hv_ringbuffer_init()
+ *
+ *Initialize the ring buffer
+ *
+ */
 int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
 		   void *buffer, u32 buflen)
 {
@@ -325,28 +285,24 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
 	return 0;
 }
 
-/*++
-
-Name:
-	hv_ringbuffer_cleanup()
-
-Description:
-	Cleanup the ring buffer
-
---*/
+/*
+ *
+ * hv_ringbuffer_cleanup()
+ *
+ * Cleanup the ring buffer
+ *
+ */
 void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
 {
 }
 
-/*++
-
-Name:
-	hv_ringbuffer_write()
-
-Description:
-	Write to the ring buffer
-
---*/
+/*
+ *
+ * hv_ringbuffer_write()
+ *
+ * Write to the ring buffer
+ *
+ */
 int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 		    struct scatterlist *sglist, u32 sgcount)
 {
@@ -373,7 +329,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
-	/* Dumpring_info(Outring_info, "BEFORE "); */
 
 	/* If there is only room for the packet, assume it is full. */
 	/* Otherwise, the next time around, we think the ring buffer */
@@ -408,22 +363,19 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	/* Now, update the write location */
 	hv_set_next_write_location(outring_info, next_write_location);
 
-	/* Dumpring_info(Outring_info, "AFTER "); */
 
 	spin_unlock_irqrestore(&outring_info->ring_lock, flags);
 	return 0;
 }
 
 
-/*++
-
-Name:
-	hv_ringbuffer_peek()
-
-Description:
-	Read without advancing the read index
-
---*/
+/*
+ *
+ * hv_ringbuffer_peek()
+ *
+ * Read without advancing the read index
+ *
+ */
 int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 		   void *Buffer, u32 buflen)
 {
@@ -440,11 +392,6 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
 	/* Make sure there is something to read */
 	if (bytes_avail_toread < buflen) {
-		/* DPRINT_DBG(VMBUS,
-			"got callback but not enough to read "
-			"<avail to read %d read size %d>!!",
-			bytes_avail_toread,
-			BufferLen); */
 
 		spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
 
@@ -465,15 +412,13 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 }
 
 
-/*++
-
-Name:
-	hv_ringbuffer_read()
-
-Description:
-	Read and advance the read index
-
---*/
+/*
+ *
+ * hv_ringbuffer_read()
+ *
+ * Read and advance the read index
+ *
+ */
 int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 		   u32 buflen, u32 offset)
 {
@@ -492,8 +437,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
-	/* Dumpring_info(Inring_info, "BEFORE "); */
-
 	/* Make sure there is something to read */
 	if (bytes_avail_toread < buflen) {
 		spin_unlock_irqrestore(&inring_info->ring_lock, flags);
@@ -522,24 +465,20 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	/* Update the read index */
 	hv_set_next_read_location(inring_info, next_read_location);
 
-	/* Dumpring_info(Inring_info, "AFTER "); */
-
 	spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
 	return 0;
 }
 
 
-/*++
-
-Name:
-	hv_copyto_ringbuffer()
-
-Description:
-	Helper routine to copy from source to ring buffer.
-	Assume there is enough room. Handles wrap-around in dest case only!!
-
---*/
+/*
+ *
+ * hv_copyto_ringbuffer()
+ *
+ * Helper routine to copy from source to ring buffer.
+ * Assume there is enough room. Handles wrap-around in dest case only!!
+ *
+ */
 static u32
 hv_copyto_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
@@ -566,16 +505,14 @@ hv_copyto_ringbuffer(
 }
 
 
-/*++
-
-Name:
-	hv_copyfrom_ringbuffer()
-
-Description:
-	Helper routine to copy to source from ring buffer.
-	Assume there is enough room. Handles wrap-around in src case only!!
-
---*/
+/*
+ *
+ * hv_copyfrom_ringbuffer()
+ *
+ * Helper routine to copy to source from ring buffer.
+ * Assume there is enough room. Handles wrap-around in src case only!!
+ *
+ */
 static u32
 hv_copyfrom_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
@@ -605,5 +542,3 @@ hv_copyfrom_ringbuffer(
 	return start_read_offset;
 }
 
-
-/* eof */
Signature · 1 line
1.7.4.1
#112 lore raw

PATCH 105/206 Staging: hv: Get rid of the forward declaration of hv_copyfrom_ringbuffer

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving code around.

---
 drivers/staging/hv/ring_buffer.c |   83 +++++++++++++++++---------------------
 1 files changed, 37 insertions(+), 46 deletions(-)
drivers/staging/hv/ring_buffer.c +37 -46
index 8544516..56521fd 100644
@@ -199,6 +199,43 @@ void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 }
 
 
+/*
+ *
+ * hv_copyfrom_ringbuffer()
+ *
+ * Helper routine to copy to source from ring buffer.
+ * Assume there is enough room. Handles wrap-around in src case only!!
+ *
+ */
+static u32 hv_copyfrom_ringbuffer(
+	struct hv_ring_buffer_info	*ring_info,
+	void				*dest,
+	u32				destlen,
+	u32				start_read_offset)
+{
+	void *ring_buffer = hv_get_ring_buffer(ring_info);
+	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
+
+	u32 frag_len;
+
+	/* wrap-around detected at the src */
+	if (destlen > ring_buffer_size - start_read_offset) {
+		frag_len = ring_buffer_size - start_read_offset;
+
+		memcpy(dest, ring_buffer + start_read_offset, frag_len);
+		memcpy(dest + frag_len, ring_buffer, destlen - frag_len);
+	} else
+
+		memcpy(dest, ring_buffer + start_read_offset, destlen);
+
+
+	start_read_offset += destlen;
+	start_read_offset %= ring_buffer_size;
+
+	return start_read_offset;
+}
+
+
 
 static u32
 hv_copyto_ringbuffer(
@@ -207,14 +244,6 @@ hv_copyto_ringbuffer(
 	void				*src,
 	u32				srclen);
 
-static u32
-hv_copyfrom_ringbuffer(
-	struct hv_ring_buffer_info	*ring_info,
-	void				*dest,
-	u32				destlen,
-	u32				start_read_offset);
-
-
 
 /*
  *
@@ -504,41 +533,3 @@ hv_copyto_ringbuffer(
 	return start_write_offset;
 }
 
-
-/*
- *
- * hv_copyfrom_ringbuffer()
- *
- * Helper routine to copy to source from ring buffer.
- * Assume there is enough room. Handles wrap-around in src case only!!
- *
- */
-static u32
-hv_copyfrom_ringbuffer(
-	struct hv_ring_buffer_info	*ring_info,
-	void				*dest,
-	u32				destlen,
-	u32				start_read_offset)
-{
-	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
-
-	u32 frag_len;
-
-	/* wrap-around detected at the src */
-	if (destlen > ring_buffer_size - start_read_offset) {
-		frag_len = ring_buffer_size - start_read_offset;
-
-		memcpy(dest, ring_buffer + start_read_offset, frag_len);
-		memcpy(dest + frag_len, ring_buffer, destlen - frag_len);
-	} else
-
-		memcpy(dest, ring_buffer + start_read_offset, destlen);
-
-
-	start_read_offset += destlen;
-	start_read_offset %= ring_buffer_size;
-
-	return start_read_offset;
-}
-
Signature · 1 line
1.7.4.1
#113 lore raw

PATCH 106/206 Staging: hv: Get rid of the forward declaration of hv_copyto_ringbuffer()

In reply to K. Y. Srinivasan

Get rid of the forward declaration by moving the code around.

---
 drivers/staging/hv/ring_buffer.c |   66 +++++++++++++++----------------------
 1 files changed, 27 insertions(+), 39 deletions(-)
drivers/staging/hv/ring_buffer.c +27 -39
index 56521fd..2a461ddee 100644
@@ -236,14 +236,37 @@ static u32 hv_copyfrom_ringbuffer(
 }
 
 
-
-static u32
-hv_copyto_ringbuffer(
+/*
+ *
+ * hv_copyto_ringbuffer()
+ *
+ * Helper routine to copy from source to ring buffer.
+ * Assume there is enough room. Handles wrap-around in dest case only!!
+ *
+ */
+static u32 hv_copyto_ringbuffer(
 	struct hv_ring_buffer_info	*ring_info,
 	u32				start_write_offset,
 	void				*src,
-	u32				srclen);
+	u32				srclen)
+{
+	void *ring_buffer = hv_get_ring_buffer(ring_info);
+	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
+	u32 frag_len;
+
+	/* wrap-around detected! */
+	if (srclen > ring_buffer_size - start_write_offset) {
+		frag_len = ring_buffer_size - start_write_offset;
+		memcpy(ring_buffer + start_write_offset, src, frag_len);
+		memcpy(ring_buffer, src + frag_len, srclen - frag_len);
+	} else
+		memcpy(ring_buffer + start_write_offset, src, srclen);
 
+	start_write_offset += srclen;
+	start_write_offset %= ring_buffer_size;
+
+	return start_write_offset;
+}
 
 /*
  *
@@ -498,38 +521,3 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 
 	return 0;
 }
-
-
-/*
- *
- * hv_copyto_ringbuffer()
- *
- * Helper routine to copy from source to ring buffer.
- * Assume there is enough room. Handles wrap-around in dest case only!!
- *
- */
-static u32
-hv_copyto_ringbuffer(
-	struct hv_ring_buffer_info	*ring_info,
-	u32				start_write_offset,
-	void				*src,
-	u32				srclen)
-{
-	void *ring_buffer = hv_get_ring_buffer(ring_info);
-	u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
-	u32 frag_len;
-
-	/* wrap-around detected! */
-	if (srclen > ring_buffer_size - start_write_offset) {
-		frag_len = ring_buffer_size - start_write_offset;
-		memcpy(ring_buffer + start_write_offset, src, frag_len);
-		memcpy(ring_buffer, src + frag_len, srclen - frag_len);
-	} else
-		memcpy(ring_buffer + start_write_offset, src, srclen);
-
-	start_write_offset += srclen;
-	start_write_offset %= ring_buffer_size;
-
-	return start_write_offset;
-}
-
Signature · 1 line
1.7.4.1
#114 lore raw

PATCH 107/206 Staging: hv: Get rid of the volatile qualifier for a variable in ring_buffer.c

In reply to K. Y. Srinivasan

Access to this variable is already serialized via a spin lock. Get rid of the unnecessary volatile qualifier.

---
 drivers/staging/hv/ring_buffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/ring_buffer.c +1 -1
index 2a461ddee..badf52a 100644
@@ -364,7 +364,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	u32 totalbytes_towrite = 0;
 
 	struct scatterlist *sg;
-	volatile u32 next_write_location;
+	u32 next_write_location;
 	u64 prev_indices = 0;
 	unsigned long flags;
 
Signature · 1 line
1.7.4.1
#115 lore raw

PATCH 108/206 Staging: hv: Cleanup ring_buffer.h

In reply to K. Y. Srinivasan

Access to these variables is already serialized via a spin lock. Get rid of the unnecessary volatile qualifier.

---
 drivers/staging/hv/ring_buffer.h |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/staging/hv/ring_buffer.h +3 -4
index 1bc0b8a..089c536 100644
@@ -30,12 +30,12 @@
 
 struct hv_ring_buffer {
 	/* Offset in bytes from the start of ring data below */
-	volatile u32 write_index;
+	u32 write_index;
 
 	/* Offset in bytes from the start of ring data below */
-	volatile u32 read_index;
+	u32 read_index;
 
-	volatile u32 interrupt_mask;
+	u32 interrupt_mask;
 
 	/* Pad it to PAGE_SIZE so that data starts on page boundary */
 	u8	reserved[4084];
@@ -45,7 +45,6 @@ struct hv_ring_buffer {
 	 * vmbus connection also uses this data structure and its data starts
 	 * here, we commented out this field.
 	 */
-	/* volatile u32 InterruptMask; */
 
 	/*
 	 * Ring data starts here + RingDataStartOffset
Signature · 1 line
1.7.4.1
#116 lore raw

PATCH 109/206 Staging: hv: Rename the variable gSupportedDeviceClasses

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel_mgmt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/staging/hv/channel_mgmt.c +3 -2
index 1929ab3..71b79c6 100644
@@ -42,7 +42,7 @@ struct vmbus_channel_message_table_entry {
 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
 
 static const struct hv_guid
-	gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
+	supported_device_classes[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
 	/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
 	/* Storage - SCSI */
 	{
@@ -459,7 +459,8 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 	offer = (struct vmbus_channel_offer_channel *)hdr;
 	for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
 		if (memcmp(&offer->offer.if_type,
-		    &gSupportedDeviceClasses[i], sizeof(struct hv_guid)) == 0) {
+			&supported_device_classes[i],
+			sizeof(struct hv_guid)) == 0) {
 			fsupported = 1;
 			break;
 		}
Signature · 1 line
1.7.4.1
#117 lore raw

PATCH 110/206 Staging: hv: Rename the variable messageHandler

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel_mgmt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/channel_mgmt.c +3 -3
index 71b79c6..bc6e235 100644
@@ -35,7 +35,7 @@
 
 struct vmbus_channel_message_table_entry {
 	enum vmbus_channel_message_type messageType;
-	void (*messageHandler)(struct vmbus_channel_message_header *msg);
+	void (*message_handler)(struct vmbus_channel_message_header *msg);
 };
 
 #define MAX_MSG_TYPES                    4
@@ -740,8 +740,8 @@ void vmbus_onmessage(void *context)
 		return;
 	}
 
-	if (gChannelMessageTable[hdr->msgtype].messageHandler)
-		gChannelMessageTable[hdr->msgtype].messageHandler(hdr);
+	if (gChannelMessageTable[hdr->msgtype].message_handler)
+		gChannelMessageTable[hdr->msgtype].message_handler(hdr);
 	else
 		pr_err("Unhandled channel message type %d\n", hdr->msgtype);
 }
Signature · 1 line
1.7.4.1
#118 lore raw

PATCH 111/206 Staging: hv: Rename the variable messageType

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel_mgmt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/channel_mgmt.c +1 -1
index bc6e235..a8be565 100644
@@ -34,7 +34,7 @@
 #include "utils.h"
 
 struct vmbus_channel_message_table_entry {
-	enum vmbus_channel_message_type messageType;
+	enum vmbus_channel_message_type message_type;
 	void (*message_handler)(struct vmbus_channel_message_header *msg);
 };
 
Signature · 1 line
1.7.4.1
#119 lore raw

PATCH 112/206 Staging: hv: Rename the variable gChannelMessageTable

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel_mgmt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/channel_mgmt.c +3 -3
index a8be565..95eef92 100644
@@ -698,7 +698,7 @@ static void vmbus_onversion_response(
 
 /* Channel message dispatch table */
 static struct vmbus_channel_message_table_entry
-	gChannelMessageTable[CHANNELMSG_COUNT] = {
+	channel_message_table[CHANNELMSG_COUNT] = {
 	{CHANNELMSG_INVALID,			NULL},
 	{CHANNELMSG_OFFERCHANNEL,		vmbus_onoffer},
 	{CHANNELMSG_RESCIND_CHANNELOFFER,	vmbus_onoffer_rescind},
@@ -740,8 +740,8 @@ void vmbus_onmessage(void *context)
 		return;
 	}
 
-	if (gChannelMessageTable[hdr->msgtype].message_handler)
-		gChannelMessageTable[hdr->msgtype].message_handler(hdr);
+	if (channel_message_table[hdr->msgtype].message_handler)
+		channel_message_table[hdr->msgtype].message_handler(hdr);
 	else
 		pr_err("Unhandled channel message type %d\n", hdr->msgtype);
 }
Signature · 1 line
1.7.4.1
#120 lore raw

PATCH 113/206 Staging: hv: Use completion abstraction to synchronize in vmbus_channel_msginfo

In reply to K. Y. Srinivasan

Use completion abstraction to synchronize in vmbus_channel_msginfo.

---
 drivers/staging/hv/channel.c      |   31 ++++++++++++-------------------
 drivers/staging/hv/channel_mgmt.c |   31 ++++++++++++++-----------------
 drivers/staging/hv/channel_mgmt.h |    4 ++--
 drivers/staging/hv/connection.c   |    9 ++++-----
 4 files changed, 32 insertions(+), 43 deletions(-)
drivers/staging/hv/channel.c +12 -19
index 5fcf9d3..1b50cb7 100644
@@ -177,7 +177,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	struct vmbus_channel_msginfo *openInfo = NULL;
 	void *in, *out;
 	unsigned long flags;
-	int ret, err = 0;
+	int ret, t, err = 0;
 
 	/* Aligned to page size */
 	/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
@@ -240,7 +240,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		goto errorout;
 	}
 
-	init_waitqueue_head(&openInfo->waitevent);
+	init_completion(&openInfo->waitevent);
 
 	openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
 	openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
@@ -270,11 +270,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	if (ret != 0)
 		goto Cleanup;
 
-	openInfo->wait_condition = 0;
-	wait_event_timeout(openInfo->waitevent,
-			openInfo->wait_condition,
-			msecs_to_jiffies(1000));
-	if (openInfo->wait_condition == 0) {
+	t = wait_for_completion_timeout(&openInfo->waitevent, HZ);
+	if (t == 0) {
 		err = -ETIMEDOUT;
 		goto errorout;
 	}
@@ -495,6 +492,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 	u32 next_gpadl_handle;
 	unsigned long flags;
 	int ret = 0;
+	int t;
 
 	next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
 	atomic_inc(&vmbus_connection.next_gpadl_handle);
@@ -503,7 +501,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 	if (ret)
 		return ret;
 
-	init_waitqueue_head(&msginfo->waitevent);
+	init_completion(&msginfo->waitevent);
 
 	gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
 	gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
@@ -518,7 +516,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	msginfo->wait_condition = 0;
 	ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
 			       sizeof(*msginfo));
 	if (ret != 0)
@@ -546,10 +543,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 
 		}
 	}
-	wait_event_timeout(msginfo->waitevent,
-				msginfo->wait_condition,
-				msecs_to_jiffies(1000));
-	BUG_ON(msginfo->wait_condition == 0);
+	t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
+	BUG_ON(t == 0);
 
 
 	/* At this point, we received the gpadl created msg */
@@ -573,7 +568,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	struct vmbus_channel_gpadl_teardown *msg;
 	struct vmbus_channel_msginfo *info;
 	unsigned long flags;
-	int ret;
+	int ret, t;
 
 	/* ASSERT(gpadl_handle != 0); */
 
@@ -582,7 +577,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	if (!info)
 		return -ENOMEM;
 
-	init_waitqueue_head(&info->waitevent);
+	init_completion(&info->waitevent);
 
 	msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
 
@@ -594,14 +589,12 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	list_add_tail(&info->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-	info->wait_condition = 0;
 	ret = vmbus_post_msg(msg,
 			       sizeof(struct vmbus_channel_gpadl_teardown));
 
 	BUG_ON(ret != 0);
-	wait_event_timeout(info->waitevent,
-			info->wait_condition, msecs_to_jiffies(1000));
-	BUG_ON(info->wait_condition == 0);
+	t = wait_for_completion_timeout(&info->waitevent, HZ);
+	BUG_ON(t == 0);
 
 	/* Received a torndown response */
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
drivers/staging/hv/channel_mgmt.c +14 -17
index 95eef92..33cb5d5 100644
@@ -556,9 +556,9 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
 			    openmsg->openid == result->openid) {
 				memcpy(&msginfo->response.open_result,
 				       result,
-				       sizeof(struct vmbus_channel_open_result));
-				msginfo->wait_condition = 1;
-				wake_up(&msginfo->waitevent);
+				       sizeof(
+					struct vmbus_channel_open_result));
+				complete(&msginfo->waitevent);
 				break;
 			}
 		}
@@ -603,9 +603,9 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
 			    (gpadlcreated->gpadl == gpadlheader->gpadl)) {
 				memcpy(&msginfo->response.gpadl_created,
 				       gpadlcreated,
-				       sizeof(struct vmbus_channel_gpadl_created));
-				msginfo->wait_condition = 1;
-				wake_up(&msginfo->waitevent);
+				       sizeof(
+					struct vmbus_channel_gpadl_created));
+				complete(&msginfo->waitevent);
 				break;
 			}
 		}
@@ -648,9 +648,9 @@ static void vmbus_ongpadl_torndown(
 			if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) {
 				memcpy(&msginfo->response.gpadl_torndown,
 				       gpadl_torndown,
-				       sizeof(struct vmbus_channel_gpadl_torndown));
-				msginfo->wait_condition = 1;
-				wake_up(&msginfo->waitevent);
+				       sizeof(
+					struct vmbus_channel_gpadl_torndown));
+				complete(&msginfo->waitevent);
 				break;
 			}
 		}
@@ -689,8 +689,7 @@ static void vmbus_onversion_response(
 			memcpy(&msginfo->response.version_response,
 			      version_response,
 			      sizeof(struct vmbus_channel_version_response));
-			msginfo->wait_condition = 1;
-			wake_up(&msginfo->waitevent);
+			complete(&msginfo->waitevent);
 		}
 	}
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
@@ -753,7 +752,7 @@ int vmbus_request_offers(void)
 {
 	struct vmbus_channel_message_header *msg;
 	struct vmbus_channel_msginfo *msginfo;
-	int ret;
+	int ret, t;
 
 	msginfo = kmalloc(sizeof(*msginfo) +
 			  sizeof(struct vmbus_channel_message_header),
@@ -761,7 +760,7 @@ int vmbus_request_offers(void)
 	if (!msginfo)
 		return -ENOMEM;
 
-	init_waitqueue_head(&msginfo->waitevent);
+	init_completion(&msginfo->waitevent);
 
 	msg = (struct vmbus_channel_message_header *)msginfo->msg;
 
@@ -776,10 +775,8 @@ int vmbus_request_offers(void)
 		goto cleanup;
 	}
 
-	msginfo->wait_condition = 0;
-	wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
-			msecs_to_jiffies(1000));
-	if (msginfo->wait_condition == 0) {
+	t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto cleanup;
 	}
drivers/staging/hv/channel_mgmt.h +2 -2
index 3b2c393..f895d0a 100644
@@ -28,6 +28,7 @@
 #include <linux/list.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
+#include <linux/completion.h>
 #include "ring_buffer.h"
 #include "vmbus_channel_interface.h"
 #include "vmbus_packet_format.h"
@@ -290,8 +291,7 @@ struct vmbus_channel_msginfo {
 	struct list_head submsglist;
 
 	/* Synchronize the request/response if needed */
-	int wait_condition;
-	wait_queue_head_t waitevent;
+	struct completion  waitevent;
 	union {
 		struct vmbus_channel_version_supported version_supported;
 		struct vmbus_channel_open_result open_result;
drivers/staging/hv/connection.c +4 -5
index 4f411a9..92add38 100644
@@ -44,6 +44,7 @@ struct vmbus_connection vmbus_connection = {
 int vmbus_connect(void)
 {
 	int ret = 0;
+	int t;
 	struct vmbus_channel_msginfo *msginfo = NULL;
 	struct vmbus_channel_initiate_contact *msg;
 	unsigned long flags;
@@ -101,7 +102,7 @@ int vmbus_connect(void)
 		goto Cleanup;
 	}
 
-	init_waitqueue_head(&msginfo->waitevent);
+	init_completion(&msginfo->waitevent);
 
 	msg = (struct vmbus_channel_initiate_contact *)msginfo->msg;
 
@@ -134,10 +135,8 @@ int vmbus_connect(void)
 	}
 
 	/* Wait for the connection response */
-	msginfo->wait_condition = 0;
-	wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
-			msecs_to_jiffies(1000));
-	if (msginfo->wait_condition == 0) {
+	t =  wait_for_completion_timeout(&msginfo->waitevent, HZ);
+	if (t == 0) {
 		spin_lock_irqsave(&vmbus_connection.channelmsg_lock,
 				flags);
 		list_del(&msginfo->msglistentry);
Signature · 1 line
1.7.4.1
#121 lore raw

PATCH 114/206 Staging: hv: Get rid of some unnecessary state from struct vmbus_msginfo

In reply to K. Y. Srinivasan

This state is not used anywhere; get rid of it.

---
 drivers/staging/hv/vmbus_private.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/vmbus_private.h +0 -4
index 6f0d8df..bea331e 100644
@@ -91,10 +91,6 @@ struct vmbus_msginfo {
 	/* Bookkeeping stuff */
 	struct list_head msglist_entry;
 
-	/* Synchronize the request/response if needed */
-	int wait_condition;
-	wait_queue_head_t  wait_event;
-
 	/* The message itself */
 	unsigned char msg[0];
 };
Signature · 1 line
1.7.4.1
#122 lore raw

PATCH 115/206 Staging: hv: Use completion abstraction in struct netvsc_device

In reply to K. Y. Srinivasan

Use completion abstraction in struct netvsc_device instead of struct wait_queue_head_t to synchronize.

---
 drivers/staging/hv/netvsc.c |   32 +++++++++++++-------------------
 drivers/staging/hv/netvsc.h |    3 +--
 2 files changed, 14 insertions(+), 21 deletions(-)
drivers/staging/hv/netvsc.c +13 -19
index 832f62e..4eb4482 100644
@@ -213,6 +213,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 static int netvsc_init_recv_buf(struct hv_device *device)
 {
 	int ret = 0;
+	int t;
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 
@@ -260,7 +261,6 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		send_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
 
 	/* Send the gpadl notification request */
-	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
 			       sizeof(struct nvsp_message),
 			       (unsigned long)init_packet,
@@ -272,10 +272,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		goto cleanup;
 	}
 
-	wait_event_timeout(net_device->channel_init_wait,
-			net_device->wait_condition,
-			msecs_to_jiffies(1000));
-	BUG_ON(net_device->wait_condition == 0);
+	t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+	BUG_ON(t == 0);
 
 
 	/* Check the response */
@@ -394,6 +392,7 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 static int netvsc_init_send_buf(struct hv_device *device)
 {
 	int ret = 0;
+	int t;
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 
@@ -443,7 +442,6 @@ static int netvsc_init_send_buf(struct hv_device *device)
 		NETVSC_SEND_BUFFER_ID;
 
 	/* Send the gpadl notification request */
-	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
 			       sizeof(struct nvsp_message),
 			       (unsigned long)init_packet,
@@ -455,10 +453,9 @@ static int netvsc_init_send_buf(struct hv_device *device)
 		goto cleanup;
 	}
 
-	wait_event_timeout(net_device->channel_init_wait,
-			net_device->wait_condition,
-			msecs_to_jiffies(1000));
-	BUG_ON(net_device->wait_condition == 0);
+	t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+
+	BUG_ON(t == 0);
 
 	/* Check the response */
 	if (init_packet->msg.v1_msg.
@@ -487,7 +484,7 @@ exit:
 
 static int netvsc_connect_vsp(struct hv_device *device)
 {
-	int ret;
+	int ret, t;
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 	int ndis_version;
@@ -509,7 +506,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
 		NVSP_MAX_PROTOCOL_VERSION;
 
 	/* Send the init request */
-	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
 			       sizeof(struct nvsp_message),
 			       (unsigned long)init_packet,
@@ -519,10 +515,9 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	if (ret != 0)
 		goto cleanup;
 
-	wait_event_timeout(net_device->channel_init_wait,
-			net_device->wait_condition,
-			msecs_to_jiffies(1000));
-	if (net_device->wait_condition == 0) {
+	t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto cleanup;
 	}
@@ -647,8 +642,7 @@ static void netvsc_send_completion(struct hv_device *device,
 		/* Copy the response back */
 		memcpy(&net_device->channel_init_pkt, nvsp_packet,
 		       sizeof(struct nvsp_message));
-		net_device->wait_condition = 1;
-		wake_up(&net_device->channel_init_wait);
+		complete(&net_device->channel_init_wait);
 	} else if (nvsp_packet->hdr.msg_type ==
 		   NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE) {
 		/* Get the send context */
@@ -1123,7 +1117,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 		list_add_tail(&packet->list_ent,
 			      &net_device->recv_pkt_list);
 	}
-	init_waitqueue_head(&net_device->channel_init_wait);
+	init_completion(&net_device->channel_init_wait);
 
 	/* Open the channel */
 	ret = vmbus_open(device->channel, net_driver->ring_buf_size,
drivers/staging/hv/netvsc.h +1 -2
index 45d24b9..9ebea3b 100644
@@ -318,8 +318,7 @@ struct netvsc_device {
 	struct nvsp_1_receive_buffer_section *recv_section;
 
 	/* Used for NetVSP initialization protocol */
-	int wait_condition;
-	wait_queue_head_t channel_init_wait;
+	struct completion channel_init_wait;
 	struct nvsp_message channel_init_pkt;
 
 	struct nvsp_message revoke_packet;
Signature · 1 line
1.7.4.1
#123 lore raw

Re: [PATCH 115/206] Staging: hv: Use completion abstraction in struct netvsc_device

Quoted 5 lines
drivers/staging/hv/netvsc.c +0 -1
-	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
 			       sizeof(struct nvsp_message),
 			       (unsigned long)init_packet,

drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device *device) · line 276

Quoted 9 lines
drivers/staging/hv/netvsc.c +2 -4
@@ -272,10 +272,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		goto cleanup;
 	}
 
-	wait_event_timeout(net_device->channel_init_wait,
-			net_device->wait_condition,
-			msecs_to_jiffies(1000));
-	BUG_ON(net_device->wait_condition == 0);
+	t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+	BUG_ON(t == 0);

I don't think you want a BUG_ON here, but rather fail the initialization.

Also I think you really should add synchronous versions of vmbus_sendpacket*, to the vmbus core so that all the synchronous waiting can be consolidated into a few helpers instead of needing to opencode it everywhere.

#124 lore raw

RE: [PATCH 115/206] Staging: hv: Use completion abstraction in struct netvsc_device

Quoted 21 lines

-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Tuesday, May 10, 2011 3:07 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang; Abhishek Kane (Mindtree Consulting PVT LTD); Hank Janssen
Subject: Re: [PATCH 115/206] Staging: hv: Use completion abstraction in struct netvsc_device

drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device

Quoted 5 lines
drivers/staging/hv/netvsc.c +0 -1
-	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
 			       sizeof(struct nvsp_message),
 			       (unsigned long)init_packet,
@@ -272,10 +272,8 @@ static int netvsc_init_recv_buf(struct hv_device

*device)

Quoted 3 lines
drivers/staging/hv/netvsc.c +0 -0
 		goto cleanup;
 	}
 
Quoted 9 lines

drivers/staging/hv/netvsc.c static int netvsc_init_recv_buf(struct hv_device *device) · line 276

Quoted 6 lines
drivers/staging/hv/netvsc.c +2 -4
-	wait_event_timeout(net_device->channel_init_wait,
-			net_device->wait_condition,
-			msecs_to_jiffies(1000));
-	BUG_ON(net_device->wait_condition == 0);
+	t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+	BUG_ON(t == 0);

I don't think you want a BUG_ON here, but rather fail the initialization.

This is existing code and all I did was change the synchronization primitive used. Back in Feb. when this was done (prior to then), the wait was indefinite and one of the comments that was longstanding was that the wait had to be bounded and so these timed waits were introduced. When this was done,
in some cases, there was no easy way to roll-back state if we did not get the response within our expected window of time. This is one such instance where the guest is handing over the receive buffers (guest physical addresses) to the host. There was a discussion on this very topic on this mailing list and the consensus was to leave the BUG_ON() call in cases where we could not reasonably recover.

Quoted 5 lines

Also I think you really should add synchronous versions of vmbus_sendpacket*, to the vmbus core so that all the synchronous waiting can be consolidated into a few helpers instead of needing to opencode it everywhere.

True; but having a non-blocking interface at the lowest level gives you the most flexibility. In addition to this non-blocking interface, we may want to look at potentially a blocking interface. In the current code, the blocking primitive that is embedded in a higher level abstraction is used for a variety of situations including the initial handshake which is what can be addressed with a synchronous API at the lowest level.

Regards,

K. Y

#125 lore raw

PATCH 116/206 Staging: hv: Use the completion abstraction in struct rndis_request

In reply to K. Y. Srinivasan

Use the completion abstraction in struct rndis_request to synchronize.

---
 drivers/staging/hv/rndis_filter.c |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)
drivers/staging/hv/rndis_filter.c +14 -19
index ee74cd1..2037836 100644
@@ -59,8 +59,7 @@ struct rndis_device {
 
 struct rndis_request {
 	struct list_head list_ent;
-	int wait_condition;
-	wait_queue_head_t wait_event;
+	struct completion  wait_event;
 
 	/*
 	 * FIXME: We assumed a fixed size response here. If we do ever need to
@@ -125,7 +124,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
 	if (!request)
 		return NULL;
 
-	init_waitqueue_head(&request->wait_event);
+	init_completion(&request->wait_event);
 
 	rndis_msg = &request->request_msg;
 	rndis_msg->ndis_msg_type = msg_type;
@@ -305,8 +304,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 			}
 		}
 
-		request->wait_condition = 1;
-		wake_up(&request->wait_event);
+		complete(&request->wait_event);
 	} else {
 		dev_err(&dev->net_dev->dev->device,
 			"no rndis request found for this response "
@@ -465,6 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	struct rndis_query_request *query;
 	struct rndis_query_complete *query_complete;
 	int ret = 0;
+	int t;
 
 	if (!result)
 		return -EINVAL;
@@ -484,14 +483,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	query->info_buflen = 0;
 	query->dev_vc_handle = 0;
 
-	request->wait_condition = 0;
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
 		goto Cleanup;
 
-	wait_event_timeout(request->wait_event, request->wait_condition,
-				msecs_to_jiffies(1000));
-	if (request->wait_condition == 0) {
+	t = wait_for_completion_timeout(&request->wait_event, HZ);
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
 	}
@@ -543,7 +540,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	struct rndis_set_request *set;
 	struct rndis_set_complete *set_complete;
 	u32 status;
-	int ret;
+	int ret, t;
 
 	request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -562,14 +559,13 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request),
 	       &new_filter, sizeof(u32));
 
-	request->wait_condition = 0;
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
 		goto Cleanup;
 
-	wait_event_timeout(request->wait_event, request->wait_condition,
-		msecs_to_jiffies(2000));
-	if (request->wait_condition == 0) {
+	t = wait_for_completion_timeout(&request->wait_event, HZ);
+
+	if (t == 0) {
 		ret = -1;
 		dev_err(&dev->net_dev->dev->device,
 			"timeout before we got a set response...\n");
@@ -624,7 +620,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	struct rndis_initialize_request *init;
 	struct rndis_initialize_complete *init_complete;
 	u32 status;
-	int ret;
+	int ret, t;
 
 	request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
@@ -642,7 +638,6 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
 	dev->state = RNDIS_DEV_INITIALIZING;
 
-	request->wait_condition = 0;
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0) {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
@@ -650,9 +645,9 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	}
 
 
-	wait_event_timeout(request->wait_event, request->wait_condition,
-		msecs_to_jiffies(1000));
-	if (request->wait_condition == 0) {
+	t = wait_for_completion_timeout(&request->wait_event, HZ);
+
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
 	}
Signature · 1 line
1.7.4.1
#126 lore raw

PATCH 117/206 Staging: hv: Get rid of some dead code in channel.c

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/channel.c |   71 ------------------------------------------
 1 files changed, 0 insertions(+), 71 deletions(-)
drivers/staging/hv/channel.c +0 -71
index 1b50cb7..a2a190e 100644
@@ -42,37 +42,6 @@ static int create_gpadl_header(
 static void dump_vmbus_channel(struct vmbus_channel *channel);
 static void vmbus_setevent(struct vmbus_channel *channel);
 
-
-#if 0
-static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
-{
-	int i = 0;
-	int j = 0;
-
-	DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
-		   MonitorPage, MonitorPage->trigger_state);
-
-	for (i = 0; i < 4; i++)
-		DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
-			   MonitorPage->trigger_group[i].as_uint64);
-
-	for (i = 0; i < 4; i++) {
-		for (j = 0; j < 32; j++) {
-			DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
-				   MonitorPage->latency[i][j]);
-		}
-	}
-	for (i = 0; i < 4; i++) {
-		for (j = 0; j < 32; j++) {
-			DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
-			       MonitorPage->parameter[i][j].connectionid.asu32);
-			DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
-				MonitorPage->parameter[i][j].flag_number);
-		}
-	}
-}
-#endif
-
 /*
  * vmbus_setevent- Trigger an event notification on the specified
  * channel.
@@ -99,28 +68,6 @@ static void vmbus_setevent(struct vmbus_channel *channel)
 	}
 }
 
-#if 0
-static void VmbusChannelClearEvent(struct vmbus_channel *channel)
-{
-	struct hv_monitor_page *monitorPage;
-
-	if (Channel->offermsg.monitor_allocated) {
-		/* Each u32 represents 32 channels */
-		sync_clear_bit(Channel->offermsg.child_relid & 31,
-			  (unsigned long *)vmbus_connection.send_int_page +
-			  (Channel->offermsg.child_relid >> 5));
-
-		monitorPage = (struct hv_monitor_page *)
-			vmbus_connection.monitor_pages;
-		monitorPage++; /* Get the child to parent monitor page */
-
-		sync_clear_bit(Channel->monitor_bit,
-			  (unsigned long *)&monitorPage->trigger_group
-					[Channel->monitor_grp].Pending);
-	}
-}
-
-#endif
 /*
  * vmbus_get_debug_info -Retrieve various channel debug info
  */
@@ -179,10 +126,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	unsigned long flags;
 	int ret, t, err = 0;
 
-	/* Aligned to page size */
-	/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
-	/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
-
 	newchannel->onchannel_callback = onchannelcallback;
 	newchannel->channel_callback_context = context;
 
@@ -193,7 +136,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	if (!out)
 		return -ENOMEM;
 
-	/* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
 
 	in = (void *)((unsigned long)out + send_ringbuffer_size);
 
@@ -361,9 +303,6 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 
 	int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
 
-	/* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
-	/* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
-
 	pagecount = size >> PAGE_SHIFT;
 	pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
 
@@ -695,8 +634,6 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
 
 	dump_vmbus_channel(channel);
 
-	/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
-
 	/* Setup the descriptor */
 	desc.type = type; /* VmbusPacketTypeDataInBand; */
 	desc.flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
@@ -754,8 +691,6 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
 	packetlen = descsize + bufferlen;
 	packetlen_aligned = ALIGN(packetlen, sizeof(u64));
 
-	/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
-
 	/* Setup the descriptor */
 	desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
 	desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
@@ -819,7 +754,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 	packetlen = descsize + bufferlen;
 	packetlen_aligned = ALIGN(packetlen, sizeof(u64));
 
-	/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
 
 	/* Setup the descriptor */
 	desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
@@ -885,11 +819,8 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 		return 0;
 	}
 
-	/* VmbusChannelClearEvent(Channel); */
-
 	packetlen = desc.len8 << 3;
 	userlen = packetlen - (desc.offset8 << 3);
-	/* ASSERT(userLen > 0); */
 
 	*buffer_actual_len = userlen;
 
@@ -938,7 +869,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 		return 0;
 	}
 
-	/* VmbusChannelClearEvent(Channel); */
 
 	packetlen = desc.len8 << 3;
 	userlen = packetlen - (desc.offset8 << 3);
@@ -970,7 +900,6 @@ EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
 void vmbus_onchannel_event(struct vmbus_channel *channel)
 {
 	dump_vmbus_channel(channel);
-	/* ASSERT(Channel->OnChannelCallback); */
 
 	channel->onchannel_callback(channel->channel_callback_context);
 
Signature · 1 line
1.7.4.1
#127 lore raw

PATCH 118/206 Staging: hv: Change Cleanup to cleanup

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/connection.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/staging/hv/connection.c +10 -10
index 92add38..3632bcc 100644
@@ -58,7 +58,7 @@ int vmbus_connect(void)
 	vmbus_connection.work_queue = create_workqueue("hv_vmbus_con");
 	if (!vmbus_connection.work_queue) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	INIT_LIST_HEAD(&vmbus_connection.chn_msg_list);
@@ -75,7 +75,7 @@ int vmbus_connect(void)
 	(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
 	if (vmbus_connection.int_page == NULL) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	vmbus_connection.recv_int_page = vmbus_connection.int_page;
@@ -91,7 +91,7 @@ int vmbus_connect(void)
 	(void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1);
 	if (vmbus_connection.monitor_pages == NULL) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	msginfo = kzalloc(sizeof(*msginfo) +
@@ -99,7 +99,7 @@ int vmbus_connect(void)
 			  GFP_KERNEL);
 	if (msginfo == NULL) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	init_completion(&msginfo->waitevent);
@@ -131,7 +131,7 @@ int vmbus_connect(void)
 		list_del(&msginfo->msglistentry);
 		spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
 					flags);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Wait for the connection response */
@@ -143,7 +143,7 @@ int vmbus_connect(void)
 		spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
 					flags);
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
@@ -158,13 +158,13 @@ int vmbus_connect(void)
 			"Version %d not supported by Hyper-V\n",
 			VMBUS_REVISION_NUMBER);
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	kfree(msginfo);
 	return 0;
 
-Cleanup:
+cleanup:
 	vmbus_connection.conn_state = DISCONNECTED;
 
 	if (vmbus_connection.work_queue)
@@ -207,7 +207,7 @@ int vmbus_disconnect(void)
 	ret = vmbus_post_msg(msg,
 			       sizeof(struct vmbus_channel_message_header));
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	free_pages((unsigned long)vmbus_connection.int_page, 0);
 	free_pages((unsigned long)vmbus_connection.monitor_pages, 1);
@@ -219,7 +219,7 @@ int vmbus_disconnect(void)
 
 	pr_info("hv_vmbus disconnected\n");
 
-Cleanup:
+cleanup:
 	kfree(msg);
 	return ret;
 }
Signature · 1 line
1.7.4.1
#128 lore raw

PATCH 119/206 Staging: hv: Get rid of some dead code in connection.c

In reply to K. Y. Srinivasan

Get rid some commented code and dated comments.T

---
 drivers/staging/hv/connection.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/hv/connection.c +4 -6
index 3632bcc..dd62585 100644
@@ -263,11 +263,6 @@ static void process_chn_event(u32 relid)
 
 	if (channel) {
 		vmbus_onchannel_event(channel);
-		/*
-		 * WorkQueueQueueWorkItem(channel->dataWorkQueue,
-		 *			  vmbus_onchannel_event,
-		 *			  (void*)channel);
-		 */
 	} else {
 		pr_err("channel not found for relid - %u\n", relid);
 	}
@@ -295,7 +290,10 @@ void vmbus_on_event(unsigned long data)
 				relid = (dword << 5) + bit;
 
 				if (relid == 0) {
-					/* special case - vmbus channel protocol msg */
+					/*
+					 * Special case - vmbus
+					 * channel protocol msg
+					 */
 					continue;
 				}
 				process_chn_event(relid);
Signature · 1 line
1.7.4.1
#129 lore raw

PATCH 120/206 Staging: hv: Get rid of some dead code from hv.c

In reply to K. Y. Srinivasan

Get rid of some commented code.

---
 drivers/staging/hv/hv.c |   31 -------------------------------
 1 files changed, 0 insertions(+), 31 deletions(-)
drivers/staging/hv/hv.c +0 -31
index e6312bd..e0c2861 100644
@@ -82,34 +82,7 @@ static int query_hypervisor_info(void)
 	op = HVCPUID_VENDOR_MAXFUNCTION;
 	cpuid(op, &eax, &ebx, &ecx, &edx);
 
-/*	DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
-		    (ebx & 0xFF),
-		    ((ebx >> 8) & 0xFF),
-		    ((ebx >> 16) & 0xFF),
-		    ((ebx >> 24) & 0xFF),
-		    (ecx & 0xFF),
-		    ((ecx >> 8) & 0xFF),
-		    ((ecx >> 16) & 0xFF),
-		    ((ecx >> 24) & 0xFF),
-		    (edx & 0xFF),
-		    ((edx >> 8) & 0xFF),
-		    ((edx >> 16) & 0xFF),
-		    ((edx >> 24) & 0xFF));
-*/
 	max_leaf = eax;
-/*	eax = 0;
-	ebx = 0;
-	ecx = 0;
-	edx = 0;
-	op = HVCPUID_INTERFACE;
-	cpuid(op, &eax, &ebx, &ecx, &edx);
-
-	DPRINT_INFO(VMBUS, "Interface ID: %c%c%c%c",
-		    (eax & 0xFF),
-		    ((eax >> 8) & 0xFF),
-		    ((eax >> 16) & 0xFF),
-		    ((eax >> 24) & 0xFF));
-*/
 
 	if (max_leaf >= HVCPUID_VERSION) {
 		eax = 0;
@@ -399,10 +372,6 @@ void hv_synic_init(void *irqarg)
 
 	wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
 
-	/* Setup the interception SINT. */
-	/* wrmsrl((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */
-	/*	  interceptionSint.as_uint64); */
-
 	/* Setup the shared SINT. */
 	rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
Signature · 1 line
1.7.4.1
#130 lore raw

PATCH 121/206 Staging: hv: Change Cleanup to cleanup

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/hv.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/hv/hv.c +9 -9
index e0c2861..2efac38 100644
@@ -161,7 +161,7 @@ int hv_init(void)
 	       sizeof(void *) * MAX_NUM_CPUS);
 
 	if (!query_hypervisor_presence())
-		goto Cleanup;
+		goto cleanup;
 
 	max_leaf = query_hypervisor_info();
 	/* HvQueryHypervisorFeatures(maxLeaf); */
@@ -172,7 +172,7 @@ int hv_init(void)
 	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
 	if (hv_context.guestid != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	/* Write our OS info */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
@@ -188,7 +188,7 @@ int hv_init(void)
 	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
 	if (!virtaddr)
-		goto Cleanup;
+		goto cleanup;
 
 	hypercall_msr.enable = 1;
 
@@ -200,7 +200,7 @@ int hv_init(void)
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
 	if (!hypercall_msr.enable)
-		goto Cleanup;
+		goto cleanup;
 
 	hv_context.hypercall_page = virtaddr;
 
@@ -209,7 +209,7 @@ int hv_init(void)
 			kmalloc(sizeof(struct hv_input_signal_event_buffer),
 				GFP_KERNEL);
 	if (!hv_context.signal_event_buffer)
-		goto Cleanup;
+		goto cleanup;
 
 	hv_context.signal_event_param =
 		(struct hv_input_signal_event *)
@@ -224,7 +224,7 @@ int hv_init(void)
 
 	return ret;
 
-Cleanup:
+cleanup:
 	if (virtaddr) {
 		if (hypercall_msr.enable) {
 			hypercall_msr.as_uint64 = 0;
@@ -345,7 +345,7 @@ void hv_synic_init(void *irqarg)
 
 	if (hv_context.synic_message_page[cpu] == NULL) {
 		pr_err("Unable to allocate SYNIC message page\n");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	hv_context.synic_event_page[cpu] =
@@ -353,7 +353,7 @@ void hv_synic_init(void *irqarg)
 
 	if (hv_context.synic_event_page[cpu] == NULL) {
 		pr_err("Unable to allocate SYNIC event page\n");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the Synic's message page */
@@ -391,7 +391,7 @@ void hv_synic_init(void *irqarg)
 	hv_context.synic_initialized = true;
 	return;
 
-Cleanup:
+cleanup:
 	if (hv_context.synic_event_page[cpu])
 		free_page((unsigned long)hv_context.synic_event_page[cpu]);
 
Signature · 1 line
1.7.4.1
#131 lore raw

PATCH 122/206 Staging: hv: Get rid of unnecessary state from struct storvsc_driver

In reply to K. Y. Srinivasan

This is unused state; get rid of it.

---
 drivers/staging/hv/storvsc_api.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -3
index 1887940..055902b 100644
@@ -83,9 +83,6 @@ struct storvsc_driver {
 	/* Maximum # of requests in flight per channel/device */
 	u32 max_outstanding_req_per_channel;
 
-	/* Specific to this driver */
-	int (*on_io_request)(struct hv_device *device,
-			   struct hv_storvsc_request *request);
 };
 
 struct storvsc_device_info {
Signature · 1 line
1.7.4.1
#132 lore raw

PATCH 123/206 Staging: hv: Get rid unnecessary DPRINT

In reply to K. Y. Srinivasan

Get rid unnecessary DPRINT.

---
 drivers/staging/hv/blkvsc_drv.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -4
index 7fb0cf1..8ff9a58 100644
@@ -192,10 +192,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 			   sizeof(struct vstor_packet) + sizeof(u64),
 			   sizeof(u64)));
 
-	DPRINT_INFO(BLKVSC, "max io outstd %u",
-		    stor_driver->max_outstanding_req_per_channel);
-
-
 	return ret;
 }
 
Signature · 1 line
1.7.4.1
#133 lore raw

PATCH 124/206 Staging: hv: Get rid of unnecessary code/comments

In reply to K. Y. Srinivasan

Get rid of unnecessary code/comments.

---
 drivers/staging/hv/blkvsc_drv.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -15
index 8ff9a58..77b081c 100644
@@ -174,24 +174,9 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 
 	stor_driver = hvdr_to_stordr(driver);
 
-	/* Make sure we are at least 2 pages since 1 page is used for control */
-
 	driver->name = drv_name;
 	memcpy(&driver->dev_type, &dev_type, sizeof(struct hv_guid));
 
-
-	/*
-	 * Divide the ring buffer data size (which is 1 page less than the ring
-	 * buffer size since that page is reserved for the ring buffer indices)
-	 * by the max request size (which is
-	 * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
-	 */
-	stor_driver->max_outstanding_req_per_channel =
-		((stor_driver->ring_buffer_size - PAGE_SIZE) /
-		  ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
-			   sizeof(struct vstor_packet) + sizeof(u64),
-			   sizeof(u64)));
-
 	return ret;
 }
 
Signature · 1 line
1.7.4.1
#134 lore raw

PATCH 125/206 Staging: hv: Assign the name directly

In reply to K. Y. Srinivasan

Assign the driver name directly.

---
 drivers/staging/hv/blkvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index 77b081c..e0d34c1 100644
@@ -842,7 +842,7 @@ static int blkvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	blk_vsc_initialize(&storvsc_drv->base);
 
-	drv->driver.name = storvsc_drv->base.name;
+	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
Signature · 1 line
1.7.4.1
#135 lore raw

PATCH 126/206 Staging: hv: Move the assignment of driver name

In reply to K. Y. Srinivasan

In preperation to eliminating blk_vsc_initialize(), move the assignment of driver name.

---
 drivers/staging/hv/blkvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index e0d34c1..1e6ef6f 100644
@@ -174,7 +174,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 
 	stor_driver = hvdr_to_stordr(driver);
 
-	driver->name = drv_name;
 	memcpy(&driver->dev_type, &dev_type, sizeof(struct hv_guid));
 
 	return ret;
@@ -842,6 +841,7 @@ static int blkvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	blk_vsc_initialize(&storvsc_drv->base);
 
+	drv->name = drv_name;
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
Signature · 1 line
1.7.4.1
#136 lore raw

PATCH 127/206 Staging: hv: Inline the copying of dev_type guid

In reply to K. Y. Srinivasan

In preperation to eliminating blk_vsc_initialize(), move the copying of dev_type field.

---
 drivers/staging/hv/blkvsc_drv.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -2
index 1e6ef6f..7e25707 100644
@@ -174,8 +174,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 
 	stor_driver = hvdr_to_stordr(driver);
 
-	memcpy(&driver->dev_type, &dev_type, sizeof(struct hv_guid));
-
 	return ret;
 }
 
@@ -841,6 +839,7 @@ static int blkvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	blk_vsc_initialize(&storvsc_drv->base);
 
+	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
 	drv->name = drv_name;
 	drv->driver.name = drv_name;
 
Signature · 1 line
1.7.4.1
#137 lore raw

PATCH 128/206 Staging: hv: Now get rid of the empty function

In reply to K. Y. Srinivasan

Now, get rid of the empty function.

---
 drivers/staging/hv/blkvsc_drv.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -15
index 7e25707..f8a3bce 100644
@@ -166,18 +166,6 @@ static int blkvsc_device_add(struct hv_device *device,
 	return ret;
 }
 
-
-static int blk_vsc_initialize(struct hv_driver *driver)
-{
-	struct storvsc_driver *stor_driver;
-	int ret = 0;
-
-	stor_driver = hvdr_to_stordr(driver);
-
-	return ret;
-}
-
-
 static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 			void (*request_completion)(struct hv_storvsc_request *))
 {
@@ -836,9 +824,6 @@ static int blkvsc_drv_init(void)
 
 	storvsc_drv->ring_buffer_size = blkvsc_ringbuffer_size;
 
-	/* Callback to client driver to complete the initialization */
-	blk_vsc_initialize(&storvsc_drv->base);
-
 	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
 	drv->name = drv_name;
 	drv->driver.name = drv_name;
Signature · 1 line
1.7.4.1
#138 lore raw

PATCH 129/206 Staging: hv: Move the sector size check into blkvsc_drv_init

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/blkvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -2
index f8a3bce..ed1439f 100644
@@ -822,6 +822,8 @@ static int blkvsc_drv_init(void)
 	struct hv_driver *drv = &blkvsc_drv.base;
 	int ret;
 
+	BUILD_BUG_ON(sizeof(sector_t) != 8);
+
 	storvsc_drv->ring_buffer_size = blkvsc_ringbuffer_size;
 
 	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
@@ -1046,8 +1048,6 @@ static int __init blkvsc_init(void)
 {
 	int ret;
 
-	BUILD_BUG_ON(sizeof(sector_t) != 8);
-
 	ret = blkvsc_drv_init();
 
 	return ret;
Signature · 1 line
1.7.4.1
#139 lore raw

Re: [PATCH 129/206] Staging: hv: Move the sector size check into blkvsc_drv_init

Quoted 1 line · K. Y. Srinivasan

The subject line says it all.

Is there any good reason to not support a 32-bit sector_t?

#140 lore raw

PATCH 130/206 Staging: hv: Make blkvsc_drv_init the module init function

In reply to K. Y. Srinivasan

Now, get rid of the redundant function and make blkvsc_drv_init the module init function.

---
 drivers/staging/hv/blkvsc_drv.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -10
index ed1439f..eebaaee 100644
@@ -1044,15 +1044,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
 	spin_unlock_irqrestore(&blkdev->lock, flags);
 }
 
-static int __init blkvsc_init(void)
-{
-	int ret;
-
-	ret = blkvsc_drv_init();
-
-	return ret;
-}
-
 static void __exit blkvsc_exit(void)
 {
 	blkvsc_drv_exit();
@@ -1061,5 +1052,5 @@ static void __exit blkvsc_exit(void)
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V virtual block driver");
-module_init(blkvsc_init);
+module_init(blkvsc_drv_init);
 module_exit(blkvsc_exit);
Signature · 1 line
1.7.4.1
#141 lore raw

PATCH 131/206 Staging: hv: Get rid of some unnecessary DPRINTs

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -8
index 0d7e43b..07db877 100644
@@ -103,10 +103,6 @@ static int storvsc_initialize(struct hv_driver *driver)
 			   sizeof(struct vstor_packet) + sizeof(u64),
 			   sizeof(u64)));
 
-	DPRINT_INFO(STORVSC, "max io %u, currently %u\n",
-		    stor_driver->max_outstanding_req_per_channel,
-		    STORVSC_MAX_IO_REQUESTS);
-
 
 	return 0;
 }
@@ -807,10 +803,6 @@ static int storvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	storvsc_initialize(&storvsc_drv_obj->base);
 
-	DPRINT_INFO(STORVSC_DRV,
-		    "max outstanding reqs %u",
-		    storvsc_drv_obj->max_outstanding_req_per_channel);
-
 	if (storvsc_drv_obj->max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
Signature · 1 line
1.7.4.1
#142 lore raw

PATCH 132/206 Staging: hv: Compute max_outstanding_req_per_channel where it is needed

In reply to K. Y. Srinivasan

Compute max_outstanding_req_per_channel where it is needed.

---
 drivers/staging/hv/storvsc_drv.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)
drivers/staging/hv/storvsc_drv.c +15 -15
index 07db877..7d8b8f9 100644
@@ -90,20 +90,6 @@ static int storvsc_initialize(struct hv_driver *driver)
 	memcpy(&driver->dev_type, &gStorVscDeviceType,
 	       sizeof(struct hv_guid));
 
-
-	/*
-	 * Divide the ring buffer data size (which is 1 page less
-	 * than the ring buffer size since that page is reserved for
-	 * the ring buffer indices) by the max request size (which is
-	 * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
-	 */
-	stor_driver->max_outstanding_req_per_channel =
-		((stor_driver->ring_buffer_size - PAGE_SIZE) /
-		  ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
-			   sizeof(struct vstor_packet) + sizeof(u64),
-			   sizeof(u64)));
-
-
 	return 0;
 }
 
@@ -797,13 +783,27 @@ static int storvsc_drv_init(void)
 	int ret;
 	struct storvsc_driver *storvsc_drv_obj = &storvsc_drv;
 	struct hv_driver *drv = &storvsc_drv.base;
+	u32 max_outstanding_req_per_channel;
+
+	/*
+	 * Divide the ring buffer data size (which is 1 page less
+	 * than the ring buffer size since that page is reserved for
+	 * the ring buffer indices) by the max request size (which is
+	 * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
+	 */
+
+	max_outstanding_req_per_channel =
+	((storvsc_ringbuffer_size - PAGE_SIZE) /
+	ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
+	sizeof(struct vstor_packet) + sizeof(u64),
+	sizeof(u64)));
 
 	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
 
 	/* Callback to client driver to complete the initialization */
 	storvsc_initialize(&storvsc_drv_obj->base);
 
-	if (storvsc_drv_obj->max_outstanding_req_per_channel <
+	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
 
Signature · 1 line
1.7.4.1
#143 lore raw

PATCH 133/206 Staging: hv: Get rid of max_outstanding_req_per_channel from struct storvsc_driver

In reply to K. Y. Srinivasan

Now, Get rid of max_outstanding_req_per_channel from struct storvsc_driver.

---
 drivers/staging/hv/storvsc_api.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -4
index 055902b..99d878a 100644
@@ -79,10 +79,6 @@ struct storvsc_driver {
 
 	/* Set by caller (in bytes) */
 	u32 ring_buffer_size;
-
-	/* Maximum # of requests in flight per channel/device */
-	u32 max_outstanding_req_per_channel;
-
 };
 
 struct storvsc_device_info {
Signature · 1 line
1.7.4.1
#144 lore raw

PATCH 134/206 Staging: hv: Add ring_buffer_size to struct storvsc_device_info

In reply to K. Y. Srinivasan

Add ring_buffer_size to struct storvsc_device_info

---
 drivers/staging/hv/storvsc_api.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/staging/hv/storvsc_api.h +1 -0
index 99d878a..fac607c 100644
@@ -82,6 +82,7 @@ struct storvsc_driver {
 };
 
 struct storvsc_device_info {
+	u32 ring_buffer_size;
 	unsigned int port_number;
 	unsigned char path_id;
 	unsigned char target_id;
Signature · 1 line
1.7.4.1
#145 lore raw

PATCH 135/206 Staging: hv: Use the rinbuffer size info in struct storvsc_device_info

In reply to K. Y. Srinivasan

Use the rinbuffer size info in struct storvsc_device_info.

---
 drivers/staging/hv/blkvsc_drv.c  |    5 ++---
 drivers/staging/hv/storvsc.c     |   10 ++++------
 drivers/staging/hv/storvsc_drv.c |    1 +
 3 files changed, 7 insertions(+), 9 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -3
index eebaaee..c04aaa3 100644
@@ -146,6 +146,8 @@ static int blkvsc_device_add(struct hv_device *device,
 
 	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;
@@ -818,14 +820,11 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct storvsc_driver *storvsc_drv = &blkvsc_drv;
 	struct hv_driver *drv = &blkvsc_drv.base;
 	int ret;
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	storvsc_drv->ring_buffer_size = blkvsc_ringbuffer_size;
-
 	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
 	drv->name = drv_name;
 	drv->driver.name = drv_name;
drivers/staging/hv/storvsc.c +4 -6
index 41361f5..8d7a490 100644
@@ -363,19 +363,17 @@ static void storvsc_on_channel_callback(void *context)
 	return;
 }
 
-static int storvsc_connect_to_vsp(struct hv_device *device)
+static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 {
 	struct vmstorage_channel_properties props;
-	struct storvsc_driver *stor_driver;
 	int ret;
 
-	stor_driver = drv_to_stordrv(device->device.driver);
 	memset(&props, 0, sizeof(struct vmstorage_channel_properties));
 
 	/* Open the channel */
 	ret = vmbus_open(device->channel,
-			 stor_driver->ring_buffer_size,
-			 stor_driver->ring_buffer_size,
+			 ring_size,
+			 ring_size,
 			 (void *)&props,
 			 sizeof(struct vmstorage_channel_properties),
 			 storvsc_on_channel_callback, device);
@@ -413,7 +411,7 @@ 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);
+	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
 
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
drivers/staging/hv/storvsc_drv.c +1 -0
index 7d8b8f9..1fb0521 100644
@@ -733,6 +733,7 @@ static int storvsc_probe(struct hv_device *device)
 	}
 
 	device_info.port_number = host->host_no;
+	device_info.ring_buffer_size  = storvsc_ringbuffer_size;
 	/* Call to the vsc driver to add the device */
 	ret = storvsc_dev_add(device, (void *)&device_info);
 
Signature · 1 line
1.7.4.1
#146 lore raw

PATCH 136/206 Staging: hv: Get rid of the unnecessary assignment of ring size

In reply to K. Y. Srinivasan

Now, get rid of the unnecessary assignment of ring size.

---
 drivers/staging/hv/storvsc_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -2
index 1fb0521..f37c836 100644
@@ -799,8 +799,6 @@ static int storvsc_drv_init(void)
 	sizeof(struct vstor_packet) + sizeof(u64),
 	sizeof(u64)));
 
-	storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
-
 	/* Callback to client driver to complete the initialization */
 	storvsc_initialize(&storvsc_drv_obj->base);
 
Signature · 1 line
1.7.4.1
#147 lore raw

PATCH 137/206 Staging: hv: Get rid of the ring size state from struct storvsc_driver

In reply to K. Y. Srinivasan

Now, get rid of the ring size state from struct storvsc_driver.

---
 drivers/staging/hv/storvsc_api.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -3
index fac607c..d2917eb 100644
@@ -76,9 +76,6 @@ struct hv_storvsc_request {
 /* Represents the block vsc driver */
 struct storvsc_driver {
 	struct hv_driver base;
-
-	/* Set by caller (in bytes) */
-	u32 ring_buffer_size;
 };
 
 struct storvsc_device_info {
Signature · 1 line
1.7.4.1
#148 lore raw

PATCH 138/206 Staging: hv: Directly assign the driver name

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -1
index f37c836..e342bcc 100644
@@ -806,7 +806,7 @@ static int storvsc_drv_init(void)
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
 
-	drv->driver.name = storvsc_drv_obj->base.name;
+	drv->driver.name = driver_name;
 
 
 	/* The driver belongs to vmbus */
Signature · 1 line
1.7.4.1
#149 lore raw

PATCH 139/206 Staging: hv: Move the assignment of name to the hv_driver

In reply to K. Y. Srinivasan

In preperation to eliminate the function storvsc_initialize() move the name assignment.

---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -1
index e342bcc..9447130 100644
@@ -86,7 +86,6 @@ static int storvsc_initialize(struct hv_driver *driver)
 
 	/* Make sure we are at least 2 pages since 1 page is used for control */
 
-	driver->name = driver_name;
 	memcpy(&driver->dev_type, &gStorVscDeviceType,
 	       sizeof(struct hv_guid));
 
@@ -806,6 +805,7 @@ static int storvsc_drv_init(void)
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
 
+	drv->name = driver_name;
 	drv->driver.name = driver_name;
 
 
Signature · 1 line
1.7.4.1
#150 lore raw

PATCH 140/206 Staging: hv: Inline the copying of the dev_type information

In reply to K. Y. Srinivasan

In preperation to eliminate the function storvsc_initialize() move the copying of dev_type info.

---
 drivers/staging/hv/storvsc_drv.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/staging/hv/storvsc_drv.c +3 -6
index 9447130..3be4f1a 100644
@@ -83,12 +83,6 @@ static int storvsc_initialize(struct hv_driver *driver)
 
 	stor_driver = hvdr_to_stordr(driver);
 
-
-	/* Make sure we are at least 2 pages since 1 page is used for control */
-
-	memcpy(&driver->dev_type, &gStorVscDeviceType,
-	       sizeof(struct hv_guid));
-
 	return 0;
 }
 
@@ -801,6 +795,9 @@ static int storvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	storvsc_initialize(&storvsc_drv_obj->base);
 
+	memcpy(&drv->dev_type, &gStorVscDeviceType,
+	       sizeof(struct hv_guid));
+
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
Signature · 1 line
1.7.4.1
#151 lore raw

PATCH 141/206 Staging: hv: Now get rid of an empty function

In reply to K. Y. Srinivasan

The subject line says it all.

---
 drivers/staging/hv/storvsc_drv.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -16
index 3be4f1a..de6984f 100644
@@ -74,18 +74,6 @@ struct storvsc_cmd_request {
 };
 
 
-/*
- * storvsc_initialize - Main entry point
- */
-static int storvsc_initialize(struct hv_driver *driver)
-{
-	struct storvsc_driver *stor_driver;
-
-	stor_driver = hvdr_to_stordr(driver);
-
-	return 0;
-}
-
 static int storvsc_device_alloc(struct scsi_device *sdevice)
 {
 	/*
@@ -775,7 +763,6 @@ static struct storvsc_driver storvsc_drv = {
 static int storvsc_drv_init(void)
 {
 	int ret;
-	struct storvsc_driver *storvsc_drv_obj = &storvsc_drv;
 	struct hv_driver *drv = &storvsc_drv.base;
 	u32 max_outstanding_req_per_channel;
 
@@ -792,9 +779,6 @@ static int storvsc_drv_init(void)
 	sizeof(struct vstor_packet) + sizeof(u64),
 	sizeof(u64)));
 
-	/* Callback to client driver to complete the initialization */
-	storvsc_initialize(&storvsc_drv_obj->base);
-
 	memcpy(&drv->dev_type, &gStorVscDeviceType,
 	       sizeof(struct hv_guid));
 
Signature · 1 line
1.7.4.1
#152 lore raw

PATCH 142/206 Staging: hv: Get rid of some unused functions

In reply to K. Y. Srinivasan

Now get rid of unused functions.

---
 drivers/staging/hv/storvsc_api.h |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -12
index d2917eb..4db913f 100644
@@ -144,18 +144,6 @@ static inline void put_stor_device(struct hv_device *device)
 	atomic_dec(&stor_device->ref_count);
 }
 
-static inline struct storvsc_driver *hvdr_to_stordr(struct hv_driver *d)
-{
-	return container_of(d, struct storvsc_driver, base);
-}
-
-static inline
-struct storvsc_driver *drv_to_stordrv(struct device_driver *d)
-{
-	struct hv_driver *hvdrv = drv_to_hv_drv(d);
-	return hvdr_to_stordr(hvdrv);
-}
-
 static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
 {
 	dev->drain_notify = true;
Signature · 1 line
1.7.4.1
#153 lore raw

PATCH 143/206 Staging: hv: Make storvsc_drv an instance of hv_driver

In reply to K. Y. Srinivasan

In preparation for eliminating struct storvsc_driver, make the variable storvsc_drv an instance of struct hv_driver.

---
 drivers/staging/hv/storvsc_drv.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc_drv.c +5 -5
index de6984f..907d855 100644
@@ -751,9 +751,9 @@ static int storvsc_probe(struct hv_device *device)
 
 /* The one and only one */
 
-static struct storvsc_driver storvsc_drv = {
-	.base.probe = storvsc_probe,
-	.base.remove = storvsc_remove,
+static struct hv_driver storvsc_drv = {
+	.probe = storvsc_probe,
+	.remove = storvsc_remove,
 };
 
 
@@ -763,7 +763,7 @@ static struct storvsc_driver storvsc_drv = {
 static int storvsc_drv_init(void)
 {
 	int ret;
-	struct hv_driver *drv = &storvsc_drv.base;
+	struct hv_driver *drv = &storvsc_drv;
 	u32 max_outstanding_req_per_channel;
 
 	/*
@@ -805,7 +805,7 @@ static int storvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void storvsc_drv_exit(void)
 {
-	struct hv_driver *drv = &storvsc_drv.base;
+	struct hv_driver *drv = &storvsc_drv;
 	struct device *current_dev = NULL;
 	int ret;
 
Signature · 1 line
1.7.4.1
#154 lore raw

PATCH 144/206 Staging: hv: Make blkvsc_drv an instance of struct hv_driver

In reply to K. Y. Srinivasan

Make blkvsc_drv an instance of struct hv_driver.

---
 drivers/staging/hv/blkvsc_drv.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/hv/blkvsc_drv.c +6 -6
index c04aaa3..10da9bb 100644
@@ -801,10 +801,10 @@ static void blkvsc_request(struct request_queue *queue)
 
 
 /* The one and only one */
-static  struct storvsc_driver blkvsc_drv = {
-	.base.probe =  blkvsc_probe,
-	.base.remove =  blkvsc_remove,
-	.base.shutdown = blkvsc_shutdown,
+static  struct hv_driver blkvsc_drv = {
+	.probe =  blkvsc_probe,
+	.remove =  blkvsc_remove,
+	.shutdown = blkvsc_shutdown,
 };
 
 static const struct block_device_operations block_ops = {
@@ -820,7 +820,7 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct hv_driver *drv = &blkvsc_drv.base;
+	struct hv_driver *drv = &blkvsc_drv;
 	int ret;
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
@@ -844,7 +844,7 @@ static int blkvsc_drv_exit_cb(struct device *dev, void *data)
 
 static void blkvsc_drv_exit(void)
 {
-	struct hv_driver *drv = &blkvsc_drv.base;
+	struct hv_driver *drv = &blkvsc_drv;
 	struct device *current_dev;
 	int ret;
 
Signature · 1 line
1.7.4.1
#155 lore raw

PATCH 145/206 Staging: hv: Get rid of struct storvsc_driver

In reply to K. Y. Srinivasan

Now get rid of struct storvsc_driver as it is not needed.

---
 drivers/staging/hv/storvsc_api.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc_api.h +0 -5
index 4db913f..b163515 100644
@@ -73,11 +73,6 @@ struct hv_storvsc_request {
 };
 
 
-/* Represents the block vsc driver */
-struct storvsc_driver {
-	struct hv_driver base;
-};
-
 struct storvsc_device_info {
 	u32 ring_buffer_size;
 	unsigned int port_number;
Signature · 1 line
1.7.4.1
#156 lore raw

PATCH 146/206 Staging: hv: Directly assign the driver name

In reply to K. Y. Srinivasan

Directly assign the driver name.

---
 drivers/staging/hv/hv_mouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/hv_mouse.c +1 -1
index 4475534..5f30e39 100644
@@ -997,7 +997,7 @@ static int __init mousevsc_init(void)
 	/* Callback to client driver to complete the initialization */
 	mouse_vsc_initialize(&input_drv_obj->base);
 
-	drv->driver.name = input_drv_obj->base.name;
+	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
 	vmbus_child_driver_register(&drv->driver);
Signature · 1 line
1.7.4.1
#157 lore raw

PATCH 147/206 Staging: hv: Move the assignment of name variable

In reply to K. Y. Srinivasan

In preparation to eliminate mouse_vsc_initialize, move the assignment of driver name.

---
 drivers/staging/hv/hv_mouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/hv_mouse.c +1 -1
index 5f30e39..b4c087f 100644
@@ -979,7 +979,6 @@ static void mousevsc_drv_exit(void)
 
 static int mouse_vsc_initialize(struct hv_driver *driver)
 {
-	driver->name = driver_name;
 	memcpy(&driver->dev_type, &mouse_guid,
 	       sizeof(struct hv_guid));
 
@@ -998,6 +997,7 @@ static int __init mousevsc_init(void)
 	mouse_vsc_initialize(&input_drv_obj->base);
 
 	drv->driver.name = driver_name;
+	drv->name = driver_name;
 
 	/* The driver belongs to vmbus */
 	vmbus_child_driver_register(&drv->driver);
Signature · 1 line
1.7.4.1
#158 lore raw

PATCH 148/206 Staging: hv: Move the code to copy dev_type information

In reply to K. Y. Srinivasan

In preparation to eliminate mouse_vsc_initialize, move the code that copies the dev_type info.

---
 drivers/staging/hv/hv_mouse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/hv_mouse.c +2 -2
index b4c087f..85b95d8 100644
@@ -979,8 +979,6 @@ static void mousevsc_drv_exit(void)
 
 static int mouse_vsc_initialize(struct hv_driver *driver)
 {
-	memcpy(&driver->dev_type, &mouse_guid,
-	       sizeof(struct hv_guid));
 
 	return 0;
 }
@@ -995,6 +993,8 @@ static int __init mousevsc_init(void)
 
 	/* Callback to client driver to complete the initialization */
 	mouse_vsc_initialize(&input_drv_obj->base);
+	memcpy(&drv->dev_type, &mouse_guid,
+	       sizeof(struct hv_guid));
 
 	drv->driver.name = driver_name;
 	drv->name = driver_name;
Signature · 1 line
1.7.4.1
#159 lore raw

PATCH 149/206 Staging: hv: Get rid of an empty function

In reply to K. Y. Srinivasan

Now, get rid of the empty function.

---
 drivers/staging/hv/hv_mouse.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
drivers/staging/hv/hv_mouse.c +0 -10
index 85b95d8..6dc2761 100644
@@ -977,22 +977,12 @@ static void mousevsc_drv_exit(void)
 	return;
 }
 
-static int mouse_vsc_initialize(struct hv_driver *driver)
-{
-
-	return 0;
-}
-
-
 static int __init mousevsc_init(void)
 {
-	struct mousevsc_drv_obj *input_drv_obj = &mousevsc_drv;
 	struct hv_driver *drv = &mousevsc_drv.base;
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
-	/* Callback to client driver to complete the initialization */
-	mouse_vsc_initialize(&input_drv_obj->base);
 	memcpy(&drv->dev_type, &mouse_guid,
 	       sizeof(struct hv_guid));
 
Signature · 1 line
1.7.4.1
#160 lore raw

PATCH 150/206 Staging: hv: Make mousevsc_drv an instance of struct hv_driver

In reply to K. Y. Srinivasan

In preparation to eliminate struct mousevsc_drv_obj, make struct mousevsc_drv an instance of struct hv_driver.

---
 drivers/staging/hv/hv_mouse.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/hv/hv_mouse.c +9 -9
index 6dc2761..0eca451 100644
@@ -428,14 +428,14 @@ Cleanup:
 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
 				struct synthhid_input_report *input_report)
 {
-	struct mousevsc_drv_obj *input_drv;
+	struct hv_driver *input_drv;
 
 	if (!input_device->init_complete) {
 		pr_info("Initialization incomplete...ignoring input_report msg");
 		return;
 	}
 
-	input_drv = drv_to_mousedrv(input_device->device->device.driver);
+	input_drv = drv_to_hv_drv(input_device->device->device.driver);
 
 	inputreport_callback(input_device->device,
 			     input_report->buffer,
@@ -680,7 +680,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 {
 	int ret = 0;
 	struct mousevsc_dev *input_dev;
-	struct mousevsc_drv_obj *input_drv;
+	struct hv_driver *input_drv;
 	struct hv_input_dev_info dev_info;
 
 	input_dev = alloc_input_device(device);
@@ -720,7 +720,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		return ret;
 	}
 
-	input_drv = drv_to_mousedrv(input_dev->device->device.driver);
+	input_drv = drv_to_hv_drv(input_dev->device->device.driver);
 
 	dev_info.vendor = input_dev->hid_dev_info.vendor;
 	dev_info.product = input_dev->hid_dev_info.product;
@@ -943,14 +943,14 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 	return 1;
 }
 
-static struct  mousevsc_drv_obj mousevsc_drv = {
-	.base.probe = mousevsc_probe,
-	.base.remove = mousevsc_remove,
+static struct  hv_driver mousevsc_drv = {
+	.probe = mousevsc_probe,
+	.remove = mousevsc_remove,
 };
 
 static void mousevsc_drv_exit(void)
 {
-	struct hv_driver *drv = &mousevsc_drv.base;
+	struct hv_driver *drv = &mousevsc_drv;
 	int ret;
 
 	struct device *current_dev = NULL;
@@ -979,7 +979,7 @@ static void mousevsc_drv_exit(void)
 
 static int __init mousevsc_init(void)
 {
-	struct hv_driver *drv = &mousevsc_drv.base;
+	struct hv_driver *drv = &mousevsc_drv;
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
Signature · 1 line
1.7.4.1
#161 lore raw

PATCH 151/206 Staging: hv: Get rid of some unused code

In reply to K. Y. Srinivasan

Now, get rid of struct mousevsc_drv_obj.

---
 drivers/staging/hv/hv_mouse.c |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
drivers/staging/hv/hv_mouse.c +0 -14
index 0eca451..af4db64 100644
@@ -45,20 +45,6 @@ struct hv_input_dev_info {
 	char name[128];
 };
 
-/* Represents the input vsc driver */
-/* FIXME - can be removed entirely */
-struct mousevsc_drv_obj {
-	struct hv_driver base;
-};
-
-
-static inline
-struct mousevsc_drv_obj *drv_to_mousedrv(struct device_driver *d)
-{
-	struct hv_driver *hvdrv = drv_to_hv_drv(d);
-	return container_of(hvdrv, struct mousevsc_drv_obj, base);
-}
-
 /* The maximum size of a synthetic input message. */
 #define SYNTHHID_MAX_INPUT_REPORT_SIZE 16
 
Signature · 1 line
1.7.4.1
#162 lore raw

PATCH 152/206 Staging: hv: Create a common header for all hyperv drivers to include

In reply to K. Y. Srinivasan

Create a common header for all hyperv drivers to include. Free at last ...

---
 include/linux/hyperv.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/hyperv.h
include/linux/hyperv.h new file +23 -0
new file mode 100644
index 0000000..ce27244
@@ -0,0 +1,23 @@
+/*
+ *
+ * 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 <[email protected]>
+ *   Hank Janssen  <[email protected]>
+ *   K. Y. Srinivasan <[email protected]>
+ *
+ */
Signature · 1 line
1.7.4.1
#163 lore raw

PATCH 153/206 Staging: hv:Include the contents of channel.h

In reply to K. Y. Srinivasan

The subject line says it all.

---
 include/linux/hyperv.h |   89 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)
include/linux/hyperv.h +89 -0
index ce27244..d13d72a 100644
@@ -21,3 +21,92 @@
  *   K. Y. Srinivasan <[email protected]>
  *
  */
+
+#ifndef _HYPERV_H
+#define _HYPERV_H
+
+#include "channel_mgmt.h"
+
+/* The format must be the same as struct vmdata_gpa_direct */
+struct vmbus_channel_packet_page_buffer {
+	u16 type;
+	u16 dataoffset8;
+	u16 length8;
+	u16 flags;
+	u64 transactionid;
+	u32 reserved;
+	u32 rangecount;
+	struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
+} __packed;
+
+/* The format must be the same as struct vmdata_gpa_direct */
+struct vmbus_channel_packet_multipage_buffer {
+	u16 type;
+	u16 dataoffset8;
+	u16 length8;
+	u16 flags;
+	u64 transactionid;
+	u32 reserved;
+	u32 rangecount;		/* Always 1 in this case */
+	struct hv_multipage_buffer range;
+} __packed;
+
+
+extern int vmbus_open(struct vmbus_channel *channel,
+			    u32 send_ringbuffersize,
+			    u32 recv_ringbuffersize,
+			    void *userdata,
+			    u32 userdatalen,
+			    void(*onchannel_callback)(void *context),
+			    void *context);
+
+extern void vmbus_close(struct vmbus_channel *channel);
+
+extern int vmbus_sendpacket(struct vmbus_channel *channel,
+				  const void *buffer,
+				  u32 bufferLen,
+				  u64 requestid,
+				  enum vmbus_packet_type type,
+				  u32 flags);
+
+extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
+					    struct hv_page_buffer pagebuffers[],
+					    u32 pagecount,
+					    void *buffer,
+					    u32 bufferlen,
+					    u64 requestid);
+
+extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
+					struct hv_multipage_buffer *mpb,
+					void *buffer,
+					u32 bufferlen,
+					u64 requestid);
+
+extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
+				      void *kbuffer,
+				      u32 size,
+				      u32 *gpadl_handle);
+
+extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
+				     u32 gpadl_handle);
+
+extern int vmbus_recvpacket(struct vmbus_channel *channel,
+				  void *buffer,
+				  u32 bufferlen,
+				  u32 *buffer_actual_len,
+				  u64 *requestid);
+
+extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
+				     void *buffer,
+				     u32 bufferlen,
+				     u32 *buffer_actual_len,
+				     u64 *requestid);
+
+extern void vmbus_onchannel_event(struct vmbus_channel *channel);
+
+extern void vmbus_get_debug_info(struct vmbus_channel *channel,
+				     struct vmbus_channel_debug_info *debug);
+
+extern void vmbus_ontimer(unsigned long data);
+
+#endif /* _HYPERV_H_ */
Signature · 1 line
1.7.4.1
#164 lore raw

PATCH 154/206 Staging: hv: Include the contents of channel_mgmt.h

In reply to K. Y. Srinivasan

The subject line says it all.

---
 include/linux/hyperv.h |  292 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 291 insertions(+), 1 deletions(-)
include/linux/hyperv.h +291 -1
index d13d72a..932aafa 100644
@@ -25,7 +25,297 @@
 #ifndef _HYPERV_H
 #define _HYPERV_H
 
-#include "channel_mgmt.h"
+
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+#include <linux/completion.h>
+#include "ring_buffer.h"
+#include "vmbus_channel_interface.h"
+#include "vmbus_packet_format.h"
+
+/* Version 1 messages */
+enum vmbus_channel_message_type {
+	CHANNELMSG_INVALID			=  0,
+	CHANNELMSG_OFFERCHANNEL		=  1,
+	CHANNELMSG_RESCIND_CHANNELOFFER	=  2,
+	CHANNELMSG_REQUESTOFFERS		=  3,
+	CHANNELMSG_ALLOFFERS_DELIVERED	=  4,
+	CHANNELMSG_OPENCHANNEL		=  5,
+	CHANNELMSG_OPENCHANNEL_RESULT		=  6,
+	CHANNELMSG_CLOSECHANNEL		=  7,
+	CHANNELMSG_GPADL_HEADER		=  8,
+	CHANNELMSG_GPADL_BODY			=  9,
+	CHANNELMSG_GPADL_CREATED		= 10,
+	CHANNELMSG_GPADL_TEARDOWN		= 11,
+	CHANNELMSG_GPADL_TORNDOWN		= 12,
+	CHANNELMSG_RELID_RELEASED		= 13,
+	CHANNELMSG_INITIATE_CONTACT		= 14,
+	CHANNELMSG_VERSION_RESPONSE		= 15,
+	CHANNELMSG_UNLOAD			= 16,
+#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
+	CHANNELMSG_VIEWRANGE_ADD		= 17,
+	CHANNELMSG_VIEWRANGE_REMOVE		= 18,
+#endif
+	CHANNELMSG_COUNT
+};
+
+struct vmbus_channel_message_header {
+	enum vmbus_channel_message_type msgtype;
+	u32 padding;
+} __packed;
+
+/* Query VMBus Version parameters */
+struct vmbus_channel_query_vmbus_version {
+	struct vmbus_channel_message_header header;
+	u32 version;
+} __packed;
+
+/* VMBus Version Supported parameters */
+struct vmbus_channel_version_supported {
+	struct vmbus_channel_message_header header;
+	bool version_supported;
+} __packed;
+
+/* Offer Channel parameters */
+struct vmbus_channel_offer_channel {
+	struct vmbus_channel_message_header header;
+	struct vmbus_channel_offer offer;
+	u32 child_relid;
+	u8 monitorid;
+	bool monitor_allocated;
+} __packed;
+
+/* Rescind Offer parameters */
+struct vmbus_channel_rescind_offer {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+} __packed;
+
+/*
+ * Request Offer -- no parameters, SynIC message contains the partition ID
+ * Set Snoop -- no parameters, SynIC message contains the partition ID
+ * Clear Snoop -- no parameters, SynIC message contains the partition ID
+ * All Offers Delivered -- no parameters, SynIC message contains the partition
+ *		           ID
+ * Flush Client -- no parameters, SynIC message contains the partition ID
+ */
+
+/* Open Channel parameters */
+struct vmbus_channel_open_channel {
+	struct vmbus_channel_message_header header;
+
+	/* Identifies the specific VMBus channel that is being opened. */
+	u32 child_relid;
+
+	/* ID making a particular open request at a channel offer unique. */
+	u32 openid;
+
+	/* GPADL for the channel's ring buffer. */
+	u32 ringbuffer_gpadlhandle;
+
+	/* GPADL for the channel's server context save area. */
+	u32 server_contextarea_gpadlhandle;
+
+	/*
+	* The upstream ring buffer begins at offset zero in the memory
+	* described by RingBufferGpadlHandle. The downstream ring buffer
+	* follows it at this offset (in pages).
+	*/
+	u32 downstream_ringbuffer_pageoffset;
+
+	/* User-specific data to be passed along to the server endpoint. */
+	unsigned char userdata[MAX_USER_DEFINED_BYTES];
+} __packed;
+
+/* Open Channel Result parameters */
+struct vmbus_channel_open_result {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+	u32 openid;
+	u32 status;
+} __packed;
+
+/* Close channel parameters; */
+struct vmbus_channel_close_channel {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+} __packed;
+
+/* Channel Message GPADL */
+#define GPADL_TYPE_RING_BUFFER		1
+#define GPADL_TYPE_SERVER_SAVE_AREA	2
+#define GPADL_TYPE_TRANSACTION		8
+
+/*
+ * The number of PFNs in a GPADL message is defined by the number of
+ * pages that would be spanned by ByteCount and ByteOffset.  If the
+ * implied number of PFNs won't fit in this packet, there will be a
+ * follow-up packet that contains more.
+ */
+struct vmbus_channel_gpadl_header {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+	u32 gpadl;
+	u16 range_buflen;
+	u16 rangecount;
+	struct gpa_range range[0];
+} __packed;
+
+/* This is the followup packet that contains more PFNs. */
+struct vmbus_channel_gpadl_body {
+	struct vmbus_channel_message_header header;
+	u32 msgnumber;
+	u32 gpadl;
+	u64 pfn[0];
+} __packed;
+
+struct vmbus_channel_gpadl_created {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+	u32 gpadl;
+	u32 creation_status;
+} __packed;
+
+struct vmbus_channel_gpadl_teardown {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+	u32 gpadl;
+} __packed;
+
+struct vmbus_channel_gpadl_torndown {
+	struct vmbus_channel_message_header header;
+	u32 gpadl;
+} __packed;
+
+#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
+struct vmbus_channel_view_range_add {
+	struct vmbus_channel_message_header header;
+	PHYSICAL_ADDRESS viewrange_base;
+	u64 viewrange_length;
+	u32 child_relid;
+} __packed;
+
+struct vmbus_channel_view_range_remove {
+	struct vmbus_channel_message_header header;
+	PHYSICAL_ADDRESS viewrange_base;
+	u32 child_relid;
+} __packed;
+#endif
+
+struct vmbus_channel_relid_released {
+	struct vmbus_channel_message_header header;
+	u32 child_relid;
+} __packed;
+
+struct vmbus_channel_initiate_contact {
+	struct vmbus_channel_message_header header;
+	u32 vmbus_version_requested;
+	u32 padding2;
+	u64 interrupt_page;
+	u64 monitor_page1;
+	u64 monitor_page2;
+} __packed;
+
+struct vmbus_channel_version_response {
+	struct vmbus_channel_message_header header;
+	bool version_supported;
+} __packed;
+
+enum vmbus_channel_state {
+	CHANNEL_OFFER_STATE,
+	CHANNEL_OPENING_STATE,
+	CHANNEL_OPEN_STATE,
+};
+
+struct vmbus_channel {
+	struct list_head listentry;
+
+	struct hv_device *device_obj;
+
+	struct timer_list poll_timer; /* SA-111 workaround */
+	struct work_struct work;
+
+	enum vmbus_channel_state state;
+
+	struct vmbus_channel_offer_channel offermsg;
+	/*
+	 * These are based on the OfferMsg.MonitorId.
+	 * Save it here for easy access.
+	 */
+	u8 monitor_grp;
+	u8 monitor_bit;
+
+	u32 ringbuffer_gpadlhandle;
+
+	/* Allocated memory for ring buffer */
+	void *ringbuffer_pages;
+	u32 ringbuffer_pagecount;
+	struct hv_ring_buffer_info outbound;	/* send to parent */
+	struct hv_ring_buffer_info inbound;	/* receive from parent */
+	spinlock_t inbound_lock;
+	struct workqueue_struct *controlwq;
+
+	/* Channel callback are invoked in this workqueue context */
+	/* HANDLE dataWorkQueue; */
+
+	void (*onchannel_callback)(void *context);
+	void *channel_callback_context;
+};
+
+struct vmbus_channel_debug_info {
+	u32 relid;
+	enum vmbus_channel_state state;
+	struct hv_guid interfacetype;
+	struct hv_guid interface_instance;
+	u32 monitorid;
+	u32 servermonitor_pending;
+	u32 servermonitor_latency;
+	u32 servermonitor_connectionid;
+	u32 clientmonitor_pending;
+	u32 clientmonitor_latency;
+	u32 clientmonitor_connectionid;
+
+	struct hv_ring_buffer_debug_info inbound;
+	struct hv_ring_buffer_debug_info outbound;
+};
+
+/*
+ * Represents each channel msg on the vmbus connection This is a
+ * variable-size data structure depending on the msg type itself
+ */
+struct vmbus_channel_msginfo {
+	/* Bookkeeping stuff */
+	struct list_head msglistentry;
+
+	/* So far, this is only used to handle gpadl body message */
+	struct list_head submsglist;
+
+	/* Synchronize the request/response if needed */
+	struct completion  waitevent;
+	union {
+		struct vmbus_channel_version_supported version_supported;
+		struct vmbus_channel_open_result open_result;
+		struct vmbus_channel_gpadl_torndown gpadl_torndown;
+		struct vmbus_channel_gpadl_created gpadl_created;
+		struct vmbus_channel_version_response version_response;
+	} response;
+
+	u32 msgsize;
+	/*
+	 * The channel message that goes out on the "wire".
+	 * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
+	 */
+	unsigned char msg[0];
+};
+
+
+void free_channel(struct vmbus_channel *channel);
+
+void vmbus_onmessage(void *context);
+
+int vmbus_request_offers(void);
+
 
 /* The format must be the same as struct vmdata_gpa_direct */
 struct vmbus_channel_packet_page_buffer {
Signature · 1 line
1.7.4.1
#165 lore raw

PATCH 155/206 Staging: hv: Include the contents of ring_buffer.h

In reply to K. Y. Srinivasan

The subject line says it all.

---
 include/linux/hyperv.h |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)
include/linux/hyperv.h +44 -1
index 932aafa..d0eec1d 100644
@@ -30,7 +30,50 @@
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
-#include "ring_buffer.h"
+#include <linux/scatterlist.h>
+
+struct hv_ring_buffer {
+	/* Offset in bytes from the start of ring data below */
+	u32 write_index;
+
+	/* Offset in bytes from the start of ring data below */
+	u32 read_index;
+
+	u32 interrupt_mask;
+
+	/* Pad it to PAGE_SIZE so that data starts on page boundary */
+	u8	reserved[4084];
+
+	/* NOTE:
+	 * The interrupt_mask field is used only for channels but since our
+	 * vmbus connection also uses this data structure and its data starts
+	 * here, we commented out this field.
+	 */
+
+	/*
+	 * Ring data starts here + RingDataStartOffset
+	 * !!! DO NOT place any fields below this !!!
+	 */
+	u8 buffer[0];
+} __packed;
+
+struct hv_ring_buffer_info {
+	struct hv_ring_buffer *ring_buffer;
+	u32 ring_size;			/* Include the shared header */
+	spinlock_t ring_lock;
+
+	u32 ring_datasize;		/* < ring_size */
+	u32 ring_data_startoffset;
+};
+
+struct hv_ring_buffer_debug_info {
+	u32 current_interrupt_mask;
+	u32 current_read_index;
+	u32 current_write_index;
+	u32 bytes_avail_toread;
+	u32 bytes_avail_towrite;
+};
+
 #include "vmbus_channel_interface.h"
 #include "vmbus_packet_format.h"
 
Signature · 1 line
1.7.4.1