Commit dd0813b6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Staging: hv: make gVmbusConnection.ChannelMsgLock a real spinlock

Don't use the wrapper functions for this lock, make it a real
lock so that we know what is going on.

I don't think we really want to be doing a irqsave for this code, but I
left it alone to preserve the original codepath.  It should be reviewed
later.

Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6436873a
...@@ -214,6 +214,7 @@ VmbusChannelOpen( ...@@ -214,6 +214,7 @@ VmbusChannelOpen(
VMBUS_CHANNEL_OPEN_CHANNEL* openMsg; VMBUS_CHANNEL_OPEN_CHANNEL* openMsg;
VMBUS_CHANNEL_MSGINFO* openInfo; VMBUS_CHANNEL_MSGINFO* openInfo;
void *in, *out; void *in, *out;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
...@@ -280,9 +281,9 @@ VmbusChannelOpen( ...@@ -280,9 +281,9 @@ VmbusChannelOpen(
memcpy(openMsg->UserData, UserData, UserDataLen); memcpy(openMsg->UserData, UserData, UserDataLen);
} }
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &openInfo->MsgListEntry); INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &openInfo->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Sending channel open msg..."); DPRINT_DBG(VMBUS, "Sending channel open msg...");
...@@ -306,9 +307,9 @@ VmbusChannelOpen( ...@@ -306,9 +307,9 @@ VmbusChannelOpen(
} }
Cleanup: Cleanup:
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&openInfo->MsgListEntry); REMOVE_ENTRY_LIST(&openInfo->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
WaitEventClose(openInfo->WaitEvent); WaitEventClose(openInfo->WaitEvent);
kfree(openInfo); kfree(openInfo);
...@@ -531,6 +532,7 @@ VmbusChannelEstablishGpadl( ...@@ -531,6 +532,7 @@ VmbusChannelEstablishGpadl(
LIST_ENTRY* anchor; LIST_ENTRY* anchor;
LIST_ENTRY* curr; LIST_ENTRY* curr;
u32 nextGpadlHandle; u32 nextGpadlHandle;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
...@@ -549,9 +551,9 @@ VmbusChannelEstablishGpadl( ...@@ -549,9 +551,9 @@ VmbusChannelEstablishGpadl(
DumpGpadlHeader(gpadlMsg); DumpGpadlHeader(gpadlMsg);
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry); INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d", Kbuffer, Size, msgCount); DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d", Kbuffer, Size, msgCount);
...@@ -592,9 +594,9 @@ VmbusChannelEstablishGpadl( ...@@ -592,9 +594,9 @@ VmbusChannelEstablishGpadl(
*GpadlHandle = gpadlMsg->Gpadl; *GpadlHandle = gpadlMsg->Gpadl;
Cleanup: Cleanup:
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry); REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
WaitEventClose(msgInfo->WaitEvent); WaitEventClose(msgInfo->WaitEvent);
kfree(msgInfo); kfree(msgInfo);
...@@ -624,6 +626,7 @@ VmbusChannelTeardownGpadl( ...@@ -624,6 +626,7 @@ VmbusChannelTeardownGpadl(
int ret=0; int ret=0;
VMBUS_CHANNEL_GPADL_TEARDOWN *msg; VMBUS_CHANNEL_GPADL_TEARDOWN *msg;
VMBUS_CHANNEL_MSGINFO* info; VMBUS_CHANNEL_MSGINFO* info;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
...@@ -640,9 +643,9 @@ VmbusChannelTeardownGpadl( ...@@ -640,9 +643,9 @@ VmbusChannelTeardownGpadl(
msg->ChildRelId = Channel->OfferMsg.ChildRelId; msg->ChildRelId = Channel->OfferMsg.ChildRelId;
msg->Gpadl = GpadlHandle; msg->Gpadl = GpadlHandle;
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &info->MsgListEntry); INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &info->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
ret = VmbusPostMessage(msg, sizeof(VMBUS_CHANNEL_GPADL_TEARDOWN)); ret = VmbusPostMessage(msg, sizeof(VMBUS_CHANNEL_GPADL_TEARDOWN));
if (ret != 0) if (ret != 0)
...@@ -653,9 +656,9 @@ VmbusChannelTeardownGpadl( ...@@ -653,9 +656,9 @@ VmbusChannelTeardownGpadl(
WaitEventWait(info->WaitEvent); WaitEventWait(info->WaitEvent);
// Received a torndown response // Received a torndown response
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&info->MsgListEntry); REMOVE_ENTRY_LIST(&info->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
WaitEventClose(info->WaitEvent); WaitEventClose(info->WaitEvent);
kfree(info); kfree(info);
......
...@@ -472,13 +472,14 @@ VmbusChannelOnOpenResult( ...@@ -472,13 +472,14 @@ VmbusChannelOnOpenResult(
VMBUS_CHANNEL_MSGINFO* msgInfo; VMBUS_CHANNEL_MSGINFO* msgInfo;
VMBUS_CHANNEL_MESSAGE_HEADER* requestHeader; VMBUS_CHANNEL_MESSAGE_HEADER* requestHeader;
VMBUS_CHANNEL_OPEN_CHANNEL* openMsg; VMBUS_CHANNEL_OPEN_CHANNEL* openMsg;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
DPRINT_DBG(VMBUS, "vmbus open result - %d", result->Status); DPRINT_DBG(VMBUS, "vmbus open result - %d", result->Status);
// Find the open msg, copy the result and signal/unblock the wait event // Find the open msg, copy the result and signal/unblock the wait event
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
{ {
...@@ -497,7 +498,7 @@ VmbusChannelOnOpenResult( ...@@ -497,7 +498,7 @@ VmbusChannelOnOpenResult(
} }
} }
} }
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
...@@ -525,13 +526,14 @@ VmbusChannelOnGpadlCreated( ...@@ -525,13 +526,14 @@ VmbusChannelOnGpadlCreated(
VMBUS_CHANNEL_MSGINFO *msgInfo; VMBUS_CHANNEL_MSGINFO *msgInfo;
VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader; VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;
VMBUS_CHANNEL_GPADL_HEADER *gpadlHeader; VMBUS_CHANNEL_GPADL_HEADER *gpadlHeader;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d", gpadlCreated->CreationStatus); DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d", gpadlCreated->CreationStatus);
// Find the establish msg, copy the result and signal/unblock the wait event // Find the establish msg, copy the result and signal/unblock the wait event
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
{ {
...@@ -551,7 +553,7 @@ VmbusChannelOnGpadlCreated( ...@@ -551,7 +553,7 @@ VmbusChannelOnGpadlCreated(
} }
} }
} }
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
...@@ -579,11 +581,12 @@ VmbusChannelOnGpadlTorndown( ...@@ -579,11 +581,12 @@ VmbusChannelOnGpadlTorndown(
VMBUS_CHANNEL_MSGINFO* msgInfo; VMBUS_CHANNEL_MSGINFO* msgInfo;
VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader; VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;
VMBUS_CHANNEL_GPADL_TEARDOWN *gpadlTeardown; VMBUS_CHANNEL_GPADL_TEARDOWN *gpadlTeardown;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
// Find the open msg, copy the result and signal/unblock the wait event // Find the open msg, copy the result and signal/unblock the wait event
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
{ {
...@@ -602,7 +605,7 @@ VmbusChannelOnGpadlTorndown( ...@@ -602,7 +605,7 @@ VmbusChannelOnGpadlTorndown(
} }
} }
} }
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
...@@ -630,10 +633,11 @@ VmbusChannelOnVersionResponse( ...@@ -630,10 +633,11 @@ VmbusChannelOnVersionResponse(
VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader; VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;
VMBUS_CHANNEL_INITIATE_CONTACT *initiate; VMBUS_CHANNEL_INITIATE_CONTACT *initiate;
VMBUS_CHANNEL_VERSION_RESPONSE *versionResponse = (VMBUS_CHANNEL_VERSION_RESPONSE*)hdr; VMBUS_CHANNEL_VERSION_RESPONSE *versionResponse = (VMBUS_CHANNEL_VERSION_RESPONSE*)hdr;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList)
{ {
...@@ -647,7 +651,7 @@ VmbusChannelOnVersionResponse( ...@@ -647,7 +651,7 @@ VmbusChannelOnVersionResponse(
WaitEventSet(msgInfo->WaitEvent); WaitEventSet(msgInfo->WaitEvent);
} }
} }
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
......
...@@ -53,6 +53,7 @@ VmbusConnect( ...@@ -53,6 +53,7 @@ VmbusConnect(
int ret=0; int ret=0;
VMBUS_CHANNEL_MSGINFO *msgInfo=NULL; VMBUS_CHANNEL_MSGINFO *msgInfo=NULL;
VMBUS_CHANNEL_INITIATE_CONTACT *msg; VMBUS_CHANNEL_INITIATE_CONTACT *msg;
unsigned long flags;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
...@@ -65,7 +66,7 @@ VmbusConnect( ...@@ -65,7 +66,7 @@ VmbusConnect(
gVmbusConnection.WorkQueue = WorkQueueCreate("vmbusQ"); gVmbusConnection.WorkQueue = WorkQueueCreate("vmbusQ");
INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelMsgList); INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
gVmbusConnection.ChannelMsgLock = SpinlockCreate(); spin_lock_init(&gVmbusConnection.channelmsg_lock);
INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelList); INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelList);
gVmbusConnection.ChannelLock = SpinlockCreate(); gVmbusConnection.ChannelLock = SpinlockCreate();
...@@ -107,9 +108,9 @@ VmbusConnect( ...@@ -107,9 +108,9 @@ VmbusConnect(
// Add to list before we send the request since we may receive the response // Add to list before we send the request since we may receive the response
// before returning from this routine // before returning from this routine
SpinlockAcquire(gVmbusConnection.ChannelMsgLock); spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry); INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry);
SpinlockRelease(gVmbusConnection.ChannelMsgLock); spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, monitor1 pfn %llx,, monitor2 pfn %llx", DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, monitor1 pfn %llx,, monitor2 pfn %llx",
msg->InterruptPage, msg->MonitorPage1, msg->MonitorPage2); msg->InterruptPage, msg->MonitorPage1, msg->MonitorPage2);
...@@ -156,7 +157,6 @@ VmbusConnect( ...@@ -156,7 +157,6 @@ VmbusConnect(
WorkQueueClose(gVmbusConnection.WorkQueue); WorkQueueClose(gVmbusConnection.WorkQueue);
SpinlockClose(gVmbusConnection.ChannelLock); SpinlockClose(gVmbusConnection.ChannelLock);
SpinlockClose(gVmbusConnection.ChannelMsgLock);
if (gVmbusConnection.InterruptPage) if (gVmbusConnection.InterruptPage)
{ {
...@@ -222,8 +222,6 @@ VmbusDisconnect( ...@@ -222,8 +222,6 @@ VmbusDisconnect(
// TODO: iterate thru the msg list and free up // TODO: iterate thru the msg list and free up
SpinlockClose(gVmbusConnection.ChannelMsgLock);
WorkQueueClose(gVmbusConnection.WorkQueue); WorkQueueClose(gVmbusConnection.WorkQueue);
gVmbusConnection.ConnectState = Disconnected; gVmbusConnection.ConnectState = Disconnected;
......
...@@ -80,7 +80,7 @@ typedef struct _VMBUS_CONNECTION { ...@@ -80,7 +80,7 @@ typedef struct _VMBUS_CONNECTION {
// 2 pages - 1st page for parent->child notification and 2nd is child->parent notification // 2 pages - 1st page for parent->child notification and 2nd is child->parent notification
void * MonitorPages; void * MonitorPages;
LIST_ENTRY ChannelMsgList; LIST_ENTRY ChannelMsgList;
HANDLE ChannelMsgLock; spinlock_t channelmsg_lock;
// List of channels // List of channels
LIST_ENTRY ChannelList; LIST_ENTRY ChannelList;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment