none
How can I get virtual address for the physically contiguous memory obtained using StorPortAllocateContiguousMemorySpecifyCacheNode() ? RRS feed

  • Question

  • Hello,

       I have a code that assigns physical memory and gets virtual handle for that  using StorAllocatePool and StorPortAllocateMdl and StorPortBuildMdl .and it works.

      status = StorPortAllocatePool(ic, ic->request_dma_sz, 'SAS', (PVOID *)&(ic->request_dma));
      status = StorPortAllocateMdl (ic, &(ic->request_dma), ic->request_dma_sz, (PVOID *)ic->request);
      status = StorPortBuildMdlForNonPagedPool(ic,ic->request);

    Now, I want to assign a large chunk of physically contiguous memory. So, I want to use StorPortAllocateContiguousMemorySpecifyCacheNode().

    1) Similar to the StorPortAllocatePool case above, how can I allocate and Build MDL for the  StorPortAllocateContiguousMemorySpecifyCacheNode() case?

    Thanks to this forum, I have had a lot of help and have been able to make progress,

    Appreciate your help.

    Regards.

    Tuesday, June 19, 2018 1:35 AM

Answers

  • It is the same model, to get a MDL just replace the StorPortAllocatePool with StorPortAllocateContiguousMemorySpecifyCacheNode using the buffer pointer from it.   The question though is why do you want physically contiguous memory, if you are going to be dealing with MDL's since they are there to eliminate the need for contiguous.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Tuesday, June 19, 2018 10:32 AM

All replies

  • It is the same model, to get a MDL just replace the StorPortAllocatePool with StorPortAllocateContiguousMemorySpecifyCacheNode using the buffer pointer from it.   The question though is why do you want physically contiguous memory, if you are going to be dealing with MDL's since they are there to eliminate the need for contiguous.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Tuesday, June 19, 2018 10:32 AM
  • Sorry, my reply does not appear to be clear. So, re-wording my response.

    Thanks once again.  After I read your response, I realized that I don't need MDL when I assign a huge chunk of memory. So, I am following the procedure listed below. But I have intermittent success. Can you please tell me if this procedure listed below is correct?

    A huge Thankyou for your help.

    status = StorPortAllocateContiguousMemorySpecifyCacheNode (ic,
                                                                  ic->sz,
                                                                  minPhysicalAddress,
                                                                  maxPhysicalAddress,
                                                                  boundaryPhysicalAddress,
                                                                  MmCached,
                                                                  MM_ANY_NODE_OK,
                                                                 (PVOID *)&(ic->buf))

    to get the virtual pointer to physically contiguous memory.

    2) ic->buf_dma =  StorPortGetPhysicalAddress(ic, NULL,(PVOID)&(ic->buf), &segmentLength)  on the virtual pointer to get the physical address that I pass it to the hardware.

    3) I pass ic->buf_dma to the hardware and read the response from the hardware by reading the virtual pointer ic->buf

    I am getting intermittent success. Please let me know if this sequence is correct?

    Thanks.

    Wednesday, June 20, 2018 12:57 AM