[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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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();
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[PATCH 05/12] Get rid of the forward declaration for vmbus_uevent
Signed-off-by: K. Y. Srinivasan k...@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={ -
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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)) { +
[PATCH 07/12] Staging: hv: Get rid of the forward declaration for vmbus_probe
Get rid of the forward declaration of vmbus_probe by moving the code around. Signed-off-by: K. Y. Srinivasan k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@microsoft.com --- drivers/staging/hv/vmbus_drv.c | 107 1 files changed, 53 insertions(+), 54 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 5dcfd98..8153a4d 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_probe(struct device *device); static int vmbus_remove(struct device *device); static void vmbus_shutdown(struct device *device); @@ -196,6 +195,59 @@ static int vmbus_match(struct device *device, struct device_driver *driver) return match; } + +/* + * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe() + * + * We need a callback because we cannot invoked device_unregister() inside + * vmbus_probe() since vmbus_probe() may be invoked inside device_register() + * i.e. we cannot call device_unregister() inside device_register() + */ +static void vmbus_probe_failed_cb(struct work_struct *context) +{ + struct hv_device *device_ctx = (struct hv_device *)context; + + /* +* Kick off the process of unregistering the device. +* This will call vmbus_remove() and eventually vmbus_device_release() +*/ + device_unregister(device_ctx-device); + + /* put_device(device_ctx-device); */ +} + +/* + * vmbus_probe - Add the new vmbus's child device + */ +static int vmbus_probe(struct device *child_device) +{ + int ret = 0; + struct hv_driver *drv = + drv_to_hv_drv(child_device-driver); + struct hv_device *dev = device_to_hv_device(child_device); + + /* Let the specific open-source driver handles the probe if it can */ + if (drv-driver.probe) { + ret = dev-probe_error = + drv-driver.probe(child_device); + if (ret != 0) { + DPRINT_ERR(VMBUS_DRV, probe() failed for device %s + (%p) on driver %s (%d)..., + dev_name(child_device), child_device, + child_device-driver-name, ret); + + INIT_WORK(dev-probe_failed_work_item, + vmbus_probe_failed_cb); + schedule_work(dev-probe_failed_work_item); + } + } else { + DPRINT_ERR(VMBUS_DRV, probe() method not set for driver - %s, + child_device-driver-name); + ret = -1; + } + return ret; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = vmbus, @@ -724,59 +776,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) device_obj-device); } - -/* - * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe() - * - * We need a callback because we cannot invoked device_unregister() inside - * vmbus_probe() since vmbus_probe() may be invoked inside device_register() - * i.e. we cannot call device_unregister() inside device_register() - */ -static void vmbus_probe_failed_cb(struct work_struct *context) -{ - struct hv_device *device_ctx = (struct hv_device *)context; - - /* -* Kick off the process of unregistering the device. -* This will call vmbus_remove() and eventually vmbus_device_release() -*/ - device_unregister(device_ctx-device); - - /* put_device(device_ctx-device); */ -} - -/* - * vmbus_probe - Add the new vmbus's child device - */ -static int vmbus_probe(struct device *child_device) -{ - int ret = 0; - struct hv_driver *drv = - drv_to_hv_drv(child_device-driver); - struct hv_device *dev = device_to_hv_device(child_device); - - /* Let the specific open-source driver handles the probe if it can */ - if (drv-driver.probe) { - ret = dev-probe_error = - drv-driver.probe(child_device); - if (ret != 0) { - DPRINT_ERR(VMBUS_DRV, probe() failed for device %s - (%p) on driver %s (%d)..., - dev_name(child_device), child_device, - child_device-driver-name, ret); - - INIT_WORK(dev-probe_failed_work_item, - vmbus_probe_failed_cb); - schedule_work(dev-probe_failed_work_item); - } - } else { - DPRINT_ERR(VMBUS_DRV, probe() method not set
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II
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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[PATCH 08/12] Staging: hv: Get rid of the forward declaration for vmbus_remove
Get rid of the forward declaration of vmbus_remove by moving the code around. Signed-off-by: K. Y. Srinivasan k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@microsoft.com --- drivers/staging/hv/vmbus_drv.c | 59 +++ 1 files changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 8153a4d..3feed10 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_remove(struct device *device); static void vmbus_shutdown(struct device *device); static irqreturn_t vmbus_isr(int irq, void *dev_id); @@ -248,6 +247,35 @@ static int vmbus_probe(struct device *child_device) return ret; } +/* + * vmbus_remove - Remove a vmbus device + */ +static int vmbus_remove(struct device *child_device) +{ + int ret; + struct hv_driver *drv; + + + if (child_device-driver) { + drv = drv_to_hv_drv(child_device-driver); + + /* +* Let the specific open-source driver handles the removal if +* it can +*/ + if (drv-driver.remove) { + ret = drv-driver.remove(child_device); + } else { + DPRINT_ERR(VMBUS_DRV, + remove() method not set for driver - %s, + child_device-driver-name); + ret = -1; + } + } + + return 0; +} + /* The one and only one */ static struct hv_bus hv_bus = { .bus.name = vmbus, @@ -777,35 +805,6 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) } /* - * vmbus_remove - Remove a vmbus device - */ -static int vmbus_remove(struct device *child_device) -{ - int ret; - struct hv_driver *drv; - - - if (child_device-driver) { - drv = drv_to_hv_drv(child_device-driver); - - /* -* Let the specific open-source driver handles the removal if -* it can -*/ - if (drv-driver.remove) { - ret = drv-driver.remove(child_device); - } else { - DPRINT_ERR(VMBUS_DRV, - remove() method not set for driver - %s, - child_device-driver-name); - ret = -1; - } - } - - return 0; -} - -/* * vmbus_shutdown - Shutdown a vmbus device */ static void vmbus_shutdown(struct device *child_device) -- 1.5.5.6 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
[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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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
[PATCH 03/12] Staging: hv: Cleanup irq management
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 k...@microsoft.com Signed-off-by: Haiyang Zhang haiya...@microsoft.com Signed-off-by: Mike Sterling mike.sterl...@microsoft.com Signed-off-by: Abhishek Kane v-abk...@microsoft.com Signed-off-by: Hank Janssen hjans...@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 haiya...@microsoft.com * Hank Janssen hjans...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
RE: [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II
-Original Message- From: Greg KH [mailto:gre...@suse.de] Sent: Tuesday, March 15, 2011 6:05 PM To: KY Srinivasan Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org; virtualizat...@lists.osdl.org Subject: Re: [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II 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. :) If possible, I would love to get your feedback even if you cannot check in these patches. Also, if you can give me feedback as to what else would need to be fixed to exit staging as far as the vmbus driver is concerned, I can work on those over the next couple of weeks until the tree opens up. If it is ok with you we will send the DPRINT cleanup patches in the next couple of days. Regards, K. Y ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
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. confused, greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
On Tue, Mar 15, 2011 at 03:22:46PM -0700, Greg KH wrote: 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. Ah, one has the proper subject and changelog entry and the other doesn't. Which to use? thanks, greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II
On Tue, Mar 15, 2011 at 10:24:41PM +, KY Srinivasan wrote: -Original Message- From: Greg KH [mailto:gre...@suse.de] Sent: Tuesday, March 15, 2011 6:05 PM To: KY Srinivasan Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org; virtualizat...@lists.osdl.org Subject: Re: [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II 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. :) If possible, I would love to get your feedback even if you cannot check in these patches. Also, if you can give me feedback as to what else would need to be fixed to exit staging as far as the vmbus driver is concerned, I can work on those over the next couple of weeks until the tree opens up. As I'm going to be very busy with the merge window issues, coupled with spring break and the LF Collab summit, I doubt I'll be able to do this, sorry. Give me a few weeks please. If it is ok with you we will send the DPRINT cleanup patches in the next couple of days. That's fine, they can sit in the same to-apply mbox next to these :) greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
RE: [PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
-Original Message- From: Greg KH [mailto:g...@kroah.com] Sent: Tuesday, March 15, 2011 6:23 PM To: KY Srinivasan Cc: gre...@suse.de; linux-ker...@vger.kernel.org; de...@linuxdriverproject.org; virtualizat...@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 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent
On Tue, Mar 15, 2011 at 10:39:07PM +, KY Srinivasan wrote: -Original Message- From: Greg KH [mailto:g...@kroah.com] Sent: Tuesday, March 15, 2011 6:23 PM To: KY Srinivasan Cc: gre...@suse.de; linux-ker...@vger.kernel.org; de...@linuxdriverproject.org; virtualizat...@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. No I got it, that's fine. thanks, greg k-h ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 0/2] Fix hot-unplug: device removal while port in use
On Fri, 11 Mar 2011 16:46:28 +0530, Amit Shah amit.s...@redhat.com wrote: Ideally virtio_pci_release_dev() shouldn't be needed at all; all that work can be moved to virtio_pci_remove(). virtio_pci_release_dev() was added in 29f9f12e to curb a warning: virtio: add PCI device release() function Add a release() function for virtio_pci devices so as to avoid: Device 'virtio0' does not have a release() function, it is broken and must be fixed So we could have an empty release() function that does nothing, and all of the current functionality be moved to virtio_pci_remove(), as it was earlier. This should keep everyone happy. Is that fine? Greg K-H needs to be asked this question, I think. Cheers, Rusty. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH 00/02] virtio: Virtio platform driver
On Thu, 10 Mar 2011 16:05:41 +0900, Magnus Damm magnus.d...@gmail.com wrote: virtio: Virtio platform driver [PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver I have no problem with these patches, but it's just churn until we see your actual drivers. The S/390 devs might be interested, as their bus is very similar too... Cheers, Rusty. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH] virtio_pci: Prevent double-free of pci regions after device hot-unplug
On Mon, 14 Mar 2011 17:45:02 +0530, Amit Shah amit.s...@redhat.com wrote: In the case where a virtio-console port is in use (opened by a program) and a virtio-console device is removed, the port is kept around but all the virtio-related state is assumed to be gone. When the port is finally released (close() called), we call device_destroy() on the port's device. This results in the parent device's structures to be freed as well. This includes the PCI regions for the virtio-console PCI device. Once this is done, however, virtio_pci_release_dev() kicks in, as the last ref to the virtio device is now gone, and attempts to do pci_iounmap(pci_dev, vp_dev-ioaddr); pci_release_regions(pci_dev); pci_disable_device(pci_dev); which results in a double-free warning. Move the code that releases regions, etc., to the virtio_pci_remove() function, and all that's now left in release_dev is the final freeing of the vp_dev. Signed-off-by: Amit Shah amit.s...@redhat.com Applied. Thanks, Rusty. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCH] virtio: console: Enable call to hvc_remove() on console port remove
On Mon, 14 Mar 2011 17:45:48 +0530, Amit Shah amit.s...@redhat.com wrote: This call was disabled as hot-unplugging one virtconsole port led to another virtconsole port freezing. Upon testing it again, this now works, so enable it. Applied, Rusty. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/virtualization