Re: Mapping Kernel-space to User-space

David C. Niemi (niemidc@clark.net)
Mon, 26 Jun 1995 19:42:01 -0400 (EDT)


On Tue, 27 Jun 1995 glenn@physics.unimelb.EDU.AU wrote:
...
> A while ago I changed a driver I was working on to kmalloc(....,
> GFP_DMA). Unfortunately, I found this worked unreliably (I have not
> checked this recently). Frequently, the kmalloc()'s failed though
> there was plenty of VM available. get_dma_pages() (which is called by
> kmalloc for DMA pages) just keeps calling get_free_page() until it
> gets a page below 16MB - there is no technique for indicating a
> preference for such pages. get-dma-pages() eventually gives up and
> returns to kmalloc() without getting a suitable DMA page. This problem
> is most noticeable when using loading modules which use DMA after
> memory consumption has been pushed past the 16MB mark. There is also
> no control over alignment of the DMA pages.
>
> Previously, I had been using David Niemi's DMA manager patches, which
> reserved a separate pool of DMA pages at boot time, and supported any
> alignment requirements you could think of. However, David has
> indicated that this is not a favoured approach. Is there any plan to
> provide some form of DMA support which selectively targets the memory
> below 16MB, and supports alignment requirements? There are a number of
> people working on device drivers for laboratory data acquisition who
> would find this useful.
>
> Thanks for any info or insights anyone can offer in this regard.

The new approach does not worry about alignment, because it uses the
"buddy system" to ensure that any 64KB chunk is aligned to a 64KB
boundary (as per 8-bit DMA), 128KB chunks aligned to a 128KB boundary (as
per 16-bit DMA), etc. This is achieved at no significant loss in memory,
since no memory is dedicated to DMA per se. If you need less than a 2^N
chunk, take the next higher 2^N chunk and just eat the difference; when
you are done give it back.

As for not getting the desired pages via __get_dma_pages(), Alain and I
found some significant improvements to make a couple of months ago, which
have now been put into the kernel as of 1.3.4. I expect this will meet
your needs (once again, look at how the floppy driver gets its DMA memory
to see how to call it).

Let me know if you have any further questions.

Cheers,

=========== David C. Niemi ========== Reston, Virginia, USA ===========
Even a simpleton recognizes the need for power, but fewer see the need
for balance. Power without perception is like a blind man with a large
hammer, who must be guided through his tasks. Power without control is
like a windstorm, awesome to behold but capable only of destruction.
--------- niemidc@clark.net (H) ---------- (703) 904-3596 (W) ---------