Query regarding StorSurpriseRemoval

Hello Gurus,
There is little/no documentation on StorSurpriseRemoval.

Two basic questions:

  1. Since it is not documented, should I or should I not handle this PNP
    action in storport miniport driver?
  2. If yes, is the expectation from the handler any different from
    StorRemoveDevice?

Regards,
Chakri

This request will appear as part of WLK tests.

Storport expects you do the same as you do in StorRemoveDevice. After SurpriseRemoval, you won’t get StorRemoveDevice. Make sure to free all your resources. This is different from straight WDM sequence, where you’ll get REMOVE_DEVICE after SURPRISE_REMOVAL.

Did you perchance misspell something? Do you mean StorPortSurpriseRemoval?
But that’s a moot point since it really isn’t documented and given you
discovered it by reverse engineering into StorPort, you ain’t supposed to be
using it. But that’s moot too, since if you’re in the kernel, you can pretty
well do what you god damned please. So, given you found the beast, with a
little bit of study you can grok the calling parameters and figure out how
to use it. Should you? Hell no, and personally I would not want crap like
that on any system I support. Why? Because it’s undocumented. That means it
may not be there in the next release of the OS, or work the same in the next
service pack, and code using this undocumented nugget will then fail.

So, why do you think you need to use it? Most likely there is an approved,
documented method to solve your problem.

Gary G. Little
H (952) 223-1349
C (952) 454-4629
xxxxx@comcast.net

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Chakri
Sent: Friday, July 09, 2010 9:42 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Query regarding StorSurpriseRemoval

Hello Gurus,
There is little/no documentation on StorSurpriseRemoval.

Two basic questions:

  1. Since it is not documented, should I or should I not handle this PNP
    action in storport miniport driver?
  2. If yes, is the expectation from the handler any different from
    StorRemoveDevice?

Regards,
Chakri


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

Thank you Grigora.

You nailed down my situation. My only hesitation is handling undocumented
stuff. Is this the “WLK only” situation?

Regards,
Chakri

wrote in message news:xxxxx@ntdev…
> This request will appear as part of WLK tests.
>
> Storport expects you do the same as you do in StorRemoveDevice. After
> SurpriseRemoval, you won’t get StorRemoveDevice. Make sure to free all
> your resources. This is different from straight WDM sequence, where you’ll
> get REMOVE_DEVICE after SURPRISE_REMOVAL.
>

Thank you Gary for your thoughtful response. I appreciate your time.

Negative, it is spit on me by WLK via SRB_FUNCTION_PNP (as Grigora correctly
pin pointed) when I ran pnpdtest for surprise removal.
BTW, my adapter is not in boot path FWIW.

The following is published structure from storport.h and srb.h (WDK
7600.16385.0):
//
// PNP minor function codes.
//
typedef enum {
StorStartDevice = 0x0,
StorRemoveDevice = 0x2,
StorStopDevice = 0x4,
StorQueryCapabilities = 0x9,
StorQueryResourceRequirements = 0xB,
StorFilterResourceRequirements = 0xD,
StorSurpriseRemoval = 0x17
} STOR_PNP_ACTION, *PSTOR_PNP_ACTION;

I would love to agree. But verifier doesn’t like it and for right reasons, I
get BSOD 0x000000C4 (param1=0x62, param4=1) as I didn’t free up my resources
as StorRemoveDevice is not called and I did not handle StorSurpriseRemoval.

I tried google without any luck and that is why this post.

Regards,
Chakri

“Gary G. Little” wrote in message
news:xxxxx@ntdev…
> Did you perchance misspell something? Do you mean StorPortSurpriseRemoval?
> But that’s a moot point since it really isn’t documented and given you
> discovered it by reverse engineering into StorPort, you ain’t supposed to
> be
> using it. But that’s moot too, since if you’re in the kernel, you can
> pretty
> well do what you god damned please. So, given you found the beast, with a
> little bit of study you can grok the calling parameters and figure out how
> to use it. Should you? Hell no, and personally I would not want crap like
> that on any system I support. Why? Because it’s undocumented. That means
> it
> may not be there in the next release of the OS, or work the same in the
> next
> service pack, and code using this undocumented nugget will then fail.
>
> So, why do you think you need to use it? Most likely there is an approved,
> documented method to solve your problem.
>
> Gary G. Little
> H (952) 223-1349
> C (952) 454-4629
> xxxxx@comcast.net
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Chakri
> Sent: Friday, July 09, 2010 9:42 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Query regarding StorSurpriseRemoval
>
> Hello Gurus,
> There is little/no documentation on StorSurpriseRemoval.
>
> Two basic questions:
> 1. Since it is not documented, should I or should I not handle this PNP
> action in storport miniport driver?
> 2. If yes, is the expectation from the handler any different from
> StorRemoveDevice?
>
> Regards,
> Chakri
>
>
> —
> 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
>
>

