[PATCH 0000/0025] Staging: hv: Driver cleanup

2011-09-08 Thread K. Y. Srinivasan
Address Greg's VmBus audit comments:

1) Leverage driver_data field in struct hv_vmbus_device_id to
   simplify driver code.

2) Make the util driver conform to the Linux Driver Model.

3) Get rid of the ext field in struct hv_device by using the
   driver specific data functionality.

4) Other general cleanup.


Regards,

K. Y

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 05/25] Staging: hv: vmbus: Change the signature of struct hv_driver probe function

2011-09-08 Thread K. Y. Srinivasan
In preparation to leveraging the driver_data field in struct
hv_vmbus_device_id, change the signature of struct hv_driver probe function.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_mouse.c|3 ++-
 drivers/staging/hv/hv_util.c |3 ++-
 drivers/staging/hv/hyperv.h  |2 +-
 drivers/staging/hv/netvsc_drv.c  |3 ++-
 drivers/staging/hv/storvsc_drv.c |3 ++-
 drivers/staging/hv/vmbus_drv.c   |8 +++-
 6 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index dbb04ee..5ff8a03 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -823,7 +823,8 @@ static int mousevsc_on_device_remove(struct hv_device 
*device)
 }
 
 
-static int mousevsc_probe(struct hv_device *dev)
+static int mousevsc_probe(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
int ret = 0;
 
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 6039217..d9460fdd 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -239,7 +239,8 @@ static void heartbeat_onchannelcallback(void *context)
  * The devices managed by the util driver don't need any additional
  * setup.
  */
-static int util_probe(struct hv_device *dev)
+static int util_probe(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
return 0;
 }
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index c249811..caa3a7b 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -810,7 +810,7 @@ struct hv_driver {
 
struct device_driver driver;
 
-   int (*probe)(struct hv_device *);
+   int (*probe)(struct hv_device *, const struct hv_vmbus_device_id *);
int (*remove)(struct hv_device *);
void (*shutdown)(struct hv_device *);
 
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 30b9c80..d06cde2 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -329,7 +329,8 @@ static void netvsc_send_garp(struct work_struct *w)
 }
 
 
-static int netvsc_probe(struct hv_device *dev)
+static int netvsc_probe(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
struct net_device *net = NULL;
struct net_device_context *net_device_ctx;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index b0c4e56..fff1e5b 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1380,7 +1380,8 @@ MODULE_DEVICE_TABLE(vmbus, id_table);
  * storvsc_probe - Add a new device for this driver
  */
 
-static int storvsc_probe(struct hv_device *device)
+static int storvsc_probe(struct hv_device *device,
+   const struct hv_vmbus_device_id *dev_id)
 {
int ret;
struct Scsi_Host *host;
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 375e451..c7df7f4 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -299,9 +299,15 @@ static int vmbus_probe(struct device *child_device)
struct hv_driver *drv =
drv_to_hv_drv(child_device-driver);
struct hv_device *dev = device_to_hv_device(child_device);
+   const struct hv_vmbus_device_id *dev_id = drv-id_table;
+
+   for (; !is_null_guid(dev_id-guid); dev_id++)
+   if (!memcmp(dev_id-guid, dev-dev_type.b,
+   sizeof(uuid_le)))
+   break;
 
if (drv-probe) {
-   ret = drv-probe(dev);
+   ret = drv-probe(dev, dev_id);
if (ret != 0)
pr_err(probe failed for device %s (%d)\n,
   dev_name(child_device), ret);
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 16/25] Staging: hv: storvsc: Get rid of alloc_stor_device() by inlining the code

2011-09-08 Thread K. Y. Srinivasan
Get rid of alloc_stor_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   24 ++--
 1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ef93205..e7d0f92 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -332,23 +332,6 @@ static inline void storvsc_wait_to_drain(struct 
storvsc_device *dev)
dev-drain_notify = false;
 }
 
-static inline struct storvsc_device *alloc_stor_device(struct hv_device 
*device)
-{
-   struct storvsc_device *stor_device;
-
-   stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
-   if (!stor_device)
-   return NULL;
-
-   stor_device-destroy = false;
-   init_waitqueue_head(stor_device-waiting_to_drain);
-   stor_device-device = device;
-   device-ext = stor_device;
-
-   return stor_device;
-}
-
-
 static inline struct storvsc_device *get_in_stor_device(
struct hv_device *device)
 {
@@ -1382,13 +1365,18 @@ static int storvsc_probe(struct hv_device *device,
return -ENOMEM;
}
 
-   stor_device = alloc_stor_device(device);
+   stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
if (!stor_device) {
kmem_cache_destroy(host_dev-request_pool);
scsi_host_put(host);
return -ENOMEM;
}
 
+   stor_device-destroy = false;
+   init_waitqueue_head(stor_device-waiting_to_drain);
+   stor_device-device = device;
+   device-ext = stor_device;
+
stor_device-port_number = host-host_no;
ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
if (ret) {
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 09/25] Staging: hv: util: Perform some service specific de-initialization in util_remove()

2011-09-08 Thread K. Y. Srinivasan
In preparation for modifying the util driver to fully conform to the
Linux Driver Model, perform some service specific de-initialization in
util_remove() as opposed to in exit_hyperv_utils() as is currently done.


Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_util.c |   29 -
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index b86128a..2475ab2 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -291,6 +291,30 @@ error:
 static int util_remove(struct hv_device *dev,
const struct hv_vmbus_device_id *dev_id)
 {
+   int service = dev_id-driver_data;
+
+   switch (service) {
+   case HV_SHUTDOWN:
+   kfree(shut_txf_buf);
+   break;
+
+   case HV_TIMESYNC:
+   kfree(time_txf_buf);
+   break;
+
+   case HV_HEARTBEAT:
+   kfree(hbeat_txf_buf);
+   break;
+
+   case HV_KVP:
+   hv_kvp_deinit();
+   break;
+
+   default:
+   pr_err(unknown util service\n);
+   return -ENODEV;
+   }
+
return 0;
 }
 
@@ -370,11 +394,6 @@ static void exit_hyperv_utils(void)
chn_cb_negotiate;
hv_cb_utils[HV_KVP_MSG].callback = NULL;
 
-   hv_kvp_deinit();
-
-   kfree(shut_txf_buf);
-   kfree(time_txf_buf);
-   kfree(hbeat_txf_buf);
vmbus_driver_unregister(util_drv);
 }
 
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 08/25] Staging: hv: util: Perform some service specific initialization in util_probe()

2011-09-08 Thread K. Y. Srinivasan
In preparation for modifying the util driver to fully conform to the 
Linux Driver Model, perform some service specific initialization in
util_probe() as opposed to in init_hyperv_utils() as is currently done. 

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_util.c |   77 -
 1 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 661631d..b86128a 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -34,6 +34,13 @@ static u8 *shut_txf_buf;
 static u8 *time_txf_buf;
 static u8 *hbeat_txf_buf;
 
+enum hv_util_services {
+   HV_SHUTDOWN,
+   HV_TIMESYNC,
+   HV_HEARTBEAT,
+   HV_KVP,
+};
+
 static void shutdown_onchannelcallback(void *context)
 {
struct vmbus_channel *channel = context;
@@ -242,7 +249,43 @@ static void heartbeat_onchannelcallback(void *context)
 static int util_probe(struct hv_device *dev,
const struct hv_vmbus_device_id *dev_id)
 {
+   void *buf = NULL;
+   int service = dev_id-driver_data;
+
+   switch (service) {
+   case HV_SHUTDOWN:
+   buf = shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!shut_txf_buf)
+   goto error;
+   break;
+
+   case HV_TIMESYNC:
+   buf = time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!time_txf_buf)
+   goto error;
+   break;
+
+   case HV_HEARTBEAT:
+   buf = hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!hbeat_txf_buf)
+   goto error;
+   break;
+
+   case HV_KVP:
+   if (hv_kvp_init())
+   return -ENODEV;
+   break;
+
+   default:
+   pr_err(unknown util service\n);
+   return -ENODEV;
+   }
+
return 0;
+
+error:
+   return -ENOMEM;
+
 }
 
 static int util_remove(struct hv_device *dev,
@@ -254,16 +297,20 @@ static int util_remove(struct hv_device *dev,
 static const struct hv_vmbus_device_id id_table[] = {
/* Shutdown guid */
{ VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
-  0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) },
+  0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB)
+ .driver_data = HV_SHUTDOWN },
/* Time synch guid */
{ VMBUS_DEVICE(0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
-  0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) },
+  0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf)
+ .driver_data = HV_TIMESYNC },
/* Heartbeat guid */
{ VMBUS_DEVICE(0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
-  0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) },
+  0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d)
+ .driver_data = HV_HEARTBEAT },
/* KVP guid */
{ VMBUS_DEVICE(0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
-  0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6) },
+  0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6)
+ .driver_data = HV_KVP },
{ },
 };
 
@@ -282,24 +329,10 @@ static int __init init_hyperv_utils(void)
int ret;
pr_info(Registering HyperV Utility Driver\n);
 
-   if (hv_kvp_init())
-   return -ENODEV;
-
-
-   shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-   time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-   hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-
-   if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
-   pr_info(Unable to allocate memory for receive buffer\n);
-   ret = -ENOMEM;
-   goto err;
-   }
-
ret = vmbus_driver_register(util_drv);
 
if (ret != 0)
-   goto err;
+   return ret;
 
hv_cb_utils[HV_SHUTDOWN_MSG].callback = shutdown_onchannelcallback;
 
@@ -311,12 +344,6 @@ static int __init init_hyperv_utils(void)
 
return 0;
 
-err:
-   kfree(shut_txf_buf);
-   kfree(time_txf_buf);
-   kfree(hbeat_txf_buf);
-
-   return ret;
 }
 
 static void exit_hyperv_utils(void)
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 17/25] Staging: hv: storvsc: Get rid of some unnecessary state and definitions

2011-09-08 Thread K. Y. Srinivasan
Now, get rid of some unnecessary state and definitions.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e7d0f92..57c1035 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -245,7 +245,6 @@ enum storvsc_request_type {
 
 
 struct hv_storvsc_request {
-   struct hv_storvsc_request *request;
struct hv_device *device;
 
/* Synchronize the request/response if needed */
@@ -260,14 +259,6 @@ struct hv_storvsc_request {
 };
 
 
-struct storvsc_device_info {
-   u32 ring_buffer_size;
-   unsigned int port_number;
-   unsigned char path_id;
-   unsigned char target_id;
-};
-
-
 /* A storvsc device is a device object that contains a vmbus channel */
 struct storvsc_device {
struct hv_device *device;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 03/25] Staging: hv: vmbus: Rename vmbus_child_device_unregister

2011-09-08 Thread K. Y. Srinivasan
The vmbus devices are NOT child devices; rename vmbus_child_device_unregister
to reflect this.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/channel_mgmt.c |2 +-
 drivers/staging/hv/hyperv_vmbus.h |2 +-
 drivers/staging/hv/vmbus_drv.c|4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c 
b/drivers/staging/hv/channel_mgmt.c
index a927046..60ce1d1 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -333,7 +333,7 @@ static void vmbus_process_rescind_offer(struct work_struct 
*work)
 struct vmbus_channel,
 work);
 
-   vmbus_child_device_unregister(channel-device_obj);
+   vmbus_device_unregister(channel-device_obj);
 }
 
 /*
diff --git a/drivers/staging/hv/hyperv_vmbus.h 
b/drivers/staging/hv/hyperv_vmbus.h
index b2dfcd6..3d2d836 100644
--- a/drivers/staging/hv/hyperv_vmbus.h
+++ b/drivers/staging/hv/hyperv_vmbus.h
@@ -606,7 +606,7 @@ struct hv_device *vmbus_device_create(uuid_le *type,
 struct vmbus_channel *channel);
 
 int vmbus_device_register(struct hv_device *child_device_obj);
-void vmbus_child_device_unregister(struct hv_device *device_obj);
+void vmbus_device_unregister(struct hv_device *device_obj);
 
 /* static void */
 /* VmbusChildDeviceDestroy( */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 6d54ea1..375e451 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -650,10 +650,10 @@ int vmbus_device_register(struct hv_device 
*child_device_obj)
 }
 
 /*
- * vmbus_child_device_unregister - Remove the specified child device
+ * vmbus_device_unregister - Remove the specified child device
  * from the vmbus.
  */
