linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: 'Kyungmin Park' <kmpark@infradead.org>,
	'Michal Nazarewicz' <m.nazarewicz@samsung.com>,
	linux-arm-kernel@lists.infradead.org,
	'Daniel Walker' <dwalker@codeaurora.org>,
	'Johan MOSSBERG' <johan.xx.mossberg@stericsson.com>,
	'Mel Gorman' <mel@csn.ul.ie>,
	linux-kernel@vger.kernel.org,
	'Michal Nazarewicz' <mina86@mina86.com>,
	linux-mm@kvack.org, 'Ankita Garg' <ankita@in.ibm.com>,
	'Andrew Morton' <akpm@linux-foundation.org>,
	linux-media@vger.kernel.org,
	'KAMEZAWA Hiroyuki' <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCHv8 00/12] Contiguous Memory Allocator
Date: Thu, 23 Dec 2010 13:44:32 +0000	[thread overview]
Message-ID: <20101223134432.GJ3636@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <00ec01cba2a2$af20b8b0$0d622a10$%szyprowski@samsung.com>

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.

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

> Please notice that there are also use cases where the memory will not be
> accessed by the CPU at all (like DMA transfers between multimedia devices
> and the system memory).

Rubbish - if you think that, then you have very little understanding of
modern CPUs.  Modern CPUs speculatively access _any_ memory which is
visible to them, and as the ARM architecture progresses, the speculative
prefetching will become more aggressive.  So if you have memory mapped
in the kernel direct map, then you _have_ to assume that the CPU will
fire off accesses to that memory at any time, loading it into its cache.

> > Okay, so I'm just going to assume that CMA has _no_ _business_ being
> > used on ARM, and is not something that should interest anyone in the
> > ARM community.
> 
> Go ahead! Remeber to remove dma_coherent because it also breaks the spec. :)
> Oh, I forgot. We can also remove all device drivers that might use DMA. :)

The only solution I've come up for dma_alloc_coherent() is to reserve
the entire coherent DMA region at boot time, taking it out of the
kernel's view of available memory and thereby preventing it from ever
being mapped or the kernel using that memory for any other purpose.
That's about the best we can realistically do for ARM to conform to the
spec.

Every time I've brought this issue up with you, you've brushed it aside.
So if you feel that the right thing to do is to ignore such issues, you
won't be surprised if I keep opposing your efforts to get this into
mainline.

If you're serious about making this work, then provide some proper code
which shows how to use this for DMA on ARM systems without violating
the architecture specification.  Until you do, I see no hope that CMA
will ever be suitable for use on ARM.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2010-12-23 13:45 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15 20:34 [PATCHv8 00/12] Contiguous Memory Allocator Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 01/12] mm: migrate.c: fix compilation error Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 02/12] lib: bitmap: Added alignment offset for bitmap_find_next_zero_area() Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 03/12] lib: genalloc: Generic allocator improvements Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 04/12] mm: move some functions from memory_hotplug.c to page_isolation.c Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 05/12] mm: alloc_contig_freed_pages() added Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 06/12] mm: alloc_contig_range() added Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 07/12] mm: cma: Contiguous Memory Allocator added Michal Nazarewicz
2011-02-02 12:43   ` Ankita Garg
2011-02-02 14:58     ` Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 08/12] mm: MIGRATE_CMA migration type added Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 09/12] mm: MIGRATE_CMA isolation functions added Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 10/12] mm: MIGRATE_CMA support added to CMA Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 11/12] mm: cma: Test device and application added Michal Nazarewicz
2010-12-15 20:34 ` [PATCHv8 12/12] ARM: cma: Added CMA to Aquila, Goni and c210 universal boards Michal Nazarewicz
2010-12-23  9:30 ` [PATCHv8 00/12] Contiguous Memory Allocator Kyungmin Park
2010-12-23 10:06   ` Russell King - ARM Linux
2010-12-23 10:58     ` Marek Szyprowski
2010-12-23 12:19       ` Russell King - ARM Linux
2010-12-23 13:09         ` Marek Szyprowski
2010-12-23 13:44           ` Russell King - ARM Linux [this message]
2011-01-12 18:49             ` Marek Szyprowski
2011-01-12 19:04               ` Nicolas Pitre
2011-01-13  7:01                 ` Marek Szyprowski
2010-12-23 13:35         ` Tomasz Fujak
2010-12-23 13:48           ` Russell King - ARM Linux
2010-12-23 14:04             ` Tomasz Fujak
2010-12-23 14:16               ` Russell King - ARM Linux
2010-12-23 14:42                 ` Felipe Contreras
2010-12-23 15:02                   ` Michal Nazarewicz
2010-12-23 18:04                   ` David Brown
2010-12-23 13:41     ` Michal Nazarewicz
2010-12-23 13:51       ` Russell King - ARM Linux
2010-12-23 14:08         ` Tomasz Fujak
2010-12-23 14:20           ` Russell King - ARM Linux
2010-12-23 15:35             ` Tomasz Fujak
2011-01-04 23:12             ` Jamie Lokier
2011-01-04 16:23     ` Johan MOSSBERG
2011-01-04 16:59       ` Michał Nazarewicz
2011-01-04 17:19       ` Russell King - ARM Linux
2011-01-04 17:31         ` Santosh Shilimkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101223134432.GJ3636@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=ankita@in.ibm.com \
    --cc=dwalker@codeaurora.org \
    --cc=johan.xx.mossberg@stericsson.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kmpark@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.nazarewicz@samsung.com \
    --cc=m.szyprowski@samsung.com \
    --cc=mel@csn.ul.ie \
    --cc=mina86@mina86.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).