Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 162286
b: refs/heads/master
c: 53af545
h: refs/heads/master
v: v3
  • Loading branch information
Bill Pemberton authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 96dc104 commit 6e3f6d1
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 66 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: d29274efb73735c6a94f20214b1e4ea994da8848
refs/heads/master: 53af545b277508d6b4829e90546cbd1beef536a9
34 changes: 18 additions & 16 deletions trunk/drivers/staging/hv/Channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
memcpy(openMsg->UserData, UserData, UserDataLen);

spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&openInfo->MsgListEntry);
list_add_tail(&openInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);

DPRINT_DBG(VMBUS, "Sending channel open msg...");
Expand All @@ -271,7 +271,7 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,

Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&openInfo->MsgListEntry);
list_del(&openInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);

kfree(openInfo->WaitEvent);
Expand Down Expand Up @@ -362,7 +362,7 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct gpa_range) + pfnCount * sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL);

INITIALIZE_LIST_HEAD(&msgHeader->SubMsgList);
INIT_LIST_HEAD(&msgHeader->SubMsgList);
msgHeader->MessageSize = msgSize;

gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
Expand Down Expand Up @@ -411,8 +411,8 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
gpadlBody->Pfn[i] = pfn + pfnSum + i;

/* add to msg header */
INSERT_TAIL_LIST(&msgHeader->SubMsgList,
&msgBody->MsgListEntry);
list_add_tail(&msgBody->MsgListEntry,
&msgHeader->SubMsgList);
pfnSum += pfnCurr;
pfnLeft -= pfnCurr;
}
Expand Down Expand Up @@ -457,8 +457,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_msginfo *subMsgInfo;
u32 msgCount;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
u32 nextGpadlHandle;
unsigned long flags;
int ret;
Expand All @@ -481,10 +480,10 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
DumpGpadlHeader(gpadlMsg);

spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&msgInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&msgInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);

spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
Kbuffer, Size, msgCount);

Expand All @@ -499,7 +498,9 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
}

if (msgCount > 1) {
ITERATE_LIST_ENTRIES(anchor, curr, &msgInfo->SubMsgList) {
list_for_each(curr, &msgInfo->SubMsgList) {

/* FIXME: should this use list_entry() instead ? */
subMsgInfo = (struct vmbus_channel_msginfo *)curr;
gpadlBody =
(struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
Expand Down Expand Up @@ -532,7 +533,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,

Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);

kfree(msgInfo->WaitEvent);
Expand Down Expand Up @@ -570,7 +571,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg->Gpadl = GpadlHandle;

spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &info->MsgListEntry);
list_add_tail(&info->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);

ret = VmbusPostMessage(msg,
Expand All @@ -584,7 +586,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)

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

kfree(info->WaitEvent);
Expand Down Expand Up @@ -651,7 +653,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)

if (Channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
REMOVE_ENTRY_LIST(&Channel->ListEntry);
list_del(&Channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);

FreeVmbusChannel(Channel);
Expand Down
50 changes: 21 additions & 29 deletions trunk/drivers/staging/hv/ChannelMgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/list.h>
#include "osd.h"
#include "logging.h"
#include "VmbusPrivate.h"
Expand Down Expand Up @@ -136,8 +137,6 @@ static void VmbusChannelProcessOffer(void *context)
{
struct vmbus_channel *newChannel = context;
struct vmbus_channel *channel;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
bool fNew = true;
int ret;
unsigned long flags;
Expand All @@ -147,10 +146,7 @@ static void VmbusChannelProcessOffer(void *context)
/* Make sure this is a new offer */
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);

ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) {
channel = CONTAINING_RECORD(curr, struct vmbus_channel,
ListEntry);

list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
if (!memcmp(&channel->OfferMsg.Offer.InterfaceType,
&newChannel->OfferMsg.Offer.InterfaceType,
sizeof(struct hv_guid)) &&
Expand All @@ -163,8 +159,8 @@ static void VmbusChannelProcessOffer(void *context)
}

if (fNew)
INSERT_TAIL_LIST(&gVmbusConnection.ChannelList,
&newChannel->ListEntry);
list_add_tail(&newChannel->ListEntry,
&gVmbusConnection.ChannelList);

spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);

Expand Down Expand Up @@ -201,7 +197,7 @@ static void VmbusChannelProcessOffer(void *context)
newChannel->OfferMsg.ChildRelId);

spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
REMOVE_ENTRY_LIST(&newChannel->ListEntry);
list_del(&newChannel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);

FreeVmbusChannel(newChannel);
Expand Down Expand Up @@ -360,8 +356,7 @@ static void VmbusChannelOnOffersDelivered(
static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_open_result *result;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_open_channel *openMsg;
Expand All @@ -377,7 +372,8 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);

ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;

Expand Down Expand Up @@ -408,8 +404,7 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_gpadl_created *gpadlCreated;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_gpadl_header *gpadlHeader;
Expand All @@ -427,7 +422,8 @@ static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr)
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);

ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;