-void vmbus_child_device_unregister(struct hv_device *device_obj)
+void vmbus_device_unregister(struct hv_device *device_obj)
 {
/*
 * Kick off the process of unregistering the device.
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 18/25] Staging: hv: storvsc: Eliminate the usage of ext field in struct hv_device

2011-09-08 Thread K. Y. Srinivasan
Now, eliminate the usage of ext field in struct  hv_device for storvsc driver.
We do this by registering pointer to struct storvsc_device as the driver
specific data and eliminating the current usage of driver specific data to
save and retrieve the pointer to struct Scsi_Host.
Additionally, all access to the driver specific data is through
the vmbus wrapper functions.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   24 +++-
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 57c1035..98d47cd 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -266,6 +266,7 @@ struct storvsc_device {
bool destroy;
bool drain_notify;
atomic_t num_outstanding_req;
+   struct Scsi_Host *host;
 
wait_queue_head_t waiting_to_drain;
 
@@ -306,7 +307,8 @@ static inline struct storvsc_device *get_out_stor_device(
 {
struct storvsc_device *stor_device;
 
-   stor_device = (struct storvsc_device *)device-ext;
+   stor_device =
+   (struct storvsc_device *)hv_get_drvdata(device);
 
if (stor_device  stor_device-destroy)
stor_device = NULL;
@@ -328,7 +330,8 @@ static inline struct storvsc_device *get_in_stor_device(
 {
struct storvsc_device *stor_device;
 
-   stor_device = (struct storvsc_device *)device-ext;
+   stor_device =
+   (struct storvsc_device *)hv_get_drvdata(device);
 
if (!stor_device)
goto get_in_err;
@@ -480,7 +483,8 @@ static void storvsc_on_io_completion(struct hv_device 
*device,
struct storvsc_device *stor_device;
struct vstor_packet *stor_pkt;
 
-   stor_device = (struct storvsc_device *)device-ext;
+   stor_device =
+   (struct storvsc_device *)hv_get_drvdata(device);
 
stor_pkt = request-vstor_packet;
 
@@ -630,7 +634,8 @@ static int storvsc_dev_remove(struct hv_device *device)
struct storvsc_device *stor_device;
unsigned long flags;
 
-   stor_device = (struct storvsc_device *)device-ext;
+   stor_device =
+   (struct storvsc_device *)hv_get_drvdata(device);
 
spin_lock_irqsave(device-channel-inbound_lock, flags);
stor_device-destroy = true;
@@ -652,7 +657,7 @@ static int storvsc_dev_remove(struct hv_device *device)
 * allow incoming packets.
 */
spin_lock_irqsave(device-channel-inbound_lock, flags);
-   device-ext = NULL;
+   hv_set_drvdata(device, NULL);
spin_unlock_irqrestore(device-channel-inbound_lock, flags);
 
/* Close the channel */
@@ -963,7 +968,9 @@ static unsigned int copy_to_bounce_buffer(struct 
scatterlist *orig_sgl,
 static int storvsc_remove(struct hv_device *dev,
const struct hv_vmbus_device_id *dev_id)
 {
-   struct Scsi_Host *host = dev_get_drvdata(dev-device);
+   struct storvsc_device *stor_device =
+   (struct storvsc_device *)hv_get_drvdata(dev);
+   struct Scsi_Host *host = stor_device-host;
struct hv_host_device *host_dev =
(struct hv_host_device *)host-hostdata;
 
@@ -1338,8 +1345,6 @@ static int storvsc_probe(struct hv_device *device,
if (!host)
return -ENOMEM;
 
-   dev_set_drvdata(device-device, host);
-
host_dev = (struct hv_host_device *)host-hostdata;
memset(host_dev, 0, sizeof(struct hv_host_device));
 
@@ -1366,7 +1371,8 @@ static int storvsc_probe(struct hv_device *device,
stor_device-destroy = false;
init_waitqueue_head(stor_device-waiting_to_drain);
stor_device-device = device;
-   device-ext = stor_device;
+   stor_device-host = host;
+   hv_set_drvdata(device, stor_device);
 
stor_device-port_number = host-host_no;
ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 02/25] Staging: hv: vmbus: Rename vmbus_child_device_register

2011-09-08 Thread K. Y. Srinivasan
The vmbus devices are NOT child devices; rename vmbus_child_device_register
to reflect this.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/channel_mgmt.c |2 +-
 drivers/staging/hv/hyperv_vmbus.h |2 +-
 drivers/staging/hv/vmbus_drv.c|4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c 
b/drivers/staging/hv/channel_mgmt.c
index f99b944..a927046 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -393,7 +393,7 @@ static void vmbus_process_offer(struct work_struct *work)
 * binding which eventually invokes the device driver's AddDevice()
 * method.
 */
-   ret = vmbus_child_device_register(newchannel-device_obj);
+   ret = vmbus_device_register(newchannel-device_obj);
if (ret != 0) {
pr_err(unable to add child device object (relid %d)\n,
   newchannel-offermsg.child_relid);
diff --git a/drivers/staging/hv/hyperv_vmbus.h 
b/drivers/staging/hv/hyperv_vmbus.h
index e97e2cf..b2dfcd6 100644
--- a/drivers/staging/hv/hyperv_vmbus.h
+++ b/drivers/staging/hv/hyperv_vmbus.h
@@ -605,7 +605,7 @@ struct hv_device *vmbus_device_create(uuid_le *type,
 uuid_le *instance,
 struct vmbus_channel *channel);
 
-int vmbus_child_device_register(struct hv_device *child_device_obj);
+int vmbus_device_register(struct hv_device *child_device_obj);
 void vmbus_child_device_unregister(struct hv_device *device_obj);
 
 /* static void */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 382baee..6d54ea1 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -619,9 +619,9 @@ struct hv_device *vmbus_device_create(uuid_le *type,
 }
 
 /*
- * vmbus_child_device_register - Register the child device
+ * vmbus_device_register - Register the child device
  */
-int vmbus_child_device_register(struct hv_device *child_device_obj)
+int vmbus_device_register(struct hv_device *child_device_obj)
 {
int ret = 0;
 
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 12/25] Staging: hv: vmbus: Get rid of hv_cb_utils[] and other unneeded code

2011-09-08 Thread K. Y. Srinivasan
Now that the transformation of the util driver is complete,
get rid of hv_cb_utils[] and other unneeded code

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/channel_mgmt.c |   94 -
 drivers/staging/hv/hyperv.h   |8 ---
 2 files changed, 0 insertions(+), 102 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c 
b/drivers/staging/hv/channel_mgmt.c
index 3c67e4c..f20cd84 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -158,100 +158,6 @@ void prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
 }
 EXPORT_SYMBOL(prep_negotiate_resp);
 
-/**
- * chn_cb_negotiate() - Default handler for non IDE/SCSI/NETWORK
- * Hyper-V requests
- * @context: Pointer to argument structure.
- *
- * Set up the default handler for non device driver specific requests
- * from Hyper-V. This stub responds to the default negotiate messages
- * that come in for every non IDE/SCSI/Network request.
- * This behavior is normally overwritten in the hv_utils driver. That
- * driver handles requests like graceful shutdown, heartbeats etc.
- *
- * Mainly used by Hyper-V drivers.
- */
-void chn_cb_negotiate(void *context)
-{
-   struct vmbus_channel *channel = context;
-   u8 *buf;
-   u32 buflen, recvlen;
-   u64 requestid;
-
-   struct icmsg_hdr *icmsghdrp;
-   struct icmsg_negotiate *negop = NULL;
-
-   buflen = PAGE_SIZE;
-   buf = kmalloc(buflen, GFP_ATOMIC);
-
-   vmbus_recvpacket(channel, buf, buflen, recvlen, requestid);
-
-   if (recvlen  0) {
-   icmsghdrp = (struct icmsg_hdr *)buf[
-   sizeof(struct vmbuspipe_hdr)];
-
-   prep_negotiate_resp(icmsghdrp, negop, buf);
-
-   icmsghdrp-icflags = ICMSGHDRFLAG_TRANSACTION
-   | ICMSGHDRFLAG_RESPONSE;
-
-   vmbus_sendpacket(channel, buf,
-  recvlen, requestid,
-  VM_PKT_DATA_INBAND, 0);
-   }
-
-   kfree(buf);
-}
-EXPORT_SYMBOL(chn_cb_negotiate);
-
-/*
- * Function table used for message responses for non IDE/SCSI/Network type
- * messages. (Such as KVP/Shutdown etc)
- */
-struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
-   /* 0E0B6031-5213-4934-818B-38D90CED39DB */
-   /* Shutdown */
-   {
-   .msg_type = HV_SHUTDOWN_MSG,
-   .data.b = {
-   0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
-   0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
-   },
-   .log_msg = Shutdown channel functionality initialized
-   },
-
-   /* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */
-   /* TimeSync */
-   {
-   .msg_type = HV_TIMESYNC_MSG,
-   .data.b = {
-   0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
-   0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
-   },
-   .log_msg = Timesync channel functionality initialized
-   },
-   /* {57164f39-9115-4e78-ab55-382f3bd5422d} */
-   /* Heartbeat */
-   {
-   .msg_type = HV_HEARTBEAT_MSG,
-   .data.b = {
-   0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
-   0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
-   },
-   .log_msg = Heartbeat channel functionality initialized
-   },
-   /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
-   /* KVP */
-   {
-   .data.b = {
-   0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
-   0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
-   },
-   .log_msg = KVP channel functionality initialized
-   },
-};
-EXPORT_SYMBOL(hv_cb_utils);
-
 /*
  * alloc_channel - Allocate and initialize a vmbus channel object
  */
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index cf02ae1..685a132 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -941,12 +941,6 @@ struct ictimesync_data {
u8 flags;
 } __packed;
 
-/* Index for each IC struct in array hv_cb_utils[] */
-#define HV_SHUTDOWN_MSG0
-#define HV_TIMESYNC_MSG1
-#define HV_HEARTBEAT_MSG   2
-#define HV_KVP_MSG 3
-
 struct hyperv_service_callback {
u8 msg_type;
char *log_msg;
@@ -957,7 +951,5 @@ struct hyperv_service_callback {
 
 extern void prep_negotiate_resp(struct icmsg_hdr *,
struct icmsg_negotiate *, u8 *);
-extern void chn_cb_negotiate(void *);
-extern struct hyperv_service_callback hv_cb_utils[];
 
 #endif /* _HYPERV_H */
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https

[PATCH 07/25] Staging: hv: vmbus: Change the signature of struct hv_driver remove() function

2011-09-08 Thread K. Y. Srinivasan
In preparation for leveraging the driver_data in  struct
hv_vmbus_device_id, change the signature of struct hv_driver remove() function.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_mouse.c|3 ++-
 drivers/staging/hv/hv_util.c |3 ++-
 drivers/staging/hv/hyperv.h  |2 +-
 drivers/staging/hv/netvsc_drv.c  |3 ++-
 drivers/staging/hv/storvsc_drv.c |3 ++-
 drivers/staging/hv/vmbus_drv.c   |9 -
 6 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 5ff8a03..d60f287 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -847,7 +847,8 @@ static int mousevsc_probe(struct hv_device *dev,
return 0;
 }
 
-static int mousevsc_remove(struct hv_device *dev)
+static int mousevsc_remove(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
struct input_device_context *input_dev_ctx;
int ret;
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index d9460fdd..661631d 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -245,7 +245,8 @@ static int util_probe(struct hv_device *dev,
return 0;
 }
 
-static int util_remove(struct hv_device *dev)
+static int util_remove(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
return 0;
 }
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index caa3a7b..cf02ae1 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -811,7 +811,7 @@ struct hv_driver {
struct device_driver driver;
 
int (*probe)(struct hv_device *, const struct hv_vmbus_device_id *);
-   int (*remove)(struct hv_device *);
+   int (*remove)(struct hv_device *, const struct hv_vmbus_device_id *);
void (*shutdown)(struct hv_device *);
 
 };
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index d06cde2..d0189a3 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -384,7 +384,8 @@ out:
return ret;
 }
 
-static int netvsc_remove(struct hv_device *dev)
+static int netvsc_remove(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
struct net_device *net = dev_get_drvdata(dev-device);
struct net_device_context *ndev_ctx;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e2c63e5..e5da758 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1021,7 +1021,8 @@ static unsigned int copy_to_bounce_buffer(struct 
scatterlist *orig_sgl,
 }
 
 
-static int storvsc_remove(struct hv_device *dev)
+static int storvsc_remove(struct hv_device *dev,
+   const struct hv_vmbus_device_id *dev_id)
 {
struct Scsi_Host *host = dev_get_drvdata(dev-device);
struct hv_host_device *host_dev =
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index c7df7f4..b9aeb76 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -329,12 +329,19 @@ static int vmbus_remove(struct device *child_device)
struct hv_driver *drv;
 
struct hv_device *dev = device_to_hv_device(child_device);
+   const struct hv_vmbus_device_id *dev_id;
 
if (child_device-driver) {
drv = drv_to_hv_drv(child_device-driver);
+   dev_id = drv-id_table;
+
+   for (; !is_null_guid(dev_id-guid); dev_id++)
+   if (!memcmp(dev_id-guid, dev-dev_type.b,
+   sizeof(uuid_le)))
+   break;
 
if (drv-remove) {
-   ret = drv-remove(dev);
+   ret = drv-remove(dev, dev_id);
} else {
pr_err(remove not set for driver %s\n,
dev_name(child_device));
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 04/25] Staging: hv: vmbus: Cleanup dated comments in channel_mgmt.c

2011-09-08 Thread K. Y. Srinivasan
Cleanup dated comments in channel_mgmt.c.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/channel_mgmt.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c 
b/drivers/staging/hv/channel_mgmt.c
index 60ce1d1..c68e5fa 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -433,9 +433,6 @@ static void vmbus_process_offer(struct work_struct *work)
 /*
  * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
  *
- * We ignore all offers except network and storage offers. For each network and
- * storage offers, we create a channel object and queue a work item to the
- * channel object to process the offer synchronously
  */
 static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 {
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 14/25] Staging: hv: vmbus: Introduce functions for setting and getting driver data

2011-09-08 Thread K. Y. Srinivasan
In preparation for getting rid of the ext field in the struct hv_device,
introduce vmbus specific wrapper functions to set/get driver specific data.


Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv.h |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 685a132..2879750 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -843,6 +843,15 @@ static inline struct hv_driver *drv_to_hv_drv(struct 
device_driver *d)
return container_of(d, struct hv_driver, driver);
 }
 
+static inline void hv_set_drvdata(struct hv_device *dev, void *data)
+{
+   dev_set_drvdata(dev-device, data);
+}
+
+static inline void *hv_get_drvdata(struct hv_device *dev)
+{
+   return dev_get_drvdata(dev-device);
+}
 
 /* Vmbus interface */
 #define vmbus_driver_register(driver)  \
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 15/25] Staging: hv: storvsc: Get rid of storvsc_dev_add() by inlining the code

2011-09-08 Thread K. Y. Srinivasan
Get rid of storvsc_dev_add() by inlining the code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   58 +
 1 files changed, 14 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e5da758..ef93205 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -651,41 +651,6 @@ static int storvsc_connect_to_vsp(struct hv_device 
*device, u32 ring_size)
return ret;
 }
 
-static int storvsc_dev_add(struct hv_device *device,
-   void *additional_info)
-{
-   struct storvsc_device *stor_device;
-   struct storvsc_device_info *device_info;
-   int ret = 0;
-
-   device_info = (struct storvsc_device_info *)additional_info;
-   stor_device = alloc_stor_device(device);
-   if (!stor_device)
-   return -ENOMEM;
-
-   /* Save the channel properties to our storvsc channel */
-
-   /*
-* If we support more than 1 scsi channel, we need to set the
-* port number here to the scsi channel but how do we get the
-* scsi channel prior to the bus scan.
-*
-* The host does not support this.
-*/
-
-   stor_device-port_number = device_info-port_number;
-   /* Send it back up */
-   ret = storvsc_connect_to_vsp(device, device_info-ring_buffer_size);
-   if (ret) {
-   kfree(stor_device);
-   return ret;
-   }
-   device_info-path_id = stor_device-path_id;
-   device_info-target_id = stor_device-target_id;
-
-   return ret;
-}
-
 static int storvsc_dev_remove(struct hv_device *device)
 {
struct storvsc_device *stor_device;
@@ -1389,10 +1354,10 @@ static int storvsc_probe(struct hv_device *device,
int ret;
struct Scsi_Host *host;
struct hv_host_device *host_dev;
-   struct storvsc_device_info device_info;
bool dev_is_ide = ((dev_id-driver_data == 1) ? true : false);
int path = 0;
int target = 0;
+   struct storvsc_device *stor_device;
 
host = scsi_host_alloc(scsi_driver,
   sizeof(struct hv_host_device));
@@ -1417,22 +1382,27 @@ static int storvsc_probe(struct hv_device *device,
return -ENOMEM;
}
 
-   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);
+   stor_device = alloc_stor_device(device);
+   if (!stor_device) {
+   kmem_cache_destroy(host_dev-request_pool);
+   scsi_host_put(host);
+   return -ENOMEM;
+   }
 
-   if (ret != 0) {
+   stor_device-port_number = host-host_no;
+   ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
+   if (ret) {
kmem_cache_destroy(host_dev-request_pool);
scsi_host_put(host);
-   return -ENODEV;
+   kfree(stor_device);
+   return ret;
}
 
if (dev_is_ide)
storvsc_get_ide_info(device, target, path);
 
-   host_dev-path = device_info.path_id;
-   host_dev-target = device_info.target_id;
+   host_dev-path = stor_device-path_id;
+   host_dev-target = stor_device-target_id;
 
/* max # of devices per target */
host-max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 21/25] Staging: hv: vmbus: Get rid of the ext field in struct hv_device

2011-09-08 Thread K. Y. Srinivasan
Now that we have eliminated all uses of the ext field in struct hv_device,
get rid of the ext field.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 2879750..7ba274f 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -827,9 +827,6 @@ struct hv_device {
struct device device;
 
struct vmbus_channel *channel;
-
-   /* Device extension; */
-   void *ext;
 };
 
 
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 19/25] Staging: hv: netvsc: Get rid of the usage of the ext field in struct hv_device

2011-09-08 Thread K. Y. Srinivasan
Now, eliminate the usage of ext field in struct  hv_device for netvsc driver.
We do this by registering pointer to struct netvsc_device as the driver
specific data and eliminating the current usage of driver specific data
to save and retrieve the pointer to struct net_device.
Additionally, all access to the driver specific data is through
the vmbus wrapper functions. As part of this cleanup, we also get rid
of some unnecessary debug print statements.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv_net.h   |2 +
 drivers/staging/hv/netvsc.c   |   90 +++-
 drivers/staging/hv/netvsc_drv.c   |   29 ++--
 drivers/staging/hv/rndis_filter.c |   36 +++
 4 files changed, 100 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index af8a37f..366dd2b 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -392,6 +392,8 @@ struct netvsc_device {
struct nvsp_message revoke_packet;
/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
 
+   struct net_device *ndev;
+
/* Holds rndis device info */
void *extension;
 };
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 115629f..b046873 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -35,6 +35,8 @@
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
struct netvsc_device *net_device;
+   struct net_device *ndev =
+   (struct net_device *)hv_get_drvdata(device);
 
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device)
@@ -43,8 +45,9 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
 
net_device-destroy = false;
net_device-dev = device;
-   device-ext = net_device;
+   net_device-ndev = ndev;
 
+   hv_set_drvdata(device, net_device);
return net_device;
 }
 
@@ -52,7 +55,8 @@ static struct netvsc_device *get_outbound_net_device(struct 
hv_device *device)
 {
struct netvsc_device *net_device;
 
-   net_device = device-ext;
+   net_device =
+   (struct netvsc_device *)hv_get_drvdata(device);
if (net_device  net_device-destroy)
net_device = NULL;
 
@@ -63,7 +67,8 @@ static struct netvsc_device *get_inbound_net_device(struct 
hv_device *device)
 {
struct netvsc_device *net_device;
 
-   net_device = device-ext;
+   net_device =
+   (struct netvsc_device *)hv_get_drvdata(device);
 
if (!net_device)
goto get_in_err;
@@ -81,7 +86,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device 
*net_device)
 {
struct nvsp_message *revoke_packet;
int ret = 0;
-   struct net_device *ndev = dev_get_drvdata(net_device-dev-device);
+   struct net_device *ndev = net_device-ndev;
 
/*
 * If we got a section count, it means we received a
@@ -153,14 +158,12 @@ static int netvsc_init_recv_buf(struct hv_device *device)
int t;
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
-   struct net_device *ndev = dev_get_drvdata(device-device);
+   struct net_device *ndev;
 
net_device = get_outbound_net_device(device);
-   if (!net_device) {
-   netdev_err(ndev, unable to get net device...
-  device being destroyed?\n);
+   if (!net_device)
return -ENODEV;
-   }
+   ndev = net_device-ndev;
 
net_device-recv_buf =
(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
@@ -269,14 +272,12 @@ static int netvsc_connect_vsp(struct hv_device *device)
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
int ndis_version;
-   struct net_device *ndev = dev_get_drvdata(device-device);
+   struct net_device *ndev;
 
net_device = get_outbound_net_device(device);
-   if (!net_device) {
-   netdev_err(ndev, unable to get net device...
-  device being destroyed?\n);
+   if (!net_device)
return -ENODEV;
-   }
+   ndev = net_device-ndev;
 
init_packet = net_device-channel_init_pkt;
 
@@ -357,7 +358,7 @@ int netvsc_device_remove(struct hv_device *device)
struct hv_netvsc_packet *netvsc_packet, *pos;
unsigned long flags;
 
-   net_device = (struct netvsc_device *)device-ext;
+   net_device = (struct netvsc_device *)hv_get_drvdata(device);
spin_lock_irqsave(device-channel-inbound_lock, flags);
net_device-destroy = true;
spin_unlock_irqrestore(device-channel-inbound_lock, flags);
@@ -381,7 +382,7 @@ int netvsc_device_remove(struct hv_device *device)
 */
 
spin_lock_irqsave(device-channel

[PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code

2011-09-07 Thread K. Y. Srinivasan
The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could significantly  minimize the
code in the timesource driver.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 arch/x86/kernel/cpu/mshyperv.c |   24 +
 drivers/staging/hv/Makefile|2 +-
 drivers/staging/hv/hv_timesource.c |  101 
 3 files changed, 25 insertions(+), 102 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include linux/types.h
+#include linux/time.h
+#include linux/clocksource.h
 #include linux/module.h
 #include asm/processor.h
 #include asm/hypervisor.h
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
!memcmp(Microsoft Hv, hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+   cycle_t current_tick;
+   /*
+* Read the partition counter to get the current tick count. This count
+* is set to 0 when the partition is created and is incremented in
+* 100 nanosecond units.
+*/
+   rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+   return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+   .name   = hyperv_clocksource,
+   .rating = 400, /* use this when running on Hyperv*/
+   .read   = read_hv_clock,
+   .mask   = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
printk(KERN_INFO HyperV: features 0x%x, hints 0x%x\n,
   ms_hyperv.features, ms_hyperv.hints);
+
+
+   clocksource_register_hz(hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)   += hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)   += hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)   += hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)   += hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c 
b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 2b0f9aa..000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan ksriniva...@novell.com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
-
-#include linux/clocksource.h
-#include linux/init.h
-#include linux/module.h
-#include linux/pci.h
-#include linux/dmi.h
-#include asm/hyperv.h
-#include asm/mshyperv.h
-#include asm/hypervisor.h
-
-#define HV_CLOCK_SHIFT 22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-   cycle_t current_tick;
-   /*
-* Read the partition counter to get the current tick count. This count
-* is set to 0 when the partition is created and is incremented in
-* 100 nanosecond units.
-*/
-   rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-   return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-   .name   = hyperv_clocksource,
-   .rating = 400, /* use this when running on Hyperv*/
-   .read   = read_hv_clock,
-   .mask   = CLOCKSOURCE_MASK(64),
-   /*
-* The time ref counter in HyperV is in 100ns units.
-* The definition of mult is:
-* mult/2^shift = ns/cyc = 100
-* mult = (100  shift)
-*/
-   .mult   = (100  HV_CLOCK_SHIFT),
-   .shift  = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-   {
-   .ident = Hyper-V

[PATCH 1/1] Staging: hv: Update TODO file

2011-09-02 Thread K. Y. Srinivasan
Based on input from Greg, update the TODO file.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/TODO |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO
index 582fd4a..7c9a93f 100644
--- a/drivers/staging/hv/TODO
+++ b/drivers/staging/hv/TODO
@@ -1,14 +1,11 @@
 TODO:
-   - fix remaining checkpatch warnings and errors
- audit the vmbus to verify it is working properly with the
  driver model
-   - see if the vmbus can be merged with the other virtual busses
- in the kernel
- audit the network driver
  - checking for carrier inside open is wrong, network device API
 confusion??
-   - audit the block driver
- audit the scsi driver
 
 Please send patches for this code to Greg Kroah-Hartman gre...@suse.de,
-Hank Janssen hjans...@microsoft.com, and Haiyang Zhang 
haiya...@microsoft.com.
+Hank Janssen hjans...@microsoft.com, Haiyang Zhang haiya...@microsoft.com,
+K. Y. Srinivasan k...@microsoft.com
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 3/4] Staging: hv: vmbus: Check for events before messages

2011-09-01 Thread K. Y. Srinivasan
The Windows team has informed us that on Windows guests on Hyper-V,
they check for events before messages. They also recommended that we do
the same. This patch addresses this.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/vmbus_drv.c |   22 ++
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index b5e06d6..cd43ddd 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -442,14 +442,11 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id)
union hv_synic_event_flags *event;
bool handled = false;
 
-   page_addr = hv_context.synic_message_page[cpu];
-   msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
-
-   /* Check if there are actual msgs to be process */
-   if (msg-header.message_type != HVMSG_NONE) {
-   handled = true;
-   tasklet_schedule(msg_dpc);
-   }
+   /*
+* Check for events before checking for messages. This is the order
+* in which events and messages are checked in Windows guests on
+* Hyper-V, and the Windows team suggested we do the same.
+*/
 
page_addr = hv_context.synic_event_page[cpu];
event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
@@ -460,6 +457,15 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id)
tasklet_schedule(event_dpc);
}
 
+   page_addr = hv_context.synic_message_page[cpu];
+   msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
+
+   /* Check if there are actual msgs to be processed */
+   if (msg-header.message_type != HVMSG_NONE) {
+   handled = true;
+   tasklet_schedule(msg_dpc);
+   }
+
if (handled)
return IRQ_HANDLED;
else
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 0000/0004] Staging: hv: Driver cleanup

2011-09-01 Thread K. Y. Srinivasan
Address the comments on the last couple of patch sets.


Regards,

K. Y

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 2/4] Staging: hv: vmbus: Fix a bug in error handling in vmbus_bus_init()

