Re: DMA and Cache coherency on machines without hardware enforced

Russell King (rmk@arm.linux.org.uk)
Thu, 2 Dec 1999 23:59:54 +0000 (GMT)


Jes Sorensen writes:
> I still see a need for a get_free_coherent_page() for use in cases
> where you want to share physical memory with devices. On coherent
> architectures get_free_page() does just fine today, but on machines
> like the m68k it does not. Having a standard interface would making
> device drivers portable a lot easier.
>
> Question is which API would be the most appropriate.

We've been through this discussion before a few years ago. I seem to
remember the following arguments against this proposal:

1. Not all architectures which needed a shared region to be non-cacheable
could have the cache disabled for individual pages.
2. Kernel memory may not be mapped in on a page by page basis, which
makes the controlling of any per-page cache bits difficult, or
else you have to map in the kernel page by page and pay a different
penalty.

A possible solution would be to map in two copies of kernel memory, one
cached and one uncached, but this may not be practical, especially if you
have large amounts of RAM.

If you dynamically map in RAM by some means by the allocation function
(eg, get_free_coherent_page()) you need to know both the virtual and bus
address of that page. In this case, it may not be possible for virt_to_bus
to operate on this memory, particularly if get_free_coherent_page
dynamically maps in pages for this purpose.

I'm just wondering (out loud) if get_free_coherent_page() could return a
struct page, then page_address() would give the virtual address. There
could be a bus_page_address() which returns the bus address of the page?
This would allow get_free_coherent_page() to do any special allocation or
remapping it deems necessary, but the driver itself would still be able
to get both the virtual and bus addresses cleanly?

Hmm, Jes' suggestion is beginning to grow on me, esp with the new zone
code in 2.3. ;)
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/