Discussion:
memory allocation for storport miniport driver.
(too old to reply)
hitesh
2010-07-26 06:32:27 UTC
Permalink
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
eagersh
2010-07-26 17:34:02 UTC
Permalink
Post by hitesh
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
Maxim S. Shatskih
2010-07-26 18:13:30 UTC
Permalink
Post by hitesh
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.
Post by hitesh
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
***@storagecraft.com
http://www.storagecraft.com
hitesh
2010-07-27 03:34:28 UTC
Permalink
On Jul 26, 11:13 pm, "Maxim S. Shatskih"
Post by Maxim S. Shatskih
Post by hitesh
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.
Post by hitesh
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
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
Maxim S. Shatskih
2010-07-27 09:07:21 UTC
Permalink
Post by hitesh
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.
Post by hitesh
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
***@storagecraft.com
http://www.storagecraft.com
eagersh
2010-07-27 16:16:51 UTC
Permalink
Post by hitesh
On Jul 26, 11:13 pm, "Maxim S. Shatskih"
Post by Maxim S. Shatskih
Post by hitesh
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.
Post by hitesh
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
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
also i want
to allocate memory in some large amount which could be upto 2 MB.
is it fine to allocate so much memory permanently?
You could use ScsiPortGetPhysicalAddress for both type of memory
either allocated by StorPortGetUncachedExtension or
StorPortAllocateContiguousMemorySpecifyCacheNode.
If you could predict how much memory you could use for DMA it is
better to use StorPortGetUncachedExtension. 2MB memory allocation
should be OK for a system.
It would not hurt a system.

Igor Sharovar

Loading...