2011-09-01 Thread K. Y. Srinivasan
Fix a bug in error handling in vmbus_bus_init().

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/vmbus_drv.c |   26 +++---
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 757943b..b5e06d6 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -492,7 +492,7 @@ static int vmbus_bus_init(int irq)
 
ret = bus_register(hv_bus);
if (ret)
-   return ret;
+   goto err_cleanup;
 
ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
driver_name, hv_acpi_dev);
@@ -500,10 +500,7 @@ static int vmbus_bus_init(int irq)
if (ret != 0) {
pr_err(Unable to request IRQ %d\n,
   irq);
-
-   bus_unregister(hv_bus);
-
-   return ret;
+   goto err_unregister;
}
 
vector = IRQ0_VECTOR + irq;
@@ -514,16 +511,23 @@ static int vmbus_bus_init(int irq)
 */
on_each_cpu(hv_synic_init, (void *)vector, 1);
ret = vmbus_connect();
-   if (ret) {
-   free_irq(irq, hv_acpi_dev);
-   bus_unregister(hv_bus);
-   return ret;
-   }
-
+   if (ret)
+   goto err_irq;
 
vmbus_request_offers();
 
return 0;
+
+err_irq:
+   free_irq(irq, hv_acpi_dev);
+
+err_unregister:
+   bus_unregister(hv_bus);
+
+err_cleanup:
+   hv_cleanup();
+
+   return ret;
 }
 
 /**
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 1/4] Staging: hv: util: Deal with driver register failures

2011-09-01 Thread K. Y. Srinivasan
Properly deal with vmbus_driver_register() failures.

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

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index e29a2a2..6039217 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -277,6 +277,7 @@ static  struct hv_driver util_drv = {
 
 static int __init init_hyperv_utils(void)
 {
+   int ret;
pr_info(Registering HyperV Utility Driver\n);
 
if (hv_kvp_init())
@@ -289,12 +290,15 @@ static int __init init_hyperv_utils(void)
 
if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
pr_info(Unable to allocate memory for receive buffer\n);
-   kfree(shut_txf_buf);
-   kfree(time_txf_buf);
-   kfree(hbeat_txf_buf);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err;
}
 
+   ret = vmbus_driver_register(util_drv);
+
+   if (ret != 0)
+   goto err;
+
hv_cb_utils[HV_SHUTDOWN_MSG].callback = shutdown_onchannelcallback;
 
hv_cb_utils[HV_TIMESYNC_MSG].callback = timesync_onchannelcallback;
@@ -303,7 +307,14 @@ static int __init init_hyperv_utils(void)
 
hv_cb_utils[HV_KVP_MSG].callback = hv_kvp_onchannelcallback;
 
-   return vmbus_driver_register(util_drv);
+   return 0;
+
+err:
+   kfree(shut_txf_buf);
+   kfree(time_txf_buf);
+   kfree(hbeat_txf_buf);
+
+   return ret;
 }
 
 static void exit_hyperv_utils(void)
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 4/4] Staging: hv: vmbus: Cleanup the code in process_chn_event()

2011-09-01 Thread K. Y. Srinivasan
A channel in Hyper-V is equivalent to a device. Thus, a channel is
persistent once it is presented to the guest, even if the driver
managing this device is unloaded. By checking and invoking the driver
specific callback function under the protection of the channel
inbound_lock, we can properly deal with racing driver unloads since an
unloading driver sets the callback to NULL under the protection of this
inbound_lock.



Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/connection.c |   18 --
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 9e99c04..649b91b 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -219,11 +219,25 @@ static void process_chn_event(u32 relid)
 */
