[ofw] Add Assert to debug BS while deleting WDF device

Uri Habusha urih at mellanox.co.il
Thu Dec 2 04:10:12 PST 2010


Okay, I applied the patch in our svn and run regression on it now.  I made some minor changes in your patch. Please review

-----Original Message-----
From: Hefty, Sean [mailto:sean.hefty at intel.com] 
Sent: Wednesday, December 01, 2010 10:45 PM
To: Uri Habusha; ofw at lists.openfabrics.org; Smith, Stan; Fabian Tillier
Subject: RE: Add Assert to debug BS while deleting WDF device

> WmCreateControlDevice is called but get an error after creating the 
> device object, as a result the function calls to WdfObjectDelete to 
> delete the control device.
> Afterwards WmPowerD0Exit function is called. Since the DevList is 
> empty it sets the destroy flag to true and then try to delete the device object.
> However this object already deleted and we got a BS

I thought that opensm was actively running over winmad when the blue screen happened.

> I think that the right fix is not delete it on error in 
> WmCreateControlDevice, and always delete it in WmPowerD0Exit function
> 
> Sean what do you think.

I think we want to cleanup immediately after failures.  We need to guarantee that anything needed for the control device to operate (e.g. the IoQueue) are initialized properly.

The bigger issue is now trying to understand why WmCreateControlDevice ran into an error.

> BTW, if the winmad\winverb has debug print we can find the problem 
> more easily without wasting too much time. Sean any objection to add 
> debug print. If it's okay with you I will add it.

Debug prints added in error cases sound fine.

Can you try this patch?  I'm not where I can test it today, but should be able to tomorrow.

- Sean


winmad/winverbs: handle failure creating control device

From: Sean Hefty <sean.hefty at intel.com>

If we fail to create a control device during power entry, we will try to free the device during power exit, even though the device does not exist.  This will lead to a blue screen.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
 trunk/core/winmad/kernel/wm_driver.c   |    3 ++-
 trunk/core/winverbs/kernel/wv_driver.c |    5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/trunk/core/winmad/kernel/wm_driver.c b/trunk/core/winmad/kernel/wm_driver.c
index 6d3cbdf..927dc29 100644
--- a/trunk/core/winmad/kernel/wm_driver.c
+++ b/trunk/core/winmad/kernel/wm_driver.c
@@ -220,6 +220,7 @@ static VOID WmCreateControlDevice(WDFDRIVER Driver)
 
 err2:
 	WdfObjectDelete(ControlDevice);
+	ControlDevice = NULL;
 	return;
 err1:
 	WdfDeviceInitFree(pinit);
@@ -364,7 +365,7 @@ static NTSTATUS WmPowerD0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetSta
 		ExFreePoolWithTag(pdev->pPortArray, 'pimw');
 	}
 
-	if (destroy) {
+	if (destroy && ctrldev) {
 		WdfObjectDelete(ctrldev);
 	}
 
diff --git a/trunk/core/winverbs/kernel/wv_driver.c b/trunk/core/winverbs/kernel/wv_driver.c
index d532160..90f0e4d 100644
--- a/trunk/core/winverbs/kernel/wv_driver.c
+++ b/trunk/core/winverbs/kernel/wv_driver.c
@@ -459,6 +459,7 @@ static VOID WvCreateControlDevice(WDFDRIVER Driver)
 
 err2:
 	WdfObjectDelete(ControlDevice);
+	ControlDevice = NULL;
 	return;
 err1:
 	WdfDeviceInitFree(pinit);
@@ -567,7 +568,9 @@ static VOID WvRdmaDeviceCleanup(WDFDEVICE Device)
 			IbCmInterface.InterfaceHeader.InterfaceDereference(IbCmInterface.
 															   InterfaceHeader.Context);
 		}
-		WdfObjectDelete(ctrldev);
+		if (ctrldev != NULL) {
+			WdfObjectDelete(ctrldev);
+		}
 	}
 }
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmad.patch
Type: application/octet-stream
Size: 4388 bytes
Desc: winmad.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20101202/b294e0d3/attachment.obj>


More information about the ofw mailing list