[PATCHv8 00/12] Contiguous Memory Allocator

Marek Szyprowski m.szyprowski at samsung.com
Wed Jan 12 13:49:56 EST 2011


Hello,

I'm sorry for the delay. Just got back from my holidays and getting thought
the mails.

On Thursday, December 23, 2010 2:45 PM Russell King - ARM Linux wrote:

> On Thu, Dec 23, 2010 at 02:09:44PM +0100, Marek Szyprowski wrote:
> > Hello,
> >
> > On Thursday, December 23, 2010 1:19 PM Russell King - ARM Linux wrote:
> >
> > > On Thu, Dec 23, 2010 at 11:58:08AM +0100, Marek Szyprowski wrote:
> > > > Actually this contiguous memory allocator is a better replacement for
> > > > alloc_pages() which is used by dma_alloc_coherent(). It is a generic
> > > > framework that is not tied only to ARM architecture.
> > >
> > > ... which is open to abuse.  What I'm trying to find out is - if it
> > > can't be used for DMA, what is it to be used for?
> > >
> > > Or are we inventing an everything-but-ARM framework?
> >
> > We are trying to get something that really works and SOLVES some of the
> > problems with real devices that require contiguous memory for DMA.
> 
> So, here you've confirmed that it's for DMA.

Right, otherwise it wouldn't really make much sense. Note that our proposal
already works for non-arm platforms. 

> > > > > In other words, do we _actually_ have a use for this which doesn't
> > > > > involve doing something like allocating 32MB of memory from it,
> > > > > remapping it so that it's DMA coherent, and then performing DMA
> > > > > on the resulting buffer?
> > > >
> > > > This is an arm specific problem, also related to dma_alloc_coherent()
> > > > allocator. To be 100% conformant with ARM specification we would
> > > > probably need to unmap all pages used by the dma_coherent allocator
> > > > from the LOW MEM area. This is doable, but completely not related
> > > > to the CMA and this patch series.
> > >
> > > You've already been told why we can't unmap pages from the kernel
> > > direct mapping.
> >
> > It requires some amount of work but I see no reason why we shouldn't be
> > able to unmap that pages to stay 100% conformant with ARM spec.
> 
> I have considered - and tried - to do that with the dma_alloc_coherent()
> spec, but it is NOT POSSIBLE to do so - too many factors stand in the
> way of making it work, such as the need bring the system to a complete
> halt to modify all the L1 page tables and broadcast the TLB operations
> to invalidate the old mappings.  None of that can be done from all the
> contexts under which dma_alloc_coherent() is called from.

I understand that this requires a lot of work, but I still think this might
be possible to get it working with some additional constraints.

I understand that modifying L1 page tables is definitely not a proper way of
handling this. It simply costs too much. But what if we consider that the DMA
memory can be only allocated from a specific range of the system memory?
Assuming that this range of memory is known during the boot time, it CAN be
mapped with two-level of tables in MMU. First level mapping will stay the
same all the time for all processes, but it would be possible to unmap the
pages required for DMA from the second level mapping what will be visible
from all the processes at once.

Is there any reason why such solution won't work?

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center






More information about the linux-arm-kernel mailing list