channel = relid2channel(relid);
 
+   if (!channel) {
+   pr_err(channel not found for relid - %u\n, relid);
+   return;
+   }
+
+   /*
+* A channel once created is persistent even when there
+* is no driver handling the device. An unloading driver
+* sets the onchannel_callback to NULL under the
+* protection of the channel inbound_lock. Thus, checking
+* and invoking the driver specific callback takes care of
+* orderly unloading of the driver.
+*/
+
spin_lock_irqsave(channel-inbound_lock, flags);
-   if (channel  (channel-onchannel_callback != NULL))
+   if (channel-onchannel_callback != NULL)
channel-onchannel_callback(channel-channel_callback_context);
else
-   pr_err(channel not found for relid - %u\n, relid);
+   pr_err(no channel callback for relid - %u\n, relid);
 
spin_unlock_irqrestore(channel-inbound_lock, flags);
 }
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


Hyper-V TODO file

2011-09-01 Thread K. Y. Srinivasan

Greg,

The TODO file for Hyper-V drivers has not been updated in a while and does
not reflect the current state of these drivers:

1) There are no more checkpatch warnings/errors in this code. One of the TODO
work items is fix remaining checkpatch warnings and errors.

2) With your help, we have fixed all of the issues related to these drivers
conforming to the Linux Device Driver model. One of the TODO work items is 
audit the vmbus to verify it is working properly with the driver model.

3) Like all other virtualization platforms, the protocol to communicate with
the host is very host specific. The ringbuffer control structures are shared
between the host and the guest and so, the guest is compelled to follow the
mandates of the host. Thus, it is not possible for us to merge the vmbus with
other virtual buses in the system. One of the TODO work items is  see if the 
vmbus can be merged with the other virtual busses in the kernel.

4) A couple of months ago, we had posted the network driver for community 
review.
We have submitted patches (and these have been applied) to address the review
comments. One of the TODO work items is audit the network driver

5) Recently, we have merged the IDE and scsi drivers into a single driver that
can handle both IDE and SCSI devices. These patches have been already checked 
in.
As part of this effort, we have addressed all of the community comments on the
combined storage driver. The TODO file currently has two work items on this
issue: audit the block driver and audit the scsi driver.

Greg, as I have been pestering you for some time now, we are very interested in
exiting staging and we are willing to dedicate the necessary development 
resources to address whatever issues that may still be pending. So, your help
in identifying what needs to be done will be greatly appreciated. To that end,
I think it will be useful to update the TODO file to reflect the current state 
of
the drivers. Let us know how we should proceed here. 

Regards,

K. Y

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 03/46] Staging: hv: storvsc: Rename must_get_stor_device()

2011-08-27 Thread K. Y. Srinivasan
In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 04/46] Staging: hv: storvsc: Rename get_stor_device()

2011-08-27 Thread K. Y. Srinivasan
In preparation for cleaning up how we manage reference counts on the stor
device, clearly distinguish why we are attempting to acquire a reference.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 14/46] Staging: hv: netvsc: Prevent outgoing traffic when netvsc dev is destroyed

2011-08-27 Thread K. Y. Srinivasan
Prevent outgoing traffic when netvsc dev is destroyed.

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

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 8eb4039..67065c1 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -56,7 +56,8 @@ static struct netvsc_device *get_outbound_net_device(struct 
hv_device *device)
struct netvsc_device *net_device;
 
net_device = device-ext;
-   if (net_device  atomic_read(net_device-refcnt)  1)
+   if (net_device  (atomic_read(net_device-refcnt)  1) 
+   !net_device-destroy)
atomic_inc(net_device-refcnt);
else
net_device = NULL;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 09/46] Staging: hv: storvsc: Get rid of final_release_stor_device() by inlining code

2011-08-27 Thread K. Y. Srinivasan
Get rid of final_release_stor_device() by inlining code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc.c |   23 ++-
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 1976a34..3e9829f 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -67,22 +67,6 @@ static inline struct storvsc_device *get_in_stor_device(
return stor_device;
 }
 
-/* Drop ref count to 0. No one can use stor_device object. */
-static inline struct storvsc_device *final_release_stor_device(
-   struct hv_device *device)
-{
-   struct storvsc_device *stor_device;
-
-   stor_device = (struct storvsc_device *)device-ext;
-
-   /* Busy wait until the ref drop to 1, then set it to 0 */
-   while (atomic_cmpxchg(stor_device-ref_count, 1, 0) != 1)
-   udelay(100);
-
-   device-ext = NULL;
-   return stor_device;
-}
-
 static int storvsc_channel_init(struct hv_device *device)
 {
struct storvsc_device *stor_device;
@@ -401,7 +385,12 @@ int storvsc_dev_remove(struct hv_device *device)
 
storvsc_wait_to_drain(stor_device);
 
-   stor_device = final_release_stor_device(device);
+   /*
+* Since we have already drained, we don't need to busy wait
+* as was done in final_release_stor_device()
+*/
+   atomic_set(stor_device-ref_count, 0);
+   device-ext = NULL;
 
/* Close the channel */
vmbus_close(device-channel);
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 01/46] Staging: hv: storvsc: Inline free_stor_device()

2011-08-27 Thread K. Y. Srinivasan
Inline the code for  free_stor_device() and get rid of the function.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 05/46] Staging: hv: storvsc: Cleanup alloc_stor_device()

2011-08-27 Thread K. Y. Srinivasan
Cleanup alloc_stor_device(), we can set the ref_count directly.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 12/46] Staging: hv: netvsc: Cleanup alloc_net_device()

2011-08-27 Thread K. Y. Srinivasan
Cleanup alloc_net_device(); we can directly set the refcnt.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 13/46] Staging: hv: netvsc: Introduce state to manage the lifecycle of net device

