none
Memory Alignment for a DMA transaction RRS feed

  • Question

  • I am writing a DMA-based driver for a custom made PCI-Express device using WDF for Windows 7.

    As you may know, PCI-Express bus transactions are not allowed to cross a 4k memory boundary. The custom device does not check this, and therefore we need to ensure that the driver only requests DMA transfers which are aligned to 4k memory boundaries.

    The profile for the device is WdfDmaProfilePacket64.

    I tried using WdfDeviceSetAlignmentRequirement(DevExt->Device, 4095), but this does not result in the DMA start address to be properly aligned.

    How can we configure the WDF framework so that it only requests properly aligned addresses?

    Regards,

    Wouter
    Embedded systems and software engineer
    Sorama

    Friday, August 16, 2013 2:40 PM

Answers

  • Hi,

    Apparently the device address alignment is not always honored (look at it more as an optimization hint than an enforced requirement), so try this instead:

    1. Request two scatter gather elements and perform two < 4K transfers if the buffer they are given spans a page.

    OR

    2. Allocate a single-page bounce buffer from common buffer, and if the incoming buffer spans a page copy into the bounce buffer and do the DMA from there.

    Let us know if this helps and if you have any questions.

    Friday, December 13, 2013 5:53 PM

All replies

  • Hi Wouter,

    I have encountered the same problem. Have you solve it? Can we share something useful?

    Regards,

    raymond

    raymond_rule*hotmail.com

    Thursday, December 12, 2013 9:25 AM
  • Hi,

    Apparently the device address alignment is not always honored (look at it more as an optimization hint than an enforced requirement), so try this instead:

    1. Request two scatter gather elements and perform two < 4K transfers if the buffer they are given spans a page.

    OR

    2. Allocate a single-page bounce buffer from common buffer, and if the incoming buffer spans a page copy into the bounce buffer and do the DMA from there.

    Let us know if this helps and if you have any questions.

    Friday, December 13, 2013 5:53 PM