From: hitesh on
hi,
i am writing a storport miniport driver and i have to allocate memory.
which is the best option for allocating memory?

my requirement is i have to use that memory which can be accessed by
both host and device, want to use DMA also.

till now i found two options
1) allocate memory and lock the MDL pages. i dont know whether it is
possible in Storport miniport or not? i found the functions also. is
it advisable to lock the pages for a long time? till the driver is
loaded?

2) use storport function
StorPortAllocateContiguousMemorySpecifyCacheNode( )
3) use function StorPortGetUncachedExtension( )

if my memory allocation requirement is too much, then is it fine to
use uncached extension? and whcih of this function i should use
dynamically to allocate memory?

thnaks,
Hitesh
From: eagersh on
On Jul 26, 12:32 am, hitesh <hitesh.ughr...(a)gmail.com> wrote:
> hi,
> i am writing a storport miniport driver and i have to allocate memory.
> which is the best option for allocating memory?
>
> my requirement is i have to use that memory which can be accessed by
> both host and device, want to use DMA also.
>
> till now i found two options
> 1) allocate memory and lock the MDL pages. i dont know whether it is
> possible in Storport miniport or not? i found the functions also. is
> it advisable to lock the pages for a long time? till the driver is
> loaded?
>
> 2) use storport function
> StorPortAllocateContiguousMemorySpecifyCacheNode( )
> 3)  use function StorPortGetUncachedExtension( )
>
> if my memory allocation requirement is too much, then is it fine to
> use uncached extension? and whcih of this function i should use
> dynamically to allocate memory?
>
> thnaks,
> Hitesh
I think all three solutions could work.
The more standard solution is to use StorPortGetUncachedExtension but
StorPortAllocateContiguousMemorySpecifyCacheNode would be better for
dynamic allocation.
Do you have any specific concern or you just try to find the best
approach?

Igor Sharovar

From: Maxim S. Shatskih on
> i am writing a storport miniport driver and i have to allocate memory.
> which is the best option for allocating memory?

What memory? to what is it associated? to device? to LUN? to a request in progress?

Enlarge the device/LUN/SRB extension on this size.

> my requirement is i have to use that memory which can be accessed by
> both host and device, want to use DMA also.

Device and SRB extensions are DMAable using the same ScsiPortGetPhysicalAddress (at least in ScsiPort).

--
Maxim S. Shatskih
Windows DDK MVP
maxim(a)storagecraft.com
http://www.storagecraft.com

From: hitesh on
On Jul 26, 11:13 pm, "Maxim S. Shatskih"
<ma...(a)storagecraft.com.no.spam> wrote:
> > i am writing a storport miniport driver and i have to allocate memory.
> > which is the best option for allocating memory?
>
> What memory? to what is it associated? to device? to LUN? to a request in progress?
>
> Enlarge the device/LUN/SRB extension on this size.
>
> > my requirement is i have to use that memory which can be accessed by
> > both host and device, want to use DMA also.
>
> Device and SRB extensions are DMAable using the same ScsiPortGetPhysicalAddress (at least in ScsiPort).
>
> --
> Maxim S. Shatskih
> Windows DDK MVP
> ma...(a)storagecraft.comhttp://www.storagecraft.com

thanks maxim,
but if i am not wrong as per my understanding i have to know the
extension size before i start the driver.
is it possible to allocate memory which i dont know during the
initialization but dynamically e.g. in build io and start io i found
that i am running out of memory for my command/data transfer and i
need to allocate some more memory? will this function
"ScsiPortGetPhysicalAddress" works during that time also?
if i can't use the same function then what is the alternate? if i use
other functions then will there be any problem? how it is different ?
thanks,
Hitesh
From: Maxim S. Shatskih on
>is it possible to allocate memory which i dont know during the
>initialization but dynamically e.g. in build io and start io i found
>that i am running out of memory for my command/data transfer

I would probably set the SRB extension size to cover the _largest possible_ command/data transfer.

>need to allocate some more memory? will this function
>"ScsiPortGetPhysicalAddress" works during that time also?

IIRC no. Only the IRP's MDL, the device extension and the SRB extension are covered by this mechanism in SCSIPORT. For instance, LUN extension is not.

--
Maxim S. Shatskih
Windows DDK MVP
maxim(a)storagecraft.com
http://www.storagecraft.com