[Openib-windows] a possible bug

Leonid Keller leonid at mellanox.co.il
Wed Jun 7 07:12:47 PDT 2006


Hi Fab,
 
DDK states in IoSkipCurrentIrpStackLocation() description:
If your driver calls IoSkipCurrentIrpStackLocation, be careful not to
modify the IO_STACK_LOCATION structure in a way that could inadvertently
affect the lower driver or the system's behavior with respect to that
driver. Examples include modifying the IO_STACK_LOCATION structure's
Parameters union or calling IoMarkIrpPending
<mk:@MSITStore:C:\WINDDK\3790.1830\help\kmarch.chm::/hh/kmarch/k104_4789
03ab-e597-4df6-a66e-e0c1fbea49d9.xml.htm> .

Look at hca_set_power(), case DevicePowerState:

    we call IoMarkIrpPending(), then IoQueueWorkItem( .., __PowerDownCb,
..);

Then __PowerDownCb calls IoSkipCurrentIrpStackLocation() and
PoCallDriver().

Looks like it's a wrong behaviour.

But what's the right one ?

What do you think about such idea ?

    -- set a completion routine in __PowerDownCb();

    -- call PoStartNextPowerIrp() in te completion routine.

I.e., something like the following:

static void __PowerDownCb(
 IN    DEVICE_OBJECT*    p_dev_obj,
 IN    void*      context )
{

    ...    // current stuff
    mthca_remove_one( p_ext );

    IoCopyCurrentIrpStackLocationToNext( p_irp );
    IoSetCompletionRoutine( p_irp, __DevicePowerCbCompletion, NULL,
TRUE, TRUE, TRUE );
    PoCallDriver( p_ext->cl_ext.p_next_do, p_irp );
    IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );

}


static NTSTATUS __DevicePowerCbCompletion(
 IN    DEVICE_OBJECT    *p_dev_obj,
 IN    IRP       *p_irp,
 IN    void      *context )
{
 hca_dev_ext_t  *p_ext  = (hca_dev_ext_t*)p_dev_obj->DeviceExtension;
  PoStartNextPowerIrp( p_irp );
  IoCompleteRequest( p_irp, IO_NO_INCREMENT );
  IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );
  return STATUS_SUCCESS;
}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20060607/794d4e4e/attachment.html>


More information about the ofw mailing list