Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Sept/Oct 2019 Issue of The NT Insider available


Download PDF here: http://insider.osr.com/2019/ntinsider_2019_01.pdf

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

StorPortAllocatePool vs StorPortAllocateContiguousMemorySpecifyCacheNode for DMA

Suresh_PatilSuresh_Patil Member Posts: 119
Hi,

Can we use StorPortAllocatePool for getting virtual address and then use StorPortGetPhysicalAddress on that virtual address for doing DMA to disk for sending READ/WRITE requests to disk?

When I tried doing so I saw intermittent crashes while running IO. However after replacing StorPortAllocatePool by StorPortAllocateContiguousMemorySpecifyCacheNode routine I see more stable behavior.
Is it recommended to use StorPortAllocateContiguousMemorySpecifyCacheNode for doing normal READ/WRITE IO operations to disk? Thanks.

Regards,
Suresh

Comments

  • Slava_ImameevSlava_Imameev Member Posts: 480
    > "Is it recommended to use StorPortAllocateContiguousMemorySpecifyCacheNode for
    doing normal READ/WRITE IO operations to disk"

    No, if you are not ignoring *Length value returned by StorPortGetPhysicalAddress which might be less than the size of a buffer allocated by StorPortAllocatePool

    > "StorPortAllocateContiguousMemorySpecifyCacheNode routine I see more stable
    behavior"

    Did you mean that you still experienced crashes?
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,103
    xxxxx@yahoo.com wrote:
    > Can we use StorPortAllocatePool for getting virtual address and then use StorPortGetPhysicalAddress on that virtual address for doing DMA to disk for sending READ/WRITE requests to disk?
    >
    > When I tried doing so I saw intermittent crashes while running IO.

    You are aware, I hope, that StorPortGetPhysicalAddress only returns the
    physical address of the first page. A buffer that is contiguous in
    virtual space is almost never contiguous in physical space. Example:

    virtual physical
    1234000 9AB000
    1235000 17F6000
    1236000 17000
    1237000 F739000

    If you have buffers more than 4096 bytes, you need to use
    StorPortGetScatterGatherList.


    > However after replacing StorPortAllocatePool by StorPortAllocateContiguousMemorySpecifyCacheNode routine I see more stable behavior.
    > Is it recommended to use StorPortAllocateContiguousMemorySpecifyCacheNode for doing normal READ/WRITE IO operations to disk? Thanks.

    If your hardware supports scatter/gather, use
    StorPortGetScatterGatherList. If it does not, you'll either need to do
    your DMA one page at a time, or you'll have to use a common buffer.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Suresh_PatilSuresh_Patil Member Posts: 119
    Thanks Tim! I overlooked the non-contiguous physical address nature of StorPortAllocatePool.
    Unfortunately our hardware does not support scatter-gather. But I was wondering then why did you suggest to do DMA one page at a time instead of using StorPortAllocateContiguousMemorySpecifyCacheNode ?

    @Slava: No, with StorPortAllocateContiguousMemorySpecifyCacheNode there were no more crashes. Sorry for confusing :-)

    Regards,
    Suresh
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,103
    On Aug 17, 2016, at 11:13 PM, xxxxx@yahoo.com wrote:
    >
    > Thanks Tim! I overlooked the non-contiguous physical address nature of StorPortAllocatePool.
    > Unfortunately our hardware does not support scatter-gather. But I was wondering then why did you suggest to do DMA one page at a time instead of using StorPortAllocateContiguousMemorySpecifyCacheNode ?

    If you are given a buffer from above and your hardware does not support DMA, you have two options. You can do the DMA from the original buffer one page at a time, or you can allocate a common buffer, copy the data over, and DMA in one bunch.

    It's not immediately obvious which option is faster. For a 64k buffer, you have the cost of setting up 16 transfers vs the cost of copying the buffer.

    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE