* [PATCH 07/24] Staging: hv: mousevsc: Use completion primitive to synchronize
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
Use completion primitive to synchronize.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 30 ++++++++++--------------------
1 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 74faa26..ea9e1f3 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -162,10 +162,7 @@ struct mousevsc_dev {
struct mousevsc_prt_msg protocol_req;
struct mousevsc_prt_msg protocol_resp;
/* Synchronize the request/response if needed */
- wait_queue_head_t protocol_wait_event;
- wait_queue_head_t dev_info_wait_event;
- int protocol_wait_condition;
- int device_wait_condition;
+ struct completion wait_event;
int dev_info_status;
struct hid_descriptor *hid_desc;
@@ -194,6 +191,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
input_dev->device = device;
hv_set_drvdata(device, input_dev);
+ init_completion(&input_dev->wait_event);
return input_dev;
}
@@ -379,8 +377,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
goto cleanup;
}
- input_device->device_wait_condition = 1;
- wake_up(&input_device->dev_info_wait_event);
+ complete(&input_device->wait_event);
return;
@@ -392,8 +389,7 @@ cleanup:
input_device->report_desc = NULL;
input_device->dev_info_status = -1;
- input_device->device_wait_condition = 1;
- wake_up(&input_device->dev_info_wait_event);
+ complete(&input_device->wait_event);
}
static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
@@ -444,8 +440,7 @@ static void mousevsc_on_receive(struct hv_device *device,
memcpy(&input_dev->protocol_resp, pipe_msg,
pipe_msg->size + sizeof(struct pipe_prt_msg) -
sizeof(unsigned char));
- input_dev->protocol_wait_condition = 1;
- wake_up(&input_dev->protocol_wait_event);
+ complete(&input_dev->wait_event);
break;
case SynthHidInitialDeviceInfo:
@@ -565,6 +560,7 @@ static void mousevsc_on_channel_callback(void *context)
static int mousevsc_connect_to_vsp(struct hv_device *device)
{
int ret = 0;
+ int t;
struct mousevsc_dev *input_dev;
struct mousevsc_prt_msg *request;
struct mousevsc_prt_msg *response;
@@ -576,8 +572,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
return -1;
}
- init_waitqueue_head(&input_dev->protocol_wait_event);
- init_waitqueue_head(&input_dev->dev_info_wait_event);
request = &input_dev->protocol_req;
@@ -607,10 +601,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
goto cleanup;
}
- input_dev->protocol_wait_condition = 0;
- wait_event_timeout(input_dev->protocol_wait_event,
- input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
- if (input_dev->protocol_wait_condition == 0) {
+ t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ);
+ if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
@@ -624,10 +616,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
goto cleanup;
}
- input_dev->device_wait_condition = 0;
- wait_event_timeout(input_dev->dev_info_wait_event,
- input_dev->device_wait_condition, msecs_to_jiffies(1000));
- if (input_dev->device_wait_condition == 0) {
+ t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ);
+ if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 06/24] Staging: hv: mousevsc: Correctly initialize the header size
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
Correctly initialize the header size.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 19cfc23..74faa26 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -590,7 +590,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
request->size = sizeof(struct synthhid_protocol_request);
request->request.header.type = SynthHidProtocolRequest;
- request->request.header.size = sizeof(unsigned long);
+ request->request.header.size = sizeof(unsigned int);
request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
pr_info("synthhid protocol request...");
--
1.7.4.1
^ permalink raw reply related
* [PATCH 05/24] Staging: hv: mousevsc: Handle the case where we may get bogus report desc size
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
Handle the case where we may get bogus report desc size from the host.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b7cc164..19cfc23 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -341,6 +341,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
/* Save the report desc */
input_device->report_desc_size = desc->desc[0].wDescriptorLength;
+ if (input_device->report_desc_size == 0)
+ goto cleanup;
input_device->report_desc = kzalloc(input_device->report_desc_size,
GFP_ATOMIC);
--
1.7.4.1
^ permalink raw reply related
* [PATCH 04/24] Staging: hv: mousevsc: Change the allocation flags to reflect interrupt context
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
Change the allocation flags to reflect interrupt context.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 016d7e5..b7cc164 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -329,7 +329,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
desc = &device_info->hid_descriptor;
WARN_ON(desc->bLength == 0);
- input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
+ input_device->hid_desc = kzalloc(desc->bLength, GFP_ATOMIC);
if (!input_device->hid_desc) {
pr_err("unable to allocate hid descriptor - size %d",
@@ -342,7 +342,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
/* Save the report desc */
input_device->report_desc_size = desc->desc[0].wDescriptorLength;
input_device->report_desc = kzalloc(input_device->report_desc_size,
- GFP_KERNEL);
+ GFP_ATOMIC);
if (!input_device->report_desc) {
pr_err("unable to allocate report descriptor - size %d",
@@ -541,7 +541,7 @@ static void mousevsc_on_channel_callback(void *context)
} else if (ret == -ENOBUFS) {
/* Handle large packet */
bufferlen = bytes_recvd;
- buffer = kzalloc(bytes_recvd, GFP_KERNEL);
+ buffer = kzalloc(bytes_recvd, GFP_ATOMIC);
if (buffer == NULL) {
buffer = packet;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 03/24] Staging: hv: mousevsc: Fixup some bogus WARN_ON() calls
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
Fix the bogus WARN_ON() calls.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 69eb00e..016d7e5 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -200,7 +200,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
static void free_input_device(struct mousevsc_dev *device)
{
- WARN_ON(atomic_read(&device->ref_count) == 0);
+ WARN_ON(atomic_read(&device->ref_count) != 0);
kfree(device);
}
@@ -327,7 +327,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
/* Save the hid desc */
desc = &device_info->hid_descriptor;
- WARN_ON(desc->bLength > 0);
+ WARN_ON(desc->bLength == 0);
input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
@@ -447,7 +447,7 @@ static void mousevsc_on_receive(struct hv_device *device,
break;
case SynthHidInitialDeviceInfo:
- WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info));
+ WARN_ON(pipe_msg->size < sizeof(struct hv_input_dev_info));
/*
* Parse out the device info into device attr,
--
1.7.4.1
^ permalink raw reply related
* [PATCH 02/24] Staging: hv: mousevsc: Get rid of the struct input_device_context
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>
The state maintained in struct input_device_context can easily be included
in the struct mousevsc_dev structure. Simplify the code by consolidating
the state.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 51 ++++++++++------------------------------
1 files changed, 13 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 44a2b23..69eb00e 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -172,15 +172,11 @@ struct mousevsc_dev {
unsigned char *report_desc;
u32 report_desc_size;
struct hv_input_dev_info hid_dev_info;
-};
-
-struct input_device_context {
- struct hv_device *device_ctx;
- struct hid_device *hid_device;
- struct hv_input_dev_info device_info;
int connected;
+ struct hid_device *hid_device;
};
+
static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
{
struct mousevsc_dev *input_dev;
@@ -402,7 +398,6 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
struct synthhid_input_report *input_report)
{
struct hv_driver *input_drv;
- struct input_device_context *input_dev_ctx;
if (!input_device->init_complete) {
pr_info("Initialization incomplete...ignoring input_report msg");
@@ -411,9 +406,8 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
input_drv = drv_to_hv_drv(input_device->device->device.driver);
- input_dev_ctx = dev_get_drvdata(&input_device->device->device);
- hid_input_report(input_dev_ctx->hid_device,
+ hid_input_report(input_device->hid_device,
HID_INPUT_REPORT, input_report->buffer, input_report->header.size, 1);
}
@@ -662,9 +656,8 @@ static void mousevsc_hid_close(struct hid_device *hid)
static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
{
- struct input_device_context *input_device_ctx =
- dev_get_drvdata(&dev->device);
struct hid_device *hid_dev;
+ struct mousevsc_dev *input_device = hv_get_drvdata(dev);
/* hid_debug = -1; */
hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL);
@@ -681,9 +674,9 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
hid_dev->ll_driver->close = mousevsc_hid_close;
hid_dev->bus = BUS_VIRTUAL;
- hid_dev->vendor = input_device_ctx->device_info.vendor;
- hid_dev->product = input_device_ctx->device_info.product;
- hid_dev->version = input_device_ctx->device_info.version;
+ hid_dev->vendor = input_device->hid_dev_info.vendor;
+ hid_dev->product = input_device->hid_dev_info.product;
+ hid_dev->version = input_device->hid_dev_info.version;
hid_dev->dev = dev->device;
sprintf(hid_dev->name, "%s",
@@ -695,7 +688,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
if (!hidinput_connect(hid_dev, 0)) {
hid_dev->claimed |= HID_CLAIMED_INPUT;
- input_device_ctx->connected = 1;
+ input_device->connected = 1;
DPRINT_INFO(INPUTVSC_DRV,
"HID device claimed by input\n");
@@ -707,7 +700,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
"input or hiddev\n");
}
- input_device_ctx->hid_device = hid_dev;
+ input_device->hid_device = hid_dev;
}
kfree(hid_dev);
@@ -719,8 +712,6 @@ static int mousevsc_on_device_add(struct hv_device *device,
int ret = 0;
struct mousevsc_dev *input_dev;
struct hv_driver *input_drv;
- struct hv_input_dev_info dev_info;
- struct input_device_context *input_device_ctx;
input_dev = alloc_input_device(device);
@@ -761,14 +752,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
input_drv = drv_to_hv_drv(input_dev->device->device.driver);
- dev_info.vendor = input_dev->hid_dev_info.vendor;
- dev_info.product = input_dev->hid_dev_info.product;
- dev_info.version = input_dev->hid_dev_info.version;
- /* Send the device info back up */
- input_device_ctx = dev_get_drvdata(&device->device);
- memcpy(&input_device_ctx->device_info, &dev_info,
- sizeof(struct hv_input_dev_info));
/* Send the report desc back up */
/* workaround SA-167 */
@@ -828,12 +812,6 @@ static int mousevsc_probe(struct hv_device *dev,
{
int ret = 0;
- struct input_device_context *input_dev_ctx;
-
- input_dev_ctx = kmalloc(sizeof(struct input_device_context),
- GFP_KERNEL);
-
- dev_set_drvdata(&dev->device, input_dev_ctx);
/* Call to the vsc driver to add the device */
ret = mousevsc_on_device_add(dev, NULL);
@@ -849,13 +827,12 @@ static int mousevsc_probe(struct hv_device *dev,
static int mousevsc_remove(struct hv_device *dev)
{
- struct input_device_context *input_dev_ctx;
+ struct mousevsc_dev *input_dev = hv_get_drvdata(dev);
int ret;
- input_dev_ctx = dev_get_drvdata(&dev->device);
- if (input_dev_ctx->connected) {
- hidinput_disconnect(input_dev_ctx->hid_device);
- input_dev_ctx->connected = 0;
+ if (input_dev->connected) {
+ hidinput_disconnect(input_dev->hid_device);
+ input_dev->connected = 0;
}
/*
@@ -868,8 +845,6 @@ static int mousevsc_remove(struct hv_device *dev)
"unable to remove vsc device (ret %d)", ret);
}
- kfree(input_dev_ctx);
-
return ret;
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 01/24] Staging: hv: mousevsc: Fixup struct hv_input_dev_info
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322456-9747-1-git-send-email-kys@microsoft.com>
This structure is protocol defined structure and must match the definition
on the host side. Make appropriate adjustments.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_mouse.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index fcb023a..44a2b23 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -30,10 +30,11 @@
* Data types
*/
struct hv_input_dev_info {
+ unsigned int size;
unsigned short vendor;
unsigned short product;
unsigned short version;
- char name[128];
+ unsigned short reserved[11];
};
/* The maximum size of a synthetic input message. */
@@ -686,7 +687,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
hid_dev->dev = dev->device;
sprintf(hid_dev->name, "%s",
- input_device_ctx->device_info.name);
+ "Microsoft Vmbus HID-compliant Mouse");
/*
* HJ Do we want to call it with a 0
@@ -763,7 +764,6 @@ static int mousevsc_on_device_add(struct hv_device *device,
dev_info.vendor = input_dev->hid_dev_info.vendor;
dev_info.product = input_dev->hid_dev_info.product;
dev_info.version = input_dev->hid_dev_info.version;
- strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
/* Send the device info back up */
input_device_ctx = dev_get_drvdata(&device->device);
--
1.7.4.1
^ permalink raw reply related
* [PATCH 0000/0024] Staging: hv: mousevsc cleanup
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: K. Y. Srinivasan
The mouse driver while being in the tree for several months now, has
never been functional. This patch set cleans up this driver and makes
the driver functional. Furthermore, this driver is now about 30% smaller.
Regards,
K. Y
^ permalink raw reply
* [PATCH] staging: hv: remove the carrier status check from netvsc_open()
From: Haiyang Zhang @ 2011-09-28 20:24 UTC (permalink / raw)
To: haiyangz, kys, gregkh, linux-kernel, devel, virtualization
Checking carrier status in netvsc_open() is not necessary.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/staging/hv/TODO | 2 --
drivers/staging/hv/netvsc_drv.c | 19 +++++++------------
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO
index fcc57c2..ed4d636 100644
--- a/drivers/staging/hv/TODO
+++ b/drivers/staging/hv/TODO
@@ -1,7 +1,5 @@
TODO:
- audit the network driver
- - checking for carrier inside open is wrong, network device API
- confusion??
- audit the scsi driver
Please send patches for this code to Greg Kroah-Hartman <gregkh@suse.de>,
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 69c233e..561ba58 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -69,20 +69,15 @@ static int netvsc_open(struct net_device *net)
struct hv_device *device_obj = net_device_ctx->device_ctx;
int ret = 0;
- if (netif_carrier_ok(net)) {
- /* Open up the device */
- ret = rndis_filter_open(device_obj);
- if (ret != 0) {
- netdev_err(net, "unable to open device (ret %d).\n",
- ret);
- return ret;
- }
-
- netif_start_queue(net);
- } else {
- netdev_err(net, "unable to open device...link is down.\n");
+ /* Open up the device */
+ ret = rndis_filter_open(device_obj);
+ if (ret != 0) {
+ netdev_err(net, "unable to open device (ret %d).\n", ret);
+ return ret;
}
+ netif_start_queue(net);
+
return ret;
}
--
1.6.3.2
^ permalink raw reply related
* [PATCH 1/1] Staging: hv: Update the TODO file
From: K. Y. Srinivasan @ 2011-09-22 19:40 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang
Now that all vmbus audit related comments have been addressed,
update the TODO file to reflect this.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/TODO | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO
index 7c9a93f..fcc57c2 100644
--- a/drivers/staging/hv/TODO
+++ b/drivers/staging/hv/TODO
@@ -1,6 +1,4 @@
TODO:
- - audit the vmbus to verify it is working properly with the
- driver model
- audit the network driver
- checking for carrier inside open is wrong, network device API
confusion??
--
1.7.4.1
^ permalink raw reply related
* RE: Hyper-V TODO file
From: KY Srinivasan @ 2011-09-22 18:22 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <20110922173618.GA5624@suse.de>
> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Thursday, September 22, 2011 1:36 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: Hyper-V TODO file
>
> On Thu, Sep 22, 2011 at 05:20:59PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:gregkh@suse.de]
> > > Sent: Thursday, September 22, 2011 1:05 PM
> > > To: KY Srinivasan
> > > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > > virtualization@lists.osdl.org
> > > Subject: Re: Hyper-V TODO file
> > >
> > > On Thu, Sep 22, 2011 at 09:17:20AM -0700, K. Y. Srinivasan wrote:
> > > >
> > > > Greg,
> > > >
> > > > With your last checkin of the patches for Hyper-V, I have addressed all of
> > > > the issues you had raised as part of the vmbus audit. Should I send you a
> > > > patch to update the TODO file to reflect this. Let me know.
> > >
> > > Yes, please send patches.
> >
> > Thanks Greg. In addition to the patch to update the TODO file, do you want me
> to
> > send you patches for moving the vmbus and util driver out of staging as well.
>
> No, I'll do that if we agree that it is ready to do so.
Fair enough! When you said earlier " Yes, please send patches", I naturally assumed that you
meant more than a single patch required to update the TODO file. I must admit that there was also
a good measure of wishful thinking on my part as well!
Regards,
K. Y
^ permalink raw reply
* Re: Hyper-V TODO file
From: Greg KH @ 2011-09-22 17:36 UTC (permalink / raw)
To: KY Srinivasan
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <6E21E5352C11B742B20C142EB499E048081E935D@TK5EX14MBXC124.redmond.corp.microsoft.com>
On Thu, Sep 22, 2011 at 05:20:59PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@suse.de]
> > Sent: Thursday, September 22, 2011 1:05 PM
> > To: KY Srinivasan
> > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > virtualization@lists.osdl.org
> > Subject: Re: Hyper-V TODO file
> >
> > On Thu, Sep 22, 2011 at 09:17:20AM -0700, K. Y. Srinivasan wrote:
> > >
> > > Greg,
> > >
> > > With your last checkin of the patches for Hyper-V, I have addressed all of
> > > the issues you had raised as part of the vmbus audit. Should I send you a
> > > patch to update the TODO file to reflect this. Let me know.
> >
> > Yes, please send patches.
>
> Thanks Greg. In addition to the patch to update the TODO file, do you want me to
> send you patches for moving the vmbus and util driver out of staging as well.
No, I'll do that if we agree that it is ready to do so.
thanks,
greg k-h
^ permalink raw reply
* RE: Hyper-V TODO file
From: KY Srinivasan @ 2011-09-22 17:20 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <20110922170450.GA4490@suse.de>
> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Thursday, September 22, 2011 1:05 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: Hyper-V TODO file
>
> On Thu, Sep 22, 2011 at 09:17:20AM -0700, K. Y. Srinivasan wrote:
> >
> > Greg,
> >
> > With your last checkin of the patches for Hyper-V, I have addressed all of
> > the issues you had raised as part of the vmbus audit. Should I send you a
> > patch to update the TODO file to reflect this. Let me know.
>
> Yes, please send patches.
Thanks Greg. In addition to the patch to update the TODO file, do you want me to
send you patches for moving the vmbus and util driver out of staging as well.
Regards,
K. Y
^ permalink raw reply
* Re: Hyper-V TODO file
From: Greg KH @ 2011-09-22 17:04 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: linux-kernel, devel, virtualization
In-Reply-To: <1316708240-25048-1-git-send-email-kys@microsoft.com>
On Thu, Sep 22, 2011 at 09:17:20AM -0700, K. Y. Srinivasan wrote:
>
> Greg,
>
> With your last checkin of the patches for Hyper-V, I have addressed all of
> the issues you had raised as part of the vmbus audit. Should I send you a
> patch to update the TODO file to reflect this. Let me know.
Yes, please send patches.
^ permalink raw reply
* Hyper-V TODO file
From: K. Y. Srinivasan @ 2011-09-22 16:17 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Greg,
With your last checkin of the patches for Hyper-V, I have addressed all of
the issues you had raised as part of the vmbus audit. Should I send you a
patch to update the TODO file to reflect this. Let me know.
Regards,
K. Y
^ permalink raw reply
* Re: Hyper-V TODO file
From: Joe Perches @ 2011-09-22 16:05 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: devel, gregkh, linux-kernel, virtualization
In-Reply-To: <1316708240-25048-1-git-send-email-kys@microsoft.com>
On Thu, 2011-09-22 at 09:17 -0700, K. Y. Srinivasan wrote:
> With your last checkin of the patches for Hyper-V, I have addressed all of
> the issues you had raised as part of the vmbus audit. Should I send you a
> patch to update the TODO file to reflect this. Let me know.
Is there really anything left to do but send
the patch that moves hv out of staging?
^ permalink raw reply
* RE: [PATCH 1/3] Staging: hv: util: Perform some service specific init/deinit in probe/remove
From: KY Srinivasan @ 2011-09-18 22:26 UTC (permalink / raw)
To: Joe Perches
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
Haiyang Zhang
In-Reply-To: <1316368394.4916.2.camel@Joe-Laptop>
> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Sunday, September 18, 2011 1:53 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 1/3] Staging: hv: util: Perform some service specific
> init/deinit in probe/remove
>
> On Sun, 2011-09-18 at 10:31 -0700, K. Y. Srinivasan wrote:
> > In preparation for modifying the util driver to fully conform to the
> > Linux Driver Model,
> []
> > diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
> []
> > static const struct hv_vmbus_device_id id_table[] = {
> > /* Shutdown guid */
> > { VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
> > - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) },
> > + 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB)
> > + .driver_data = (unsigned long)&util_shutdown },
>
> Isn't this a kernel_ulong_t ?
Yes; but kernel_ulong_t is unsigned long and this code is compiled only in the kernel.
Regards,
K. Y
>
> > + .driver_data = (unsigned long)&util_timesynch },
>
> etc.
>
>
^ permalink raw reply
* Re: [PATCH 1/3] Staging: hv: util: Perform some service specific init/deinit in probe/remove
From: Joe Perches @ 2011-09-18 17:53 UTC (permalink / raw)
To: K. Y. Srinivasan
Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1316367095-739-1-git-send-email-kys@microsoft.com>
On Sun, 2011-09-18 at 10:31 -0700, K. Y. Srinivasan wrote:
> In preparation for modifying the util driver to fully conform to the
> Linux Driver Model,
[]
> diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
[]
> static const struct hv_vmbus_device_id id_table[] = {
> /* Shutdown guid */
> { VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
> - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) },
> + 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB)
> + .driver_data = (unsigned long)&util_shutdown },
Isn't this a kernel_ulong_t ?
> + .driver_data = (unsigned long)&util_timesynch },
etc.
^ permalink raw reply
* [PATCH 3/3] Staging: hv: vmbus: Get rid of hv_cb_utils[] and other unneeded code
From: K. Y. Srinivasan @ 2011-09-18 17:31 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1316367095-739-1-git-send-email-kys@microsoft.com>
Now that the transformation of the util driver is complete,
get rid of hv_cb_utils[] and other unneeded code.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/channel_mgmt.c | 94 -------------------------------------
drivers/staging/hv/hyperv.h | 13 -----
2 files changed, 0 insertions(+), 107 deletions(-)
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 99cc334..9f00752 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -158,100 +158,6 @@ void prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
}
EXPORT_SYMBOL(prep_negotiate_resp);
-/**
- * chn_cb_negotiate() - Default handler for non IDE/SCSI/NETWORK
- * Hyper-V requests
- * @context: Pointer to argument structure.
- *
- * Set up the default handler for non device driver specific requests
- * from Hyper-V. This stub responds to the default negotiate messages
- * that come in for every non IDE/SCSI/Network request.
- * This behavior is normally overwritten in the hv_utils driver. That
- * driver handles requests like graceful shutdown, heartbeats etc.
- *
- * Mainly used by Hyper-V drivers.
- */
-void chn_cb_negotiate(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
-
- struct icmsg_hdr *icmsghdrp;
- struct icmsg_negotiate *negop = NULL;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- prep_negotiate_resp(icmsghdrp, negop, buf);
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VM_PKT_DATA_INBAND, 0);
- }
-
- kfree(buf);
-}
-EXPORT_SYMBOL(chn_cb_negotiate);
-
-/*
- * Function table used for message responses for non IDE/SCSI/Network type
- * messages. (Such as KVP/Shutdown etc)
- */
-struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
- /* 0E0B6031-5213-4934-818B-38D90CED39DB */
- /* Shutdown */
- {
- .msg_type = HV_SHUTDOWN_MSG,
- .data.b = {
- 0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
- 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
- },
- .log_msg = "Shutdown channel functionality initialized"
- },
-
- /* {9527E630-D0AE-497b-ADCE-E80AB0175CAF} */
- /* TimeSync */
- {
- .msg_type = HV_TIMESYNC_MSG,
- .data.b = {
- 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
- 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
- },
- .log_msg = "Timesync channel functionality initialized"
- },
- /* {57164f39-9115-4e78-ab55-382f3bd5422d} */
- /* Heartbeat */
- {
- .msg_type = HV_HEARTBEAT_MSG,
- .data.b = {
- 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
- 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
- },
- .log_msg = "Heartbeat channel functionality initialized"
- },
- /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
- /* KVP */
- {
- .data.b = {
- 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
- 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6
- },
- .log_msg = "KVP channel functionality initialized"
- },
-};
-EXPORT_SYMBOL(hv_cb_utils);
-
/*
* alloc_channel - Allocate and initialize a vmbus channel object
*/
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 49ef2b2..0cbfc59 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -581,11 +581,6 @@ struct vmbus_channel {
struct work_struct work;
enum vmbus_channel_state state;
- /*
- * For util channels, stash the
- * the service index for easy access.
- */
- s8 util_index;
struct vmbus_channel_offer_channel offermsg;
/*
@@ -963,12 +958,6 @@ struct ictimesync_data {
u8 flags;
} __packed;
-/* Index for each IC struct in array hv_cb_utils[] */
-#define HV_SHUTDOWN_MSG 0
-#define HV_TIMESYNC_MSG 1
-#define HV_HEARTBEAT_MSG 2
-#define HV_KVP_MSG 3
-
struct hyperv_service_callback {
u8 msg_type;
char *log_msg;
@@ -979,7 +968,5 @@ struct hyperv_service_callback {
extern void prep_negotiate_resp(struct icmsg_hdr *,
struct icmsg_negotiate *, u8 *);
-extern void chn_cb_negotiate(void *);
-extern struct hyperv_service_callback hv_cb_utils[];
#endif /* _HYPERV_H */
--
1.7.4.1
^ permalink raw reply related
* [PATCH 2/3] Staging: hv: util: Properly handle util services in the util driver
From: K. Y. Srinivasan @ 2011-09-18 17:31 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1316367095-739-1-git-send-email-kys@microsoft.com>
Now, properly handle util services in the util driver and eliminate code
that will not be necessary. In the current code, util services were
all handled not as other vmbus devices (net, block) but rather through
special handling (channel setup etc.). In this patch we handle all
services using the standard Linux Driver Model.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/channel_mgmt.c | 36 ------------------------
drivers/staging/hv/hv_kvp.c | 7 +++++
drivers/staging/hv/hv_util.c | 55 +++++++++++--------------------------
3 files changed, 23 insertions(+), 75 deletions(-)
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index c68e5fa..99cc334 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -181,24 +181,6 @@ void chn_cb_negotiate(void *context)
struct icmsg_hdr *icmsghdrp;
struct icmsg_negotiate *negop = NULL;
- if (channel->util_index >= 0) {
- /*
- * This is a properly initialized util channel.
- * Route this callback appropriately and setup state
- * so that we don't need to reroute again.
- */
- if (hv_cb_utils[channel->util_index].callback != NULL) {
- /*
- * The util driver has established a handler for
- * this service; do the magic.
- */
- channel->onchannel_callback =
- hv_cb_utils[channel->util_index].callback;
- (hv_cb_utils[channel->util_index].callback)(channel);
- return;
- }
- }
-
buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);
@@ -348,7 +330,6 @@ static void vmbus_process_offer(struct work_struct *work)
struct vmbus_channel *channel;
bool fnew = true;
int ret;
- int cnt;
unsigned long flags;
/* The next possible work is rescind handling */
@@ -410,23 +391,6 @@ static void vmbus_process_offer(struct work_struct *work)
* can cleanup properly
*/
newchannel->state = CHANNEL_OPEN_STATE;
- newchannel->util_index = -1; /* Invalid index */
-
- /* Open IC channels */
- for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
- if (!uuid_le_cmp(newchannel->offermsg.offer.if_type,
- hv_cb_utils[cnt].data) &&
- vmbus_open(newchannel, 2 * PAGE_SIZE,
- 2 * PAGE_SIZE, NULL, 0,
- chn_cb_negotiate,
- newchannel) == 0) {
- hv_cb_utils[cnt].channel = newchannel;
- newchannel->util_index = cnt;
-
- pr_info("%s\n", hv_cb_utils[cnt].log_msg);
-
- }
- }
}
}
diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
index ff0d9ab..9aa9ede 100644
--- a/drivers/staging/hv/hv_kvp.c
+++ b/drivers/staging/hv/hv_kvp.c
@@ -177,6 +177,13 @@ kvp_respond_to_host(char *key, char *value, int error)
channel = kvp_transaction.recv_channel;
req_id = kvp_transaction.recv_req_id;
+ if (channel->onchannel_callback == NULL)
+ /*
+ * We have raced with util driver being unloaded;
+ * silently return.
+ */
+ return;
+
icmsghdrp = (struct icmsg_hdr *)
&recv_buffer[sizeof(struct vmbuspipe_hdr)];
kvp_msg = (struct hv_kvp_msg *)
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index a1539a7..faa6607 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -269,19 +269,32 @@ static int util_probe(struct hv_device *dev,
if (srv->util_init) {
ret = srv->util_init(srv);
if (ret) {
- kfree(srv->recv_buffer);
- return -ENODEV;
+ ret = -ENODEV;
+ goto error1;
}
}
+ ret = vmbus_open(dev->channel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0,
+ srv->util_cb, dev->channel);
+ if (ret)
+ goto error;
+
hv_set_drvdata(dev, srv);
return 0;
+
+error:
+ if (srv->util_deinit)
+ srv->util_deinit();
+error1:
+ kfree(srv->recv_buffer);
+ return ret;
}
static int util_remove(struct hv_device *dev)
{
struct hv_util_service *srv = hv_get_drvdata(dev);
+ vmbus_close(dev->channel);
if (srv->util_deinit)
srv->util_deinit();
kfree(srv->recv_buffer);
@@ -321,51 +334,15 @@ static struct hv_driver util_drv = {
static int __init init_hyperv_utils(void)
{
- int ret;
pr_info("Registering HyperV Utility Driver\n");
-
- ret = vmbus_driver_register(&util_drv);
-
- if (ret != 0)
- return ret;
-
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
-
- hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
-
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
-
- hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
-
- return 0;
-
+ return vmbus_driver_register(&util_drv);
}
static void exit_hyperv_utils(void)
{
pr_info("De-Registered HyperV Utility Driver\n");
- if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL)
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL;
-
- if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL)
- hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL;
-
- if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL)
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL;
-
- if (hv_cb_utils[HV_KVP_MSG].channel != NULL)
- hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_KVP_MSG].callback = NULL;
-
vmbus_driver_unregister(&util_drv);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 1/3] Staging: hv: util: Perform some service specific init/deinit in probe/remove
From: K. Y. Srinivasan @ 2011-09-18 17:31 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1316367053-700-1-git-send-email-kys@microsoft.com>
In preparation for modifying the util driver to fully conform to the
Linux Driver Model, perform some service specific init and de-init
operations in util_probe()/util_remove() as opposed to in
init_hyperv_utils()/exit_hyperv_utils() as is currently done.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_kvp.c | 7 +--
drivers/staging/hv/hv_kvp.h | 2 +-
drivers/staging/hv/hv_util.c | 91 +++++++++++++++++++++++++----------------
drivers/staging/hv/hyperv.h | 13 ++++++
4 files changed, 71 insertions(+), 42 deletions(-)
diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
index 13b0ecf..ff0d9ab 100644
--- a/drivers/staging/hv/hv_kvp.c
+++ b/drivers/staging/hv/hv_kvp.c
@@ -312,16 +312,14 @@ callback_done:
}
int
-hv_kvp_init(void)
+hv_kvp_init(struct hv_util_service *srv)
{
int err;
err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
if (err)
return err;
- recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
- if (!recv_buffer)
- return -ENOMEM;
+ recv_buffer = srv->recv_buffer;
return 0;
}
@@ -330,5 +328,4 @@ void hv_kvp_deinit(void)
{
cn_del_callback(&kvp_id);
cancel_delayed_work_sync(&kvp_work);
- kfree(recv_buffer);
}
diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/staging/hv/hv_kvp.h
index 8c402f3..9b765d7 100644
--- a/drivers/staging/hv/hv_kvp.h
+++ b/drivers/staging/hv/hv_kvp.h
@@ -175,7 +175,7 @@ struct hv_kvp_msg {
struct hv_kvp_msg_enumerate kvp_data;
};
-int hv_kvp_init(void);
+int hv_kvp_init(struct hv_util_service *);
void hv_kvp_deinit(void);
void hv_kvp_onchannelcallback(void *);
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index d9460fdd..a1539a7 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -30,9 +30,27 @@
#include "hyperv.h"
#include "hv_kvp.h"
-static u8 *shut_txf_buf;
-static u8 *time_txf_buf;
-static u8 *hbeat_txf_buf;
+
+static void shutdown_onchannelcallback(void *context);
+static struct hv_util_service util_shutdown = {
+ .util_cb = shutdown_onchannelcallback,
+};
+
+static void timesync_onchannelcallback(void *context);
+static struct hv_util_service util_timesynch = {
+ .util_cb = timesync_onchannelcallback,
+};
+
+static void heartbeat_onchannelcallback(void *context);
+static struct hv_util_service util_heartbeat = {
+ .util_cb = heartbeat_onchannelcallback,
+};
+
+static struct hv_util_service util_kvp = {
+ .util_cb = hv_kvp_onchannelcallback,
+ .util_init = hv_kvp_init,
+ .util_deinit = hv_kvp_deinit,
+};
static void shutdown_onchannelcallback(void *context)
{
@@ -40,6 +58,7 @@ static void shutdown_onchannelcallback(void *context)
u32 recvlen;
u64 requestid;
u8 execute_shutdown = false;
+ u8 *shut_txf_buf = util_shutdown.recv_buffer;
struct shutdown_msg_data *shutdown_msg;
@@ -169,6 +188,7 @@ static void timesync_onchannelcallback(void *context)
u64 requestid;
struct icmsg_hdr *icmsghdrp;
struct ictimesync_data *timedatap;
+ u8 *time_txf_buf = util_timesynch.recv_buffer;
vmbus_recvpacket(channel, time_txf_buf,
PAGE_SIZE, &recvlen, &requestid);
@@ -207,6 +227,7 @@ static void heartbeat_onchannelcallback(void *context)
u64 requestid;
struct icmsg_hdr *icmsghdrp;
struct heartbeat_msg_data *heartbeat_msg;
+ u8 *hbeat_txf_buf = util_heartbeat.recv_buffer;
vmbus_recvpacket(channel, hbeat_txf_buf,
PAGE_SIZE, &recvlen, &requestid);
@@ -235,34 +256,56 @@ static void heartbeat_onchannelcallback(void *context)
}
}
-/*
- * The devices managed by the util driver don't need any additional
- * setup.
- */
static int util_probe(struct hv_device *dev,
const struct hv_vmbus_device_id *dev_id)
{
+ struct hv_util_service *srv =
+ (struct hv_util_service *)dev_id->driver_data;
+ int ret;
+
+ srv->recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!srv->recv_buffer)
+ return -ENOMEM;
+ if (srv->util_init) {
+ ret = srv->util_init(srv);
+ if (ret) {
+ kfree(srv->recv_buffer);
+ return -ENODEV;
+ }
+ }
+
+ hv_set_drvdata(dev, srv);
return 0;
}
static int util_remove(struct hv_device *dev)
{
+ struct hv_util_service *srv = hv_get_drvdata(dev);
+
+ if (srv->util_deinit)
+ srv->util_deinit();
+ kfree(srv->recv_buffer);
+
return 0;
}
static const struct hv_vmbus_device_id id_table[] = {
/* Shutdown guid */
{ VMBUS_DEVICE(0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
- 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB) },
+ 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB)
+ .driver_data = (unsigned long)&util_shutdown },
/* Time synch guid */
{ VMBUS_DEVICE(0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
- 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) },
+ 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf)
+ .driver_data = (unsigned long)&util_timesynch },
/* Heartbeat guid */
{ VMBUS_DEVICE(0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
- 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) },
+ 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d)
+ .driver_data = (unsigned long)&util_heartbeat },
/* KVP guid */
{ VMBUS_DEVICE(0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
- 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6) },
+ 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6)
+ .driver_data = (unsigned long)&util_kvp },
{ },
};
@@ -281,24 +324,11 @@ static int __init init_hyperv_utils(void)
int ret;
pr_info("Registering HyperV Utility Driver\n");
- if (hv_kvp_init())
- return -ENODEV;
-
-
- shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-
- if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
- pr_info("Unable to allocate memory for receive buffer\n");
- ret = -ENOMEM;
- goto err;
- }
ret = vmbus_driver_register(&util_drv);
if (ret != 0)
- goto err;
+ return ret;
hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
@@ -310,12 +340,6 @@ static int __init init_hyperv_utils(void)
return 0;
-err:
- kfree(shut_txf_buf);
- kfree(time_txf_buf);
- kfree(hbeat_txf_buf);
-
- return ret;
}
static void exit_hyperv_utils(void)
@@ -342,11 +366,6 @@ static void exit_hyperv_utils(void)
&chn_cb_negotiate;
hv_cb_utils[HV_KVP_MSG].callback = NULL;
- hv_kvp_deinit();
-
- kfree(shut_txf_buf);
- kfree(time_txf_buf);
- kfree(hbeat_txf_buf);
vmbus_driver_unregister(&util_drv);
}
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index 91e557b..49ef2b2 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -892,6 +892,19 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver);
#define HV_ERROR_NOT_SUPPORTED 0x80070032
#define HV_ERROR_MACHINE_LOCKED 0x800704F7
+/*
+ * While we want to handle util services as regular devices,
+ * there is only one instance of each of these services; so
+ * we statically allocate the service specific state.
+ */
+
+struct hv_util_service {
+ u8 *recv_buffer;
+ void (*util_cb)(void *);
+ int (*util_init)(struct hv_util_service *);
+ void (*util_deinit)(void);
+};
+
struct vmbuspipe_hdr {
u32 flags;
u32 msgsize;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 0000/0003] Staging: hv: Driver cleanup
From: K. Y. Srinivasan @ 2011-09-18 17:30 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: K. Y. Srinivasan
Address Greg's VmBus audit comments:
1) Make the util driver conform to the Linux Driver Model.
Regards,
K. Y
^ permalink raw reply
* RE: [PATCH 0000/0020] Staging: hv: Driver cleanup
From: KY Srinivasan @ 2011-09-17 13:26 UTC (permalink / raw)
To: Greg KH
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
In-Reply-To: <20110916180708.GA32174@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Friday, September 16, 2011 2:07 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org
> Subject: Re: [PATCH 0000/0020] Staging: hv: Driver cleanup
>
> On Tue, Sep 13, 2011 at 10:59:19AM -0700, K. Y. Srinivasan wrote:
> > Address Greg's VmBus audit comments:
> >
> > 1) Leverage driver_data field in struct hv_vmbus_device_id to
> > simplify driver code.
> >
> > 2) Make the util driver conform to the Linux Driver Model.
> >
> > 3) Get rid of the ext field in struct hv_device by using the
> > driver specific data functionality.
> >
> > 4) Implement vmbus specific wrapper functions for setting and getting
> > driver specific data..
> >
> > 5) Other general cleanup.
>
> I applied 17 of these (i.e. the ones I didn't comment on.)
Thanks Greg. Looking at your comments, it looks like the only
issue in the 3 patches not checked in is related to unnecessary
messages being put out. I will get the fixed patches out soon.
Regards,
K. Y
>
> greg k-h
^ permalink raw reply
* RE: [PATCH 06/20] Staging: hv: util: Properly handle util services in the util driver
From: KY Srinivasan @ 2011-09-17 13:26 UTC (permalink / raw)
To: Greg KH
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
Haiyang Zhang
In-Reply-To: <20110916180311.GB25531@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Friday, September 16, 2011 2:03 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 06/20] Staging: hv: util: Properly handle util services in the
> util driver
>
> On Tue, Sep 13, 2011 at 10:59:42AM -0700, K. Y. Srinivasan wrote:
> > static int __init init_hyperv_utils(void)
> > {
> > - int ret;
> > pr_info("Registering HyperV Utility Driver\n");
>
> All of these "registering" and "unregistering" messages should be
> removed, they do nothing but clutter up the logs and are pointless. You
> can find this information out any time you want by looking in sysfs
> instead of trying to parse random strings out of the kernel log.
I was just trying to preserve the messages that were being put out
In the existing code. I will get rid of these messages and send you updated
patches.
Regards,
K. Y
^ permalink raw reply
* Re: [PATCH 0000/0020] Staging: hv: Driver cleanup
From: Greg KH @ 2011-09-16 18:07 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1315936759-20623-1-git-send-email-kys@microsoft.com>
On Tue, Sep 13, 2011 at 10:59:19AM -0700, K. Y. Srinivasan wrote:
> Address Greg's VmBus audit comments:
>
> 1) Leverage driver_data field in struct hv_vmbus_device_id to
> simplify driver code.
>
> 2) Make the util driver conform to the Linux Driver Model.
>
> 3) Get rid of the ext field in struct hv_device by using the
> driver specific data functionality.
>
> 4) Implement vmbus specific wrapper functions for setting and getting
> driver specific data..
>
> 5) Other general cleanup.
I applied 17 of these (i.e. the ones I didn't comment on.)
greg k-h
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox