Subject: Re: CVS commit: syssrc
To: Jason R Thorpe <>
From: Matthew Jacob <>
List: tech-kern
Date: 02/24/2001 17:52:45
On Sat, 24 Feb 2001, Jason R Thorpe wrote:

> On Sat, Feb 24, 2001 at 04:14:36PM -0800, Matthew Jacob wrote:
> > I think the problem here is that there's no ordering requirement stated
> > that says that bus_dmamap_load[_raw] has to occur after bus_dmamem_map. I
> > can see that this would work okay if this was required.
> Nono... if you're using dmamap_load_raw, by definition you are not loading
> memory that is mapped into the kernel address space.  In that case, there
> is, by definition, no cache coherency issue.  (You still have to use
> dmamap_sync, tho, since there might be bounce buffers involved.)

Given what you say below, then it's a non-issue. Otherwise I think I was
misunderstood here- if the only hint as to where to allocate and map memory so
that it can be coherent via bus_dmamem_map, then the bus_dmamap_load (which
may set bits in an iommu pte- something which really can't necessarily happen
at bus_dmamap_sync time) has to happen after the hint.

>  > There's also nothing that can be use to give a hint to bus_dmamem_alloc that
>  > it should make an allocation such that a subsequent bus_dmamem_map with
>  > BUS_DMA_COHERENT would succeed sensibly
>  > 
>  > That is, unless you count the page-size allocation rule for bus_dmamem_alloc
>  > to be a sufficient guard. I don't- you assume that all you need to do is to
>  > rip a cpu mapping away from a page to guarantee you can make a piece of memory
>  > sync-able. This may not be a reasonable efficient mechanism. It'd be better to
>  > be able to tell bus_dmamem_alloc what you want the memory for to begin with.
> This all falls into the "DMA safe memory" category, which is that
> bus_dmamem_alloc() allocates.  If a piece of memory cannot be made
> coherent (either by a COHERENT mapping or by synchrnoization), then
> it should not be returned by bus_dmamem_alloc().

Yes- well- I'd mentioned this to Eduardo in that the implication might indeed
have to be that bus_dmamem_alloc has to be made coherent'able. I still think a
hint flag would be more gracious.

This all of a sudden has a sickening familiarity. The same issue was discussed
at Sun- and I think I took your part in *that* discussion. I think I made the
argument that if you wanted to have streaming I/O to memory, just allocate via
kmem_alloc and map it as you would any other I/O request.