K. Y. Srinivasan
2011-Mar-15 22:02 UTC
[PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II
This patch-set fixes the following issues in the vmbus driver (vmbus_drv.c): Make vmbus driver a platform pci device and cleanup root device management and irq allocation (patches 1/12 through 3/12): 1) Make vmbus driver a platform pci driver. 2) Cleanup root device management. 3) Leverage the pci model for allocating irq. General cleanup of vmbus driver (patches 4/12 though 12/12): 1) Rename vmbus_driver_context structure and do related cleanup. 2) Get rid of forward declarations by moving code. Regards, K. Y
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 01/12] Staging: hv: Make vmbus driver a pci driver
Make vmbus driver a pci driver. This is in preparation to cleaning up the root device management as well as the irq allocation for this driver. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 63 +++++++++++++++++++++++----------------- 1 files changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index b473f46..1ef2f0f 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -40,6 +40,8 @@ #define VMBUS_IRQ 0x5 #define VMBUS_IRQ_VECTOR IRQ5_VECTOR +struct pci_dev *hv_pci_dev; + /* Main vmbus driver data structure */ struct vmbus_driver_context { @@ -977,36 +979,24 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) } } -static struct dmi_system_id __initdata microsoft_hv_dmi_table[] = { - { - .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, microsoft_hv_dmi_table); -static int __init vmbus_init(void) + +static int __devinit hv_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) { - DPRINT_INFO(VMBUS_DRV, - "Vmbus initializing.... current log level 0x%x (%x,%x)", - vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel)); - /* Todo: it is used for loglevel, to be ported to new kernel. */ + int err; - if (!dmi_check_system(microsoft_hv_dmi_table)) - return -ENODEV; + hv_pci_dev = pdev; - return vmbus_bus_init(); -} + err = pci_enable_device(pdev); + if (err) + return err; -static void __exit vmbus_exit(void) -{ - vmbus_bus_exit(); - /* Todo: it is used for loglevel, to be ported to new kernel. */ + err = vmbus_bus_init(); + if (err) + pci_disable_device(pdev); + + return err; } /* @@ -1021,10 +1011,29 @@ 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) +{ + return pci_register_driver(&hv_bus_driver); +} + +static void __exit hv_pci_exit(void) +{ + vmbus_bus_exit(); + pci_unregister_driver(&hv_bus_driver); +} + + + MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); module_param(vmbus_irq, int, S_IRUGO); module_param(vmbus_loglevel, int, S_IRUGO); -module_init(vmbus_init); -module_exit(vmbus_exit); +module_init(hv_pci_init); +module_exit(hv_pci_exit); -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 02/12] Staging: hv: Cleanup root device handling
Now we can complete the cleanup of the root device management - use the pci device as the root device for all Hyper-V devices. As part of this cleanup get rid of the root device object from vmbus_driver_context. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 130 +++------------------------------------- 1 files changed, 8 insertions(+), 122 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 1ef2f0f..3d2789b 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -44,13 +44,9 @@ struct pci_dev *hv_pci_dev; /* Main vmbus driver data structure */ struct vmbus_driver_context { - struct bus_type bus; struct tasklet_struct msg_dpc; struct tasklet_struct event_dpc; - - /* The bus root device */ - struct hv_device device_ctx; }; static int vmbus_match(struct device *device, struct device_driver *driver); @@ -62,7 +58,6 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env); static irqreturn_t vmbus_isr(int irq, void *dev_id); static void vmbus_device_release(struct device *device); -static void vmbus_bus_release(struct device *device); static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, @@ -119,54 +114,6 @@ static struct vmbus_driver_context vmbus_drv = { static const char *driver_name = "hyperv"; -/* - * Windows vmbus does not defined this. - * We defined this to be consistent with other devices - */ -/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */ -static const struct hv_guid device_type = { - .data = { - 0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d, - 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85 - } -}; - -/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */ -static const struct hv_guid device_id = { - .data = { - 0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40, - 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5 - } -}; - -static struct hv_device *vmbus_device; /* vmbus root device */ - - -/* - * vmbus_dev_add - Callback when the root bus device is added - */ -static int vmbus_dev_add(struct hv_device *dev, void *info) -{ - u32 *irqvector = info; - int ret; - - vmbus_device = dev; - - memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid)); - memcpy(&vmbus_device->dev_instance, &device_id, - sizeof(struct hv_guid)); - - /* strcpy(dev->name, "vmbus"); */ - /* SynIC setup... */ - on_each_cpu(hv_synic_init, (void *)irqvector, 1); - - /* Connect to VMBus in the root partition */ - ret = vmbus_connect(); - - /* VmbusSendEvent(device->localPortId+1); */ - return ret; -} - struct onmessage_work_context { struct work_struct work; @@ -418,17 +365,13 @@ static ssize_t vmbus_show_device_attr(struct device *dev, * * Here, we * - initialize the vmbus driver context - * - setup various driver entry points * - invoke the vmbus hv main init routine * - get the irq resource - * - invoke the vmbus to add the vmbus root device - * - setup the vmbus root device * - retrieve the channel offers */ static int vmbus_bus_init(void) { struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; - struct hv_device *dev_ctx = &vmbus_drv.device_ctx; int ret; unsigned int vector; @@ -485,45 +428,19 @@ static int vmbus_bus_init(void) DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector); - /* Add the root device */ - memset(dev_ctx, 0, sizeof(struct hv_device)); - - ret = vmbus_dev_add(dev_ctx, &vector); - if (ret != 0) { - DPRINT_ERR(VMBUS_DRV, - "ERROR - Unable to add vmbus root device"); - - free_irq(vmbus_irq, NULL); - - bus_unregister(&vmbus_drv_ctx->bus); - - ret = -1; - goto cleanup; - } - /* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */ - dev_set_name(&dev_ctx->device, "vmbus_0_0"); - - /* No need to bind a driver to the root device. */ - dev_ctx->device.parent = NULL; - /* NULL; vmbus_remove() does not get invoked */ - dev_ctx->device.bus = &vmbus_drv_ctx->bus; - - /* Setup the device dispatch table */ - dev_ctx->device.release = vmbus_bus_release; - - /* register the root device */ - ret = device_register(&dev_ctx->device); + /* + * Notify the hypervisor of our irq and + * connect to the host. + */ + on_each_cpu(hv_synic_init, (void *)&vector, 1); + ret = vmbus_connect(); if (ret) { - DPRINT_ERR(VMBUS_DRV, - "ERROR - Unable to register vmbus root device"); - free_irq(vmbus_irq, NULL); bus_unregister(&vmbus_drv_ctx->bus); - - ret = -1; goto cleanup; } + vmbus_request_offers(); wait_for_completion(&hv_channel_ready); @@ -540,7 +457,6 @@ static void vmbus_bus_exit(void) { struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; - struct hv_device *dev_ctx = &vmbus_drv.device_ctx; vmbus_release_unattached_channels(); vmbus_disconnect(); @@ -548,9 +464,6 @@ static void vmbus_bus_exit(void) hv_cleanup(); - /* Unregister the root bus device */ - device_unregister(&dev_ctx->device); - bus_unregister(&vmbus_drv_ctx->bus); free_irq(vmbus_irq, NULL); @@ -674,7 +587,7 @@ int vmbus_child_device_register(struct hv_device *child_device_obj) /* The new device belongs to this bus */ child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */ - child_device_obj->device.parent = &vmbus_device->device; + child_device_obj->device.parent = &hv_pci_dev->dev; child_device_obj->device.release = vmbus_device_release; /* @@ -875,14 +788,6 @@ static int vmbus_remove(struct device *child_device) int ret; struct hv_driver *drv; - /* Special case root bus device */ - if (child_device->parent == NULL) { - /* - * No-op since it is statically defined and handle in - * vmbus_bus_exit() - */ - return 0; - } if (child_device->driver) { drv = drv_to_hv_drv(child_device->driver); @@ -911,14 +816,6 @@ static void vmbus_shutdown(struct device *child_device) { struct hv_driver *drv; - /* Special case root bus device */ - if (child_device->parent == NULL) { - /* - * No-op since it is statically defined and handle in - * vmbus_bus_exit() - */ - return; - } /* The device may not be attached yet */ if (!child_device->driver) @@ -933,17 +830,6 @@ static void vmbus_shutdown(struct device *child_device) return; } -/* - * vmbus_bus_release - Final callback release of the vmbus root device - */ -static void vmbus_bus_release(struct device *device) -{ - /* FIXME */ - /* Empty release functions are a bug, or a major sign - * of a problem design, this MUST BE FIXED! */ - dev_err(device, "%s needs to be fixed!\n", __func__); - WARN_ON(1); -} /* * vmbus_device_release - Final callback release of the vmbus child device -- 1.5.5.6
Now that vmbus_driver is a pci driver, cleanup the irq allocation mess by using the standard irq allocation mechanisms. Note that this patch generates an error when the checkpatch script is run because of the IRQF_SAMPLE_RANDOM flag used in request_irq() function. This interrupt may be the only external event this VM will get and consequently if this flag (IRQF_SAMPLE_RANDOM) is not specified, experimentally we have shown that the entropy in the VM will very very low. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 3d2789b..239b91c 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -17,6 +17,8 @@ * Authors: * Haiyang Zhang <haiyangz at microsoft.com> * Hank Janssen <hjanssen at microsoft.com> + * + * 3/9/2011: K. Y. Srinivasan - Significant restructuring and cleanup */ #include <linux/init.h> #include <linux/module.h> @@ -36,10 +38,6 @@ #include "vmbus_private.h" -/* FIXME! We need to do this dynamically for PIC and APIC system */ -#define VMBUS_IRQ 0x5 -#define VMBUS_IRQ_VECTOR IRQ5_VECTOR - struct pci_dev *hv_pci_dev; /* Main vmbus driver data structure */ @@ -69,7 +67,6 @@ EXPORT_SYMBOL(vmbus_loglevel); /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */ /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */ -static int vmbus_irq = VMBUS_IRQ; /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { @@ -369,7 +366,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev, * - get the irq resource * - retrieve the channel offers */ -static int vmbus_bus_init(void) +static int vmbus_bus_init(struct pci_dev *pdev) { struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; int ret; @@ -412,21 +409,23 @@ static int vmbus_bus_init(void) } /* Get the interrupt resource */ - ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM, - driver_name, NULL); + ret = request_irq(pdev->irq, vmbus_isr, + IRQF_SHARED | IRQF_SAMPLE_RANDOM, + driver_name, pdev); if (ret != 0) { DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d", - vmbus_irq); + pdev->irq); bus_unregister(&vmbus_drv_ctx->bus); ret = -1; goto cleanup; } - vector = VMBUS_IRQ_VECTOR; - DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector); + vector = IRQ0_VECTOR + pdev->irq; + DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", pdev->irq, + vector); /* * Notify the hypervisor of our irq and @@ -435,7 +434,7 @@ static int vmbus_bus_init(void) on_each_cpu(hv_synic_init, (void *)&vector, 1); ret = vmbus_connect(); if (ret) { - free_irq(vmbus_irq, NULL); + free_irq(pdev->irq, pdev); bus_unregister(&vmbus_drv_ctx->bus); goto cleanup; } @@ -466,7 +465,7 @@ static void vmbus_bus_exit(void) bus_unregister(&vmbus_drv_ctx->bus); - free_irq(vmbus_irq, NULL); + free_irq(hv_pci_dev->irq, hv_pci_dev); tasklet_kill(&vmbus_drv_ctx->msg_dpc); tasklet_kill(&vmbus_drv_ctx->event_dpc); @@ -878,7 +877,7 @@ static int __devinit hv_pci_probe(struct pci_dev *pdev, if (err) return err; - err = vmbus_bus_init(); + err = vmbus_bus_init(pdev); if (err) pci_disable_device(pdev); @@ -918,7 +917,6 @@ static void __exit hv_pci_exit(void) MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); -module_param(vmbus_irq, int, S_IRUGO); module_param(vmbus_loglevel, int, S_IRUGO); module_init(hv_pci_init); -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 04/12] Staging: hv: Rename vmbus_driver_context structure
Now that struct vmbus_driver_context is properly cleaned up, rename this structure appropriately and cleanup the code. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 32 +++++++++++++++----------------- 1 files changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 239b91c..f292b03 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -41,7 +41,7 @@ struct pci_dev *hv_pci_dev; /* Main vmbus driver data structure */ -struct vmbus_driver_context { +struct hv_bus { struct bus_type bus; struct tasklet_struct msg_dpc; struct tasklet_struct event_dpc; @@ -99,7 +99,7 @@ static struct device_attribute vmbus_device_attrs[] = { }; /* The one and only one */ -static struct vmbus_driver_context vmbus_drv = { +static struct hv_bus hv_bus = { .bus.name = "vmbus", .bus.match = vmbus_match, .bus.shutdown = vmbus_shutdown, @@ -368,7 +368,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, */ static int vmbus_bus_init(struct pci_dev *pdev) { - struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; int ret; unsigned int vector; @@ -393,16 +392,16 @@ static int vmbus_bus_init(struct pci_dev *pdev) } - vmbus_drv_ctx->bus.name = driver_name; + hv_bus.bus.name = driver_name; /* Initialize the bus context */ - tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_on_msg_dpc, + tasklet_init(&hv_bus.msg_dpc, vmbus_on_msg_dpc, (unsigned long)NULL); - tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_on_event, + tasklet_init(&hv_bus.event_dpc, vmbus_on_event, (unsigned long)NULL); /* Now, register the bus with LDM */ - ret = bus_register(&vmbus_drv_ctx->bus); + ret = bus_register(&hv_bus.bus); if (ret) { ret = -1; goto cleanup; @@ -417,7 +416,7 @@ static int vmbus_bus_init(struct pci_dev *pdev) DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d", pdev->irq); - bus_unregister(&vmbus_drv_ctx->bus); + bus_unregister(&hv_bus.bus); ret = -1; goto cleanup; @@ -435,7 +434,7 @@ static int vmbus_bus_init(struct pci_dev *pdev) ret = vmbus_connect(); if (ret) { free_irq(pdev->irq, pdev); - bus_unregister(&vmbus_drv_ctx->bus); + bus_unregister(&hv_bus.bus); goto cleanup; } @@ -454,7 +453,6 @@ cleanup: */ static void vmbus_bus_exit(void) { - struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; vmbus_release_unattached_channels(); @@ -463,12 +461,12 @@ static void vmbus_bus_exit(void) hv_cleanup(); - bus_unregister(&vmbus_drv_ctx->bus); + bus_unregister(&hv_bus.bus); free_irq(hv_pci_dev->irq, hv_pci_dev); - tasklet_kill(&vmbus_drv_ctx->msg_dpc); - tasklet_kill(&vmbus_drv_ctx->event_dpc); + tasklet_kill(&hv_bus.msg_dpc); + tasklet_kill(&hv_bus.event_dpc); } @@ -491,7 +489,7 @@ int vmbus_child_driver_register(struct device_driver *drv) drv, drv->name); /* The child driver on this vmbus */ - drv->bus = &vmbus_drv.bus; + drv->bus = &hv_bus.bus; ret = driver_register(drv); @@ -585,7 +583,7 @@ int vmbus_child_device_register(struct hv_device *child_device_obj) atomic_inc_return(&device_num)); /* The new device belongs to this bus */ - child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */ + child_device_obj->device.bus = &hv_bus.bus; /* device->dev.bus; */ child_device_obj->device.parent = &hv_pci_dev->dev; child_device_obj->device.release = vmbus_device_release; @@ -853,10 +851,10 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) /* Schedules a dpc if necessary */ if (ret > 0) { if (test_bit(0, (unsigned long *)&ret)) - tasklet_schedule(&vmbus_drv.msg_dpc); + tasklet_schedule(&hv_bus.msg_dpc); if (test_bit(1, (unsigned long *)&ret)) - tasklet_schedule(&vmbus_drv.event_dpc); + tasklet_schedule(&hv_bus.event_dpc); return IRQ_HANDLED; } else { -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 05/12] Get rid of the forward declaration for vmbus_uevent
Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 151 ++++++++++++++++++++-------------------- 1 files changed, 75 insertions(+), 76 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 1331a6f..42066e9 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -51,7 +51,6 @@ static int vmbus_match(struct device *device, struct device_driver *driver); static int vmbus_probe(struct device *device); static int vmbus_remove(struct device *device); static void vmbus_shutdown(struct device *device); -static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env); static irqreturn_t vmbus_isr(int irq, void *dev_id); @@ -98,6 +97,81 @@ static struct device_attribute vmbus_device_attrs[] = { __ATTR_NULL }; +/* + * vmbus_uevent - add uevent for our device + * + * 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 + */ +static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) +{ + struct hv_device *dev = device_to_hv_device(device); + int ret; + + DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_type.data[3], dev->dev_type.data[2], + dev->dev_type.data[1], dev->dev_type.data[0], + dev->dev_type.data[5], dev->dev_type.data[4], + dev->dev_type.data[7], dev->dev_type.data[6], + dev->dev_type.data[8], dev->dev_type.data[9], + dev->dev_type.data[10], + dev->dev_type.data[11], + dev->dev_type.data[12], + dev->dev_type.data[13], + dev->dev_type.data[14], + dev->dev_type.data[15]); + + ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_type.data[3], + dev->dev_type.data[2], + dev->dev_type.data[1], + dev->dev_type.data[0], + dev->dev_type.data[5], + dev->dev_type.data[4], + dev->dev_type.data[7], + dev->dev_type.data[6], + dev->dev_type.data[8], + dev->dev_type.data[9], + dev->dev_type.data[10], + dev->dev_type.data[11], + dev->dev_type.data[12], + dev->dev_type.data[13], + dev->dev_type.data[14], + dev->dev_type.data[15]); + + if (ret) + return ret; + + ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_instance.data[3], + dev->dev_instance.data[2], + dev->dev_instance.data[1], + dev->dev_instance.data[0], + dev->dev_instance.data[5], + dev->dev_instance.data[4], + dev->dev_instance.data[7], + dev->dev_instance.data[6], + dev->dev_instance.data[8], + dev->dev_instance.data[9], + dev->dev_instance.data[10], + dev->dev_instance.data[11], + dev->dev_instance.data[12], + dev->dev_instance.data[13], + dev->dev_instance.data[14], + dev->dev_instance.data[15]); + if (ret) + return ret; + + return 0; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = "vmbus", @@ -627,81 +701,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) } /* - * vmbus_uevent - add uevent for our device - * - * 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 - */ -static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) -{ - struct hv_device *dev = device_to_hv_device(device); - int ret; - - DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.data[3], dev->dev_type.data[2], - dev->dev_type.data[1], dev->dev_type.data[0], - dev->dev_type.data[5], dev->dev_type.data[4], - dev->dev_type.data[7], dev->dev_type.data[6], - dev->dev_type.data[8], dev->dev_type.data[9], - dev->dev_type.data[10], - dev->dev_type.data[11], - dev->dev_type.data[12], - dev->dev_type.data[13], - dev->dev_type.data[14], - dev->dev_type.data[15]); - - ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.data[3], - dev->dev_type.data[2], - dev->dev_type.data[1], - dev->dev_type.data[0], - dev->dev_type.data[5], - dev->dev_type.data[4], - dev->dev_type.data[7], - dev->dev_type.data[6], - dev->dev_type.data[8], - dev->dev_type.data[9], - dev->dev_type.data[10], - dev->dev_type.data[11], - dev->dev_type.data[12], - dev->dev_type.data[13], - dev->dev_type.data[14], - dev->dev_type.data[15]); - - if (ret) - return ret; - - ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_instance.data[3], - dev->dev_instance.data[2], - dev->dev_instance.data[1], - dev->dev_instance.data[0], - dev->dev_instance.data[5], - dev->dev_instance.data[4], - dev->dev_instance.data[7], - dev->dev_instance.data[6], - dev->dev_instance.data[8], - dev->dev_instance.data[9], - dev->dev_instance.data[10], - dev->dev_instance.data[11], - dev->dev_instance.data[12], - dev->dev_instance.data[13], - dev->dev_instance.data[14], - dev->dev_instance.data[15]); - if (ret) - return ret; - - return 0; -} - -/* * vmbus_match - Attempt to match the specified device to the specified driver */ static int vmbus_match(struct device *device, struct device_driver *driver) -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
Get rid of the forward declaration of vmbus_uevent by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 151 ++++++++++++++++++++-------------------- 1 files changed, 75 insertions(+), 76 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index f292b03..5243d98 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -51,7 +51,6 @@ static int vmbus_match(struct device *device, struct device_driver *driver); static int vmbus_probe(struct device *device); static int vmbus_remove(struct device *device); static void vmbus_shutdown(struct device *device); -static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env); static irqreturn_t vmbus_isr(int irq, void *dev_id); @@ -98,6 +97,81 @@ static struct device_attribute vmbus_device_attrs[] = { __ATTR_NULL }; +/* + * vmbus_uevent - add uevent for our device + * + * 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 + */ +static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) +{ + struct hv_device *dev = device_to_hv_device(device); + int ret; + + DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_type.data[3], dev->dev_type.data[2], + dev->dev_type.data[1], dev->dev_type.data[0], + dev->dev_type.data[5], dev->dev_type.data[4], + dev->dev_type.data[7], dev->dev_type.data[6], + dev->dev_type.data[8], dev->dev_type.data[9], + dev->dev_type.data[10], + dev->dev_type.data[11], + dev->dev_type.data[12], + dev->dev_type.data[13], + dev->dev_type.data[14], + dev->dev_type.data[15]); + + ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_type.data[3], + dev->dev_type.data[2], + dev->dev_type.data[1], + dev->dev_type.data[0], + dev->dev_type.data[5], + dev->dev_type.data[4], + dev->dev_type.data[7], + dev->dev_type.data[6], + dev->dev_type.data[8], + dev->dev_type.data[9], + dev->dev_type.data[10], + dev->dev_type.data[11], + dev->dev_type.data[12], + dev->dev_type.data[13], + dev->dev_type.data[14], + dev->dev_type.data[15]); + + if (ret) + return ret; + + ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" + "%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}", + dev->dev_instance.data[3], + dev->dev_instance.data[2], + dev->dev_instance.data[1], + dev->dev_instance.data[0], + dev->dev_instance.data[5], + dev->dev_instance.data[4], + dev->dev_instance.data[7], + dev->dev_instance.data[6], + dev->dev_instance.data[8], + dev->dev_instance.data[9], + dev->dev_instance.data[10], + dev->dev_instance.data[11], + dev->dev_instance.data[12], + dev->dev_instance.data[13], + dev->dev_instance.data[14], + dev->dev_instance.data[15]); + if (ret) + return ret; + + return 0; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = "vmbus", @@ -627,81 +701,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) } /* - * vmbus_uevent - add uevent for our device - * - * 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 - */ -static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) -{ - struct hv_device *dev = device_to_hv_device(device); - int ret; - - DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.data[3], dev->dev_type.data[2], - dev->dev_type.data[1], dev->dev_type.data[0], - dev->dev_type.data[5], dev->dev_type.data[4], - dev->dev_type.data[7], dev->dev_type.data[6], - dev->dev_type.data[8], dev->dev_type.data[9], - dev->dev_type.data[10], - dev->dev_type.data[11], - dev->dev_type.data[12], - dev->dev_type.data[13], - dev->dev_type.data[14], - dev->dev_type.data[15]); - - ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_type.data[3], - dev->dev_type.data[2], - dev->dev_type.data[1], - dev->dev_type.data[0], - dev->dev_type.data[5], - dev->dev_type.data[4], - dev->dev_type.data[7], - dev->dev_type.data[6], - dev->dev_type.data[8], - dev->dev_type.data[9], - dev->dev_type.data[10], - dev->dev_type.data[11], - dev->dev_type.data[12], - dev->dev_type.data[13], - dev->dev_type.data[14], - dev->dev_type.data[15]); - - if (ret) - return ret; - - ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={" - "%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}", - dev->dev_instance.data[3], - dev->dev_instance.data[2], - dev->dev_instance.data[1], - dev->dev_instance.data[0], - dev->dev_instance.data[5], - dev->dev_instance.data[4], - dev->dev_instance.data[7], - dev->dev_instance.data[6], - dev->dev_instance.data[8], - dev->dev_instance.data[9], - dev->dev_instance.data[10], - dev->dev_instance.data[11], - dev->dev_instance.data[12], - dev->dev_instance.data[13], - dev->dev_instance.data[14], - dev->dev_instance.data[15]); - if (ret) - return ret; - - return 0; -} - -/* * vmbus_match - Attempt to match the specified device to the specified driver */ static int vmbus_match(struct device *device, struct device_driver *driver) -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 06/12] Staging: hv: Get rid of the forward declaration for vmbus_match
Get rid of the forward declaration of vmbus_match by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 49 ++++++++++++++++++++------------------- 1 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 5243d98..5dcfd98 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -47,7 +47,6 @@ struct hv_bus { struct tasklet_struct event_dpc; }; -static int vmbus_match(struct device *device, struct device_driver *driver); static int vmbus_probe(struct device *device); static int vmbus_remove(struct device *device); static void vmbus_shutdown(struct device *device); @@ -172,6 +171,31 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) return 0; } + +/* + * 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 *device_ctx = device_to_hv_device(device); + + /* We found our driver ? */ + if (memcmp(&device_ctx->dev_type, &drv->dev_type, + sizeof(struct hv_guid)) == 0) { + + device_ctx->drv = drv->priv; + DPRINT_INFO(VMBUS_DRV, + "device object (%p) set to driver object (%p)", + &device_ctx, + device_ctx->drv); + + match = 1; + } + return match; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = "vmbus", @@ -700,29 +724,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) &device_obj->device); } -/* - * 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 *device_ctx = device_to_hv_device(device); - - /* We found our driver ? */ - if (memcmp(&device_ctx->dev_type, &drv->dev_type, - sizeof(struct hv_guid)) == 0) { - - device_ctx->drv = drv->priv; - DPRINT_INFO(VMBUS_DRV, - "device object (%p) set to driver object (%p)", - &device_ctx, - device_ctx->drv); - - match = 1; - } - return match; -} /* * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe() -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 09/12] Staging: hv: Get rid of the forward declaration for vmbus_shutdown
Get rid of the forward declaration of vmbus_shutdown by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 44 ++++++++++++++++++++-------------------- 1 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 3feed10..671632c 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -47,7 +47,6 @@ struct hv_bus { struct tasklet_struct event_dpc; }; -static void vmbus_shutdown(struct device *device); static irqreturn_t vmbus_isr(int irq, void *dev_id); @@ -276,6 +275,28 @@ static int vmbus_remove(struct device *child_device) return 0; } + +/* + * vmbus_shutdown - Shutdown a vmbus device + */ +static void vmbus_shutdown(struct device *child_device) +{ + struct hv_driver *drv; + + + /* The device may not be attached yet */ + if (!child_device->driver) + return; + + drv = drv_to_hv_drv(child_device->driver); + + /* Let the specific open-source driver handles the removal if it can */ + if (drv->driver.shutdown) + drv->driver.shutdown(child_device); + + return; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = "vmbus", @@ -804,27 +825,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) &device_obj->device); } -/* - * vmbus_shutdown - Shutdown a vmbus device - */ -static void vmbus_shutdown(struct device *child_device) -{ - struct hv_driver *drv; - - - /* The device may not be attached yet */ - if (!child_device->driver) - return; - - drv = drv_to_hv_drv(child_device->driver); - - /* Let the specific open-source driver handles the removal if it can */ - if (drv->driver.shutdown) - drv->driver.shutdown(child_device); - - return; -} - /* * vmbus_device_release - Final callback release of the vmbus child device -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 10/12] Staging: hv: Get rid of the forward declaration for vmbus_device_release
Get rid of the forward declaration of vmbus_device_release by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 27 ++++++++++++--------------- 1 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 671632c..976175b 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -50,8 +50,6 @@ struct hv_bus { static irqreturn_t vmbus_isr(int irq, void *dev_id); -static void vmbus_device_release(struct device *device); - static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf); @@ -297,6 +295,18 @@ static void vmbus_shutdown(struct device *child_device) return; } + +/* + * vmbus_device_release - Final callback release of the vmbus child device + */ +static void vmbus_device_release(struct device *device) +{ + struct hv_device *device_ctx = device_to_hv_device(device); + + kfree(device_ctx); + +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = "vmbus", @@ -826,19 +836,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) } -/* - * vmbus_device_release - Final callback release of the vmbus child device - */ -static void vmbus_device_release(struct device *device) -{ - struct hv_device *device_ctx = device_to_hv_device(device); - - kfree(device_ctx); - - /* !!DO NOT REFERENCE device_ctx anymore at this point!! */ -} - - static irqreturn_t vmbus_isr(int irq, void *dev_id) { -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 11/12] Staging: hv: Get rid of the forward declaration for vmbus_isr
Get rid of the forward declaration of vmbus_isr by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 47 +++++++++++++++++++-------------------- 1 files changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 976175b..194926c 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -48,7 +48,6 @@ struct hv_bus { }; -static irqreturn_t vmbus_isr(int irq, void *dev_id); static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, @@ -91,6 +90,7 @@ static struct device_attribute vmbus_device_attrs[] = { __ATTR_NULL }; + /* * vmbus_uevent - add uevent for our device * @@ -417,6 +417,28 @@ static int vmbus_on_isr(void) return ret; } + +static irqreturn_t vmbus_isr(int irq, void *dev_id) +{ + int ret; + + ret = vmbus_on_isr(); + + /* Schedules a dpc if necessary */ + if (ret > 0) { + if (test_bit(0, (unsigned long *)&ret)) + tasklet_schedule(&hv_bus.msg_dpc); + + if (test_bit(1, (unsigned long *)&ret)) + tasklet_schedule(&hv_bus.event_dpc); + + return IRQ_HANDLED; + } else { + return IRQ_NONE; + } +} + + static void get_channel_info(struct hv_device *device, struct hv_device_info *info) { @@ -836,29 +858,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) } - -static irqreturn_t vmbus_isr(int irq, void *dev_id) -{ - int ret; - - ret = vmbus_on_isr(); - - /* Schedules a dpc if necessary */ - if (ret > 0) { - if (test_bit(0, (unsigned long *)&ret)) - tasklet_schedule(&hv_bus.msg_dpc); - - if (test_bit(1, (unsigned long *)&ret)) - tasklet_schedule(&hv_bus.event_dpc); - - return IRQ_HANDLED; - } else { - return IRQ_NONE; - } -} - - - static int __devinit hv_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { -- 1.5.5.6
K. Y. Srinivasan
2011-Mar-15 22:03 UTC
[PATCH 12/12] Staging: hv: Get rid of the forward declaration for vmbus_show_device_attr
Get rid of the forward declaration of vmbus_show_device_attr by moving the code around. Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> Signed-off-by: Hank Janssen <hjanssen at microsoft.com> --- drivers/staging/hv/vmbus_drv.c | 302 +++++++++++++++++++-------------------- 1 files changed, 147 insertions(+), 155 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 194926c..3263fc8 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -47,18 +47,160 @@ struct hv_bus { struct tasklet_struct event_dpc; }; +unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL); +EXPORT_SYMBOL(vmbus_loglevel); + /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */ + /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */ + + +static void get_channel_info(struct hv_device *device, + struct hv_device_info *info) +{ + struct vmbus_channel_debug_info debug_info; + + if (!device->channel) + return; + + vmbus_get_debug_info(device->channel, &debug_info); + + info->chn_id = debug_info.relid; + info->chn_state = debug_info.state; + memcpy(&info->chn_type, &debug_info.interfacetype, + sizeof(struct hv_guid)); + memcpy(&info->chn_instance, &debug_info.interface_instance, + sizeof(struct hv_guid)); + + info->monitor_id = debug_info.monitorid; + + info->server_monitor_pending = debug_info.servermonitor_pending; + info->server_monitor_latency = debug_info.servermonitor_latency; + info->server_monitor_conn_id = debug_info.servermonitor_connectionid; + + info->client_monitor_pending = debug_info.clientmonitor_pending; + info->client_monitor_latency = debug_info.clientmonitor_latency; + info->client_monitor_conn_id = debug_info.clientmonitor_connectionid; + + info->inbound.int_mask = debug_info.inbound.current_interrupt_mask; + info->inbound.read_idx = debug_info.inbound.current_read_index; + info->inbound.write_idx = debug_info.inbound.current_write_index; + info->inbound.bytes_avail_toread + debug_info.inbound.bytes_avail_toread; + info->inbound.bytes_avail_towrite + debug_info.inbound.bytes_avail_towrite; + info->outbound.int_mask + debug_info.outbound.current_interrupt_mask; + info->outbound.read_idx = debug_info.outbound.current_read_index; + info->outbound.write_idx = debug_info.outbound.current_write_index; + info->outbound.bytes_avail_toread + debug_info.outbound.bytes_avail_toread; + info->outbound.bytes_avail_towrite + debug_info.outbound.bytes_avail_towrite; +} +/* + * vmbus_show_device_attr - Show the device attribute in sysfs. + * + * This is invoked when user does a + * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>" + */ static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, - char *buf); + char *buf) +{ + struct hv_device *device_ctx = device_to_hv_device(dev); + struct hv_device_info device_info; + memset(&device_info, 0, sizeof(struct hv_device_info)); -unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL); -EXPORT_SYMBOL(vmbus_loglevel); - /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */ - /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */ + get_channel_info(device_ctx, &device_info); + if (!strcmp(dev_attr->attr.name, "class_id")) { + return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}\n", + device_info.chn_type.data[3], + device_info.chn_type.data[2], + device_info.chn_type.data[1], + device_info.chn_type.data[0], + device_info.chn_type.data[5], + device_info.chn_type.data[4], + device_info.chn_type.data[7], + device_info.chn_type.data[6], + device_info.chn_type.data[8], + device_info.chn_type.data[9], + device_info.chn_type.data[10], + device_info.chn_type.data[11], + device_info.chn_type.data[12], + device_info.chn_type.data[13], + device_info.chn_type.data[14], + device_info.chn_type.data[15]); + } else if (!strcmp(dev_attr->attr.name, "device_id")) { + return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x%02x%02x}\n", + device_info.chn_instance.data[3], + device_info.chn_instance.data[2], + device_info.chn_instance.data[1], + device_info.chn_instance.data[0], + device_info.chn_instance.data[5], + device_info.chn_instance.data[4], + device_info.chn_instance.data[7], + device_info.chn_instance.data[6], + device_info.chn_instance.data[8], + device_info.chn_instance.data[9], + device_info.chn_instance.data[10], + device_info.chn_instance.data[11], + device_info.chn_instance.data[12], + device_info.chn_instance.data[13], + device_info.chn_instance.data[14], + device_info.chn_instance.data[15]); + } else if (!strcmp(dev_attr->attr.name, "state")) { + return sprintf(buf, "%d\n", device_info.chn_state); + } else if (!strcmp(dev_attr->attr.name, "id")) { + return sprintf(buf, "%d\n", device_info.chn_id); + } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) { + return sprintf(buf, "%d\n", device_info.outbound.int_mask); + } else if (!strcmp(dev_attr->attr.name, "out_read_index")) { + return sprintf(buf, "%d\n", device_info.outbound.read_idx); + } else if (!strcmp(dev_attr->attr.name, "out_write_index")) { + return sprintf(buf, "%d\n", device_info.outbound.write_idx); + } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) { + return sprintf(buf, "%d\n", + device_info.outbound.bytes_avail_toread); + } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) { + return sprintf(buf, "%d\n", + device_info.outbound.bytes_avail_towrite); + } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) { + return sprintf(buf, "%d\n", device_info.inbound.int_mask); + } else if (!strcmp(dev_attr->attr.name, "in_read_index")) { + return sprintf(buf, "%d\n", device_info.inbound.read_idx); + } else if (!strcmp(dev_attr->attr.name, "in_write_index")) { + return sprintf(buf, "%d\n", device_info.inbound.write_idx); + } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) { + return sprintf(buf, "%d\n", + device_info.inbound.bytes_avail_toread); + } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) { + return sprintf(buf, "%d\n", + device_info.inbound.bytes_avail_towrite); + } else if (!strcmp(dev_attr->attr.name, "monitor_id")) { + return sprintf(buf, "%d\n", device_info.monitor_id); + } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) { + return sprintf(buf, "%d\n", device_info.server_monitor_pending); + } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) { + return sprintf(buf, "%d\n", device_info.server_monitor_latency); + } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) { + return sprintf(buf, "%d\n", + device_info.server_monitor_conn_id); + } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) { + return sprintf(buf, "%d\n", device_info.client_monitor_pending); + } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) { + return sprintf(buf, "%d\n", device_info.client_monitor_latency); + } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) { + return sprintf(buf, "%d\n", + device_info.client_monitor_conn_id); + } else { + return 0; + } +} /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { @@ -438,156 +580,6 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) } } - -static void get_channel_info(struct hv_device *device, - struct hv_device_info *info) -{ - struct vmbus_channel_debug_info debug_info; - - if (!device->channel) - return; - - vmbus_get_debug_info(device->channel, &debug_info); - - info->chn_id = debug_info.relid; - info->chn_state = debug_info.state; - memcpy(&info->chn_type, &debug_info.interfacetype, - sizeof(struct hv_guid)); - memcpy(&info->chn_instance, &debug_info.interface_instance, - sizeof(struct hv_guid)); - - info->monitor_id = debug_info.monitorid; - - info->server_monitor_pending = debug_info.servermonitor_pending; - info->server_monitor_latency = debug_info.servermonitor_latency; - info->server_monitor_conn_id = debug_info.servermonitor_connectionid; - - info->client_monitor_pending = debug_info.clientmonitor_pending; - info->client_monitor_latency = debug_info.clientmonitor_latency; - info->client_monitor_conn_id = debug_info.clientmonitor_connectionid; - - info->inbound.int_mask = debug_info.inbound.current_interrupt_mask; - info->inbound.read_idx = debug_info.inbound.current_read_index; - info->inbound.write_idx = debug_info.inbound.current_write_index; - info->inbound.bytes_avail_toread - debug_info.inbound.bytes_avail_toread; - info->inbound.bytes_avail_towrite - debug_info.inbound.bytes_avail_towrite; - - info->outbound.int_mask - debug_info.outbound.current_interrupt_mask; - info->outbound.read_idx = debug_info.outbound.current_read_index; - info->outbound.write_idx = debug_info.outbound.current_write_index; - info->outbound.bytes_avail_toread - debug_info.outbound.bytes_avail_toread; - info->outbound.bytes_avail_towrite - debug_info.outbound.bytes_avail_towrite; -} - -/* - * vmbus_show_device_attr - Show the device attribute in sysfs. - * - * This is invoked when user does a - * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>" - */ -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_info device_info; - - memset(&device_info, 0, sizeof(struct hv_device_info)); - - get_channel_info(device_ctx, &device_info); - - if (!strcmp(dev_attr->attr.name, "class_id")) { - return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_type.data[3], - device_info.chn_type.data[2], - device_info.chn_type.data[1], - device_info.chn_type.data[0], - device_info.chn_type.data[5], - device_info.chn_type.data[4], - device_info.chn_type.data[7], - device_info.chn_type.data[6], - device_info.chn_type.data[8], - device_info.chn_type.data[9], - device_info.chn_type.data[10], - device_info.chn_type.data[11], - device_info.chn_type.data[12], - device_info.chn_type.data[13], - device_info.chn_type.data[14], - device_info.chn_type.data[15]); - } else if (!strcmp(dev_attr->attr.name, "device_id")) { - return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" - "%02x%02x%02x%02x%02x%02x%02x%02x}\n", - device_info.chn_instance.data[3], - device_info.chn_instance.data[2], - device_info.chn_instance.data[1], - device_info.chn_instance.data[0], - device_info.chn_instance.data[5], - device_info.chn_instance.data[4], - device_info.chn_instance.data[7], - device_info.chn_instance.data[6], - device_info.chn_instance.data[8], - device_info.chn_instance.data[9], - device_info.chn_instance.data[10], - device_info.chn_instance.data[11], - device_info.chn_instance.data[12], - device_info.chn_instance.data[13], - device_info.chn_instance.data[14], - device_info.chn_instance.data[15]); - } else if (!strcmp(dev_attr->attr.name, "state")) { - return sprintf(buf, "%d\n", device_info.chn_state); - } else if (!strcmp(dev_attr->attr.name, "id")) { - return sprintf(buf, "%d\n", device_info.chn_id); - } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) { - return sprintf(buf, "%d\n", device_info.outbound.int_mask); - } else if (!strcmp(dev_attr->attr.name, "out_read_index")) { - return sprintf(buf, "%d\n", device_info.outbound.read_idx); - } else if (!strcmp(dev_attr->attr.name, "out_write_index")) { - return sprintf(buf, "%d\n", device_info.outbound.write_idx); - } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.outbound.bytes_avail_toread); - } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.outbound.bytes_avail_towrite); - } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) { - return sprintf(buf, "%d\n", device_info.inbound.int_mask); - } else if (!strcmp(dev_attr->attr.name, "in_read_index")) { - return sprintf(buf, "%d\n", device_info.inbound.read_idx); - } else if (!strcmp(dev_attr->attr.name, "in_write_index")) { - return sprintf(buf, "%d\n", device_info.inbound.write_idx); - } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.inbound.bytes_avail_toread); - } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) { - return sprintf(buf, "%d\n", - device_info.inbound.bytes_avail_towrite); - } else if (!strcmp(dev_attr->attr.name, "monitor_id")) { - return sprintf(buf, "%d\n", device_info.monitor_id); - } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) { - return sprintf(buf, "%d\n", device_info.server_monitor_pending); - } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) { - return sprintf(buf, "%d\n", device_info.server_monitor_latency); - } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) { - return sprintf(buf, "%d\n", - device_info.server_monitor_conn_id); - } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) { - return sprintf(buf, "%d\n", device_info.client_monitor_pending); - } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) { - return sprintf(buf, "%d\n", device_info.client_monitor_latency); - } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) { - return sprintf(buf, "%d\n", - device_info.client_monitor_conn_id); - } else { - return 0; - } -} - /* * vmbus_bus_init -Main vmbus driver initialization routine. * -- 1.5.5.6
On Tue, Mar 15, 2011 at 03:02:07PM -0700, K. Y. Srinivasan wrote:> This patch-set fixes the following issues in the vmbus driver (vmbus_drv.c):<snip> Thanks for the patches, but as the .39 merge window is closed, I'll be holding on to these until after .39-rc1 is out before I can do anything with them. So don't be surprised if I don't respond to them for a few weeks. Don't worry, they aren't lost. :) thanks, greg k-h
Greg KH
2011-Mar-15 22:22 UTC
[PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
On Tue, Mar 15, 2011 at 03:03:37PM -0700, K. Y. Srinivasan wrote:> Get rid of the forward declaration of vmbus_uevent by moving > the code around.There are 2 05/12 patches and they are different. confused, greg k-h
KY Srinivasan
2011-Mar-15 22:39 UTC
[PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
> -----Original Message----- > From: Greg KH [mailto:greg at kroah.com] > Sent: Tuesday, March 15, 2011 6:23 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; Mike > Sterling; Abhishek Kane (Mindtree Consulting PVT LTD) > Subject: Re: [PATCH 05/12] Staging: hv: Get rid of the forward declaration for > vmbus_uevent > > On Tue, Mar 15, 2011 at 03:03:37PM -0700, K. Y. Srinivasan wrote: > > Get rid of the forward declaration of vmbus_uevent by moving > > the code around. > > There are 2 05/12 patches and they are different.Sorry about that Greg; I had an incorrect commit message that I fixed, but forgot to delete that patch that was generated with the incorrect commit message. Loose the patch that has the subject line: [PATCH 05/12] Get rid of the forward declaration for vmbus_uevent You want to keep the one that has the following subject line: [PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent I could resend, if you prefer. Regards, K. Y
On Tue, Mar 15, 2011 at 03:03:34PM -0700, K. Y. Srinivasan wrote:> Now that vmbus_driver is a pci driver, > cleanup the irq allocation mess by using the standard > irq allocation mechanisms. > > Note that this patch generates an error when the checkpatch > script is run because of the IRQF_SAMPLE_RANDOM flag used in > request_irq() function. This interrupt may be the only > external event this VM will get and consequently if this > flag (IRQF_SAMPLE_RANDOM) is not specified, experimentally > we have shown that the entropy in the VM will very very low. > > > Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> > Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> > Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> > Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> > Signed-off-by: Hank Janssen <hjanssen at microsoft.com> > --- > drivers/staging/hv/vmbus_drv.c | 28 +++++++++++++--------------- > 1 files changed, 13 insertions(+), 15 deletions(-) > > diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c > index 3d2789b..239b91c 100644 > --- a/drivers/staging/hv/vmbus_drv.c > +++ b/drivers/staging/hv/vmbus_drv.c > @@ -17,6 +17,8 @@ > * Authors: > * Haiyang Zhang <haiyangz at microsoft.com> > * Hank Janssen <hjanssen at microsoft.com> > + * > + * 3/9/2011: K. Y. Srinivasan - Significant restructuring and cleanupChangelog comments never belong in the file itself. If you consider yourself an author of the file now, then put your name in it with the others. thanks, greg k-h
Greg KH
2011-Apr-05 04:22 UTC
[PATCH 04/12] Staging: hv: Rename vmbus_driver_context structure
On Tue, Mar 15, 2011 at 03:03:35PM -0700, K. Y. Srinivasan wrote:> Now that struct vmbus_driver_context is properly > cleaned up, rename this structure appropriately and > cleanup the code. > > Signed-off-by: K. Y. Srinivasan <kys at microsoft.com> > Signed-off-by: Haiyang Zhang <haiyangz at microsoft.com> > Signed-off-by: Mike Sterling <mike.sterling at microsoft.com> > Signed-off-by: Abhishek Kane <v-abkane at microsoft.com> > Signed-off-by: Hank Janssen <hjanssen at microsoft.com> > --- > drivers/staging/hv/vmbus_drv.c | 32 +++++++++++++++----------------- > 1 files changed, 15 insertions(+), 17 deletions(-) > > diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c > index 239b91c..f292b03 100644 > --- a/drivers/staging/hv/vmbus_drv.c > +++ b/drivers/staging/hv/vmbus_drv.c > @@ -41,7 +41,7 @@ > struct pci_dev *hv_pci_dev; > > /* Main vmbus driver data structure */ > -struct vmbus_driver_context { > +struct hv_bus { > struct bus_type bus; > struct tasklet_struct msg_dpc; > struct tasklet_struct event_dpc; > @@ -99,7 +99,7 @@ static struct device_attribute vmbus_device_attrs[] = { > }; > > /* The one and only one */ > -static struct vmbus_driver_context vmbus_drv = { > +static struct hv_bus hv_bus = {2 spaces?> .bus.name = "vmbus", > .bus.match = vmbus_match, > .bus.shutdown = vmbus_shutdown,Wait, why is a bus_type embedded within another structure? That is going to get pulled out later, right? thanks, greg k-h