Further cleanup of the hv drivers: 1) Continue to cleanup our drivers to conform to the Linux Driver Model. 2) Fix some long standing bugs with regards to unloading and reloading the drivers - block, net and stor. 3) VMBUS is an ACPI enumerated device; make VMBUS an ACPI bus driver. 4) Get rid of channel polling code; instead the channel receive paths will be purely interrupt drive. 5) Cleanup error return values in the vmbus driver and general cleanup. 6) Fix memory barrier calls in the ring buffer code. 7) Increase the timeout values for some critical guest to host calls. Regads, K. Y
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 01/49] Staging: hv: vmbus: In vmbus_child_driver_unregister() don't set the bus field to NULL
As part of conforming to the Linux Driver Model, do not set the bus field to NULL when the driver un-registers. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at 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 ec1d38c..51af6d8 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -631,7 +631,6 @@ void vmbus_child_driver_unregister(struct device_driver *drv) driver_unregister(drv); - drv->bus = NULL; } EXPORT_SYMBOL(vmbus_child_driver_unregister); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 02/49] Staging: hv: storvsc: Cleanup the exit function in storvsc_drv.c
Get rid of unnecessary layering in the module exit path. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 942cc5f..e21f7e6 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -792,7 +792,7 @@ static int storvsc_drv_init(void) return ret; } -static void storvsc_drv_exit(void) +static void __exit storvsc_drv_exit(void) { vmbus_child_driver_unregister(&storvsc_drv.driver); } @@ -806,13 +806,8 @@ static int __init storvsc_init(void) return ret; } -static void __exit storvsc_exit(void) -{ - storvsc_drv_exit(); -} - MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); MODULE_DESCRIPTION("Microsoft Hyper-V virtual storage driver"); module_init(storvsc_init); -module_exit(storvsc_exit); +module_exit(storvsc_drv_exit); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 03/49] Staging: hv: storvsc: Cleanup the module init function in storvsc_drv.c
Get rid of unnecessary layering in the module init path. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index e21f7e6..33bce87 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -756,7 +756,7 @@ static struct hv_driver storvsc_drv = { /* * storvsc_drv_init - StorVsc driver initialization. */ -static int storvsc_drv_init(void) +static int __init storvsc_drv_init(void) { int ret; struct hv_driver *drv = &storvsc_drv; @@ -797,17 +797,8 @@ static void __exit storvsc_drv_exit(void) vmbus_child_driver_unregister(&storvsc_drv.driver); } -static int __init storvsc_init(void) -{ - int ret; - - DPRINT_INFO(STORVSC_DRV, "Storvsc initializing...."); - ret = storvsc_drv_init(); - return ret; -} - MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); MODULE_DESCRIPTION("Microsoft Hyper-V virtual storage driver"); -module_init(storvsc_init); +module_init(storvsc_drv_init); module_exit(storvsc_drv_exit); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 04/49] Staging: hv: storvsc: Fix a bug in the storvsc_remove() function
When the storvs driver unloads, we need to accomodate disk cache flushes. Re-order the code to permit this. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 33bce87..fd474d6 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -317,22 +317,20 @@ static int storvsc_remove(struct hv_device *dev) struct hv_host_device *host_dev (struct hv_host_device *)host->hostdata; + DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host); + scsi_remove_host(host); + + DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host); + scsi_host_put(host); /* * Call to the vsc driver to let it know that the device is being * removed */ storvsc_dev_remove(dev); - if (host_dev->request_pool) { kmem_cache_destroy(host_dev->request_pool); host_dev->request_pool = NULL; } - - DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host); - scsi_remove_host(host); - - DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host); - scsi_host_put(host); return 0; } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 05/49] Staging: hv: storvsc: Cleanup some dated/unnecessary comments
Cleanup some dated/unnecessary comments. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 14 +------------- 1 files changed, 1 insertions(+), 13 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index fd474d6..499e1d7 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -308,9 +308,6 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, } -/* - * storvsc_remove - Callback when our device is removed - */ static int storvsc_remove(struct hv_device *dev) { struct Scsi_Host *host = dev_get_drvdata(&dev->device); @@ -322,10 +319,7 @@ static int storvsc_remove(struct hv_device *dev) DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host); scsi_host_put(host); - /* - * Call to the vsc driver to let it know that the device is being - * removed - */ + storvsc_dev_remove(dev); if (host_dev->request_pool) { kmem_cache_destroy(host_dev->request_pool); @@ -423,7 +417,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...", scmnd->device, dev); - /* Invokes the vsc to reset the host/bus */ ret = storvsc_host_reset(dev); if (ret != 0) return ret; @@ -477,7 +470,6 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request) scmnd->host_scribble = NULL; scmnd->scsi_done = NULL; - /* !!DO NOT MODIFY the scmnd after this call */ scsi_done_fn(scmnd); kmem_cache_free(host_dev->request_pool, cmd_request); @@ -750,10 +742,6 @@ static struct hv_driver storvsc_drv = { .remove = storvsc_remove, }; - -/* - * storvsc_drv_init - StorVsc driver initialization. - */ static int __init storvsc_drv_init(void) { int ret; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 06/49] Staging: hv: stor: Get rid of unnecessary DPRINTs in stor vsc_drv.c
Get rid of unnecessary DPRINTs in stor vsc_drv.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 499e1d7..73fbded 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -92,12 +92,8 @@ static int storvsc_device_configure(struct scsi_device *sdevice) scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG, STORVSC_MAX_IO_REQUESTS); - DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld", - sdevice, PAGE_SIZE); blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE); - DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine", - sdevice); blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec); blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY); @@ -314,10 +310,8 @@ static int storvsc_remove(struct hv_device *dev) struct hv_host_device *host_dev (struct hv_host_device *)host->hostdata; - DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host); scsi_remove_host(host); - DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host); scsi_host_put(host); storvsc_dev_remove(dev); @@ -349,9 +343,6 @@ static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, info[1] = sectors_pt; info[2] = (int)cylinders; - DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", (int)cylinders, heads, - sectors_pt); - return 0; } @@ -362,7 +353,6 @@ static int storvsc_host_reset(struct hv_device *device) struct vstor_packet *vstor_packet; int ret, t; - DPRINT_INFO(STORVSC, "resetting host adapter..."); stor_device = get_stor_device(device); if (!stor_device) @@ -391,7 +381,6 @@ static int storvsc_host_reset(struct hv_device *device) goto cleanup; } - DPRINT_INFO(STORVSC, "host adapter reset completed"); /* * At this point, all outstanding requests in the adapter @@ -414,16 +403,10 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) (struct hv_host_device *)scmnd->device->host->hostdata; struct hv_device *dev = host_dev->dev; - DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...", - scmnd->device, dev); - ret = storvsc_host_reset(dev); if (ret != 0) return ret; - DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted", - scmnd->device, dev); - return ret; } @@ -500,8 +483,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, cmd_request (struct storvsc_cmd_request *)scmnd->host_scribble; - DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p", - scmnd, cmd_request); goto retry_request; } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 07/49] Staging: hv: stor: Rename the vriable gStorVscDeviceType in storvsc_drv.c
Rename the vriable gStorVscDeviceType in storvsc_drv.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at 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 73fbded..9e51356 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -44,7 +44,7 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); static const char *driver_name = "storvsc"; /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const struct hv_guid gStorVscDeviceType = { +static const struct hv_guid stor_vsci_device_type = { .data = { 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f @@ -742,7 +742,7 @@ static int __init storvsc_drv_init(void) sizeof(struct vstor_packet) + sizeof(u64), sizeof(u64))); - memcpy(&drv->dev_type, &gStorVscDeviceType, + memcpy(&drv->dev_type, &stor_vsci_device_type, sizeof(struct hv_guid)); if (max_outstanding_req_per_channel < -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 08/49] Staging: hv: stor: Get rid of the unused initialization of the name field
The name field of hv_driver is unused in storvsc_drv.c; get rid of it. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 9e51356..53e9ebd 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -749,7 +749,6 @@ static int __init storvsc_drv_init(void) STORVSC_MAX_IO_REQUESTS) return -1; - drv->name = driver_name; drv->driver.name = driver_name; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 09/49] Staging: hv: blk: Get rid of the unused initialization of the name field
The name field of hv_driver is unused in blkvsc_drv.c; get rid of it. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 46daade..bcf562f 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -824,7 +824,6 @@ static int blkvsc_drv_init(void) BUILD_BUG_ON(sizeof(sector_t) != 8); memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid)); - drv->name = drv_name; drv->driver.name = drv_name; /* The driver belongs to vmbus */ -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 10/49] Staging: hv: mouse: Get rid of the unused initialization of the name field
The name field of hv_driver is unused in hv_mouse.c; get rid of it. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/hv_mouse.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c index 359e737..b191810 100644 --- a/drivers/staging/hv/hv_mouse.c +++ b/drivers/staging/hv/hv_mouse.c @@ -936,7 +936,6 @@ static int __init mousevsc_init(void) sizeof(struct hv_guid)); drv->driver.name = driver_name; - drv->name = driver_name; /* The driver belongs to vmbus */ vmbus_child_driver_register(&drv->driver); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 12/49] Staging: hv: storvsc: Add a DMI signature to support auto-loading
To support auto-loading the storvsc driver, add a DMI signature. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/storvsc_drv.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 53e9ebd..2c6d2f2 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -24,6 +24,7 @@ #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> @@ -723,6 +724,27 @@ 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
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 13/49] Staging: hv: vmbus: Change the signature of vmbus_bus_init()
In preparation for making the vmbus driver an ACPI bus driver, change the signature of vmbus_bus_init() to accept the irq value. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 51af6d8..1b69339 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -528,7 +528,7 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) * - get the irq resource * - retrieve the channel offers */ -static int vmbus_bus_init(struct pci_dev *pdev) +static int vmbus_bus_init(int irq) { int ret; unsigned int vector; @@ -552,13 +552,13 @@ static int vmbus_bus_init(struct pci_dev *pdev) } /* Get the interrupt resource */ - ret = request_irq(pdev->irq, vmbus_isr, + ret = request_irq(irq, vmbus_isr, IRQF_SHARED | IRQF_SAMPLE_RANDOM, - driver_name, pdev); + driver_name, hv_pci_dev); if (ret != 0) { pr_err("Unable to request IRQ %d\n", - pdev->irq); + irq); bus_unregister(&hv_bus); @@ -566,7 +566,7 @@ static int vmbus_bus_init(struct pci_dev *pdev) goto cleanup; } - vector = IRQ0_VECTOR + pdev->irq; + vector = IRQ0_VECTOR + irq; /* * Notify the hypervisor of our irq and @@ -575,7 +575,7 @@ static int vmbus_bus_init(struct pci_dev *pdev) on_each_cpu(hv_synic_init, (void *)&vector, 1); ret = vmbus_connect(); if (ret) { - free_irq(pdev->irq, pdev); + free_irq(irq, hv_pci_dev); bus_unregister(&hv_bus); goto cleanup; } @@ -795,7 +795,7 @@ static int __devinit hv_pci_probe(struct pci_dev *pdev, if (pdev->irq == 0) pdev->irq = irq; - pci_probe_error = vmbus_bus_init(pdev); + pci_probe_error = vmbus_bus_init(pdev->irq); if (pci_probe_error) pci_disable_device(pdev); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 14/49] Staging: hv: vmbus: Use the DSDT specified irq for vmbus
DSDT specifies the irq value for the vmbus driver; use it unconditionally. This is an exclusive interrupt line dedicated for the vmbus driver. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 1b69339..5d7ecfd 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -552,9 +552,8 @@ static int vmbus_bus_init(int irq) } /* Get the interrupt resource */ - ret = request_irq(irq, vmbus_isr, - IRQF_SHARED | IRQF_SAMPLE_RANDOM, - driver_name, hv_pci_dev); + ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM, + driver_name, hv_pci_dev); if (ret != 0) { pr_err("Unable to request IRQ %d\n", @@ -787,15 +786,7 @@ static int __devinit hv_pci_probe(struct pci_dev *pdev, if (pci_probe_error) goto probe_cleanup; - /* - * If the PCI sub-sytem did not assign us an - * irq, use the bios provided one. - */ - - if (pdev->irq == 0) - pdev->irq = irq; - - pci_probe_error = vmbus_bus_init(pdev->irq); + pci_probe_error = vmbus_bus_init(irq); if (pci_probe_error) pci_disable_device(pdev); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 15/49] Staging: hv: vmbus: Make vmbus an acpi bus driver
Now, make the vmbus driver an ACPI bus driver. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 56 ++++++--------------------------------- 1 files changed, 9 insertions(+), 47 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 5d7ecfd..176a8cd 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -39,7 +39,7 @@ #include "hyperv_vmbus.h" -static struct pci_dev *hv_pci_dev; +static struct acpi_device *hv_acpi_dev; static struct tasklet_struct msg_dpc; static struct tasklet_struct event_dpc; @@ -49,7 +49,6 @@ EXPORT_SYMBOL(vmbus_loglevel); /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */ /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */ -static int pci_probe_error; static struct completion probe_event; static int irq; @@ -553,7 +552,7 @@ static int vmbus_bus_init(int irq) /* Get the interrupt resource */ ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM, - driver_name, hv_pci_dev); + driver_name, hv_acpi_dev); if (ret != 0) { pr_err("Unable to request IRQ %d\n", @@ -574,7 +573,7 @@ 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_pci_dev); + free_irq(irq, hv_acpi_dev); bus_unregister(&hv_bus); goto cleanup; } @@ -674,7 +673,7 @@ int vmbus_child_device_register(struct hv_device *child_device_obj) /* The new device belongs to this bus */ child_device_obj->device.bus = &hv_bus; /* device->dev.bus; */ - child_device_obj->device.parent = &hv_pci_dev->dev; + child_device_obj->device.parent = &hv_acpi_dev->dev; child_device_obj->device.release = vmbus_device_release; /* @@ -731,6 +730,8 @@ static int vmbus_acpi_add(struct acpi_device *device) { acpi_status result; + hv_acpi_dev = device; + result acpi_walk_resources(device->handle, METHOD_NAME__CRS, vmbus_walk_resources, &irq); @@ -777,25 +778,6 @@ static void vmbus_acpi_exit(void) } -static int __devinit hv_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - hv_pci_dev = pdev; - - pci_probe_error = pci_enable_device(pdev); - if (pci_probe_error) - goto probe_cleanup; - - pci_probe_error = vmbus_bus_init(irq); - - if (pci_probe_error) - pci_disable_device(pdev); - -probe_cleanup: - complete(&probe_event); - return pci_probe_error; -} - /* * 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 @@ -808,13 +790,7 @@ static const struct pci_device_id microsoft_hv_pci_table[] = { }; MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table); -static struct pci_driver hv_bus_driver = { - .name = "hv_bus", - .probe = hv_pci_probe, - .id_table = microsoft_hv_pci_table, -}; - -static int __init hv_pci_init(void) +static int __init hv_acpi_init(void) { int ret; @@ -835,21 +811,7 @@ static int __init hv_pci_init(void) return -ENODEV; } - vmbus_acpi_exit(); - init_completion(&probe_event); - ret = pci_register_driver(&hv_bus_driver); - if (ret) - return ret; - /* - * All the vmbus initialization occurs within the - * hv_pci_probe() function. Wait for hv_pci_probe() - * to complete. - */ - wait_for_completion(&probe_event); - - if (pci_probe_error) - pci_unregister_driver(&hv_bus_driver); - return pci_probe_error; + return vmbus_bus_init(irq); } @@ -857,4 +819,4 @@ MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); module_param(vmbus_loglevel, int, S_IRUGO|S_IWUSR); -module_init(hv_pci_init); +module_init(hv_acpi_init); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 16/49] Staging: hv: vmbus: Get rid of vmbus_acpi_init() by inlining the code
Staging: hv: vmbus: Get rid of vmbus_acpi_init() by inlining the code. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 15 ++------------- 1 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 176a8cd..d799f42 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -758,18 +758,6 @@ static struct acpi_driver vmbus_acpi_driver = { }, }; -static int vmbus_acpi_init(void) -{ - int result; - - - result = acpi_bus_register_driver(&vmbus_acpi_driver); - if (result < 0) - return result; - - return 0; -} - static void vmbus_acpi_exit(void) { acpi_bus_unregister_driver(&vmbus_acpi_driver); @@ -800,7 +788,8 @@ static int __init hv_acpi_init(void) * Get irq resources first. */ - ret = vmbus_acpi_init(); + ret = acpi_bus_register_driver(&vmbus_acpi_driver); + if (ret) return ret; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 17/49] Staging: hv: vmbus: Get rid of vmbus_acpi_exit() by inlining the code
Get rid of vmbus_acpi_exit() by inlining the code. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index d799f42..39cd277 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -758,14 +758,6 @@ static struct acpi_driver vmbus_acpi_driver = { }, }; -static void vmbus_acpi_exit(void) -{ - acpi_bus_unregister_driver(&vmbus_acpi_driver); - - return; -} - - /* * 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 @@ -796,7 +788,7 @@ static int __init hv_acpi_init(void) wait_for_completion(&probe_event); if (irq <= 0) { - vmbus_acpi_exit(); + acpi_bus_unregister_driver(&vmbus_acpi_driver); return -ENODEV; } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 18/49] Staging: hv: vmbus: Add the DSDT _HID name as well
Add the DSDT _HID name as well, in addition to the _DDN name. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 39cd277..1a26252 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -746,6 +746,7 @@ static int vmbus_acpi_add(struct acpi_device *device) static const struct acpi_device_id vmbus_acpi_device_ids[] = { {"VMBUS", 0}, + {"VMBus", 0}, {"", 0}, }; MODULE_DEVICE_TABLE(acpi, vmbus_acpi_device_ids); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 19/49] Staging: hv: blkvsc: Fix bugs in the module unload path
Fix bugs in the module unload path for the blkvsc driver. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/blkvsc_drv.c | 40 ++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index bcf562f..a44fc76 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -518,22 +518,18 @@ static int blkvsc_remove(struct hv_device *dev) blkvsc_do_operation(blkdev, DO_FLUSH); - blk_cleanup_queue(blkdev->gd->queue); + if (blkdev->users == 0) { + del_gendisk(blkdev->gd); + put_disk(blkdev->gd); + blk_cleanup_queue(blkdev->gd->queue); - /* - * Call to the vsc driver to let it know that the device is being - * removed - */ - storvsc_dev_remove(dev); - - del_gendisk(blkdev->gd); + storvsc_dev_remove(blkdev->device_ctx); - kmem_cache_destroy(blkdev->request_pool); - - kfree(blkdev); + kmem_cache_destroy(blkdev->request_pool); + kfree(blkdev); + } return 0; - } static void blkvsc_shutdown(struct hv_device *dev) @@ -568,13 +564,23 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) struct block_device_context *blkdev = disk->private_data; unsigned long flags; - if (blkdev->users == 1) { + spin_lock_irqsave(&blkdev->lock, flags); + + if ((--blkdev->users == 0) && (blkdev->shutting_down)) { + blk_stop_queue(blkdev->gd->queue); + spin_unlock_irqrestore(&blkdev->lock, flags); + blkvsc_do_operation(blkdev, DO_FLUSH); - } + del_gendisk(blkdev->gd); + put_disk(blkdev->gd); + blk_cleanup_queue(blkdev->gd->queue); - spin_lock_irqsave(&blkdev->lock, flags); - blkdev->users--; - spin_unlock_irqrestore(&blkdev->lock, flags); + storvsc_dev_remove(blkdev->device_ctx); + + kmem_cache_destroy(blkdev->request_pool); + kfree(blkdev); + } else + spin_unlock_irqrestore(&blkdev->lock, flags); return 0; } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 21/49] Staging: hv: vmbus: Get rid of the timer based handling of channel events
Get rid of the timer based handling of channel events. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index aca9ac8..a4bee81 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -889,7 +889,6 @@ void vmbus_onchannel_event(struct vmbus_channel *channel) channel->onchannel_callback(channel->channel_callback_context); - mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100)); } /* -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 22/49] Staging: hv: vmbus: Get rid of the call to dump channel state in channel event handler
Get rid of the call to dump channel state in channel event handler. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index a4bee81..7854de2 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -885,7 +885,6 @@ EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); */ void vmbus_onchannel_event(struct vmbus_channel *channel) { - dump_vmbus_channel(channel); channel->onchannel_callback(channel->channel_callback_context); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 23/49] Staging: hv: vmbus: Directly invoke the channel callback
Now, directly invoke the channel callback. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 37bbf77..fc93bdf 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -262,7 +262,7 @@ static void process_chn_event(u32 relid) channel = relid2channel(relid); if (channel) { - vmbus_onchannel_event(channel); + channel->onchannel_callback(channel->channel_callback_context); } else { pr_err("channel not found for relid - %u\n", relid); } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 24/49] Staging: hv: vmbus: Get rid of the unused wrapper - vmbus_onchannel_event()
Now, get rid of the unused wrapper - vmbus_onchannel_event(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 10 ---------- drivers/staging/hv/hyperv.h | 1 - 2 files changed, 0 insertions(+), 11 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 7854de2..334885d 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -881,16 +881,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); /* - * vmbus_onchannel_event - Channel event callback - */ -void vmbus_onchannel_event(struct vmbus_channel *channel) -{ - - channel->onchannel_callback(channel->channel_callback_context); - -} - -/* * vmbus_ontimer - Timer event callback */ void vmbus_ontimer(unsigned long data) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 3310e9b..e881cfe 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -691,7 +691,6 @@ extern int vmbus_recvpacket_raw(struct vmbus_channel *channel, u32 *buffer_actual_len, u64 *requestid); -extern void vmbus_onchannel_event(struct vmbus_channel *channel); extern void vmbus_get_debug_info(struct vmbus_channel *channel, struct vmbus_channel_debug_info *debug); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 25/49] Staging: hv: vmbus: Get rid of unneeded calls to dump_vmbus_channel
Get rid of unneeded calls to dump_vmbus_channel and get rid of the unused static function that dumps the channel. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 334885d..b6f8674 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -39,7 +39,6 @@ static int create_gpadl_header( u32 size, /* page-size multiple */ struct vmbus_channel_msginfo **msginfo, u32 *messagecount); -static void dump_vmbus_channel(struct vmbus_channel *channel); static void vmbus_setevent(struct vmbus_channel *channel); /* @@ -618,7 +617,6 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer, u64 aligned_data = 0; int ret; - dump_vmbus_channel(channel); /* Setup the descriptor */ desc.type = type; /* VmbusPacketTypeDataInBand; */ @@ -665,7 +663,6 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, if (pagecount > MAX_PAGE_BUFFER_COUNT) return -EINVAL; - dump_vmbus_channel(channel); /* * Adjust the size down since vmbus_channel_packet_page_buffer is the @@ -725,7 +722,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel, u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->offset, multi_pagebuffer->len); - dump_vmbus_channel(channel); if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT)) return -EINVAL; @@ -891,12 +887,3 @@ void vmbus_ontimer(unsigned long data) channel->onchannel_callback(channel->channel_callback_context); } -/* - * dump_vmbus_channel- Dump vmbus channel info to the console - */ -static void dump_vmbus_channel(struct vmbus_channel *channel) -{ - DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid); - hv_dump_ring_info(&channel->outbound, "Outbound "); - hv_dump_ring_info(&channel->inbound, "Inbound "); -} -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 27/49] Staging: hv: vmbus: Fix the memory barrier in hv_ringbuffer_read()
Use the correct barrier interface. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/ring_buffer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index 3da3330..932af1a 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -513,7 +513,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer, /* Make sure all reads are done before we update the read index since */ /* the writer may start writing to the read area once the read index */ /*is updated */ - mb(); + smp_mb(); /* Update the read index */ hv_set_next_read_location(inring_info, next_read_location); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 28/49] Staging: hv: vmbus: Introduce read dependency in hv_get_ringbuffer_availbytes()
Introduce read dependency in hv_get_ringbuffer_availbytes(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/ring_buffer.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index 932af1a..8b62553 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -50,6 +50,8 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, { u32 read_loc, write_loc; + smp_read_barrier_depends(); + /* Capture the read/write indices before they changed */ read_loc = rbi->ring_buffer->read_index; write_loc = rbi->ring_buffer->write_index; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 29/49] Staging: hv: vmbus: Change the memory barrier in hv_ringbuffer_write()
Use the correct memory barrier interface in Change the memory barrier in hv_ringbuffer_write(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/ring_buffer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c index 8b62553..42f7672 100644 --- a/drivers/staging/hv/ring_buffer.c +++ b/drivers/staging/hv/ring_buffer.c @@ -413,7 +413,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, sizeof(u64)); /* Make sure we flush all writes before updating the writeIndex */ - mb(); + smp_wmb(); /* Now, update the write location */ hv_set_next_write_location(outring_info, next_write_location); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 30/49] Staging: hv: vmbus: Get rid of the unused function vmbus_ontimer()
Now, get rid of the unused function vmbus_ontimer(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 12 ------------ 1 files changed, 0 insertions(+), 12 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index b91b369..3e4422b 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -874,15 +874,3 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer, return 0; } EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw); - -/* - * vmbus_ontimer - Timer event callback - */ -void vmbus_ontimer(unsigned long data) -{ - struct vmbus_channel *channel = (struct vmbus_channel *)data; - - if (channel->onchannel_callback) - channel->onchannel_callback(channel->channel_callback_context); -} - -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 31/49] Staging: hv: vmbus: Get rid of some dated comments in channel.c
Get rid of some dated comments in channel.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 3e4422b..95b410f 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -633,7 +633,6 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer, ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3); - /* TODO: We should determine if this is optional */ if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound)) vmbus_setevent(channel); @@ -695,7 +694,6 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3); - /* TODO: We should determine if this is optional */ if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound)) vmbus_setevent(channel); @@ -758,7 +756,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel, ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3); - /* TODO: We should determine if this is optional */ if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound)) vmbus_setevent(channel); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 32/49] Staging: hv: vmbus: Correct some dated comments in channel.c
Correct some dated comments in channel.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 95b410f..043fe25 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -185,12 +185,12 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, openMsg = (struct vmbus_channel_open_channel *)openInfo->msg; openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL; - openMsg->openid = newchannel->offermsg.child_relid; /* FIXME */ + 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 >> PAGE_SHIFT; - openMsg->server_contextarea_gpadlhandle = 0; /* TODO */ + openMsg->server_contextarea_gpadlhandle = 0; if (userdatalen > MAX_USER_DEFINED_BYTES) { err = -EINVAL; @@ -364,11 +364,11 @@ static int create_gpadl_header(void *kbuffer, u32 size, (struct vmbus_channel_gpadl_body *)msgbody->msg; /* - * FIXME: * Gpadl is u32 and we are using a pointer which could * be 64-bit + * This is governed by the guest/host protocol and + * so the hypervisor gurantees that this is ok. */ - /* gpadl_body->Gpadl = kbuffer; */ for (i = 0; i < pfncurr; i++) gpadl_body->pfn[i] = pfn + pfnsum + i; @@ -462,7 +462,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, if (msgcount > 1) { list_for_each(curr, &msginfo->submsglist) { - /* FIXME: should this use list_entry() instead ? */ submsginfo = (struct vmbus_channel_msginfo *)curr; gpadl_body (struct vmbus_channel_gpadl_body *)submsginfo->msg; @@ -577,8 +576,6 @@ void vmbus_close(struct vmbus_channel *channel) vmbus_teardown_gpadl(channel, channel->ringbuffer_gpadlhandle); - /* TODO: Send a msg to release the childRelId */ - /* Cleanup the ring buffers for this channel */ hv_ringbuffer_cleanup(&channel->outbound); hv_ringbuffer_cleanup(&channel->inbound); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 33/49] Staging: hv: vmbus: Move the definition of struct vmbus_channel
In preparation for embedding the state needed to close the channel, move the definition of struct vmbus_channel. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/hyperv.h | 77 +++++++++++++++++++++---------------------- 1 files changed, 38 insertions(+), 39 deletions(-) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 73c251e..93bbeab 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -523,45 +523,6 @@ enum vmbus_channel_state { CHANNEL_OPEN_STATE, }; -struct vmbus_channel { - struct list_head listentry; - - struct hv_device *device_obj; - - struct work_struct work; - - enum vmbus_channel_state state; - /* - * For util channels, stash the - * the service index for easy access. - */ - s8 util_index; - - struct vmbus_channel_offer_channel offermsg; - /* - * These are based on the OfferMsg.MonitorId. - * Save it here for easy access. - */ - u8 monitor_grp; - u8 monitor_bit; - - u32 ringbuffer_gpadlhandle; - - /* Allocated memory for ring buffer */ - void *ringbuffer_pages; - u32 ringbuffer_pagecount; - struct hv_ring_buffer_info outbound; /* send to parent */ - struct hv_ring_buffer_info inbound; /* receive from parent */ - spinlock_t inbound_lock; - struct workqueue_struct *controlwq; - - /* Channel callback are invoked in this workqueue context */ - /* HANDLE dataWorkQueue; */ - - void (*onchannel_callback)(void *context); - void *channel_callback_context; -}; - struct vmbus_channel_debug_info { u32 relid; enum vmbus_channel_state state; @@ -608,6 +569,44 @@ struct vmbus_channel_msginfo { unsigned char msg[0]; }; +struct vmbus_channel { + struct list_head listentry; + + struct hv_device *device_obj; + + struct work_struct work; + + enum vmbus_channel_state state; + /* + * For util channels, stash the + * the service index for easy access. + */ + s8 util_index; + + struct vmbus_channel_offer_channel offermsg; + /* + * These are based on the OfferMsg.MonitorId. + * Save it here for easy access. + */ + u8 monitor_grp; + u8 monitor_bit; + + u32 ringbuffer_gpadlhandle; + + /* Allocated memory for ring buffer */ + void *ringbuffer_pages; + u32 ringbuffer_pagecount; + struct hv_ring_buffer_info outbound; /* send to parent */ + struct hv_ring_buffer_info inbound; /* receive from parent */ + spinlock_t inbound_lock; + struct workqueue_struct *controlwq; + + /* Channel callback are invoked in this workqueue context */ + /* HANDLE dataWorkQueue; */ + + void (*onchannel_callback)(void *context); + void *channel_callback_context; +}; void free_channel(struct vmbus_channel *channel); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:49 UTC
[PATCH 34/49] Staging: hv: vmbus: Embed the state needed to close the channel
Now, embed the state needed to close the channel - so we would not have to allocate memory in the channel close path. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/hyperv.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h index 93bbeab..1747a24 100644 --- a/drivers/staging/hv/hyperv.h +++ b/drivers/staging/hv/hyperv.h @@ -569,6 +569,11 @@ struct vmbus_channel_msginfo { unsigned char msg[0]; }; +struct vmbus_close_msg { + struct vmbus_channel_msginfo info; + struct vmbus_channel_close_channel msg; +}; + struct vmbus_channel { struct list_head listentry; @@ -601,6 +606,8 @@ struct vmbus_channel { spinlock_t inbound_lock; struct workqueue_struct *controlwq; + struct vmbus_close_msg close_msg; + /* Channel callback are invoked in this workqueue context */ /* HANDLE dataWorkQueue; */ -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 36/49] Staging: hv: vmbus: Get rid of a dated comment in vmbus_drv.c
Get rid of a dated comment in vmbus_drv.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at 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 1a26252..bc74030 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -486,7 +486,6 @@ static int vmbus_on_isr(void) if (msg->header.message_type != HVMSG_NONE) ret |= 0x1; - /* TODO: Check if there are events to be process */ page_addr = hv_context.synic_event_page[cpu]; event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 37/49] Staging: hv: vmbus: Get rid of an unused function in connection.c
Get rid of an unused function in connection.c Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/connection.c | 38 ------------------------------------- drivers/staging/hv/hyperv_vmbus.h | 2 - 2 files changed, 0 insertions(+), 40 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index fc93bdf..7d7f1d5 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -185,44 +185,6 @@ cleanup: return ret; } -/* - * vmbus_disconnect - - * Sends a disconnect request on the partition service connection - */ -int vmbus_disconnect(void) -{ - int ret = 0; - struct vmbus_channel_message_header *msg; - - /* Make sure we are connected */ - if (vmbus_connection.conn_state != CONNECTED) - return -1; - - msg = kzalloc(sizeof(struct vmbus_channel_message_header), GFP_KERNEL); - if (!msg) - return -ENOMEM; - - msg->msgtype = CHANNELMSG_UNLOAD; - - ret = vmbus_post_msg(msg, - sizeof(struct vmbus_channel_message_header)); - if (ret != 0) - goto cleanup; - - free_pages((unsigned long)vmbus_connection.int_page, 0); - free_pages((unsigned long)vmbus_connection.monitor_pages, 1); - - /* TODO: iterate thru the msg list and free up */ - destroy_workqueue(vmbus_connection.work_queue); - - vmbus_connection.conn_state = DISCONNECTED; - - pr_info("hv_vmbus disconnected\n"); - -cleanup: - kfree(msg); - return ret; -} /* * relid2channel - Get the channel object given its diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h index bf30a42..349ad80 100644 --- a/drivers/staging/hv/hyperv_vmbus.h +++ b/drivers/staging/hv/hyperv_vmbus.h @@ -619,8 +619,6 @@ struct vmbus_channel *relid2channel(u32 relid); int vmbus_connect(void); -int vmbus_disconnect(void); - int vmbus_post_msg(void *buffer, size_t buflen); int vmbus_set_event(u32 child_relid); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 38/49] Staging: hv: vmbus: Get rid of a dated comment in channel_mgmt.c
Staging: hv: vmbus: Get rid of a dated comment in channel_mgmt.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel_mgmt.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 178e1c4..2d270ce 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -477,7 +477,6 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) newchannel->monitor_grp = (u8)offer->monitorid / 32; newchannel->monitor_bit = (u8)offer->monitorid % 32; - /* TODO: Make sure the offer comes from our parent partition */ INIT_WORK(&newchannel->work, vmbus_process_offer); queue_work(newchannel->controlwq, &newchannel->work); } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 39/49] Staging: hv: vmbus: Fix a memory barrier call in vmbus_drv.c
Use the correct memory barrier call in vmbus_drv.c Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at 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 bc74030..921ca9a 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -455,7 +455,7 @@ static void vmbus_on_msg_dpc(unsigned long data) * will not deliver any more messages since there is * no empty slot */ - mb(); + smp_mb(); if (msg->header.message_flags.msg_pending) { /* -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 40/49] Staging: hv: vmbus: Rename local variables in vmbus_drv.c
Rename local variables in vmbus_drv.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 921ca9a..17692ce 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -107,12 +107,12 @@ static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf) { - struct hv_device *device_ctx = device_to_hv_device(dev); + struct hv_device *hv_dev = device_to_hv_device(dev); struct hv_device_info device_info; memset(&device_info, 0, sizeof(struct hv_device_info)); - get_channel_info(device_ctx, &device_info); + get_channel_info(hv_dev, &device_info); if (!strcmp(dev_attr->attr.name, "class_id")) { return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" @@ -300,10 +300,10 @@ 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 *device_ctx = device_to_hv_device(device); + struct hv_device *hv_dev = device_to_hv_device(device); /* We found our driver ? */ - if (memcmp(&device_ctx->dev_type, &drv->dev_type, + if (memcmp(&hv_dev->dev_type, &drv->dev_type, sizeof(struct hv_guid)) == 0) match = 1; @@ -387,9 +387,9 @@ static void vmbus_shutdown(struct device *child_device) */ static void vmbus_device_release(struct device *device) { - struct hv_device *device_ctx = device_to_hv_device(device); + struct hv_device *hv_dev = device_to_hv_device(device); - kfree(device_ctx); + kfree(hv_dev); } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 41/49] Staging: hv: vmbus: Increase the timeout for some critical calls
Increase the timeout for some critical calls. In testing we discovered that the current timeout of 1 second was insufficient under some conditions. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 5a2a947..69b5641 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -480,7 +480,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, } } - t = wait_for_completion_timeout(&msginfo->waitevent, HZ); + t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ); BUG_ON(t == 0); @@ -530,7 +530,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) sizeof(struct vmbus_channel_gpadl_teardown)); BUG_ON(ret != 0); - t = wait_for_completion_timeout(&info->waitevent, HZ); + t = wait_for_completion_timeout(&info->waitevent, 5*HZ); BUG_ON(t == 0); /* Received a torndown response */ -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 42/49] Staging: hv: vmbus: Properly handle memory allocation failure in channel.c
Properly handle memory allocation failure in channel.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 69b5641..1833f27 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -355,9 +355,24 @@ static int create_gpadl_header(void *kbuffer, u32 size, sizeof(struct vmbus_channel_gpadl_body) + pfncurr * sizeof(u64); msgbody = kzalloc(msgsize, GFP_KERNEL); - /* FIXME: we probably need to more if this fails */ - if (!msgbody) + + if (!msgbody) { + struct vmbus_channel_msginfo *pos = NULL; + struct vmbus_channel_msginfo *tmp = NULL; + /* + * Free up all the allocated messages. + */ + list_for_each_entry_safe(pos, tmp, + &msgheader->submsglist, + msglistentry) { + + list_del(&pos->msglistentry); + kfree(pos); + } + goto nomem; + } + msgbody->msgsize = msgsize; (*messagecount)++; gpadl_body -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 43/49] Staging: hv: vmbus: Cleanup some error codes in vmbus_drv.c
Cleanup some error codes in vmbus_drv.c Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 17692ce..a3c99f1 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -329,7 +329,7 @@ static int vmbus_probe(struct device *child_device) } else { pr_err("probe not set for driver %s\n", dev_name(child_device)); - ret = -1; + ret = -ENODEV; } return ret; } @@ -352,7 +352,7 @@ static int vmbus_remove(struct device *child_device) } else { pr_err("remove not set for driver %s\n", dev_name(child_device)); - ret = -1; + ret = -ENODEV; } } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 44/49] Staging: hv: vmbus: Cleanup error handling in vmbus_bus_init()
Cleanup error handling in vmbus_bus_init(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index a3c99f1..be158be 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -535,7 +535,7 @@ static int vmbus_bus_init(int irq) ret = hv_init(); if (ret != 0) { pr_err("Unable to initialize the hypervisor - 0x%x\n", ret); - goto cleanup; + return ret; } /* Initialize the bus context */ @@ -544,10 +544,8 @@ static int vmbus_bus_init(int irq) /* Now, register the bus with LDM */ ret = bus_register(&hv_bus); - if (ret) { - ret = -1; - goto cleanup; - } + if (ret) + return ret; /* Get the interrupt resource */ ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM, @@ -559,8 +557,7 @@ static int vmbus_bus_init(int irq) bus_unregister(&hv_bus); - ret = -1; - goto cleanup; + return ret; } vector = IRQ0_VECTOR + irq; @@ -574,14 +571,13 @@ static int vmbus_bus_init(int irq) if (ret) { free_irq(irq, hv_acpi_dev); bus_unregister(&hv_bus); - goto cleanup; + return ret; } vmbus_request_offers(); -cleanup: - return ret; + return 0; } /** -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 45/49] Staging: hv: vmbus: Cleanup error codes in hv.c
Cleanup error codes in hv.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/hv.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c index a2cc091..824f816 100644 --- a/drivers/staging/hv/hv.c +++ b/drivers/staging/hv/hv.c @@ -277,11 +277,11 @@ u16 hv_post_message(union hv_connection_id connection_id, unsigned long addr; if (payload_size > HV_MESSAGE_PAYLOAD_BYTE_COUNT) - return -1; + return -EMSGSIZE; addr = (unsigned long)kmalloc(sizeof(struct aligned_input), GFP_ATOMIC); if (!addr) - return -1; + return -ENOMEM; aligned_msg = (struct hv_input_post_message *) (ALIGN(addr, HV_HYPERCALL_PARAM_ALIGN)); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 46/49] Staging: hv: vmbus: Cleanup error codes in connection.c
Cleanup error codes in connection.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/connection.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c index 7d7f1d5..7e15392 100644 --- a/drivers/staging/hv/connection.c +++ b/drivers/staging/hv/connection.c @@ -51,13 +51,13 @@ int vmbus_connect(void) /* Make sure we are not connecting or connected */ if (vmbus_connection.conn_state != DISCONNECTED) - return -1; + return -EISCONN; /* Initialize the vmbus connection */ vmbus_connection.conn_state = CONNECTING; vmbus_connection.work_queue = create_workqueue("hv_vmbus_con"); if (!vmbus_connection.work_queue) { - ret = -1; + ret = -ENOMEM; goto cleanup; } @@ -74,7 +74,7 @@ int vmbus_connect(void) vmbus_connection.int_page (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0); if (vmbus_connection.int_page == NULL) { - ret = -1; + ret = -ENOMEM; goto cleanup; } @@ -90,7 +90,7 @@ int vmbus_connect(void) vmbus_connection.monitor_pages (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1); if (vmbus_connection.monitor_pages == NULL) { - ret = -1; + ret = -ENOMEM; goto cleanup; } @@ -157,7 +157,7 @@ int vmbus_connect(void) pr_err("Unable to connect, " "Version %d not supported by Hyper-V\n", VMBUS_REVISION_NUMBER); - ret = -1; + ret = -ECONNREFUSED; goto cleanup; } -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 47/49] Staging: hv: vmbus: Cleanup some error values in channel.c
Cleanup some error values in channel.c. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 1833f27..21f1efc 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -811,7 +811,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer, pr_err("Buffer too small - got %d needs %d\n", bufferlen, userlen); - return -1; + return -ETOOSMALL; } *requestid = desc.trans_id; -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 48/49] Staging: hv: vmbus: Change Cleanup to cleanup in channel.c
Change the jump label Cleanup to cleanup. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c index 21f1efc..cffca7c 100644 --- a/drivers/staging/hv/channel.c +++ b/drivers/staging/hv/channel.c @@ -209,7 +209,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, sizeof(struct vmbus_channel_open_channel)); if (ret != 0) - goto Cleanup; + goto cleanup; t = wait_for_completion_timeout(&openInfo->waitevent, HZ); if (t == 0) { @@ -221,7 +221,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, if (openInfo->response.open_result.status) err = openInfo->response.open_result.status; -Cleanup: +cleanup: spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_del(&openInfo->msglistentry); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); @@ -472,7 +472,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize - sizeof(*msginfo)); if (ret != 0) - goto Cleanup; + goto cleanup; if (msgcount > 1) { list_for_each(curr, &msginfo->submsglist) { @@ -491,7 +491,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, submsginfo->msgsize - sizeof(*submsginfo)); if (ret != 0) - goto Cleanup; + goto cleanup; } } @@ -502,7 +502,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, /* At this point, we received the gpadl created msg */ *gpadl_handle = gpadlmsg->gpadl; -Cleanup: +cleanup: spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_del(&msginfo->msglistentry); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); -- 1.7.4.1
K. Y. Srinivasan
2011-Jun-06 22:50 UTC
[PATCH 49/49] Staging: hv: vmbus: Increase the timeout value in vmbus_request_offers()
Increase the timeout value in vmbus_request_offers(). Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> --- drivers/staging/hv/channel_mgmt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 2d270ce..bf011f3 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c @@ -767,7 +767,7 @@ int vmbus_request_offers(void) goto cleanup; } - t = wait_for_completion_timeout(&msginfo->waitevent, HZ); + t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ); if (t == 0) { ret = -ETIMEDOUT; goto cleanup; -- 1.7.4.1
KY Srinivasan
2011-Jun-07 14:54 UTC
[PATCH 12/49] Staging: hv: storvsc: Add a DMI signature to support auto-loading
> -----Original Message----- > From: Christoph Hellwig [mailto:hch at infradead.org] > Sent: Monday, June 06, 2011 7:13 PM > To: KY Srinivasan > Cc: gregkh at suse.de; linux-kernel at vger.kernel.org; > devel at linuxdriverproject.org; virtualization at lists.osdl.org; Haiyang Zhang; > Abhishek Kane (Mindtree Consulting PVT LTD) > Subject: Re: [PATCH 12/49] Staging: hv: storvsc: Add a DMI signature to support > auto-loading > > On Mon, Jun 06, 2011 at 03:49:36PM -0700, K. Y. Srinivasan wrote: > > To support auto-loading the storvsc driver, add a DMI signature. > > The storvsc driver is not a DMI driver, but a vmbus driver. As such it > should have a vmbus table that is used for autoloading, not a dmi one. >A while ago, Greg introduced DMI signatures to these drivers to support auto-loading. This signature is not used for anything else. For some reason, this storvsc driver was missing this signature. I added it again to only support auto-loading. Regards, K. Y
Greg KH
2011-Jun-07 20:44 UTC
[PATCH 15/49] Staging: hv: vmbus: Make vmbus an acpi bus driver
On Mon, Jun 06, 2011 at 03:49:39PM -0700, K. Y. Srinivasan wrote:> Now, make the vmbus driver an ACPI bus driver.Why an ACPI bus driver and not a PCI one? Is that what this really is? For some reason, I thought it was a PCI device that we hooked our bus off of, is that not true? greg k-h
Greg KH
2011-Jun-07 20:45 UTC
[PATCH 49/49] Staging: hv: vmbus: Increase the timeout value in vmbus_request_offers()
On Mon, Jun 06, 2011 at 03:50:13PM -0700, K. Y. Srinivasan wrote:> Increase the timeout value in vmbus_request_offers().Why? What does this solve/fix/prevent? thanks, greg k-h
On Mon, Jun 06, 2011 at 03:49:00PM -0700, K. Y. Srinivasan wrote:> Further cleanup of the hv drivers: > > 1) Continue to cleanup our drivers to conform to the Linux Driver > Model. > > 2) Fix some long standing bugs with regards to unloading and > reloading the drivers - block, net and stor. > > 3) VMBUS is an ACPI enumerated device; make VMBUS an ACPI bus driver.Ok, if that's the way the bus really is, it's good to get rid of the pci code.> 4) Get rid of channel polling code; instead the channel receive paths > will be purely interrupt drive. > > 5) Cleanup error return values in the vmbus driver and general cleanup. > > 6) Fix memory barrier calls in the ring buffer code. > > 7) Increase the timeout values for some critical guest to host calls.I applied all of these but the last one. For the last patch, please provide more information about it. Should it also go to older kernel releases to resolve issues found there? thanks, greg k-h
KY Srinivasan
2011-Jun-07 21:20 UTC
[PATCH 49/49] Staging: hv: vmbus: Increase the timeout value in vmbus_request_offers()
> -----Original Message----- > From: Greg KH [mailto:greg at kroah.com] > Sent: Tuesday, June 07, 2011 4:45 PM > To: KY Srinivasan > Cc: gregkh at suse.de; linux-kernel at vger.kernel.org; > devel at linuxdriverproject.org; virtualization at lists.osdl.org; Haiyang Zhang; > Abhishek Kane (Mindtree Consulting PVT LTD) > Subject: Re: [PATCH 49/49] Staging: hv: vmbus: Increase the timeout value in > vmbus_request_offers() > > On Mon, Jun 06, 2011 at 03:50:13PM -0700, K. Y. Srinivasan wrote: > > Increase the timeout value in vmbus_request_offers(). > > Why? What does this solve/fix/prevent?On some very loaded systems, when we tested the 1 second timeout that we had prior to this patch was insufficient. So I bumped it to 5 seconds. Regards, K. Y
KY Srinivasan
2011-Jun-08 02:44 UTC
[PATCH 12/49] Staging: hv: storvsc: Add a DMI signature to support auto-loading
> -----Original Message----- > From: Greg KH [mailto:greg at kroah.com] > Sent: Tuesday, June 07, 2011 6:25 PM > To: KY Srinivasan > Cc: Christoph Hellwig; gregkh at suse.de; linux-kernel at vger.kernel.org; > devel at linuxdriverproject.org; virtualization at lists.osdl.org; Haiyang Zhang; > Abhishek Kane (Mindtree Consulting PVT LTD) > Subject: Re: [PATCH 12/49] Staging: hv: storvsc: Add a DMI signature to support > auto-loading > > On Tue, Jun 07, 2011 at 10:19:06PM +0000, KY Srinivasan wrote: > > Thanks Greg. Can you give me some pointers here as to what needs to be > > done here. Looking at the code for virtio, it looks like I would need to add stuff > > to scripts/mod/file2alias.c as well as to include/linux/mod_devicetable.h. Will > you > > accept patches for these files to support an ID space for Hyper-V vmbus drivers. > > Yes, I will take patches for those files to implement this. > > Along with those files, you also need a way to tell userspace that new > UIDS are found before the individual drivers are loaded. Hopefully you > can do that now, but if not, it will need to be implemented.Could you elaborate on what user level changes I will have to do. Thanks, K. Y
Maybe Matching Threads
- [PATCH 00/49] Staging: hv: Driver cleanup
- [RESEND] [PATCH 00/18] Staging: hv: Cleanup vmbus driver code
- [RESEND] [PATCH 00/18] Staging: hv: Cleanup vmbus driver code
- [PATCH 00/25] Staging: hv: Cleanup vmbus driver code
- [PATCH 00/25] Staging: hv: Cleanup vmbus driver code