StorPortGetUncachedExtension vs ScsiPortGetUncachedExtension

Hi all,

StorPortGetUncachedExtension always returns same virtual address unlike AllocateCommonBuffer. However this is not mentioned in StorPortGetUncachedExtension doc
but commented in ScsiPortGetUncachedExtension.

  1. Is it correct that common buffer for DMA cannot be allocated in parts, but has to be one
    whole bunch of embedded data structures for common buffer ?
  2. Is it valid to follow comments in ScsiPortXXX while using StorPortXXX API’s ?

Thanks !

>Is it correct that common buffer for DMA cannot be allocated in parts, but has to be one
It is true. At least WDK documentation indicates this and LSI sample calls StorPortGetUncachedExtension only one time for all non cached memory.
But you also have an option to use StorPortAllocateContiguousMemorySpecifyCacheNode. It works in the same way as StorPortGetUncachedExtension and you could call this function more than one time.

Igor Sharovar

> 1. Is it correct that common buffer for DMA cannot be allocated in parts, but has to be one

whole bunch of embedded data structures for common buffer ?

In Scsi/StorPort, yes.

Also this is a generally good practice, since the common buffer is page-aligned, and you are wasting the tail of the last page.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

You only can call *AllocateUncachedExtension once, in FindAdapter. And G*d forbid you call it in a virtual miniport. You’ll have a memory and DMA_ADAPTER leak then. storport.sys makes concious effort to bypass its deallocation, but doesn’t bother to fail its allocation.

Also, StorPortAllocateContiguousMemorySpecifyCacheNode doesn’t give you the buffer’s physical address.

>Also, StorPortAllocateContiguousMemorySpecifyCacheNode doesn’t give you the buffer’s physical >address.
You need to call StorPortGetPhysicalAddress to get physical address. But if you using StorPortGetUncachedExtension you need call StorPortGetPhysicalAddress also.

Igor Sharovar

>Also this is a generally good practice, since the common buffer is page-aligned, and you are >wasting the tail of the last page.

There are situations when a driver doesn’t know in HwFindAdapter how much memory it would need. The driver could know this only after communicating with a hardware. Allocating memory with a size of “worst case” would be very inefficient.

Igor Sharovar