ScsiRestartAdapter in miniport

I have some queries regarding handling SsciRestartAdapter as part of
HwStorAdapterControl in a storport miniport driver and request your expert
opinion on this. I have gone through the documentation but haven’t been able
to find a conclusive answer. Also I have included my observations through
Windbg on a Win2k8 R2 x64 system.

  1. Per WDK, ScsiRestartAdapter is invoked when the HBA has to be
    re-initialized. What is the expected IRQL at which this interface is
    invoked? I have always seen this being invoked at DIRQL. Is it safe to
    assume that ScsiRestartAdapter will always run at DIRQL?

  2. If it is invoked at DIRQL, it does not seem to be a good idea to wait in
    ScsiRestartAdapter (for my device to be initialized completely before
    returning from the routine). How do I then ensure that my hardware has been
    completely initialized? My understanding is that once the ScsiRestartAdapter
    is completed, the adapter is ready to receive I/O requests. If this is
    correct, a wait seems necessary. When I introduced a wait, I see a DPC
    watchdog timer triggered in the debugger sometimes (with my max wait time
    being 30 seconds). How do I avoid this?
    I also see that the sample LSI miniport driver in WDK also waits for a
    couple of seconds in the ScsiRestartAdapter. So, is a wait acceptable in
    this case?

  3. WDK mentions that there is no lock held by Storport when invoking
    ScsiRestartAdapter and that both StartIo and Interrupt locks are available
    to be acquired in the ScsiRestartAdapter. However, when I try to acquire
    Interrupt lock, the call to StorPortAcquireSpinLock never completes
    (indicating a possible dead-lock). How do I then synchronize between
    ScsiRestartAdapter and the ISR? Or is the synchronization implicitly done
    (due to the IRQL at which ScsiRestartAdapter runs)?

I would really appreciate any help/pointers in this regard.

Regards,
Girish.

I think perhaps you have found a doc bug and you should bug it.

Mark Roddy

On Mon, Aug 23, 2010 at 8:05 AM, Girish Aithal wrote:

> I have some queries regarding handling SsciRestartAdapter as part of
> HwStorAdapterControl in a storport miniport driver and request your expert
> opinion on this. I have gone through the documentation but haven’t been able
> to find a conclusive answer. Also I have included my observations through
> Windbg on a Win2k8 R2 x64 system.
>
> 1. Per WDK, ScsiRestartAdapter is invoked when the HBA has to be
> re-initialized. What is the expected IRQL at which this interface is
> invoked? I have always seen this being invoked at DIRQL. Is it safe to
> assume that ScsiRestartAdapter will always run at DIRQL?
>
> 2. If it is invoked at DIRQL, it does not seem to be a good idea to wait in
> ScsiRestartAdapter (for my device to be initialized completely before
> returning from the routine). How do I then ensure that my hardware has been
> completely initialized? My understanding is that once the ScsiRestartAdapter
> is completed, the adapter is ready to receive I/O requests. If this is
> correct, a wait seems necessary. When I introduced a wait, I see a DPC
> watchdog timer triggered in the debugger sometimes (with my max wait time
> being 30 seconds). How do I avoid this?
> I also see that the sample LSI miniport driver in WDK also waits for a
> couple of seconds in the ScsiRestartAdapter. So, is a wait acceptable in
> this case?
>
> 3. WDK mentions that there is no lock held by Storport when invoking
> ScsiRestartAdapter and that both StartIo and Interrupt locks are available
> to be acquired in the ScsiRestartAdapter. However, when I try to acquire
> Interrupt lock, the call to StorPortAcquireSpinLock never completes
> (indicating a possible dead-lock). How do I then synchronize between
> ScsiRestartAdapter and the ISR? Or is the synchronization implicitly done
> (due to the IRQL at which ScsiRestartAdapter runs)?
>
> I would really appreciate any help/pointers in this regard.
>
> Regards,
> Girish.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

HwStorAdapterControl handler is a legacy leftover and generally its functionality in a stor miniport should be performed in a PNP/POWER SRB handler. In those handlers you can pend the SRB and not have to wait in a tight loop.

Which would be an even larger doc bug in the WDK.

Mark Roddy

On Mon, Aug 23, 2010 at 11:15 AM, wrote:

> HwStorAdapterControl handler is a legacy leftover and generally its
> functionality in a stor miniport should be performed in a PNP/POWER SRB
> handler. In those handlers you can pend the SRB and not have to wait in a
> tight loop.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

>Which would be an even larger doc bug in the WDK.

Even though storport miniport is generally good to have empty handlers for HwStorAdapterControl codes, storport seems to require that the miniport report them as supported. I remember something was unhappy if I didn’t do that.