Commit 880fb89c authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Staging: hv: make Device->RequestLock 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 a98f96ee
...@@ -54,7 +54,7 @@ typedef struct _RNDIS_DEVICE { ...@@ -54,7 +54,7 @@ typedef struct _RNDIS_DEVICE {
u32 LinkStatus; u32 LinkStatus;
u32 NewRequestId; u32 NewRequestId;
HANDLE RequestLock; spinlock_t request_lock;
LIST_ENTRY RequestList; LIST_ENTRY RequestList;
unsigned char HwMacAddr[HW_MACADDR_LEN]; unsigned char HwMacAddr[HW_MACADDR_LEN];
...@@ -216,12 +216,7 @@ static inline RNDIS_DEVICE* GetRndisDevice(void) ...@@ -216,12 +216,7 @@ static inline RNDIS_DEVICE* GetRndisDevice(void)
return NULL; return NULL;
} }
device->RequestLock = SpinlockCreate(); spin_lock_init(&device->request_lock);
if (!device->RequestLock)
{
kfree(device);
return NULL;
}
INITIALIZE_LIST_HEAD(&device->RequestList); INITIALIZE_LIST_HEAD(&device->RequestList);
...@@ -232,7 +227,6 @@ static inline RNDIS_DEVICE* GetRndisDevice(void) ...@@ -232,7 +227,6 @@ static inline RNDIS_DEVICE* GetRndisDevice(void)
static inline void PutRndisDevice(RNDIS_DEVICE *Device) static inline void PutRndisDevice(RNDIS_DEVICE *Device)
{ {
SpinlockClose(Device->RequestLock);
kfree(Device); kfree(Device);
} }
...@@ -241,6 +235,7 @@ static inline RNDIS_REQUEST* GetRndisRequest(RNDIS_DEVICE *Device, u32 MessageTy ...@@ -241,6 +235,7 @@ static inline RNDIS_REQUEST* GetRndisRequest(RNDIS_DEVICE *Device, u32 MessageTy
RNDIS_REQUEST *request; RNDIS_REQUEST *request;
RNDIS_MESSAGE *rndisMessage; RNDIS_MESSAGE *rndisMessage;
RNDIS_SET_REQUEST *set; RNDIS_SET_REQUEST *set;
unsigned long flags;
request = kzalloc(sizeof(RNDIS_REQUEST), GFP_KERNEL); request = kzalloc(sizeof(RNDIS_REQUEST), GFP_KERNEL);
if (!request) if (!request)
...@@ -265,18 +260,20 @@ static inline RNDIS_REQUEST* GetRndisRequest(RNDIS_DEVICE *Device, u32 MessageTy ...@@ -265,18 +260,20 @@ static inline RNDIS_REQUEST* GetRndisRequest(RNDIS_DEVICE *Device, u32 MessageTy
set->RequestId = InterlockedIncrement((int*)&Device->NewRequestId); set->RequestId = InterlockedIncrement((int*)&Device->NewRequestId);
// Add to the request list // Add to the request list
SpinlockAcquire(Device->RequestLock); spin_lock_irqsave(&Device->request_lock, flags);
INSERT_TAIL_LIST(&Device->RequestList, &request->ListEntry); INSERT_TAIL_LIST(&Device->RequestList, &request->ListEntry);
SpinlockRelease(Device->RequestLock); spin_unlock_irqrestore(&Device->request_lock, flags);
return request; return request;
} }
static inline void PutRndisRequest(RNDIS_DEVICE *Device, RNDIS_REQUEST *Request) static inline void PutRndisRequest(RNDIS_DEVICE *Device, RNDIS_REQUEST *Request)
{ {
SpinlockAcquire(Device->RequestLock); unsigned long flags;
spin_lock_irqsave(&Device->request_lock, flags);
REMOVE_ENTRY_LIST(&Request->ListEntry); REMOVE_ENTRY_LIST(&Request->ListEntry);
SpinlockRelease(Device->RequestLock); spin_unlock_irqrestore(&Device->request_lock, flags);
WaitEventClose(Request->WaitEvent); WaitEventClose(Request->WaitEvent);
kfree(Request); kfree(Request);
...@@ -385,10 +382,11 @@ RndisFilterReceiveResponse( ...@@ -385,10 +382,11 @@ RndisFilterReceiveResponse(
LIST_ENTRY *curr; LIST_ENTRY *curr;
RNDIS_REQUEST *request=NULL; RNDIS_REQUEST *request=NULL;
bool found = false; bool found = false;
unsigned long flags;
DPRINT_ENTER(NETVSC); DPRINT_ENTER(NETVSC);
SpinlockAcquire(Device->RequestLock); spin_lock_irqsave(&Device->request_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &Device->RequestList) ITERATE_LIST_ENTRIES(anchor, curr, &Device->RequestList)
{ {
request = CONTAINING_RECORD(curr, RNDIS_REQUEST, ListEntry); request = CONTAINING_RECORD(curr, RNDIS_REQUEST, ListEntry);
...@@ -403,7 +401,7 @@ RndisFilterReceiveResponse( ...@@ -403,7 +401,7 @@ RndisFilterReceiveResponse(
break; break;
} }
} }
SpinlockRelease(Device->RequestLock); spin_unlock_irqrestore(&Device->request_lock, flags);
if (found) if (found)
{ {
......
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