2011-08-27 Thread K. Y. Srinivasan
Introduce state to manage the lifecycle of net device.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv_net.h |1 +
 drivers/staging/hv/netvsc.c |6 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 5782fea..0b347c1 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -371,6 +371,7 @@ struct netvsc_device {
 
atomic_t refcnt;
atomic_t num_outstanding_sends;
+   bool destroy;
/*
 * List of free preallocated hv_netvsc_packet to represent receive
 * packet
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 7722102..8eb4039 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -43,6 +43,7 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
/* Set to 2 to allow both inbound and outbound traffic */
atomic_set(net_device-refcnt, 2);
 
+   net_device-destroy = false;
net_device-dev = device;
device-ext = net_device;
 
@@ -396,6 +397,7 @@ int netvsc_device_remove(struct hv_device *device)
 {
struct netvsc_device *net_device;
struct hv_netvsc_packet *netvsc_packet, *pos;
+   unsigned long flags;
 
/* Stop outbound traffic ie sends and receives completions */
net_device = release_outbound_net_device(device);
@@ -404,6 +406,10 @@ int netvsc_device_remove(struct hv_device *device)
return -ENODEV;
}
 
+   spin_lock_irqsave(device-channel-inbound_lock, flags);
+   net_device-destroy = true;
+   spin_unlock_irqrestore(device-channel-inbound_lock, flags);
+
/* Wait for all send completions */
while (atomic_read(net_device-num_outstanding_sends)) {
dev_err(device-device,
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 07/46] Staging: hv: storvsc: Prevent outgoing traffic when stor dev is being destroyed

2011-08-27 Thread K. Y. Srinivasan
Prevent outgoing traffic when stor dev is destroyed.

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

diff --git a/drivers/staging/hv/hyperv_storage.h 
b/drivers/staging/hv/hyperv_storage.h
index d93bf93..1a59ca0 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -294,7 +294,8 @@ static inline struct storvsc_device *get_out_stor_device(
struct storvsc_device *stor_device;
 
stor_device = (struct storvsc_device *)device-ext;
-   if (stor_device  atomic_read(stor_device-ref_count)  1)
+   if (stor_device  (atomic_read(stor_device-ref_count)  1) 
+   !stor_device-destroy)
atomic_inc(stor_device-ref_count);
else
stor_device = NULL;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 27/46] Staging: hv: storvsc: Fixup srb and scsi status for INQUIRY and MODE_SENSE

2011-08-27 Thread K. Y. Srinivasan
The current VHD handler on the Windows Host does not correctly handle
INQUIRY and MODE_SENSE commands with some options. Fixup srb_status
in these cases since the failure is not fatal.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 0bb4e0e..72ca25c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -512,6 +512,23 @@ static void storvsc_on_io_completion(struct hv_device 
*device,
 
stor_pkt = request-vstor_packet;
 
+   /*
+* The current SCSI handling on the host side does
+* not correctly handle:
+* INQUIRY command with page code parameter set to 0x80
+* MODE_SENSE command with cmd[2] == 0x1c
+*
+* Setup srb and scsi status so this won't be fatal.
+* We do this so we can distinguish truly fatal failues
+* (srb status == 0x4) and off-line the device in that case.
+*/
+
+   if ((stor_pkt-vm_srb.cdb[0] == INQUIRY) ||
+   (stor_pkt-vm_srb.cdb[0] == MODE_SENSE)) {
+   vstor_packet-vm_srb.scsi_status = 0;
+   vstor_packet-vm_srb.srb_status = 0x1;
+   }
+
 
/* Copy over the status...etc */
stor_pkt-vm_srb.scsi_status = vstor_packet-vm_srb.scsi_status;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 19/46] Staging: hv: storvsc: Handle IDE devices using the storvsc driver

2011-08-27 Thread K. Y. Srinivasan
Now, enable handling of all IDE devices by extending the storvsc
device id table to handle IDE guid. As part of this cleanup Kconfig
and Hyper-V Makefile to not build the IDE driver (blkvsc).

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/Kconfig   |7 ---
 drivers/staging/hv/Makefile  |2 --
 drivers/staging/hv/storvsc_drv.c |   21 -
 3 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig
index 5e0c9f6..26b5064 100644
--- a/drivers/staging/hv/Kconfig
+++ b/drivers/staging/hv/Kconfig
@@ -15,13 +15,6 @@ config HYPERV_STORAGE
help
 Select this option to enable the Hyper-V virtual storage driver.
 
-config HYPERV_BLOCK
-   tristate Microsoft Hyper-V virtual block driver
-   depends on BLOCK  SCSI  (LBDAF || 64BIT)
-   default HYPERV
-   help
- Select this option to enable the Hyper-V virtual block driver.
-
 config HYPERV_NET
tristate Microsoft Hyper-V virtual network driver
depends on NET
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index 3004674..bb89437 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,6 +1,5 @@
 obj-$(CONFIG_HYPERV)   += hv_vmbus.o hv_timesource.o
 obj-$(CONFIG_HYPERV_STORAGE)   += hv_storvsc.o
-obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o
 obj-$(CONFIG_HYPERV_NET)   += hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
 obj-$(CONFIG_HYPERV_MOUSE) += hv_mouse.o
@@ -9,6 +8,5 @@ hv_vmbus-y := vmbus_drv.o \
 hv.o connection.o channel.o \
 channel_mgmt.o ring_buffer.o
 hv_storvsc-y := storvsc_drv.o storvsc.o
-hv_blkvsc-y := blkvsc_drv.o  storvsc.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index f434200..9464f99 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -645,27 +645,22 @@ static struct scsi_host_template scsi_driver = {
.dma_boundary = PAGE_SIZE-1,
 };
 
+/*
+ * The storvsc_probe function assumes that the IDE guid
+ * is the second entry.
+ */
 static const struct hv_vmbus_device_id id_table[] = {
/* SCSI guid */
{ VMBUS_DEVICE(0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
   0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) },
+   /* IDE guid */
+   { VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+  0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) },
{ },
 };
 
 MODULE_DEVICE_TABLE(vmbus, id_table);
 
-/*
- * This declaration is temporary; once we get the
- * infrastructure in place, we will integrate with
- * id_table.
- */
-
-static const uuid_le ide_blk_guid = {
-   .b = {
-   0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-   0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-   }
-};
 
 /*
  * storvsc_probe - Add a new device for this driver
@@ -681,7 +676,7 @@ static int storvsc_probe(struct hv_device *device)
int path = 0;
int target = 0;
 
-   if (!uuid_le_cmp(device-dev_type, ide_blk_guid))
+   if (!memcmp(device-dev_type.b, id_table[1].guid, sizeof(uuid_le)))
dev_is_ide = true;
else
dev_is_ide = false;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 22/46] Staging: hv: storvsc: Optimize the bounce buffer handling in the read case

2011-08-27 Thread K. Y. Srinivasan
Optimize the bounce buffer handling in the read case.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 90b91ad..3e00e70 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -560,12 +560,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd 
*scmnd,
ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) 
PAGE_SHIFT;
 
-   /*
-* FIXME: We can optimize on reads by just skipping
-* this
-*/
-   copy_to_bounce_buffer(sgl, cmd_request-bounce_sgl,
- scsi_sg_count(scmnd));
+   if (vm_srb-data_in == WRITE_TYPE)
+   copy_to_bounce_buffer(sgl,
+   cmd_request-bounce_sgl,
+   scsi_sg_count(scmnd));
 
sgl = cmd_request-bounce_sgl;
sg_count = cmd_request-bounce_sgl_count;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 11/46] Staging: hv: netvsc: Inline the code for free_net_device()

2011-08-27 Thread K. Y. Srinivasan
Inline the code for free_net_device().

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 15/46] Staging: hv: netvsc: Get rid of release_outbound_net_device() by inlining the code

2011-08-27 Thread K. Y. Srinivasan
Get rid of release_outbound_net_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/netvsc.c |   38 ++
 1 files changed, 14 insertions(+), 24 deletions(-)

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 06/46] Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device

2011-08-27 Thread K. Y. Srinivasan
Introduce state to manage the lifecycle of stor device. This would be the
basis for managing the references on the stor object.

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

diff --git a/drivers/staging/hv/hyperv_storage.h 
b/drivers/staging/hv/hyperv_storage.h
index a224413..d93bf93 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -266,7 +266,7 @@ struct storvsc_device {
 
/* 0 indicates the device is being destroyed */
atomic_t ref_count;
-
+   bool destroy;
bool drain_notify;
atomic_t num_outstanding_req;
 
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 48bd8da..0f8c609 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct 
hv_device *device)
/* Set to 2 to allow both inbound and outbound traffics */
/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
atomic_set(stor_device-ref_count, 2);
-
+   stor_device-destroy = false;
init_waitqueue_head(stor_device-waiting_to_drain);
stor_device-device = device;
device-ext = stor_device;
@@ -399,9 +399,15 @@ int storvsc_dev_add(struct hv_device *device,
 int storvsc_dev_remove(struct hv_device *device)
 {
struct storvsc_device *stor_device;
+   unsigned long flags;
+
 
stor_device = release_stor_device(device);
 
+   spin_lock_irqsave(device-channel-inbound_lock, flags);
+   stor_device-destroy = true;
+   spin_unlock_irqrestore(device-channel-inbound_lock, flags);
+
/*
 * At this point, all outbound traffic should be disable. We
 * only allow inbound traffic (responses) to proceed so that
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 21/46] Staging: hv: storvsc: Optimize bounce buffer handling for the write case

2011-08-27 Thread K. Y. Srinivasan
Optimize bounce buffer handling for the write case.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 9464f99..90b91ad 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -425,17 +425,17 @@ static void storvsc_commmand_completion(struct 
hv_storvsc_request *request)
struct scsi_sense_hdr sense_hdr;
struct vmscsi_request *vm_srb;
 
+   vm_srb = request-vstor_packet.vm_srb;
if (cmd_request-bounce_sgl_count) {
-
-   /* FIXME: We can optimize on writes by just skipping this */
-   copy_from_bounce_buffer(scsi_sglist(scmnd),
+   if (vm_srb-data_in == READ_TYPE) {
+   copy_from_bounce_buffer(scsi_sglist(scmnd),
cmd_request-bounce_sgl,
scsi_sg_count(scmnd));
-   destroy_bounce_buffer(cmd_request-bounce_sgl,
- cmd_request-bounce_sgl_count);
+   destroy_bounce_buffer(cmd_request-bounce_sgl,
+   cmd_request-bounce_sgl_count);
+   }
}
 
-   vm_srb = request-vstor_packet.vm_srb;
scmnd-result = vm_srb-scsi_status;
 
if (scmnd-result) {
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 24/46] Staging: hv: storvsc: Cleanup storvsc_drv.c after adding the contents of storvsc.c

2011-08-27 Thread K. Y. Srinivasan
Cleanup storvsc_drv.c after adding the contents of storvsc.c.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |  147 +++---
 1 files changed, 27 insertions(+), 120 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ddb31cf..096f615 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -19,11 +19,17 @@
  *   Hank Janssen  hjans...@microsoft.com
  *   K. Y. Srinivasan k...@microsoft.com
  */
+
+#include linux/kernel.h
+#include linux/sched.h
+#include linux/completion.h
+#include linux/string.h
+#include linux/mm.h
+#include linux/delay.h
 #include linux/init.h
 #include linux/slab.h
 #include linux/module.h
 #include linux/device.h
-#include linux/blkdev.h
 #include scsi/scsi.h
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_host.h
@@ -37,39 +43,28 @@
 #include hyperv_storage.h
 
 
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang haiya...@microsoft.com
- *   Hank Janssen  hjans...@microsoft.com
- *   K. Y. Srinivasan k...@microsoft.com
- *
- */
-#include linux/kernel.h
-#include linux/sched.h
-#include linux/completion.h
-#include linux/string.h
-#include linux/slab.h
-#include linux/mm.h
-#include linux/delay.h
+static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
-#include hyperv.h
-#include hyperv_storage.h
+module_param(storvsc_ringbuffer_size, int, S_IRUGO);
+MODULE_PARM_DESC(storvsc_ringbuffer_size, Ring buffer size (bytes));
+
+struct hv_host_device {
+   struct hv_device *dev;
+   struct kmem_cache *request_pool;
+   unsigned int port;
+   unsigned char path;
+   unsigned char target;
+};
+
+struct storvsc_cmd_request {
+   struct list_head entry;
+   struct scsi_cmnd *cmd;
 
+   unsigned int bounce_sgl_count;
+   struct scatterlist *bounce_sgl;
+
+   struct hv_storvsc_request request;
+};
 
 static inline struct storvsc_device *alloc_stor_device(struct hv_device 
*device)
 {
@@ -500,94 +495,6 @@ int storvsc_do_io(struct hv_device *device,
return ret;
 }
 
-/*
- * The channel properties uniquely specify how the device is to be
- * presented to the guest. Map this information for use by the block
- * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
- * (storvsc_drv) and so scsi devices in the guest  are handled by
- * native upper level Linux drivers. Consequently, Hyper-V
- * block driver, while being a generic block driver, presently does not
- * deal with anything other than devices that would need to be presented
- * to the guest as an IDE disk.
- *
- * This function maps the channel properties as embedded in the input
- * parameter device_info onto information necessary to register the
- * corresponding block device.
- *
- * Currently, there is no way to stop the emulation of the block device
- * on the host side. And so, to prevent the native IDE drivers in Linux
- * from taking over these devices (to be managedby Hyper-V block
- * driver), we will take over if need be the major of the IDE controllers.
- *
- */
-
-int storvsc_get_major_info(struct storvsc_device_info *device_info,
-   struct storvsc_major_info *major_info)
-{
-   static bool ide0_registered;
-   static bool ide1_registered;
-
-   /*
-* For now we only support IDE disks.
-*/
-   major_info-devname = ide;
-   major_info-diskname = hd;
-
-   if (device_info-path_id) {
-   major_info-major = 22;
-   if (!ide1_registered) {
-   major_info-do_register = true;
-   ide1_registered = true;
-   } else
-   major_info-do_register = false;
-
-   if (device_info-target_id)
-   major_info-index = 3;
-   else
-   major_info-index = 2;
-
-   return 0;
-   } else {
-   major_info-major = 3;
-   if (!ide0_registered) {
-   major_info-do_register = true;
-   ide0_registered = true;
-   } else
-   major_info-do_register = false

[PATCH 28/46] Staging: hv: storvsc: Fix a typo

2011-08-27 Thread K. Y. Srinivasan
Fix a typo in a function name.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 72ca25c..ad0f9d4 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1130,9 +1130,9 @@ static int storvsc_host_reset_handler(struct scsi_cmnd 
*scmnd)
 
 
 /*
- * storvsc_commmand_completion - Command completion processing
+ * storvsc_command_completion - Command completion processing
  */
-static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+static void storvsc_command_completion(struct hv_storvsc_request *request)
 {
struct storvsc_cmd_request *cmd_request =
(struct storvsc_cmd_request *)request-context;
@@ -1240,7 +1240,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd 
*scmnd,
break;
}
 
-   request-on_io_completion = storvsc_commmand_completion;
+   request-on_io_completion = storvsc_command_completion;
request-context = cmd_request;/* scmnd; */
 
vm_srb-port_number = host_dev-port;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 18/46] Staging: hv: storvsc: Add code to handle IDE devices using the storvsc driver

2011-08-27 Thread K. Y. Srinivasan
Add code to handle IDE devices using the storvsc driver. The storvsc_probe()
is modified so that the storvsc driver can surface all disks presented to the
guest as scsi devices using generic upper level Linux scsi drivers.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   60 -
 1 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ae74f50..f434200 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -59,6 +59,17 @@ struct storvsc_cmd_request {
struct hv_storvsc_request request;
 };
 
+static void storvsc_get_ide_info(struct hv_device *dev, int *target, int *path)
+{
+   *target =
+   dev-dev_instance.b[5]  8 | dev-dev_instance.b[4];
+
+   *path =
+   dev-dev_instance.b[3]  24 |
+   dev-dev_instance.b[2]  16 |
+   dev-dev_instance.b[1]  8  | dev-dev_instance.b[0];
+}
+
 
 static int storvsc_device_alloc(struct scsi_device *sdevice)
 {
@@ -642,6 +653,20 @@ static const struct hv_vmbus_device_id id_table[] = {
 };
 
 MODULE_DEVICE_TABLE(vmbus, id_table);
+
+/*
+ * This declaration is temporary; once we get the
+ * infrastructure in place, we will integrate with
+ * id_table.
+ */
+
+static const uuid_le ide_blk_guid = {
+   .b = {
+   0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+   0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+   }
+};
+
 /*
  * storvsc_probe - Add a new device for this driver
  */
@@ -652,6 +677,14 @@ static int storvsc_probe(struct hv_device *device)
struct Scsi_Host *host;
struct hv_host_device *host_dev;
struct storvsc_device_info device_info;
+   bool dev_is_ide;
+   int path = 0;
+   int target = 0;
+
+   if (!uuid_le_cmp(device-dev_type, ide_blk_guid))
+   dev_is_ide = true;
+   else
+   dev_is_ide = false;
 
host = scsi_host_alloc(scsi_driver,
   sizeof(struct hv_host_device));
@@ -687,6 +720,9 @@ static int storvsc_probe(struct hv_device *device)
return -ENODEV;
}
 
+   if (dev_is_ide)
+   storvsc_get_ide_info(device, target, path);
+
host_dev-path = device_info.path_id;
host_dev-target = device_info.target_id;
 
@@ -699,17 +735,25 @@ static int storvsc_probe(struct hv_device *device)
 
/* Register the HBA and start the scsi bus scan */
ret = scsi_add_host(host, device-device);
-   if (ret != 0) {
-
-   storvsc_dev_remove(device);
+   if (ret != 0)
+   goto err_out;
 
-   kmem_cache_destroy(host_dev-request_pool);
-   scsi_host_put(host);
-   return -ENODEV;
+   if (!dev_is_ide) {
+   scsi_scan_host(host);
+   return 0;
+   }
+   ret = scsi_add_device(host, 0, target, 0);
+   if (ret) {
+   scsi_remove_host(host);
+   goto err_out;
}
+   return 0;
 
-   scsi_scan_host(host);
-   return ret;
+err_out:
+   storvsc_dev_remove(device);
+   kmem_cache_destroy(host_dev-request_pool);
+   scsi_host_put(host);
+   return -ENODEV;
 }
 
 /* The one and only one */
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 31/46] Staging: hv: util: Forcefully shutdown when shutdown is requested

2011-08-27 Thread K. Y. Srinivasan
When the host requests a shutdown, make sure we shutdown!

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_util.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index f2f456f..876d44a 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -89,7 +89,7 @@ static void shutdown_onchannelcallback(void *context)
}
 
if (execute_shutdown == true)
-   orderly_poweroff(false);
+   orderly_poweroff(true);
 }
 
 /*
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 10/46] Staging: hv: storvsc: Get rid of the reference counting in struct storvsc_device

2011-08-27 Thread K. Y. Srinivasan
Get rid of the reference counting in struct storvsc_device. We manage the 
lifecycle with 
the following logic: If the device is marked for destruction, we dot allow any
outgoing traffic on the device. Incoming traffic is allowed only to drain 
pending
outgoing traffic. Note that while the upper level code in Linux deals with 
outstanding
I/Os, we may have situations on Hyper-V where some book keeping messages are 
sent out
that the upper level Linux code may not be aware of.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv_storage.h |   18 ++
 drivers/staging/hv/storvsc.c|   33 +
 drivers/staging/hv/storvsc_drv.c|1 -
 3 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/hv/hyperv_storage.h 
b/drivers/staging/hv/hyperv_storage.h
index 1a59ca0..687cdc5 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -264,8 +264,6 @@ struct storvsc_major_info {
 struct storvsc_device {
struct hv_device *device;
 
-   /* 0 indicates the device is being destroyed */
-   atomic_t ref_count;
bool destroy;
bool drain_notify;
atomic_t num_outstanding_req;
@@ -287,32 +285,20 @@ struct storvsc_device {
 };
 
 
-/* Get the stordevice object iff exists and its refcount  1 */
 static inline struct storvsc_device *get_out_stor_device(
struct hv_device *device)
 {
struct storvsc_device *stor_device;
 
stor_device = (struct storvsc_device *)device-ext;
-   if (stor_device  (atomic_read(stor_device-ref_count)  1) 
-   !stor_device-destroy)
-   atomic_inc(stor_device-ref_count);
-   else
+
+   if (stor_device  stor_device-destroy)
stor_device = NULL;
 
return stor_device;
 }
 
 
-static inline void put_stor_device(struct hv_device *device)
-{
-   struct storvsc_device *stor_device;
-
-   stor_device = (struct storvsc_device *)device-ext;
-
-   atomic_dec(stor_device-ref_count);
-}
-
 static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
 {
dev-drain_notify = true;
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3e9829f..fb7b3ca 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -40,9 +40,6 @@ static inline struct storvsc_device *alloc_stor_device(struct 
hv_device *device)
if (!stor_device)
return NULL;
 
-   /* Set to 2 to allow both inbound and outbound traffics */
-   /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
-   atomic_set(stor_device-ref_count, 2);
stor_device-destroy = false;
init_waitqueue_head(stor_device-waiting_to_drain);
stor_device-device = device;
@@ -52,19 +49,31 @@ static inline struct storvsc_device 
*alloc_stor_device(struct hv_device *device)
 }
 
 
-/* Get the stordevice object iff exists and its refcount  0 */
 static inline struct storvsc_device *get_in_stor_device(
struct hv_device *device)
 {
struct storvsc_device *stor_device;
+   unsigned long flags;
 
+   spin_lock_irqsave(device-channel-inbound_lock, flags);
stor_device = (struct storvsc_device *)device-ext;
-   if (stor_device  atomic_read(stor_device-ref_count))
-   atomic_inc(stor_device-ref_count);
-   else
+
+   if (!stor_device)
+   goto get_in_err;
+
+   /*
+* If the device is being destroyed; allow incoming
+* traffic only to cleanup outstanding requests.
+*/
+
+   if (stor_device-destroy  
+   (atomic_read(stor_device-num_outstanding_req) == 0))
stor_device = NULL;
 
+get_in_err:
+   spin_unlock_irqrestore(device-channel-inbound_lock, flags);
return stor_device;
+
 }
 
 static int storvsc_channel_init(struct hv_device *device)
@@ -190,7 +199,6 @@ static int storvsc_channel_init(struct hv_device *device)
 
 
 cleanup:
-   put_stor_device(device);
return ret;
 }
 
@@ -303,7 +311,6 @@ static void storvsc_on_channel_callback(void *context)
}
} while (1);
 
-   put_stor_device(device);
return;
 }
 
@@ -371,7 +378,6 @@ int storvsc_dev_remove(struct hv_device *device)
unsigned long flags;
 
stor_device = (struct storvsc_device *)device-ext;
-   atomic_dec(stor_device-ref_count);
 
spin_lock_irqsave(device-channel-inbound_lock, flags);
stor_device-destroy = true;
@@ -388,9 +394,13 @@ int storvsc_dev_remove(struct hv_device *device)
/*
 * Since we have already drained, we don't need to busy wait
 * as was done in final_release_stor_device()
+* Note that we cannot set the ext pointer to NULL until
+* we have

[PATCH 08/46] Staging: hv: storvsc: Get rid of release_stor_device() by inlining the code

2011-08-27 Thread K. Y. Srinivasan
Get rid of release_stor_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc.c |   19 ++-
 1 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 0f8c609..1976a34 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -67,21 +67,6 @@ static inline struct storvsc_device *get_in_stor_device(
return stor_device;
 }
 
-/* Drop ref count to 1 to effectively disable get_out_stor_device() */
-static inline struct storvsc_device *release_stor_device(
-   struct hv_device *device)
-{
-   struct storvsc_device *stor_device;
-
-   stor_device = (struct storvsc_device *)device-ext;
-
-   /* Busy wait until the ref drop to 2, then set it to 1 */
-   while (atomic_cmpxchg(stor_device-ref_count, 2, 1) != 2)
-   udelay(100);
-
-   return stor_device;
-}
-
 /* Drop ref count to 0. No one can use stor_device object. */
 static inline struct storvsc_device *final_release_stor_device(
struct hv_device *device)
@@ -401,8 +386,8 @@ int storvsc_dev_remove(struct hv_device *device)
struct storvsc_device *stor_device;
unsigned long flags;
 
-
-   stor_device = release_stor_device(device);
+   stor_device = (struct storvsc_device *)device-ext;
+   atomic_dec(stor_device-ref_count);
 
spin_lock_irqsave(device-channel-inbound_lock, flags);
stor_device-destroy = true;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 41/46] Staging: hv: vmbus: Fix a bug in error handling in vmbus_bus_init()

2011-08-27 Thread K. Y. Srinivasan
Fix a bug in error handling in vmbus_bus_init().

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/vmbus_drv.c |   21 ++---
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 02edb11..4d1b123 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -492,7 +492,7 @@ static int vmbus_bus_init(int irq)
 
ret = bus_register(hv_bus);
if (ret)
-   return ret;
+   goto err1;
 
ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
driver_name, hv_acpi_dev);
@@ -500,10 +500,7 @@ static int vmbus_bus_init(int irq)
if (ret != 0) {
pr_err(Unable to request IRQ %d\n,
   irq);
-
-   bus_unregister(hv_bus);
-
-   return ret;
+   goto err2;
}
 
vector = IRQ0_VECTOR + irq;
@@ -514,16 +511,18 @@ static int vmbus_bus_init(int irq)
 */
on_each_cpu(hv_synic_init, (void *)vector, 1);
ret = vmbus_connect();
-   if (ret) {
-   free_irq(irq, hv_acpi_dev);
-   bus_unregister(hv_bus);
-   return ret;
-   }
-
+   if (ret)
+   goto err3;
 
vmbus_request_offers();
 
return 0;
+
+err3:  free_irq(irq, hv_acpi_dev);
+err2:  bus_unregister(hv_bus);
+err1:  hv_cleanup();
+
+   return ret;
 }
 
 /**
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 17/46] Staging: hv: netvsc: Get rid of the refcnt field in struct netvsc_device

2011-08-27 Thread K. Y. Srinivasan
Get rid of the refcnt field in struct netvsc_device. We implement the following
logic to manage the life cycle of the device: If the device is being destroyed,
we do not allow any outgoing traffic. Furthermore, if the device is being 
destroyed, we allow incoming traffic only to drain outgoing traffic. Note that
the driver may send some book keeping messages to the host not known to 
upper level Linux code.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hyperv_net.h |1 -
 drivers/staging/hv/netvsc.c |   62 --
 2 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 0b347c1..af8a37f 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -369,7 +369,6 @@ struct nvsp_message {
 struct netvsc_device {
struct hv_device *dev;
 
-   atomic_t refcnt;
atomic_t num_outstanding_sends;
bool destroy;
/*
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 388f083..9828f0b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -40,8 +40,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
if (!net_device)
return NULL;
 
-   /* Set to 2 to allow both inbound and outbound traffic */
-   atomic_set(net_device-refcnt, 2);
 
net_device-destroy = false;
net_device-dev = device;
@@ -50,43 +48,37 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
return net_device;
 }
 
-/* Get the net device object iff exists and its refcount  1 */
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
struct netvsc_device *net_device;
 
net_device = device-ext;
-   if (net_device  (atomic_read(net_device-refcnt)  1) 
-   !net_device-destroy)
-   atomic_inc(net_device-refcnt);
-   else
+   if (net_device  net_device-destroy)
net_device = NULL;
 
return net_device;
 }
 
-/* Get the net device object iff exists and its refcount  0 */
 static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
struct netvsc_device *net_device;
+   unsigned long flags;
 
+   spin_lock_irqsave(device-channel-inbound_lock, flags);
net_device = device-ext;
-   if (net_device  atomic_read(net_device-refcnt))
-   atomic_inc(net_device-refcnt);
-   else
+
+   if (!net_device)
+   goto get_in_err;
+
+   if (net_device-destroy 
+   atomic_read(net_device-num_outstanding_sends) == 0)
net_device = NULL;
 
+get_in_err:
+   spin_unlock_irqrestore(device-channel-inbound_lock, flags);
return net_device;
 }
 
-static void put_net_device(struct hv_device *device)
-{
-   struct netvsc_device *net_device;
-
-   net_device = device-ext;
-
-   atomic_dec(net_device-refcnt);
-}
 
 static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
@@ -268,7 +260,6 @@ cleanup:
netvsc_destroy_recv_buf(net_device);
 
 exit:
-   put_net_device(device);
return ret;
 }
 
@@ -349,7 +340,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
ret = netvsc_init_recv_buf(device);
 
 cleanup:
-   put_net_device(device);
return ret;
 }
 
@@ -368,7 +358,6 @@ int netvsc_device_remove(struct hv_device *device)
unsigned long flags;
 
net_device = (struct netvsc_device *)device-ext;
-   atomic_dec(net_device-refcnt);
spin_lock_irqsave(device-channel-inbound_lock, flags);
net_device-destroy = true;
spin_unlock_irqrestore(device-channel-inbound_lock, flags);
@@ -383,19 +372,17 @@ int netvsc_device_remove(struct hv_device *device)
 
netvsc_disconnect_vsp(net_device);
 
-   atomic_dec(net_device-refcnt);
-   device-ext = NULL;
/*
-* Wait until the ref cnt falls to 0.
-* We have already stopped any new references
-* for outgoing traffic. Also, at this point we don't have any
-* incoming traffic as well. So this must be outgoing refrences
-* established prior to marking the device as being destroyed.
-* Since the send path is non-blocking, it is reasonable to busy
-* wait here.
+* Since we have already drained, we don't need to busy wait
+* as was done in final_release_stor_device()
+* Note that we cannot set the ext pointer to NULL until
+* we have drained - to drain the outgoing packets, we need to
+* allow incoming packets.
 */
-   while (atomic_read(net_device-refcnt))
-   udelay(100);
+
+   spin_lock_irqsave(device-channel-inbound_lock, flags);
+   device-ext = NULL;
+   spin_unlock_irqrestore(device

[PATCH 35/46] Staging: hv: Fix a bug in vmbus_match()

2011-08-27 Thread K. Y. Srinivasan
The recent checkin that add a private pointer to hv_vmbus_device_id
introduced this bug in vmbus_match; fix it.

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

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index be62b62..51002c0 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -273,7 +273,7 @@ static int vmbus_match(struct device *device, struct 
device_driver *driver)
 
for (; !is_null_guid(id_array-guid); id_array++)
if (!memcmp(id_array-guid, hv_dev-dev_type.b,
-   sizeof(struct hv_vmbus_device_id)))
+   sizeof(uuid_le)))
return 1;
 
return 0;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 34/46] Staging: hv: vmbus: Properly deal with de-registering channel callback

2011-08-27 Thread K. Y. Srinivasan
Ensure that we correctly handle racing invocations of the channel callback
when the channel is being closed. We do this using the channel's inbound_lock.
A side-effect of this strategy is that we avoid repeatedly picking up this lock
as we drain the inbound ring-buffer.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/channel.c |   20 +---
 drivers/staging/hv/connection.c  |3 +++
 drivers/staging/hv/netvsc.c  |3 ---
 drivers/staging/hv/storvsc_drv.c |3 ---
 4 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index ac92c1f..b6f3d38 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -513,9 +513,12 @@ void vmbus_close(struct vmbus_channel *channel)
 {
struct vmbus_channel_close_channel *msg;
int ret;
+   unsigned long flags;
 
/* Stop callback and cancel the timer asap */
+   spin_lock_irqsave(channel-inbound_lock, flags);
channel-onchannel_callback = NULL;
+   spin_unlock_irqrestore(channel-inbound_lock, flags);
 
/* Send a closing message */
 
@@ -735,19 +738,15 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void 
*buffer,
u32 packetlen;
u32 userlen;
int ret;
-   unsigned long flags;
 
*buffer_actual_len = 0;
*requestid = 0;
 
-   spin_lock_irqsave(channel-inbound_lock, flags);
 
ret = hv_ringbuffer_peek(channel-inbound, desc,
 sizeof(struct vmpacket_descriptor));
-   if (ret != 0) {
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
+   if (ret != 0)
return 0;
-   }
 
packetlen = desc.len8  3;
userlen = packetlen - (desc.offset8  3);
@@ -755,7 +754,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void 
*buffer,
*buffer_actual_len = userlen;
 
if (userlen  bufferlen) {
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
 
pr_err(Buffer too small - got %d needs %d\n,
   bufferlen, userlen);
@@ -768,7 +766,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void 
*buffer,
ret = hv_ringbuffer_read(channel-inbound, buffer, userlen,
 (desc.offset8  3));
 
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
 
return 0;
 }
@@ -785,19 +782,15 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, 
void *buffer,
u32 packetlen;
u32 userlen;
int ret;
-   unsigned long flags;
 
*buffer_actual_len = 0;
*requestid = 0;
 
-   spin_lock_irqsave(channel-inbound_lock, flags);
 
ret = hv_ringbuffer_peek(channel-inbound, desc,
 sizeof(struct vmpacket_descriptor));
-   if (ret != 0) {
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
+   if (ret != 0)
return 0;
-   }
 
 
packetlen = desc.len8  3;
@@ -806,8 +799,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, 
void *buffer,
*buffer_actual_len = packetlen;
 
if (packetlen  bufferlen) {
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
-
pr_err(Buffer too small - needed %d bytes but 
got space for only %d bytes\n,
packetlen, bufferlen);
@@ -819,7 +810,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, 
void *buffer,
/* Copy over the entire packet to the user buffer */
ret = hv_ringbuffer_read(channel-inbound, buffer, packetlen, 0);
 
-   spin_unlock_irqrestore(channel-inbound_lock, flags);
return 0;
 }
 EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 7a3ec75..6aab802 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -215,6 +215,7 @@ struct vmbus_channel *relid2channel(u32 relid)
 static void process_chn_event(u32 relid)
 {
struct vmbus_channel *channel;
+   unsigned long flags;
 
/*
 * Find the channel based on this relid and invokes the
@@ -222,11 +223,13 @@ static void process_chn_event(u32 relid)
 */
channel = relid2channel(relid);
 
+   spin_lock_irqsave(channel-inbound_lock, flags);
if (channel  (channel-onchannel_callback != NULL)) {
channel-onchannel_callback(channel-channel_callback_context);
} else {
pr_err(channel not found for relid - %u\n, relid);
}
+   spin_unlock_irqrestore(channel-inbound_lock, flags);
 }
 
 /*
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 9828f0b..e4cc40a 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -62,9 +62,7 @@ static struct

[PATCH 0000/0046] Staging: hv: Driver cleanup

2011-08-27 Thread K. Y. Srinivasan
Further cleanup of the hv drivers. 

1) Cleanup reference counting.

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

3) Fix bugs.

4) Accomodate some host side scsi emulation bugs.

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

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


Regards,

K. Y

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 16/59] Staging: hv: netvsc: Get rid of the PCI signature

2011-08-25 Thread K. Y. Srinivasan
Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

2011-08-25 Thread K. Y. Srinivasan
Use the newly introduced vmbus ID in the blockvsc driver. Also, do
the associated cleanup.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c |   23 ++-
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 018b293..9b99387 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -111,14 +111,6 @@ struct block_device_context {
 
 static const char *drv_name = blkvsc;
 
-/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const uuid_le dev_type = {
-   .b = {
-   0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-   0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-   }
-};
-
 /*
  * There is a circular dependency involving blkvsc_request_completion()
  * and blkvsc_do_request().
@@ -802,10 +794,24 @@ static void blkvsc_request(struct request_queue *queue)
}
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+   {
+   /* IDE guid */
+   .guid = {
+   0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+   0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+   }
+   },
+   {
+   .guid = { }
+   },
+};
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver blkvsc_drv = {
+   .id_table = id_table,
.probe =  blkvsc_probe,
.remove =  blkvsc_remove,
.shutdown = blkvsc_shutdown,
@@ -829,7 +835,6 @@ static int blkvsc_drv_init(void)
 
BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-   memcpy(drv-dev_type, dev_type, sizeof(uuid_le));
drv-driver.name = drv_name;
 
/* The driver belongs to vmbus */
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 15/59] Staging: hv: storvsc: Get rid of the DMI signature

2011-08-25 Thread K. Y. Srinivasan
Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 08/59] Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver

2011-08-25 Thread K. Y. Srinivasan
Use the newly introduced vmbus ID in netvsc driver. Also, do the associated
cleanup.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/netvsc.c |   10 --
 drivers/staging/hv/netvsc_drv.c |   16 
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 1506b53..6f4541b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -35,15 +35,6 @@
 /* Globals */
 static const char *driver_name = netvsc;
 
-/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const uuid_le netvsc_device_type = {
-   .b = {
-   0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
-   0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
-   }
-};
-
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
struct netvsc_device *net_device;
@@ -1009,7 +1000,6 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
drv-name = driver_name;
-   memcpy(drv-dev_type, netvsc_device_type, sizeof(uuid_le));
 
return 0;
 }
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 61989f0..2e25c95 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -413,8 +413,24 @@ static int netvsc_remove(struct hv_device *dev)
return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+   {
+   /* Network guid */
+   .guid = {
+   0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
+   0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
+   }
+   },
+   {
+   .guid = { }
+   },
+};
+
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
+   .id_table = id_table,
.probe = netvsc_probe,
.remove = netvsc_remove,
 };
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 19/59] Staging: hv: util: Get rid of the PCI signature in hv_util.c

2011-08-25 Thread K. Y. Srinivasan
Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the PCI signature.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 24/59] Staging: hv: vmbus: Cleanup unnecessary comments in hv.c

2011-08-25 Thread K. Y. Srinivasan
Cleanup unnecessary comments in hv.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

2011-08-25 Thread K. Y. Srinivasan
Get rid of the unused name field in struct hv_driver.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 27/59] Staging: hv: vmbus: Get rid of the function dump_gpadl_body()

2011-08-25 Thread K. Y. Srinivasan
Get rid of the function dump_gpadl_body() since it adds no value and actually is
in the data path.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 30/59] Staging: hv: vmbus: Get rid of unnecessary comments in channel.c

2011-08-25 Thread K. Y. Srinivasan
Get rid of unnecessary comments in channel.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 20/59] Staging: hv: netvsc: Initialize the driver name directly

2011-08-25 Thread K. Y. Srinivasan
Initialize the driver name directly in netvsc_drv.c and do the necessary
adjustments.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/netvsc.c |5 -
 drivers/staging/hv/netvsc_drv.c |4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 6f4541b..d085018 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -32,9 +32,6 @@
 #include hyperv_net.h
 
 
-/* Globals */
-static const char *driver_name = netvsc;
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
struct netvsc_device *net_device;
@@ -999,7 +996,5 @@ cleanup:
 int netvsc_initialize(struct hv_driver *drv)
 {
 
-   drv-name = driver_name;
-
return 0;
 }
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index d6c6180..61de6f2 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -41,6 +41,8 @@
 #include hyperv.h
 #include hyperv_net.h
 
+static const char *driver_name = netvsc;
+
 struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
@@ -449,7 +451,7 @@ static int __init netvsc_drv_init(void)
/* Callback to client driver to complete the initialization */
netvsc_initialize(drv);
 
-   drv-driver.name = drv-name;
+   drv-driver.name = driver_name;
 
/* The driver belongs to vmbus */
ret = vmbus_child_driver_register(drv-driver);
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 05/59] Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver

2011-08-25 Thread K. Y. Srinivasan
In preparation for supporting auto-loading Hyper-V drivers
using vmbus specific aliases, introduce vmbus ID space in struct hv_driver.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 13/59] Staging: hv: vmbus: Support the notion of id tables in vmbus_match()

