SRB_FUNCTION_REMOVE_DEVICE

Hi guys:

My SCSI miniport driver doesn’t get SRB_FUNCTION_REMOVE_DEVICE when uninstall/disable its device from Device Manager or a program. When does Windows send this function code to miniport driver?

Thanks in advance.

You won’t get this request: as far as I can tell it is not even used, or at least it is not currently used. Scsiport handles all the pnp device remove logic for you.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-278644-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, February 20, 2007 12:44 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] SRB_FUNCTION_REMOVE_DEVICE

Hi guys:

My SCSI miniport driver doesn’t get SRB_FUNCTION_REMOVE_DEVICE when
uninstall/disable its device from Device Manager or a program. When
does Windows send this function code to miniport driver?

Thanks in advance.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thanks Mark.

Then, in which way I can get notified in my miniport driver when Windows removes my target?

Since I allocate a buffer in LUN_EXTENSION when I get the first INQUIRY (which means a new target on success), it’s necessary to de-allocate this buffer when the target is removed.

If it’s impossible, I may need to put this buffer as an array in LUN_EXTENSION. But I’m not sure if there is any limitation of LUN_EXTENSION’s size if I put a very large array in it (about 50 mega bytes).

I suspect the LUN extension won’t be freed until you report that the device is no longer present, or until your adapter is destroyed.

I would suggest that you track the buffer for a LUN separately (say in your device extension) and only free it when one of those two conditions occur. Your LUN_EXTENSION can then have a pointer to the buffer.

Why, may I ask, do you need to allocate 50 MB of memory per LUN?

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, February 20, 2007 2:31 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SRB_FUNCTION_REMOVE_DEVICE

Thanks Mark.

Then, in which way I can get notified in my miniport driver when Windows removes my target?

Since I allocate a buffer in LUN_EXTENSION when I get the first INQUIRY (which means a new target on success), it’s necessary to de-allocate this buffer when the target is removed.

If it’s impossible, I may need to put this buffer as an array in LUN_EXTENSION. But I’m not sure if there is any limitation of LUN_EXTENSION’s size if I put a very large array in it (about 50 mega bytes).


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

It’s for caching purpose and could be up to 50 MB.

How can I report a device which is no longer present? In fact a user may disable or uninstall my device from Device Manager which is not controlled by my driver.

Tracking the buffer in DEVICE_EXTENSION is a good idea. I can get ScsiStopAdapter notification.

You report it as not present by reporting its absence.

SCSIPORT will issue an INQUIRY to the device. You see if (a) it fails
or (b) it returns different inquiry data than before (vendor, product,
revision, device type - if any of these are different then it’s a
different LUN).

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, February 20, 2007 4:46 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SRB_FUNCTION_REMOVE_DEVICE

It’s for caching purpose and could be up to 50 MB.

How can I report a device which is no longer present? In fact a user may
disable or uninstall my device from Device Manager which is not
controlled by my driver.

Tracking the buffer in DEVICE_EXTENSION is a good idea. I can get
ScsiStopAdapter notification.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

If my miniport decides that a device is not present, that’s fine to report its absence in INQUIRY. However, if it’s the user to uninstall my device, I do not think my miniport driver can judge if the device should be reported or not.

You should not, nor can you. All you can do is make decisions based on
whether you see the device. If the user disables it you don’t get told
that.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, February 20, 2007 6:13 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SRB_FUNCTION_REMOVE_DEVICE

If my miniport decides that a device is not present, that’s fine to
report its absence in INQUIRY. However, if it’s the user to uninstall my
device, I do not think my miniport driver can judge if the device should
be reported or not.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Nor should you. A bus driver (or in this case, SCSIPORT is acting as a bus driver based on the miniport’s reported inquiry) does not tie the installed state (running, disabled, uninstalled, etc) to the presence of a device. It just reports the device and keeps all the associated data with it that it needs.

d

http://msdn2.microsoft.com/en-us/library/ms810313.aspx

“SRB_FUNCTION_REMOVE_DEVICE is defined for use in future versions of the system. It, too, is never set in SRBs sent to SCSI miniport drivers.”

-----Original Message-----
From: xxxxx@Microsoft.com [mailto:xxxxx@Microsoft.com]
Sent: Tuesday, February 20, 2007 8:33 PM
Subject: RE: SRB_FUNCTION_REMOVE_DEVICE

Nor should you. A bus driver (or in this case, SCSIPORT is acting as a bus driver based on the miniport’s reported inquiry) does not tie the installed state (running, disabled, uninstalled, etc) to the presence of a device. It just reports the device and keeps all the associated data with it that it needs.

d

Thanks guys.

Then, in this case, I do not need to worry about the memory leakage. :slight_smile:

Well you do need to worry about it given that each reported device is consuming 50MB. If these are virtual devices of some sort then you might want to send IOCTLs to your adapter telling it to get rid of or add devices so that you report them missing on the next inquiry and thus cleanup the huge buffer associated with the device.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-278882-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, February 21, 2007 7:53 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SRB_FUNCTION_REMOVE_DEVICE

Thanks guys.

Then, in this case, I do not need to worry about the memory leakage. :slight_smile:


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer