Storport miniportdriver: why is HwInitialize() not called after HwFindAdapter() routine ? RRS feed

  • Question

  • Hi,

    I am implementing a storport miniport driver for a SAS HBA. In that, DriverEntry() is successful. Then HwFindAdapter() routine initializes the portconfig and returns SP_RETURN_FOUND. Then the PnP manager does not call HwInitialize() instead calls HwStartIo() with Pnp call to remove device and the device is removed in HwRemoveDevice()

    Why is HwInitialize() not called after HwFindAdapter() instead, HwStartIO -> HwRemoveDevice() called?

    Please see details of HwFindAdapter setting and stack trace for HwStartIO() below:

    HwFindAdapter is setting the following parameters:
        PConfigInfo->AdapterInterfaceType           = PCIBus;
        PConfigInfo->VirtualDevice                  = FALSE;
        PConfigInfo->ScatterGather                  = TRUE;
        PConfigInfo->ResetTargetSupported           = TRUE;
        PConfigInfo->Master                         = TRUE;
        PConfigInfo->CachesData                     = FALSE;
        PConfigInfo->MaximumNumberOfTargets       = 8;
        PConfigInfo->NumberOfBuses                  = 1;
        PConfigInfo->Dma32BitAddresses              = TRUE;
        PConfigInfo->Dma64BitAddresses            = SCSI_DMA64_MINIPORT_SUPPORTED;
        PConfigInfo->MaximumNumberOfLogicalUnits    = SCSI_MAXIMUM_LOGICAL_UNITS;
        PConfigInfo->SynchronizationModel         = StorSynchronizeFullDuplex;
        PConfigInfo->MapBuffers                     = STOR_MAP_ALL_BUFFERS;
        PConfigInfo->AlignmentMask                  = 1; //FILE_WORD_ALIGNMENT
         PConfigInfo->MaxNumberOfIO                  = 100;
         PConfigInfo->NumberOfPhysicalBreaks         = 32;
         PConfigInfo->MaximumTransferLength          = 256*1024;

     It returns SP_RETRUN_FOUND

     Then, HwStartIO with PnP request to remove device is called instead of HwInitialize() routine

    Stack trace for HwStartIo() call

    00 94daf8e0 9285d645 8d18f96c 8d18f8d0 94daf91c TestStor!TestHwStartIo(void * PDevExt = 0x8d18f96c, struct _SCSI_REQUEST_BLOCK * PSrb = 0x8d18f8d0) (FPO: [Non-Fpo]) (CONV: stdcall)
    01 94daf8f0 9285f2e2 8d207188 8d18f8d0 8d5af008 storport!RaCallMiniportStartIo+0x1e (FPO: [Non-Fpo])
    02 94daf91c 9285f55e 8d2070e8 8d5af008 94daf944 storport!RaidAdapterPostScatterGatherExecute+0x18b (FPO: [Non-Fpo])
    03 94daf92c 9286085c 8d2070e8 8d5af008 8d18f8d0 storport!RaidAdapterExecuteXrb+0x2d (FPO: [Non-Fpo])
    04 94daf944 92861455 8d2070e8 8d5af008 8d147b50 storport!RaidAdapterRaiseIrqlAndExecuteXrb+0x1c (FPO: [Non-Fpo])
    05 94daf974 928933f5 8d207030 00000002 00000000 storport!RaidPnPPassToMiniPort+0x1c6 (FPO: [Non-Fpo])
    06 94daf994 928936d4 8d2070e8 8d144268 8d2070e8 storport!RaidAdapterReleaseResources+0x29 (FPO: [Non-Fpo])
    07 94daf9b0 92893904 8d2070e8 8d144268 92871000 storport!RaidAdapterRemoveDeviceIrp+0x41 (FPO: [Non-Fpo])
    08 94daf9cc 92893eb5 00000002 00144268 8d144320 storport!RaidAdapterPnpIrp+0xbc (FPO: [Non-Fpo])
    09 94daf9e8 8986f169 8d207030 8d144268 94dafa8c storport!RaDriverPnpIrp+0x71 (FPO: [Non-Fpo])
    0a 94dafa00 89a15214 8d147b50 8d145668 8d147b50 nt!IofCallDriver+0x63
    0b 94dafa34 89b0434c 8d147b50 94dafa68 00000000 nt!IopSynchronousCall+0xba
    0c 94dafa90 8991510a 8d147b50 00000002 94a8efe8 nt!IopRemoveDevice+0xd5
    0d 94dafabc 89afc07d 0000000a 94a8efe8 00000000 nt!PnpRemoveLockedDeviceNode+0x16c
    0e 94dafad0 89afc333 00000002 0000000a 00000000 nt!PnpDeleteLockedDeviceNode+0x2d
    0f 94dafb04 89affd23 8d147b50 94a8efe8 00000002 nt!PnpDeleteLockedDeviceNodes+0x4c
    10 94dafbc4 899ed48b 94dafbf4 00000000 94a5b920 nt!PnpProcessQueryRemoveAndEject+0x946
    11 94dafbdc 899fb598 00000000 8d5aef10 8c7ba648 nt!PnpProcessTargetDeviceEvent+0x38
    12 94dafc00 898b63cb 8d5aef10 00000000 8c7ba648 nt!PnpDeviceEventWorker+0x216
    13 94dafc50 89a4563d 00000001 0ea4d4fc 00000000 nt!ExpWorkerThread+0x10d

    Friday, January 19, 2018 11:42 PM