2011-08-25 Thread K. Y. Srinivasan
Introduce code to handle driver specific id tables to the vmbus core
(vmbus_match). This would allow us to handle more than one device type
with a given driver.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/vmbus_drv.c |   20 +++-
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index a6e7dc5..abcd592 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -255,21 +255,31 @@ static int vmbus_uevent(struct device *device, struct 
kobj_uevent_env *env)
return ret;
 }
 
+static uuid_le null_guid;
+
+static inline  bool is_null_guid(const __u8 *guid)
+{
+   if (memcmp(guid, null_guid, sizeof(uuid_le)))
+   return false;
+   return true;
+}
+
 
 /*
  * vmbus_match - Attempt to match the specified device to the specified driver
  */
 static int vmbus_match(struct device *device, struct device_driver *driver)
 {
-   int match = 0;
struct hv_driver *drv = drv_to_hv_drv(driver);
struct hv_device *hv_dev = device_to_hv_device(device);
+   const struct hv_vmbus_device_id *id_array = drv-id_table;
 
-   /* We found our driver ? */
-   if (!uuid_le_cmp(hv_dev-dev_type, drv-dev_type))
-   match = 1;
+   for (; !is_null_guid(id_array-guid); id_array++)
+   if (!memcmp(id_array-guid, hv_dev-dev_type.b,
+   sizeof(struct hv_vmbus_device_id)))
+   return 1;
 
-   return match;
+   return 0;
 }
 
 /*
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 29/59] Staging: hv: vmbus: Rename openMsg to open_msg in channel.c

2011-08-25 Thread K. Y. Srinivasan
Rename openMsg to open_msg in channel.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 25/59] Staging: hv: vmbus: Cleanup error handling in hv_init()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index d2b921b..736794e 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -151,7 +151,6 @@ static u64 do_hypercall(u64 control, void *input, void 
*output)
  */
 int hv_init(void)
 {
-   int ret = 0;
int max_leaf;
union hv_x64_msr_hypercall_contents hypercall_msr;
void *virtaddr = NULL;
@@ -214,7 +213,7 @@ int hv_init(void)
hv_context.signal_event_param-flag_number = 0;
hv_context.signal_event_param-rsvdz = 0;
 
-   return ret;
+   return 0;
 
 cleanup:
if (virtaddr) {
@@ -225,8 +224,8 @@ cleanup:
 
vfree(virtaddr);
}
-   ret = -1;
-   return ret;
+
+   return -ENOTSUPP;
 }
 
 /*
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 36/59] Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error values and cleanup error handling. I would like
to acknowledge Andre Bartke (andre.bar...@gmail.com) for highlighting this
problem.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 28/59] Staging: hv: vmbus: Get rid of the function dump_gpadl_header()

2011-08-25 Thread K. Y. Srinivasan
Get rid of the function dump_gpadl_header() as this adds no value.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

2011-08-25 Thread K. Y. Srinivasan
Now generate appropriate uevent based on the modalias string. As part of this,
cleanup the existing uevent code.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 09/59] Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver

2011-08-25 Thread K. Y. Srinivasan
Use the newly introduced vmbus ID in mouse driver. Also, do the associated
cleanup. Since the mouse driver is not functional, we disable the
autoloading of this driver.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/hv_mouse.c |   27 ++-
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 950f4b4..dd8a114 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -178,12 +178,6 @@ struct mousevsc_dev {
 
 static const char *driver_name = mousevsc;
 
-/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const uuid_le mouse_guid = {
-   .b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
-0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
-};
-
 static void deviceinfo_callback(struct hv_device *dev, struct 
hv_input_dev_info *info);
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
@@ -914,8 +908,26 @@ static void reportdesc_callback(struct hv_device *dev, 
void *packet, u32 len)
kfree(hid_dev);
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+   {
+   /* Mouse guid */
+   .guid = {
+   0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+   0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
+   }
+   },
+   {
+   .guid = { }
+   },
+};
+
+/*
+ * The mouse driver is not functional; do not auto-load it.
+ */
+/* MODULE_DEVICE_TABLE(vmbus, id_table); */
 
 static struct  hv_driver mousevsc_drv = {
+   .id_table = id_table,
.probe = mousevsc_probe,
.remove = mousevsc_remove,
 };
@@ -931,9 +943,6 @@ static int __init mousevsc_init(void)
 
DPRINT_INFO(INPUTVSC_DRV, Hyper-V Mouse driver initializing.);
 
-   memcpy(drv-dev_type, mouse_guid,
-  sizeof(uuid_le));
-
drv-driver.name = driver_name;
 
/* The driver belongs to vmbus */
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 01/59] Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature

2011-08-25 Thread K. Y. Srinivasan
VMBUS is an ACPI enumerated device, get rid of the PCI signature.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 31/59] Staging: hv: vmbus: Change the variable name openInfo to open_info in channel.c

2011-08-25 Thread K. Y. Srinivasan
Change the variable name openInfo to open_info in channel.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 33/59] Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux errno values.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 07/59] Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver

2011-08-25 Thread K. Y. Srinivasan
Use the newly introduced vmbus ID in storvsc driver. Also, do the
assciated cleanup.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   25 ++---
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e4cdbc5..ed2140c 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -44,14 +44,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, Ring buffer size 
(bytes));
 
 static const char *driver_name = storvsc;
 
-/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const uuid_le stor_vsci_device_type = {
-   .b = {
-   0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
-   0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
-   }
-};
-
 struct hv_host_device {
struct hv_device *dev;
struct kmem_cache *request_pool;
@@ -646,7 +638,20 @@ static struct scsi_host_template scsi_driver = {
.dma_boundary = PAGE_SIZE-1,
 };
 
+static const struct hv_vmbus_device_id id_table[] = {
+   {
+   /* SCSI guid */
+   .guid = {
+   0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
+   0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
+   }
+   },
+   {
+   .guid = { }
+   },
+};
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 /*
  * storvsc_probe - Add a new device for this driver
  */
@@ -720,6 +725,7 @@ static int storvsc_probe(struct hv_device *device)
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
+   .id_table = id_table,
.probe = storvsc_probe,
.remove = storvsc_remove,
 };
@@ -764,9 +770,6 @@ static int __init storvsc_drv_init(void)
sizeof(struct vstor_packet) + sizeof(u64),
sizeof(u64)));
 
-   memcpy(drv-dev_type, stor_vsci_device_type,
-  sizeof(uuid_le));
-
if (max_outstanding_req_per_channel 
STORVSC_MAX_IO_REQUESTS)
return -1;
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 0000/0059] Staging: hv: Driver cleanup

2011-08-25 Thread K. Y. Srinivasan
Further cleanup of the hv drivers. 

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

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

3) General cleanup



Regards,

K. Y 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 04/59] Staging: hv: Add code to parse struct hv_vmbus_device_id table

2011-08-25 Thread K. Y. Srinivasan
Add code to parse struct hv_vmbus_device_id table.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 44/59] Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 956f010..94f40fc 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -750,7 +750,7 @@ static int __init storvsc_drv_init(void)
 
if (max_outstanding_req_per_channel 
STORVSC_MAX_IO_REQUESTS)
-   return -1;
+   return -EINVAL;
 
drv-driver.name = driver_name;
 
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 56/59] Staging: hv: mouse: Change the jump label Cleanup to cleanup

2011-08-25 Thread K. Y. Srinivasan
Change the jump label Cleanup to cleanup.

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

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 2e04948..cbb837b 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -338,7 +338,7 @@ static void mousevsc_on_receive_device_info(struct 
mousevsc_dev *input_device,
 
if (!input_device-hid_desc) {
pr_err(unable to allocate hid descriptor - size %d, 
desc-bLength);
-   goto Cleanup;
+   goto cleanup;
}
 
memcpy(input_device-hid_desc, desc, desc-bLength);
@@ -351,7 +351,7 @@ static void mousevsc_on_receive_device_info(struct 
mousevsc_dev *input_device,
if (!input_device-report_desc) {
pr_err(unable to allocate report descriptor - size %d,
   input_device-report_desc_size);
-   goto Cleanup;
+   goto cleanup;
}
 
memcpy(input_device-report_desc,
@@ -378,7 +378,7 @@ static void mousevsc_on_receive_device_info(struct 
mousevsc_dev *input_device,
if (ret != 0) {
pr_err(unable to send synthhid device info ack - ret %d,
   ret);
-   goto Cleanup;
+   goto cleanup;
}
 
input_device-device_wait_condition = 1;
@@ -386,7 +386,7 @@ static void mousevsc_on_receive_device_info(struct 
mousevsc_dev *input_device,
 
return;
 
-Cleanup:
+cleanup:
kfree(input_device-hid_desc);
input_device-hid_desc = NULL;
 
@@ -605,7 +605,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)

VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
pr_err(unable to send synthhid protocol request.);
-   goto Cleanup;
+   goto cleanup;
}
 
input_dev-protocol_wait_condition = 0;
@@ -613,7 +613,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
input_dev-protocol_wait_condition, msecs_to_jiffies(1000));
if (input_dev-protocol_wait_condition == 0) {
ret = -ETIMEDOUT;
-   goto Cleanup;
+   goto cleanup;
}
 
response = input_dev-protocol_resp;
@@ -622,7 +622,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
pr_err(synthhid protocol request failed (version %d),
   SYNTHHID_INPUT_VERSION);
ret = -1;
-   goto Cleanup;
+   goto cleanup;
}
 
input_dev-device_wait_condition = 0;
@@ -630,7 +630,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
input_dev-device_wait_condition, msecs_to_jiffies(1000));
if (input_dev-device_wait_condition == 0) {
ret = -ETIMEDOUT;
-   goto Cleanup;
+   goto cleanup;
}
 
/*
@@ -642,7 +642,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
else
ret = -1;
 
-Cleanup:
+cleanup:
put_input_device(device);
 
return ret;
@@ -660,7 +660,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
if (!input_dev) {
ret = -1;
-   goto Cleanup;
+   goto cleanup;
}
 
input_dev-init_complete = false;
@@ -713,7 +713,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
input_dev-init_complete = true;
 
-Cleanup:
+cleanup:
return ret;
 }
 
-- 
1.7.4.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 45/59] Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 46/59] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf()

2011-08-25 Thread K. Y. Srinivasan
Cleanup error return codes in netvsc_destroy_recv_buf().

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 40/59] Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c

2011-08-25 Thread K. Y. Srinivasan
Get rid of some unnecessary DPRINTs from storvsc.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 35/59] Staging: hv: vmbus: Retry vmbus_post_msg() before giving up

2011-08-25 Thread K. Y. Srinivasan
The function hv_post_msg() can fail because of transient resource
conditions. It may be useful to retry the operation.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 54/59] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 39/59] Staging: hv: storvsc: Cleanup error handling in storvsc_do_io()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 49/59] Staging: hv: netvsc: Cleanup error return values in netvsc_send()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 26/59] Staging: hv: vmbus: Get rid of unnecessay comments in connection.c

2011-08-25 Thread K. Y. Srinivasan
Get rid of unnecessay comments in connection.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 50/59] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 18/59] Staging: hv: util: Get rid of the DMI signature in hv_util.c

2011-08-25 Thread K. Y. Srinivasan
Now that we have implemented a vmbus specific mechanism for auto-loading,
get rid of the DMI signature.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 32/59] Staging: hv: vmbus: Cleanup error values in ringbuffer.c

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux errno values in ringbuffer.c and do the associated
cleanup in the clients.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 21/59] Staging: hv: netvsc: Get rid of the empty function netvsc_initialize()

2011-08-25 Thread K. Y. Srinivasan
Now, get rid of the empty function netvsc_initialize().

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 34/59] Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe()

2011-08-25 Thread K. Y. Srinivasan
Get rid of an unnecessary print statement in netvsc_probe(). Furthermore,
this fixes a bug since netdev_err is being invoked after the device has
been freed.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 58/59] Staging: hv: netvsc: Change the jump label Cleanup to cleanup

2011-08-25 Thread K. Y. Srinivasan
Change the jump label Cleanup to cleanup.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 47/59] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 43/59] Staging: hv: storvsc: Cleanup error code returned in storvsc_probe()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 53/59] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes and cleanup some error paths.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 52/59] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 37/59] Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 59/59] Staging: hv: netvsc: Change the jump label Exit to exit

2011-08-25 Thread K. Y. Srinivasan
Change the jump lable Exit to exit.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 14/59] Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c

2011-08-25 Thread K. Y. Srinivasan
Get rid of an unnecessary include line in vmbus_drv.c.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 42/59] Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[PATCH 51/59] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()

2011-08-25 Thread K. Y. Srinivasan
Use standard Linux error codes.

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

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

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization


  1   2   3   4   5   6   7   8   9   >