Expand Down Expand Up @@ -461,8 +457,7 @@ static void VmbusChannelOnGpadlTorndown(
struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_gpadl_torndown *gpadlTorndown;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_gpadl_teardown *gpadlTeardown;
Expand All @@ -477,7 +472,8 @@ static void VmbusChannelOnGpadlTorndown(
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);

ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;

Expand Down Expand Up @@ -508,8 +504,7 @@ static void VmbusChannelOnGpadlTorndown(
static void VmbusChannelOnVersionResponse(
struct vmbus_channel_message_header *hdr)
{
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_initiate_contact *initiate;
Expand All @@ -521,7 +516,8 @@ static void VmbusChannelOnVersionResponse(
versionResponse = (struct vmbus_channel_version_response *)hdr;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);

ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;

Expand Down Expand Up @@ -659,23 +655,19 @@ int VmbusChannelRequestOffers(void)
*/
void VmbusChannelReleaseUnattachedChannels(void)
{
LIST_ENTRY *entry;
struct vmbus_channel *channel;
struct vmbus_channel *channel, *pos;
struct vmbus_channel *start = NULL;
unsigned long flags;

spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);

while (!IsListEmpty(&gVmbusConnection.ChannelList)) {
entry = TOP_LIST_ENTRY(&gVmbusConnection.ChannelList);
channel = CONTAINING_RECORD(entry, struct vmbus_channel,
ListEntry);

list_for_each_entry_safe(channel, pos, &gVmbusConnection.ChannelList,
ListEntry) {
if (channel == start)
break;

if (!channel->DeviceObject->Driver) {
REMOVE_ENTRY_LIST(&channel->ListEntry);
list_del(&channel->ListEntry);
DPRINT_INFO(VMBUS,
"Releasing unattached device object %p",
channel->DeviceObject);
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/staging/hv/ChannelMgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef _CHANNEL_MGMT_H_
#define _CHANNEL_MGMT_H_

#include "List.h"
#include <linux/list.h>
#include "RingBuffer.h"
#include "VmbusChannelInterface.h"
#include "VmbusPacketFormat.h"
Expand Down Expand Up @@ -225,7 +225,7 @@ enum vmbus_channel_state {
};

struct vmbus_channel {
LIST_ENTRY ListEntry;
struct list_head ListEntry;

struct hv_device *DeviceObject;

Expand Down Expand Up @@ -281,10 +281,10 @@ struct vmbus_channel_debug_info {
*/
struct vmbus_channel_msginfo {
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
struct list_head MsgListEntry;

/* So far, this is only used to handle gpadl body message */
LIST_ENTRY SubMsgList;
struct list_head SubMsgList;

/* Synchronize the request/response if needed */
struct osd_waitevent *WaitEvent;
Expand Down
20 changes: 8 additions & 12 deletions trunk/drivers/staging/hv/Connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ int VmbusConnect(void)
goto Cleanup;
}

INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
INIT_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
spin_lock_init(&gVmbusConnection.channelmsg_lock);

INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelList);
INIT_LIST_HEAD(&gVmbusConnection.ChannelList);
spin_lock_init(&gVmbusConnection.channel_lock);

/*
Expand Down Expand Up @@ -112,8 +112,9 @@ int VmbusConnect(void)
* receive the response before returning from this routine
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&msgInfo->MsgListEntry);
list_add_tail(&msgInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);

spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);

DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
Expand All @@ -124,14 +125,14 @@ int VmbusConnect(void)
ret = VmbusPostMessage(msg,
sizeof(struct vmbus_channel_initiate_contact));
if (ret != 0) {
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);
goto Cleanup;
}

/* Wait for the connection response */
osd_WaitEventWait(msgInfo->WaitEvent);

REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);

/* Check if successful */
if (msgInfo->Response.VersionResponse.VersionSupported) {
Expand Down Expand Up @@ -223,15 +224,10 @@ struct vmbus_channel *GetChannelFromRelId(u32 relId)
{
struct vmbus_channel *channel;
struct vmbus_channel *foundChannel = NULL;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
unsigned long flags;

spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) {
channel = CONTAINING_RECORD(curr, struct vmbus_channel,
ListEntry);

list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
if (channel->OfferMsg.ChildRelId == relId) {
foundChannel = channel;
break;
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/staging/hv/VmbusPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "ChannelMgmt.h"
#include "ChannelInterface.h"
#include "RingBuffer.h"
#include "List.h"
#include <linux/list.h>


/*
Expand Down Expand Up @@ -76,11 +76,11 @@ struct VMBUS_CONNECTION {
* is child->parent notification
*/
void *MonitorPages;
LIST_ENTRY ChannelMsgList;
struct list_head ChannelMsgList;
spinlock_t channelmsg_lock;

/* List of channels */
LIST_ENTRY ChannelList;
struct list_head ChannelList;
spinlock_t channel_lock;

struct workqueue_struct *WorkQueue;
Expand All @@ -89,7 +89,7 @@ struct VMBUS_CONNECTION {

struct VMBUS_MSGINFO {
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
struct list_head MsgListEntry;

/* Synchronize the request/response if needed */
struct osd_waitevent *WaitEvent;
Expand Down

0 comments on commit 6e3f6d1

Please sign in to comment.