lkml.org 
[lkml]   [1999]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: DMA and Cache coherency on machines without hardware enforced
Date
>> Also note that if one wants to produce the bus address to
>> program a DMA master he/she must use virt_to_bus(page), and NOT
>> virt_to_bus(ptr).
>
>Where did you get this requirement from? That isn't what
>Documentation/IO-mapping.txt appears to indicate.

Umm Bret, I knew it would not be obvious for everybody
this is why put this paragraph in. In IO-mapping.txt
Linus assumes that ioremap() works with locations on the outside
of CPU MMU or bridge. virt_to_bus is not applicable to
that at all.

I abused ioremap() giving it an address of memory on
the inside, which is, strictly speaking, illegal.
[ I am pleasantly surprised that mingo promotes this idea
(minus difference between ioremap() and ioremap_nocache()).
Yet I think it's illegal until Linus blesses it. ]
Nonetheless, consider what happens, given the 32 bits example from
IO-mapping.txt:

physical address: 0
virtual address: 0xC0000000
bus address: 0x80000000

ioremap() returns you something in the virtual space.
It may be 50000000, or F8000000, or any other weird number.
What it cannot be however, is C0000000 plus something.

virt_to_bus(), in theory could work like this:
1. walk page tables and get physical address
2. calculate bus address from that (same on x86, not same in
our example).

This would be a long operation, instead virt_to_bus just knows
how high a virtual mapping starts, subtracts 0xC0000000
to get physical, then OR-s selector bits in to get bus address
(or does whatever magic is necessary, multiplies by PI or something).

As you can see this mechanism gets completely screwed once
you feed it our imaginary ioremap-ed address 50000000 or F8000000.

I hope this is clear :).

>When you say you must use virt_to_bus(page), I'm guessing you mean that the
>address must be page aligned.

I am not sure it is necessary or, indeed, possible.
For example, sun4 has 8K pages, sun4m has 4K pages.
And how exactly a driver is supposed to align addresses, I wonder.

--Pete

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.035 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site