StorPortAllocatePool vs StorPortAllocateContiguousMemorySpecifyCacheNode for DMA

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

> “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?

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.

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 :slight_smile:

Regards,
Suresh

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.