repository: C:/dev/kvm-guest-drivers-windows
branch: master
commit 7119cda8bacf5cd72f3ef718047cf3978e864a0f
Author: Yan Vugenfirer <[email protected]>
Date: Thu Oct 22 13:00:48 2009 +0200
Correct clean up during surprise removal. The bug was found during WHQL
tests of Windows 2008 R2
diff --git a/NetKVM/Common/ParaNdis-Common.c b/NetKVM/Common/ParaNdis-Common.c
index 78fa275..3f9faa1 100644
--- a/NetKVM/Common/ParaNdis-Common.c
+++ b/NetKVM/Common/ParaNdis-Common.c
@@ -154,8 +154,23 @@ static const tConfigurationEntries defaultConfiguration =
static void ParaNdis_ResetVirtIONetDevice(PARANDIS_ADAPTER *pContext)
{
VirtIODeviceReset(&pContext->IODevice);
+ DPrintf(0, ("[%s] Done", __FUNCTION__));
/* reset all the features in the device */
WriteVirtIODeviceRegister(pContext->IODevice.addr +
VIRTIO_PCI_GUEST_FEATURES, 0);
+#ifdef VIRTIO_RESET_VERIFY
+ if (1)
+ {
+ u8 devStatus;
+ devStatus = ReadVirtIODeviceByte(pContext->IODevice.addr +
VIRTIO_PCI_STATUS);
+ if (devStatus)
+ {
+ DPrintf(0, ("[%s] Device status is still %02X",
__FUNCTION__, (ULONG)devStatus));
+ VirtIODeviceReset(&pContext->IODevice);
+ devStatus =
ReadVirtIODeviceByte(pContext->IODevice.addr + VIRTIO_PCI_STATUS);
+ DPrintf(0, ("[%s] Device status on retry %02X",
__FUNCTION__, (ULONG)devStatus));
+ }
+ }
+#endif
}
/**********************************************************
@@ -1035,7 +1050,6 @@ VOID ParaNdis_CleanupContext(PARANDIS_ADAPTER *pContext)
ensure all the incoming packets returned,
free all the buffers and their descriptors
*****************************************/
- VirtIONetRelease(pContext);
if (pContext->IODevice.addr)
{
@@ -1043,6 +1057,7 @@ VOID ParaNdis_CleanupContext(PARANDIS_ADAPTER *pContext)
ParaNdis_ResetVirtIONetDevice(pContext);
JustForCheckClearInterrupt(pContext, "exit 3");
}
+ VirtIONetRelease(pContext);
if (pContext->pBatchOfPackets)
{
@@ -1705,6 +1720,12 @@ void ParaNdis_DPCWorkBody(PARANDIS_ADAPTER *pContext)
{
pContext->bDPCInactive = FALSE;
interruptStatus =
InterlockedExchange(&pContext->InterruptStatus, 0);
+#ifdef VIRTIO_SIGNAL_ERROR
+ if (interruptStatus & 4)
+ {
+ DPrintf(0, ("[%s] ERROR signaled by hardware!!!!!",
__FUNCTION__));
+ }
+#endif
if (interruptStatus & 2)
{
if (pContext->bLinkDetectSupported)
ParaNdis_ReportLinkStatus(pContext);
@@ -1987,12 +2008,17 @@ VOID ParaNdis_OnPnPEvent(
break;
}
ParaNdis_DebugHistory(pContext, hopPnpEvent, NULL, pEvent, 0, 0);
+ DPrintf(0, ("[%s] (%s)", __FUNCTION__, pName));
if (pEvent == NdisDevicePnPEventSurpriseRemoved)
+ {
+ // on simulated surprise removal (under PnpTest) we need to
reset the device
+ // to prevent any access of device queues to memory buffers
pContext->bSurprizeRemoved = TRUE;
+ ParaNdis_ResetVirtIONetDevice(pContext);
+ }
pContext->PnpEvents[pContext->nPnpEventIndex++] = pEvent;
if (pContext->nPnpEventIndex >
sizeof(pContext->PnpEvents)/sizeof(pContext->PnpEvents[0]))
pContext->nPnpEventIndex = 0;
- DPrintf(0, ("[%s] (%s)", __FUNCTION__, pName));
}
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html