1999-12-01 15:12:17

by Ingo Molnar

[permalink] [raw]
Subject: Re: DMA and Cache coherency on machines without hardware enforced cache coherency.

On Wed, 1 Dec 1999, Ralph Blach wrote:

> I have to write a device driver for a machine which does not have
> hardware enforced cache coherency between bus master devices and the
> CPU caches. Is there a way to allocate certain buffers in uncached
> memory. I know this would lower performance, but it would also solve
> certain problems which seem to be cropping up.

ioremap_nocache(). You can also use ioremap_nocache() on allocated pages
(it's a page granularity thing) via doing something like:

page = __get_free_pages(whatever, order);
ptr = ioremap_nocache(virt_to_phys(page), 1 <<

then use 'ptr' as an uncached alias to your pages. You cannot do the above
in interrupts (obviously), and it's not fast so probably it's worth being
done once, at initization time.

for this to work you also have to modify arch/i386/mm/ioremap.c and
remove the following lines:

* Don't allow anybody to remap normal RAM that we're using..
if (phys_addr < virt_to_phys(high_memory))
return NULL;

and remove:

if (addr > high_memory)

from the iounmap() function.

or better, create a new interface (memremap_nocache()) which only remaps
normal RAM pages.

-- mingo