To further clarify, as the storport docs remain somewhat difficult,

The port driver sends SCSI_PNP_REQUEST_BLOCK requests to a miniport driver
to notify the miniport driver of Windows Plug and Play (PnP) events that
affect storage devices that are connected to the adapter.

These requests merely represent notifications that PnP events are occurring
and do not require any action by the miniport driver. A miniport driver can
do real work within the context of a PnP request (such as disabling its
hardware, for example) but is not required to do so.

*If the function member of an SRB is set to SRB_FUNCTION_PNP, the SRB is a
structure of type SCSI_PNP_REQUEST_BLOCK*.

http://msdn.microsoft.com/en-us/library/ff556016(VS.85).aspx

This is useful for miniports that, for whatever reason, have to manage their
own PNP state. Virtual miniports fit into this category. Your HwStorStartIo
routine will get these requests, which it can ignore, or not, depending on
the characteristics of the miniport.

The OP is not doing anything unsupported, just less than fully documented.

Mark Roddy

On Sat, Jul 10, 2010 at 7:58 AM, Chakri wrote:

> StorSurpriseRemoval

Hmm… Can I read it as I can safely handle StorSurpriseRemoval?

Regards,
Chakri
“Mark Roddy” wrote in message news:xxxxx@ntdev…
To further clarify, as the storport docs remain somewhat difficult,

The port driver sends SCSI_PNP_REQUEST_BLOCK requests to a miniport driver to notify the miniport driver of Windows Plug and Play (PnP) events that affect storage devices that are connected to the adapter.

These requests merely represent notifications that PnP events are occurring and do not require any action by the miniport driver. A miniport driver can do real work within the context of a PnP request (such as disabling its hardware, for example) but is not required to do so.

If the function member of an SRB is set to SRB_FUNCTION_PNP, the SRB is a structure of type SCSI_PNP_REQUEST_BLOCK.

http://msdn.microsoft.com/en-us/library/ff556016(VS.85).aspx

This is useful for miniports that, for whatever reason, have to manage their own PNP state. Virtual miniports fit into this category. Your HwStorStartIo routine will get these requests, which it can ignore, or not, depending on the characteristics of the miniport.

The OP is not doing anything unsupported, just less than fully documented.

Mark Roddy

On Sat, Jul 10, 2010 at 7:58 AM, Chakri wrote:

StorSurpriseRemoval

Yes if your ‘device’ is not a standard storage controller (i.e. a pci bus
hardware device) then you may have to do just that.

Mark Roddy

On Sat, Jul 10, 2010 at 10:53 AM, Chakri wrote:

> Hmm… Can I read it as I can safely handle StorSurpriseRemoval?
>
> Regards,
> Chakri
>
> “Mark Roddy” wrote in message news:xxxxx@ntdev…
> To further clarify, as the storport docs remain somewhat difficult,
>
> The port driver sends SCSI_PNP_REQUEST_BLOCK requests to a miniport
> driver to notify the miniport driver of Windows Plug and Play (PnP) events
> that affect storage devices that are connected to the adapter.
>
> These requests merely represent notifications that PnP events are occurring
> and do not require any action by the miniport driver. A miniport driver can
> do real work within the context of a PnP request (such as disabling its
> hardware, for example) but is not required to do so.
>
> If the function member of an SRB is set to SRB_FUNCTION_PNP, the SRB is a
> structure of type SCSI_PNP_REQUEST_BLOCK
.
>
> http://msdn.microsoft.com/en-us/library/ff556016(VS.85).aspx
>
> This is useful for miniports that, for whatever reason, have to manage
> their own PNP state. Virtual miniports fit into this category. Your
> HwStorStartIo routine will get these requests, which it can ignore, or not,
> depending on the characteristics of the miniport.
>
>
> The OP is not doing anything unsupported, just less than fully documented.
>
>
> Mark Roddy
>
>
> On Sat, Jul 10, 2010 at 7:58 AM, Chakri wrote:
>
>> StorSurpriseRemoval
>
>
>
> —
> 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
>

@Gary Little:

In WDK, there are things undocumented for good reason, there are things undocumented by omission, and there are things mis-documented. There are also things storport code owners didn’t even know a miniport should handle.

Mr. J. An. was very surprised when he heard that a miniport receives a PNP SRB with then-non-specified code which was the same as IRP_MN_SURPRISE_REMOVAL. StorSurpriseRemoval was then added in the later WDK.

Now, there is StorStartDevice. One would expect the miniport would get it after StorStopDevice (see WLK resource rebalance test). Nope. The miniport gets StorHwFindAdapter call. This effectively means the miniport can’t carry any state (such as non-persistent targets, etc) across Stop/Start cycle.

For PNPAction enum there is no documentation whatsoever, except for those one-liners. What you suggest to do, other than reverse-engineer their effects?