Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 200696
b: refs/heads/master
c: 8b5d6d3
h: refs/heads/master
v: v3
  • Loading branch information
Haiyang Zhang authored and Greg Kroah-Hartman committed Jun 30, 2010
1 parent 36b1176 commit 9a5e8a6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 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: 6c2fd308045ba902fbe9f4408daa7b949fa8f5a1
refs/heads/master: 8b5d6d3bd3e34e4cc67d875c8c88007c1c9aa960
41 changes: 30 additions & 11 deletions trunk/drivers/staging/hv/channel_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/completion.h>
#include "osd.h"
#include "logging.h"
#include "vmbus_private.h"
Expand Down Expand Up @@ -293,6 +294,25 @@ void FreeVmbusChannel(struct vmbus_channel *Channel)
Channel);
}


DECLARE_COMPLETION(hv_channel_ready);

/*
* Count initialized channels, and ensure all channels are ready when hv_vmbus
* module loading completes.
*/
static void count_hv_channel(void)
{
static int counter;
unsigned long flags;

spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
if (++counter == MAX_MSG_TYPES)
complete(&hv_channel_ready);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
}


/*
* VmbusChannelProcessOffer - Process the offer by creating a channel/device
* associated with this offer
Expand Down Expand Up @@ -373,22 +393,21 @@ static void VmbusChannelProcessOffer(void *context)
* can cleanup properly
*/
newChannel->State = CHANNEL_OPEN_STATE;
cnt = 0;

while (cnt != MAX_MSG_TYPES) {
/* Open IC channels */
for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType,
&hv_cb_utils[cnt].data,
sizeof(struct hv_guid)) == 0) {
sizeof(struct hv_guid)) == 0 &&
VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
2 * PAGE_SIZE, NULL, 0,
hv_cb_utils[cnt].callback,
newChannel) == 0) {
hv_cb_utils[cnt].channel = newChannel;
DPRINT_INFO(VMBUS, "%s",
hv_cb_utils[cnt].log_msg);

if (VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
2 * PAGE_SIZE, NULL, 0,
hv_cb_utils[cnt].callback,
newChannel) == 0)
hv_cb_utils[cnt].channel = newChannel;
hv_cb_utils[cnt].log_msg);
count_hv_channel();
}
cnt++;
}
}
DPRINT_EXIT(VMBUS);
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/staging/hv/vmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx);
void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
void vmbus_get_interface(struct vmbus_channel_interface *interface);

extern struct completion hv_channel_ready;

#endif /* _VMBUS_H_ */
3 changes: 3 additions & 0 deletions trunk/drivers/staging/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/pci.h>
#include <linux/dmi.h>
#include <linux/slab.h>
#include <linux/completion.h>
#include "version_info.h"
#include "osd.h"
#include "logging.h"
Expand Down Expand Up @@ -356,6 +357,8 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv))

vmbus_drv_obj->GetChannelOffers();

wait_for_completion(&hv_channel_ready);

cleanup:
DPRINT_EXIT(VMBUS_DRV);

Expand Down

0 comments on commit 9a5e8a6

Please sign in to comment.