summaryrefslogtreecommitdiff
path: root/drivers/staging/hv/connection.c
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2011-02-11 09:59:43 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-18 13:11:03 -0800
commit0c3b7b2f75158f9420ceeb87d5924bdbd8d0304a (patch)
treedf9a27e92c5b3c2fea857e9fed706513fb9f99b4 /drivers/staging/hv/connection.c
parentdf3493e0b3ba72f9b6192a91b24197cac41ce557 (diff)
Staging: hv: Use native wait primitives
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the osd_wait_primitive where the condition was cleared potentially after the condition was signalled. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/connection.c')
-rw-r--r--drivers/staging/hv/connection.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index ed0976aad6f..51dd362188b 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -21,6 +21,8 @@
*
*/
#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@@ -97,11 +99,7 @@ int vmbus_connect(void)
goto Cleanup;
}
- msginfo->waitevent = osd_waitevent_create();
- if (!msginfo->waitevent) {
- ret = -ENOMEM;
- goto Cleanup;
- }
+ init_waitqueue_head(&msginfo->waitevent);
msg = (struct vmbus_channel_initiate_contact *)msginfo->msg;
@@ -131,14 +129,30 @@ int vmbus_connect(void)
ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_initiate_contact));
if (ret != 0) {
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&msginfo->msglistentry);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
+ flags);
goto Cleanup;
}
/* Wait for the connection response */
- osd_waitevent_wait(msginfo->waitevent);
+ msginfo->wait_condition = 0;
+ wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
+ msecs_to_jiffies(1000));
+ if (msginfo->wait_condition == 0) {
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock,
+ flags);
+ list_del(&msginfo->msglistentry);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
+ flags);
+ ret = -ETIMEDOUT;
+ goto Cleanup;
+ }
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&msginfo->msglistentry);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
/* Check if successful */
if (msginfo->response.version_response.version_supported) {
@@ -153,7 +167,6 @@ int vmbus_connect(void)
goto Cleanup;
}
- kfree(msginfo->waitevent);
kfree(msginfo);
return 0;
@@ -174,7 +187,6 @@ Cleanup:
}
if (msginfo) {
- kfree(msginfo->waitevent);
kfree(msginfo);
}