Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 236025
b: refs/heads/master
c: 0c3b7b2
h: refs/heads/master
i:
  236023: 3ab6152
v: v3
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Feb 18, 2011
1 parent 87c9900 commit 52054e0
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 173 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: df3493e0b3ba72f9b6192a91b24197cac41ce557
refs/heads/master: 0c3b7b2f75158f9420ceeb87d5924bdbd8d0304a
58 changes: 26 additions & 32 deletions trunk/drivers/staging/hv/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* Hank Janssen <hjanssen@microsoft.com>
*/
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/module.h>
Expand Down Expand Up @@ -243,11 +245,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
goto errorout;
}

openInfo->waitevent = osd_waitevent_create();
if (!openInfo->waitevent) {
err = -ENOMEM;
goto errorout;
}
init_waitqueue_head(&openInfo->waitevent);

openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
Expand Down Expand Up @@ -280,8 +278,15 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
goto Cleanup;
}

/* FIXME: Need to time-out here */
osd_waitevent_wait(openInfo->waitevent);
openInfo->wait_condition = 0;
wait_event_timeout(openInfo->waitevent,
openInfo->wait_condition,
msecs_to_jiffies(1000));
if (openInfo->wait_condition == 0) {
err = -ETIMEDOUT;
goto errorout;
}


if (openInfo->response.open_result.status == 0)
DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
Expand All @@ -294,7 +299,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
list_del(&openInfo->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);

kfree(openInfo->waitevent);
kfree(openInfo);
return 0;

Expand Down Expand Up @@ -509,11 +513,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
if (ret)
return ret;

msginfo->waitevent = osd_waitevent_create();
if (!msginfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
}
init_waitqueue_head(&msginfo->waitevent);

gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
Expand All @@ -533,6 +533,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
msginfo->msgsize - sizeof(*msginfo));

msginfo->wait_condition = 0;
ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
sizeof(*msginfo));
if (ret != 0) {
Expand Down Expand Up @@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,

}
}
osd_waitevent_wait(msginfo->waitevent);
wait_event_timeout(msginfo->waitevent,
msginfo->wait_condition,
msecs_to_jiffies(1000));
BUG_ON(msginfo->wait_condition == 0);


/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
Expand All @@ -582,7 +587,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
list_del(&msginfo->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);

kfree(msginfo->waitevent);
kfree(msginfo);
return ret;
}
Expand All @@ -605,11 +609,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
if (!info)
return -ENOMEM;

info->waitevent = osd_waitevent_create();
if (!info->waitevent) {
kfree(info);
return -ENOMEM;
}
init_waitqueue_head(&info->waitevent);

msg = (struct vmbus_channel_gpadl_teardown *)info->msg;

Expand All @@ -621,22 +621,20 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
list_add_tail(&info->msglistentry,
&vmbus_connection.chn_msg_list);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);

info->wait_condition = 0;
ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_gpadl_teardown));
if (ret != 0) {
/* TODO: */
/* something... */
}

osd_waitevent_wait(info->waitevent);
BUG_ON(ret != 0);
wait_event_timeout(info->waitevent,
info->wait_condition, msecs_to_jiffies(1000));
BUG_ON(info->wait_condition == 0);

/* Received a torndown response */
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&info->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);

kfree(info->waitevent);
kfree(info);
return ret;
}
Expand Down Expand Up @@ -664,18 +662,14 @@ void vmbus_close(struct vmbus_channel *channel)
if (!info)
return;

/* info->waitEvent = osd_waitevent_create(); */

msg = (struct vmbus_channel_close_channel *)info->msg;
msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
msg->child_relid = channel->offermsg.child_relid;

ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
/* TODO: */
/* something... */
}

BUG_ON(ret != 0);
/* Tear down the gpadl for the channel's ring buffer */
if (channel->ringbuffer_gpadlhandle)
vmbus_teardown_gpadl(channel,
Expand Down
46 changes: 21 additions & 25 deletions trunk/drivers/staging/hv/channel_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* Hank Janssen <hjanssen@microsoft.com>
*/
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/list.h>
Expand Down Expand Up @@ -593,7 +595,8 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
memcpy(&msginfo->response.open_result,
result,
sizeof(struct vmbus_channel_open_result));
osd_waitevent_set(msginfo->waitevent);
msginfo->wait_condition = 1;
wake_up(&msginfo->waitevent);
break;
}
}
Expand Down Expand Up @@ -643,7 +646,8 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
memcpy(&msginfo->response.gpadl_created,
gpadlcreated,
sizeof(struct vmbus_channel_gpadl_created));
osd_waitevent_set(msginfo->waitevent);
msginfo->wait_condition = 1;
wake_up(&msginfo->waitevent);
break;
}
}
Expand Down Expand Up @@ -689,7 +693,8 @@ static void vmbus_ongpadl_torndown(
memcpy(&msginfo->response.gpadl_torndown,
gpadl_torndown,
sizeof(struct vmbus_channel_gpadl_torndown));
osd_waitevent_set(msginfo->waitevent);
msginfo->wait_condition = 1;
wake_up(&msginfo->waitevent);
break;
}
}
Expand Down Expand Up @@ -730,7 +735,8 @@ static void vmbus_onversion_response(
memcpy(&msginfo->response.version_response,
version_response,
sizeof(struct vmbus_channel_version_response));
osd_waitevent_set(msginfo->waitevent);
msginfo->wait_condition = 1;
wake_up(&msginfo->waitevent);
}
}
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
Expand Down Expand Up @@ -805,44 +811,34 @@ int vmbus_request_offers(void)
if (!msginfo)
return -ENOMEM;

msginfo->waitevent = osd_waitevent_create();
if (!msginfo->waitevent) {
kfree(msginfo);
return -ENOMEM;
}
init_waitqueue_head(&msginfo->waitevent);

msg = (struct vmbus_channel_message_header *)msginfo->msg;

msg->msgtype = CHANNELMSG_REQUESTOFFERS;

/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
INSERT_TAIL_LIST(&gVmbusConnection.channelMsgList,
&msgInfo->msgListEntry);
SpinlockRelease(gVmbusConnection.channelMsgLock);*/

ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_message_header));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to request offers - %d", ret);

/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
SpinlockRelease(gVmbusConnection.channelMsgLock);*/
goto cleanup;
}

goto Cleanup;
msginfo->wait_condition = 0;
wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
msecs_to_jiffies(1000));
if (msginfo->wait_condition == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
/* osd_waitevent_wait(msgInfo->waitEvent); */

/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
SpinlockRelease(gVmbusConnection.channelMsgLock);*/


Cleanup:
if (msginfo) {
kfree(msginfo->waitevent);
cleanup:
if (msginfo)
kfree(msginfo);
}

return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/hv/channel_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ struct vmbus_channel_msginfo {
struct list_head submsglist;

/* Synchronize the request/response if needed */
struct osd_waitevent *waitevent;

int wait_condition;
wait_queue_head_t waitevent;
union {
struct vmbus_channel_version_supported version_supported;
struct vmbus_channel_open_result open_result;
Expand Down
28 changes: 20 additions & 8 deletions trunk/drivers/staging/hv/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -153,7 +167,6 @@ int vmbus_connect(void)
goto Cleanup;
}

kfree(msginfo->waitevent);
kfree(msginfo);
return 0;

Expand All @@ -174,7 +187,6 @@ int vmbus_connect(void)
}

if (msginfo) {
kfree(msginfo->waitevent);
kfree(msginfo);
}

Expand Down
Loading

0 comments on commit 52054e0

Please sign in to comment.