Freigeben über


GetScatterGatherList will coallesce contiguous SG list entries

GregH asked me an interesting question at WinHEC today - one for which I didn't immediately know the answer.  He was wondering whether the new DMA DDIs (Get|PutScatterGatherList) would return a single SG entry for each page, or whether they would coallesce physically contiguous pages into a single entry.

The answer is that the coallescing is "kind of complex and probably won't happen in a way that will make complete sense to someone just looking at the generated [SG] lists".  To anyone who is familiar with the DMA DDIs that sort of answer probably isn't surprising :)

On X86 & for non-scatter-gather devices, the bounce buffers are allocated in big contiguous blocks and the DMA DDI will coallesce entries where possible.  Of course non-SG devices always get one big contiguous block no matter what, and so they'll only have a single entry.

On AMD64 the bounce buffers for an SG adapter aren't necessarily contiguous so there may be less coallescing.

Still, since you always have to plan for the worst case, this ends up being an optimization but shouldn't change your driver's behavior (unless your device uses single-page SG entries rather than address/length pairs).