All replies

  • If you look at the documentation for PORT_CONFIGURATION_INFORMATION it explicitly states that miniport drivers cannot modify AdapterInterfaceType.   Since this is the first piece of code you showed us, at least setting AdapterInterfaceType is a bug.   I would recommend you go through the documentation and your code, I suspect that if this bug is there it is likely more bugs are in setting PORT_CONFIGURATION_INFORMATION.

    Don Burn Windows Driver Consulting Website:

    Saturday, January 20, 2018 2:34 PM
  • Thanks for your response. I went through the documentation and removed everything that was not related to Port config info and set just the values listed below and still see the problem . Please let me know if you find anything wrong with the settings or am I missing anything else in HwFindAdapter routine(). Thanks for your help.


       PConfigInfo->Master                                                = TRUE;
        PConfigInfo->CachesData                                        = FALSE;
        PConfigInfo->NumberOfBuses                                  = 1;
        PConfigInfo->MaximumNumberOfLogicalUnits          = SCSI_MAXIMUM_LOGICAL_UNITS;
        PConfigInfo->SynchronizationModel                         = StorSynchronizeFullDuplex;
        PConfigInfo->MapBuffers                                          = STOR_MAP_ALL_BUFFERS;
        PConfigInfo->AlignmentMask                                    = 1; //FILE_WORD_ALIGNMENT
        PConfigInfo->MaxNumberOfIO                                  = 100;
        PConfigInfo->NumberOfPhysicalBreaks                     = 32;
        PConfigInfo->MaximumTransferLength                     = 256*1024;

       return SP_RETURN_FOUND;


    At the end of HwFindAdapter routine, Windbg reports PConfigInfo structure as below:

    Length    0xc0
     SystemIoBusNumber    1
     AdapterInterfaceType    PCIBus (0n5)
     BusInterruptLevel    0
     BusInterruptVector    0xffffff9f
     InterruptMode    Latched (0n1)
     MaximumTransferLength    0x40000
     NumberOfPhysicalBreaks    0x20
     DmaChannel    0xffffffff
     DmaPort    0xffffffff
     DmaWidth    Width8Bits (0n0)
     DmaSpeed    Compatible (0n0)
     AlignmentMask    1
     NumberOfAccessRanges    6
     AccessRanges    0x8d597360
     Reserved    0x00000000
     NumberOfBuses    0x01 ''
     InitiatorBusId    char [8] "???"
     ScatterGather    0x01 ''
     Master    0x01 ''
     CachesData    0x00 ''
     AdapterScansDown    0x00 ''
     AtdiskPrimaryClaimed    0x00 ''
     AtdiskSecondaryClaimed    0x00 ''
     Dma32BitAddresses    0x01 ''
     DemandMode    0x00 ''
     MapBuffers    0x01 ''
     NeedPhysicalAddresses    0x01 ''
     TaggedQueuing    0x01 ''
     AutoRequestSense    0x01 ''
     MultipleRequestPerLu    0x01 ''
     ReceiveEvent    0x00 ''
     RealModeInitialized    0x00 ''
     BufferAccessScsiPortControlled    0x01 ''
     MaximumNumberOfTargets    0x80 ''
     ReservedUchars    unsigned char [2] ""
     SlotNumber    0
     BusInterruptLevel2    0
     BusInterruptVector2    0
     InterruptMode2    LevelSensitive (0n0)
     DmaChannel2    0
     DmaPort2    0
     DmaWidth2    Width8Bits (0n0)
     DmaSpeed2    Compatible (0n0)
     DeviceExtensionSize    0
     SpecificLuExtensionSize    0x1c
     SrbExtensionSize    0x18
     Dma64BitAddresses    0x00 ''
     ResetTargetSupported    0x00 ''
     MaximumNumberOfLogicalUnits    0x08 ''
     WmiDataProvider    0x01 ''
     SynchronizationModel    StorSynchronizeFullDuplex (0n1)
     HwMSInterruptRoutine    0x00000000
     InterruptSynchronizationMode    InterruptSupportNone (0n0)
     DumpRegion    struct _MEMORY_REGION
     RequestedDumpBufferSize    0
     VirtualDevice    0x00 ''
     ExtendedFlags1    0
     MaxNumberOfIO    0x64

    Monday, January 22, 2018 9:40 PM