From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: Haiyang Zhang <haiyangz@microsoft.com>,
Mike Sterling <mike.sterling@microsoft.com>,
Abhishek Kane <v-abkane@microsoft.com>
Subject: [PATCH 02/12] Staging: hv: Cleanup root device handling
Date: Tue, 15 Mar 2011 15:03:33 -0700 [thread overview]
Message-ID: <1300226624-27004-2-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1300226624-27004-1-git-send-email-kys@microsoft.com>
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@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Mike Sterling <mike.sterling@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@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
WARNING: multiple messages have this Message-ID (diff)
From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Mike Sterling <mike.sterling@microsoft.com>,
Abhishek Kane <v-abkane@microsoft.com>,
Hank Janssen <hjanssen@microsoft.com>
Subject: [PATCH 02/12] Staging: hv: Cleanup root device handling
Date: Tue, 15 Mar 2011 15:03:33 -0700 [thread overview]
Message-ID: <1300226624-27004-2-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1300226624-27004-1-git-send-email-kys@microsoft.com>
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@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Mike Sterling <mike.sterling@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@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
next prev parent reply other threads:[~2011-03-15 22:03 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-15 22:02 [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 01/12] Staging: hv: Make vmbus driver a pci driver K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan [this message]
2011-03-15 22:03 ` [PATCH 02/12] Staging: hv: Cleanup root device handling K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 03/12] Staging: hv: Cleanup irq management K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 04/12] Staging: hv: Rename vmbus_driver_context structure K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 05/12] Get rid of the forward declaration for vmbus_uevent K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 05/12] Staging: hv: " K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 06/12] Staging: hv: Get rid of the forward declaration for vmbus_match K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 07/12] Staging: hv: Get rid of the forward declaration for vmbus_probe K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 08/12] Staging: hv: Get rid of the forward declaration for vmbus_remove K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 09/12] Staging: hv: Get rid of the forward declaration for vmbus_shutdown K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 10/12] Staging: hv: Get rid of the forward declaration for vmbus_device_release K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 11/12] Staging: hv: Get rid of the forward declaration for vmbus_isr K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:03 ` [PATCH 12/12] Staging: hv: Get rid of the forward declaration for vmbus_show_device_attr K. Y. Srinivasan
2011-03-15 22:03 ` K. Y. Srinivasan
2011-03-15 22:22 ` [PATCH 05/12] Staging: hv: Get rid of the forward declaration for vmbus_uevent Greg KH
2011-03-15 22:23 ` Greg KH
2011-03-15 22:39 ` KY Srinivasan
2011-03-15 22:51 ` Greg KH
2011-04-05 4:22 ` [PATCH 04/12] Staging: hv: Rename vmbus_driver_context structure Greg KH
2011-04-05 4:19 ` [PATCH 03/12] Staging: hv: Cleanup irq management Greg KH
2011-04-05 4:16 ` [PATCH 01/12] Staging: hv: Make vmbus driver a pci driver Greg KH
2011-04-05 4:16 ` Greg KH
2011-03-15 22:04 ` [PATCH 00/12] Staging: hv: Cleanup vmbus driver - Phase II Greg KH
2011-03-15 22:24 ` KY Srinivasan
2011-03-15 22:30 ` Greg KH
2011-03-17 21:39 ` Valdis.Kletnieks
2011-03-17 21:45 ` Greg KH
2011-03-17 22:58 ` Valdis.Kletnieks
2011-04-16 0:34 ` Greg KH
2011-04-16 0:34 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300226624-27004-2-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=haiyangz@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.sterling@microsoft.com \
--cc=v-abkane@microsoft.com \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.