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>
This commit is contained in:
@@ -807,7 +807,7 @@ NetVscOnDeviceAdd(
|
|||||||
|
|
||||||
// Initialize the NetVSC channel extension
|
// Initialize the NetVSC channel extension
|
||||||
netDevice->ReceiveBufferSize = NETVSC_RECEIVE_BUFFER_SIZE;
|
netDevice->ReceiveBufferSize = NETVSC_RECEIVE_BUFFER_SIZE;
|
||||||
netDevice->ReceivePacketListLock = SpinlockCreate();
|
spin_lock_init(&netDevice->receive_packet_list_lock);
|
||||||
|
|
||||||
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
|
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
|
||||||
|
|
||||||
@@ -876,8 +876,6 @@ Cleanup:
|
|||||||
kfree(packet);
|
kfree(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinlockClose(netDevice->ReceivePacketListLock);
|
|
||||||
|
|
||||||
ReleaseOutboundNetDevice(Device);
|
ReleaseOutboundNetDevice(Device);
|
||||||
ReleaseInboundNetDevice(Device);
|
ReleaseInboundNetDevice(Device);
|
||||||
|
|
||||||
@@ -952,7 +950,6 @@ NetVscOnDeviceRemove(
|
|||||||
kfree(netvscPacket);
|
kfree(netvscPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinlockClose(netDevice->ReceivePacketListLock);
|
|
||||||
WaitEventClose(netDevice->ChannelInitEvent);
|
WaitEventClose(netDevice->ChannelInitEvent);
|
||||||
FreeNetDevice(netDevice);
|
FreeNetDevice(netDevice);
|
||||||
|
|
||||||
@@ -1118,6 +1115,7 @@ NetVscOnReceive(
|
|||||||
|
|
||||||
int i=0, j=0;
|
int i=0, j=0;
|
||||||
int count=0, bytesRemain=0;
|
int count=0, bytesRemain=0;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
DPRINT_ENTER(NETVSC);
|
DPRINT_ENTER(NETVSC);
|
||||||
|
|
||||||
@@ -1164,7 +1162,7 @@ NetVscOnReceive(
|
|||||||
|
|
||||||
// Grab free packets (range count + 1) to represent this xfer page packet. +1 to represent
|
// 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
|
// 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))
|
while (!IsListEmpty(&netDevice->ReceivePacketList))
|
||||||
{
|
{
|
||||||
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
|
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
|
||||||
@@ -1175,7 +1173,7 @@ NetVscOnReceive(
|
|||||||
if (++count == vmxferpagePacket->RangeCount + 1)
|
if (++count == vmxferpagePacket->RangeCount + 1)
|
||||||
break;
|
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)
|
// 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...
|
// 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);
|
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
|
// Return it to the freelist
|
||||||
SpinlockAcquire(netDevice->ReceivePacketListLock);
|
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
||||||
for (i=count; i != 0; i--)
|
for (i=count; i != 0; i--)
|
||||||
{
|
{
|
||||||
entry = REMOVE_HEAD_LIST(&listHead);
|
entry = REMOVE_HEAD_LIST(&listHead);
|
||||||
@@ -1192,7 +1190,7 @@ NetVscOnReceive(
|
|||||||
|
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &netvscPacket->ListEntry);
|
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &netvscPacket->ListEntry);
|
||||||
}
|
}
|
||||||
SpinlockRelease(netDevice->ReceivePacketListLock);
|
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
|
||||||
|
|
||||||
NetVscSendReceiveCompletion(Device, vmxferpagePacket->d.TransactionId);
|
NetVscSendReceiveCompletion(Device, vmxferpagePacket->d.TransactionId);
|
||||||
|
|
||||||
@@ -1346,6 +1344,7 @@ NetVscOnReceiveCompletion(
|
|||||||
NETVSC_DEVICE* netDevice;
|
NETVSC_DEVICE* netDevice;
|
||||||
u64 transactionId=0;
|
u64 transactionId=0;
|
||||||
bool fSendReceiveComp = false;
|
bool fSendReceiveComp = false;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
DPRINT_ENTER(NETVSC);
|
DPRINT_ENTER(NETVSC);
|
||||||
|
|
||||||
@@ -1362,7 +1361,7 @@ NetVscOnReceiveCompletion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overloading use of the lock.
|
// Overloading use of the lock.
|
||||||
SpinlockAcquire(netDevice->ReceivePacketListLock);
|
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
||||||
|
|
||||||
ASSERT(packet->XferPagePacket->Count > 0);
|
ASSERT(packet->XferPagePacket->Count > 0);
|
||||||
packet->XferPagePacket->Count--;
|
packet->XferPagePacket->Count--;
|
||||||
@@ -1379,7 +1378,7 @@ NetVscOnReceiveCompletion(
|
|||||||
|
|
||||||
// Put the packet back
|
// Put the packet back
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
|
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
|
// Send a receive completion for the xfer page packet
|
||||||
if (fSendReceiveComp)
|
if (fSendReceiveComp)
|
||||||
|
@@ -62,7 +62,7 @@ typedef struct _NETVSC_DEVICE {
|
|||||||
int NumOutstandingSends;
|
int NumOutstandingSends;
|
||||||
// List of free preallocated NETVSC_PACKET to represent receive packet
|
// List of free preallocated NETVSC_PACKET to represent receive packet
|
||||||
LIST_ENTRY ReceivePacketList;
|
LIST_ENTRY ReceivePacketList;
|
||||||
HANDLE ReceivePacketListLock;
|
spinlock_t receive_packet_list_lock;
|
||||||
|
|
||||||
// Send buffer allocated by us but manages by NetVSP
|
// Send buffer allocated by us but manages by NetVSP
|
||||||
void * SendBuffer;
|
void * SendBuffer;
|
||||||
|
Reference in New Issue
Block a user