Author: cgutman
Date: Fri Apr 10 23:55:07 2009
New Revision: 40446
URL:
http://svn.reactos.org/svn/reactos?rev=40446&view=rev
Log:
- Acquire the adapter lock instead of just raising to DISPATCH_LEVEL (MSDN hints at this
in various areas)
Modified:
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Fri Apr 10 23:55:07
2009
@@ -355,11 +355,9 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
-
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+
Adapter->NdisMiniportBlock.PendingRequest = NULL;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
if( MacBlock->Binding->RequestCompleteHandler ) {
(*MacBlock->Binding->RequestCompleteHandler)(
@@ -367,7 +365,7 @@
Request,
Status);
}
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
VOID NTAPI
@@ -384,6 +382,7 @@
* Status = Status of send operation
*/
{
+ PLOGICAL_ADAPTER Adapter = MiniportAdapterHandle;
PADAPTER_BINDING AdapterBinding;
KIRQL OldIrql;
@@ -391,12 +390,12 @@
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -417,6 +416,7 @@
IN NDIS_STATUS Status,
IN UINT BytesTransferred)
{
+ PLOGICAL_ADAPTER Adapter = MiniportAdapterHandle;
PADAPTER_BINDING AdapterBinding;
KIRQL OldIrql;
@@ -424,13 +424,13 @@
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.TransferDataCompleteHandler)(
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status,
BytesTransferred);
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -605,7 +605,7 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
/* call the miniport's queryinfo handler */
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid,
@@ -613,7 +613,7 @@
Size,
BytesWritten,
&BytesNeeded);
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
/* FIXME: Wait in pending case! */
@@ -634,11 +634,11 @@
BOOLEAN Ret = FALSE;
KIRQL OldIrql;
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
if
(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
Ret =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext);
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return Ret;
}
@@ -667,16 +667,14 @@
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_START, NULL, 0);
NdisMIndicateStatusComplete(Adapter);
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
AddressingReset);
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->NdisMiniportBlock.ResetStatus = Status;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
-
- KeLowerIrql(OldIrql);
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (Status != NDIS_STATUS_PENDING) {
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
@@ -854,11 +852,9 @@
KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
-
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+
Adapter->NdisMiniportBlock.PendingRequest = NdisRequest;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
switch (NdisRequest->RequestType)
{
@@ -887,12 +883,10 @@
}
if (Status != NDIS_STATUS_PENDING) {
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->NdisMiniportBlock.PendingRequest = NULL;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
- }
-
- KeLowerIrql(OldIrql);
+ }
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return Status;
}
@@ -909,12 +903,10 @@
{
PLOGICAL_ADAPTER Adapter =
(PLOGICAL_ADAPTER)MiniportAdapterHandle;
- KIRQL OldIrql;
ASSERT(Adapter);
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ /* This isn't a handler supplied by the miniport */
if (Adapter->NdisMiniportBlock.SetCompleteHandler)
(Adapter->NdisMiniportBlock.SetCompleteHandler)(MiniportAdapterHandle, Status);
- KeLowerIrql(OldIrql);
}
@@ -930,12 +922,10 @@
{
PLOGICAL_ADAPTER Adapter =
(PLOGICAL_ADAPTER)MiniportAdapterHandle;
- KIRQL OldIrql;
ASSERT(Adapter);
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ /* This isn't a handler supplied by the miniport */
if( Adapter->NdisMiniportBlock.QueryCompleteHandler )
(Adapter->NdisMiniportBlock.QueryCompleteHandler)(MiniportAdapterHandle, Status);
- KeLowerIrql(OldIrql);
}
VOID
@@ -980,13 +970,11 @@
else
{
/* SendPackets is called at DISPATCH_LEVEL for all serialized
miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
- {
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock,
&RaiseOldIrql);
NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets
handler\n"));
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
(PPNDIS_PACKET)&WorkItemContext, 1);
- }
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock,
RaiseOldIrql);
NdisStatus = NDIS_GET_PACKET_STATUS((PNDIS_PACKET)WorkItemContext);
if( NdisStatus == NDIS_STATUS_RESOURCES ) {
@@ -1008,13 +996,13 @@
else
{
/* Send is called at DISPATCH_LEVEL for all serialized miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock,
&RaiseOldIrql);
NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send
handler\n"));
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
(PNDIS_PACKET)WorkItemContext,
((PNDIS_PACKET)WorkItemContext)->Private.Flags);
NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send
handler\n"));
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock,
RaiseOldIrql);
if( NdisStatus == NDIS_STATUS_RESOURCES ) {
MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
break;
@@ -1046,19 +1034,14 @@
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_START, NULL, 0);
NdisMIndicateStatusComplete(Adapter);
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
&AddressingReset);
- if (NdisStatus == NDIS_STATUS_PENDING)
- {
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
- Adapter->NdisMiniportBlock.ResetStatus = NDIS_STATUS_PENDING;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
- }
-
- KeLowerIrql(OldIrql);
+ Adapter->NdisMiniportBlock.ResetStatus = NdisStatus;
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
if (NdisStatus != NDIS_STATUS_PENDING)
MiniResetComplete(Adapter, NdisStatus, AddressingReset);
Modified: trunk/reactos/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Fri Apr 10 23:55:07
2009
@@ -204,13 +204,11 @@
NdisStatus = NDIS_STATUS_PENDING;
} else {
/* SendPackets is called at DISPATCH_LEVEL for all serialized miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
- {
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock,
&RaiseOldIrql);
NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets
handler\n"));
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext, &Packet, 1);
- }
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, RaiseOldIrql);
NdisStatus = NDIS_GET_PACKET_STATUS(Packet);
if (NdisStatus == NDIS_STATUS_RESOURCES) {
@@ -229,12 +227,12 @@
NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send
handler\n"));
} else {
/* Send is called at DISPATCH_LEVEL for all serialized miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock,
&RaiseOldIrql);
NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send
handler\n"));
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext, Packet,
Packet->Private.Flags);
NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send
handler\n"));
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, RaiseOldIrql);
if (NdisStatus == NDIS_STATUS_RESOURCES) {
MiniQueueWorkItem(Adapter, NdisWorkItemSend, Packet, TRUE);
@@ -274,8 +272,6 @@
Adapter = AdapterBinding->Adapter;
ASSERT(Adapter);
-
- /* if the following is not true, KeRaiseIrql() below will break */
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
/* XXX what is this crazy black magic? */
@@ -326,10 +322,10 @@
else
{
/* SendPackets is called at DISPATCH_LEVEL for all serialized miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &RaiseOldIrql);
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext, PacketArray,
NumberOfPackets);
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, RaiseOldIrql);
for (i = 0; i < NumberOfPackets; i++)
{
NdisStatus = NDIS_GET_PACKET_STATUS(PacketArray[i]);
@@ -353,7 +349,7 @@
else
{
/* Send is called at DISPATCH_LEVEL for all serialized miniports */
- KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &RaiseOldIrql);
for (i = 0; i < NumberOfPackets; i++)
{
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
@@ -361,7 +357,7 @@
if (NdisStatus != NDIS_STATUS_PENDING)
MiniSendComplete(Adapter, PacketArray[i], NdisStatus);
}
- KeLowerIrql(RaiseOldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, RaiseOldIrql);
}
}
}
@@ -408,7 +404,7 @@
return NDIS_STATUS_SUCCESS;
}
- KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.TransferDataHandler)(
Packet,
@@ -418,7 +414,7 @@
ByteOffset,
BytesToTransfer);
- KeLowerIrql(OldIrql);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return Status;
}