Regarding consistent_alloc

Paul Mackerras paulus at au1.ibm.com
Sat Dec 7 11:25:26 EST 2002


Matt Porter writes:

> On Fri, Dec 06, 2002 at 11:56:22AM -0500, Dan Malek wrote:
> > Matt Porter wrote:
> >
> >  > ....  If you
> > > want the kernel virtual address then you can apply __va to that.
> >
> > Errr....no, you can't.  That would give you the cached mapping.
> > You need to hang on to both the dma_handle (the phys address token)
> > and the virtual address returned by the function.  That's why both
> > are returned.
>
> That's what I said...but you clipped it out.  Once again,
> consistent_alloc provides the caller everything they need.
> An uncached mapping, a phys address, and from that you can use
> __va() to get the cached mapping.

Matt, you know this I'm sure, but other people reading this might not:

You should NOT use the cached mapping unless you really know *exactly*
what you are doing.

The PowerPC architecture specifies that accessing a given physical
address through an uncached mapping, when there exists a copy of that
physical location in cache, is a programming error.  Different
implementations will do different things in this case.

> Seemed clear enough to me the first time.  My definition of a
> "kernel virtual address" is the lowmem cached mapping.  If
> I meant the uncached mapping I would have said it was a "kernel
> vmalloc address" or something. :)

A "kernel virtual address" is, to me (and to Dan as well, I expect),
any virtual address in the kernel portion of the address space
(i.e. above TASK_SIZE).  (Of course, you are free to adopt Humpty
Dumpty's attitude in Through the Looking Glass: "'When I use a word,
Humpty Dumpty said in rather a scornful tone, 'it means just what I
choose it to mean - neither more nor less.'" ;-)

Regards,
Paul.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-embedded mailing list