aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-07-15 14:56:15 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 12:01:48 -0700
commit6436873afce6f20fecc0c5099db899b25e1e6c2b (patch)
tree4408cd43b5b17d6709e885afe77032b8ddf9a664
parent880fb89c1f23c17de6c964dca7943d2f76a8e17c (diff)
Staging: hv: make netDevice->ReceivePacketListLock 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: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/hv/NetVsc.c19
-rw-r--r--drivers/staging/hv/NetVsc.h2
2 files changed, 10 insertions, 11 deletions
diff --git a/drivers/staging/hv/NetVsc.c b/drivers/staging/hv/NetVsc.c
index a915599e1c2..7a7a382a45a 100644
--- a/drivers/staging/hv/NetVsc.c
+++ b/drivers/staging/hv/NetVsc.c
@@ -807,7 +807,7 @@ NetVscOnDeviceAdd(
// Initialize the NetVSC channel extension
netDevice->ReceiveBufferSize = NETVSC_RECEIVE_BUFFER_SIZE;
- netDevice->ReceivePacketListLock = SpinlockCreate();
+ spin_lock_init(&netDevice->receive_packet_list_lock);
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
@@ -876,8 +876,6 @@ Cleanup:
kfree(packet);
}
- SpinlockClose(netDevice->ReceivePacketListLock);
-
ReleaseOutboundNetDevice(Device);
ReleaseInboundNetDevice(Device);
@@ -952,7 +950,6 @@ NetVscOnDeviceRemove(
kfree(netvscPacket);
}
- SpinlockClose(netDevice->ReceivePacketListLock);
WaitEventClose(netDevice->ChannelInitEvent);
FreeNetDevice(netDevice);
@@ -1118,6 +1115,7 @@ NetVscOnReceive(
int i=0, j=0;
int count=0, bytesRemain=0;
+ unsigned long flags;
DPRINT_ENTER(NETVSC);
@@ -1164,7 +1162,7 @@ NetVscOnReceive(
// Grab free packets (range count + 1) to represent this xfer page packet. +1 to represent
// the xfer page packet itself. We grab it here so that we know exactly how many we can fulfil
- SpinlockAcquire(netDevice->ReceivePacketListLock);
+ spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
while (!IsListEmpty(&netDevice->ReceivePacketList))
{
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
@@ -1175,7 +1173,7 @@ NetVscOnReceive(
if (++count == vmxferpagePacket->RangeCount + 1)
break;
}
- SpinlockRelease(netDevice->ReceivePacketListLock);
+ spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
// We need at least 2 netvsc pkts (1 to represent the xfer page and at least 1 for the range)
// i.e. we can handled some of the xfer page packet ranges...
@@ -1184,7 +1182,7 @@ NetVscOnReceive(
DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. Dropping this xfer page packet completely!", count, vmxferpagePacket->RangeCount+1);
// Return it to the freelist
- SpinlockAcquire(netDevice->ReceivePacketListLock);
+ spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
for (i=count; i != 0; i--)
{
entry = REMOVE_HEAD_LIST(&listHead);
@@ -1192,7 +1190,7 @@ NetVscOnReceive(
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &netvscPacket->ListEntry);
}
- SpinlockRelease(netDevice->ReceivePacketListLock);
+ spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
NetVscSendReceiveCompletion(Device, vmxferpagePacket->d.TransactionId);
@@ -1346,6 +1344,7 @@ NetVscOnReceiveCompletion(
NETVSC_DEVICE* netDevice;
u64 transactionId=0;
bool fSendReceiveComp = false;
+ unsigned long flags;
DPRINT_ENTER(NETVSC);
@@ -1362,7 +1361,7 @@ NetVscOnReceiveCompletion(
}
// Overloading use of the lock.
- SpinlockAcquire(netDevice->ReceivePacketListLock);
+ spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
ASSERT(packet->XferPagePacket->Count > 0);
packet->XferPagePacket->Count--;
@@ -1379,7 +1378,7 @@ NetVscOnReceiveCompletion(
// Put the packet back
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
- SpinlockRelease(netDevice->ReceivePacketListLock);
+ spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
// Send a receive completion for the xfer page packet
if (fSendReceiveComp)
diff --git a/drivers/staging/hv/NetVsc.h b/drivers/staging/hv/NetVsc.h
index 3a7999db851..d6b0d678c81 100644
--- a/drivers/staging/hv/NetVsc.h
+++ b/drivers/staging/hv/NetVsc.h
@@ -62,7 +62,7 @@ typedef struct _NETVSC_DEVICE {
int NumOutstandingSends;
// List of free preallocated NETVSC_PACKET to represent receive packet
LIST_ENTRY ReceivePacketList;
- HANDLE ReceivePacketListLock;
+ spinlock_t receive_packet_list_lock;
// Send buffer allocated by us but manages by NetVSP
void * SendBuffer;