Re: [RFC] generic device DMA implementation

David Gibson (david@gibson.dropbear.id.au)
Fri, 6 Dec 2002 10:44:01 +1100


On Thu, Dec 05, 2002 at 03:43:58PM +0900, Miles Bader wrote:
> David Gibson <david@gibson.dropbear.id.au> writes:
> > > As I mentioned in my previous message, one of my platforms is like that
> > > memory, which is only 2 megabytes in size.
> >
> > Ok, that starts to make sense then (what platform is it,
> > incidentally). Is using consistent memory actually faster than doing
> > the cache flushes expliticly? Much?
>
> It's an embedded evaluation board (Midas `RTE-MOTHER-A' and
> `RTE-V850E-MA1-CB').
>
> The thing is there _is_ no cache on this machine (it's very slow), so
> cache-consistency is actually not an issue (and the cache-flushing
> macros won't help me at all).
>
> PCI devices are several busses removed from the CPU, and they only have
> this one 2MB area in common. So on this machine, PCI devices can _only_
> use consistent memory.
>
> When a driver uses the non-consistent interfaces, then:
>
> * pci_map_single allocates a `shadow area' of consistent memory and
> pci_unmap_single deallocates it

That's a little misleading: all your memory is consistent, the point
is that it is a shadow area of PCI-mappable memory.

> * pci_dma_sync_... just does a memcpy to/from the `shadow' consistent
> memory from/to the drivers kalloc'd block (in principle I think this
> is incorrect, because it uses the `dir' parameter to determine the
> direction to copy, but it works in practice)
>
> So you can see that for this platform, it would be better if drivers
> could _always_ use alloc_consistent, but many don't.

Ah, ok, now I understand. The issue here is actually nothing to do
with consistency, since your platform is fully consistent. The issue
is that there are other constraints for DMAable memory and you want
drivers to be able to easily mallocate with those constraints.

Actually, it occurs to me that PC ISA DMA is in a similar situation -
there is a constraint on DMAable memory (sufficiently low physical
address) which has nothing to do with consistency.

> Yes this is a wierd and frustrating design, but I think it does credit
> to the linux PCI layer that I could get it work at all, without
> modifying any drivers! I guess my main goal in this discussion is to
> ensure that remains the case...

Ok... see also my reply to one of James's posts.

-- 
David Gibson			| For every complex problem there is a
david@gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/