linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "'Janusz Krzysztofik'" <jkrzyszt@tis.icnet.pl>
Cc: "'Arnd Bergmann'" <arnd@arndb.de>,
	"'Marin Mitov'" <mitov@issp.bas.bg>,
	"'Daniel Walker'" <dwalker@codeaurora.org>,
	"'Russell King - ARM Linux'" <linux@arm.linux.org.uk>,
	"'Jonathan Corbet'" <corbet@lwn.net>,
	"'Mel Gorman'" <mel@csn.ul.ie>,
	"'Chunsang Jeong'" <chunsang.jeong@linaro.org>,
	"'KAMEZAWA Hiroyuki'" <kamezawa.hiroyu@jp.fujitsu.com>,
	linux-kernel@vger.kernel.org,
	"'Michal Nazarewicz'" <mina86@mina86.com>,
	"'Guennadi Liakhovetski'" <g.liakhovetski@gmx.de>,
	linaro-mm-sig@lists.linaro.org,
	"'Jesse Barker'" <jesse.barker@linaro.org>,
	"'Kyungmin Park'" <kyungmin.park@samsung.com>,
	"'Ankita Garg'" <ankita@in.ibm.com>,
	"'FUJITA Tomonori'" <fujita.tomonori@lab.ntt.co.jp>,
	"'Andrew Morton'" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: RE: [Linaro-mm-sig] [PATCH 6/8] drivers: add Contiguous Memory Allocator
Date: Tue, 12 Jul 2011 07:34:28 +0200	[thread overview]
Message-ID: <000d01cc4055$5e9ee050$1bdca0f0$%szyprowski@samsung.com> (raw)
In-Reply-To: <201107112101.18601.jkrzyszt@tis.icnet.pl>

Hello,

On Monday, July 11, 2011 9:01 PM Janusz Krzysztofik wrote:

> Dnia poniedziałek, 11 lipca 2011 o 15:47:32 Marek Szyprowski napisał(a):
> > Hello,
> >
> > On Saturday, July 09, 2011 4:57 PM Janusz Krzysztofik	wrote:
> > > On Wed, 6 Jul 2011 at 16:59:45 Arnd Bergmann wrote:
> > > > On Wednesday 06 July 2011, Nicolas Pitre wrote:
> > > > > On Wed, 6 Jul 2011, Russell King - ARM Linux wrote:
> > > > > > Another issue is that when a platform has restricted DMA
> > > > > > regions, they typically don't fall into the highmem zone.
> > > > > > As the dmabounce code allocates from the DMA coherent
> > > > > > allocator to provide it with guaranteed DMA-able memory,
> > > > > > that would be rather inconvenient.
> > > > >
> > > > > Do we encounter this in practice i.e. do those platforms
> > > > > requiring large contiguous allocations motivating this work
> > > > > have such DMA restrictions?
> > > >
> > > > You can probably find one or two of those, but we don't have to
> > > > optimize for that case. I would at least expect the maximum size
> > > > of the allocation to be smaller than the DMA limit for these,
> > > > and consequently mandate that they define a sufficiently large
> > > > CONSISTENT_DMA_SIZE for the crazy devices, or possibly add a
> > > > hack to unmap some low memory and call
> > > > dma_declare_coherent_memory() for the device.
> > >
> > > Once found that Russell has dropped his "ARM: DMA: steal memory for
> > > DMA coherent mappings" for now, let me get back to this idea of a
> > > hack that would allow for safely calling
> > > dma_declare_coherent_memory() in order to assign a device with a
> > > block of contiguous memory for exclusive use.
> >
> > We tested such approach and finally with 3.0-rc1 it works fine. You
> > can find an example for dma_declare_coherent() together with
> > required memblock_remove() calls in the following patch series:
> > http://www.spinics.net/lists/linux-samsung-soc/msg05026.html
> > "[PATCH 0/3 v2] ARM: S5P: Add support for MFC device on S5PV210 and
> > EXYNOS4"
> >
> > > Assuming there should be no problem with successfully allocating a
> > > large continuous block of coherent memory at boot time with
> > > dma_alloc_coherent(), this block could be reserved for the device.
> > > The only problem is with the dma_declare_coherent_memory() calling
> > > ioremap(), which was designed with a device's dedicated physical
> > > memory in mind, but shouldn't be called on a memory already
> > > mapped.
> >
> > All these issues with ioremap has been finally resolved in 3.0-rc1.
> > Like Russell pointed me in
> > http://www.spinics.net/lists/arm-kernel/msg127644.html, ioremap can
> > be fixed to work on early reserved memory areas by selecting
> > ARCH_HAS_HOLES_MEMORYMODEL Kconfig option.
> 
> I'm not sure. Recently I tried to refresh my now 7 months old patch in
> which I used that 'memblock_remove() then dma_declare_coherent_memery()'
> method[1]. It was different from your S5P MFC example in that it didn't
> punch any holes in the system memory, only stole a block of SDRAM from
> its tail. But Russell reminded me again: "we should not be mapping SDRAM
> using device mappings."[2]. Would defining ARCH_HAS_HOLES_MEMORYMODEL
> (even if it was justified) make any diference in my case? I don't think
> so.

Defining ARCH_HAS_HOLES_MEMORYMODEL changes the behavior of valid_pfn()
macro/function, which is used in the ioremap(). When defined, valid_pfn()
checks if the selected pfn is inside system memory or not (using memblock
information). If the area is removed with memblock_remove(), then a check
with valid_pfn() fails and ioremap() doesn't complain about mapping
system memory.

> Wnat I think, after Russell, is that we still need that obligatory
> ioremap() removed from dma_declare_coherent_memory(), or made it
> optional, or a separate dma_declare_coherent_memory()-like function
> without (obligatory) ioremap() provided by the DMA API, in order to get
> the dma_declare_coherent_memery() method being accepted without any
> reservations when used inside arch/arm, I'm afraid.

Please check again with 3.0-rc1. ARCH_HAS_HOLES_MEMORYMODEL solution was
suggested by Russell. It looks like this is the correct solution for this
problem, because I don't believe that ioremap() will be removed from 
dma_declare_coherent() anytime soon. 

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




  reply	other threads:[~2011-07-12  5:35 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  7:41 [PATCHv11 0/8] Contiguous Memory Allocator Marek Szyprowski
2011-07-05  7:41 ` [PATCH 1/8] mm: move some functions from memory_hotplug.c to page_isolation.c Marek Szyprowski
2011-07-05 11:27   ` Arnd Bergmann
2011-07-05  7:41 ` [PATCH 2/8] mm: alloc_contig_freed_pages() added Marek Szyprowski
2011-07-05 11:30   ` Arnd Bergmann
2011-07-05  7:41 ` [PATCH 3/8] mm: alloc_contig_range() added Marek Szyprowski
2011-07-05 11:31   ` Arnd Bergmann
2011-07-05  7:41 ` [PATCH 4/8] mm: MIGRATE_CMA migration type added Marek Szyprowski
2011-07-05 11:44   ` Arnd Bergmann
2011-07-05 12:27     ` Russell King - ARM Linux
2011-07-05  7:41 ` [PATCH 5/8] mm: MIGRATE_CMA isolation functions added Marek Szyprowski
2011-07-05 11:45   ` Arnd Bergmann
2011-07-05  7:41 ` [PATCH 6/8] drivers: add Contiguous Memory Allocator Marek Szyprowski
2011-07-05 10:24   ` Marek Szyprowski
2011-07-05 11:02   ` [PATCH 6/8 RESEND] " Marek Szyprowski
2011-07-05 11:50     ` Arnd Bergmann
2011-07-05 11:33   ` [PATCH 6/8] " Russell King - ARM Linux
2011-07-05 12:27     ` Arnd Bergmann
2011-07-05 12:30       ` Russell King - ARM Linux
2011-07-05 13:58         ` Arnd Bergmann
2011-07-08 17:25           ` Russell King - ARM Linux
2011-07-12 13:39             ` Arnd Bergmann
2011-08-03 17:43       ` James Bottomley
2011-09-26 12:06         ` Marek Szyprowski
2011-09-26 13:00         ` Russell King - ARM Linux
2011-07-06 13:58     ` Marek Szyprowski
2011-07-06 14:09       ` Arnd Bergmann
2011-07-06 14:23         ` Russell King - ARM Linux
2011-07-06 14:37           ` [Linaro-mm-sig] " Nicolas Pitre
2011-07-06 14:59             ` Arnd Bergmann
2011-07-09 14:57               ` Janusz Krzysztofik
2011-07-11 13:47                 ` Marek Szyprowski
2011-07-11 19:01                   ` Janusz Krzysztofik
2011-07-12  5:34                     ` Marek Szyprowski [this message]
2011-07-06 14:51           ` Arnd Bergmann
2011-07-06 15:48             ` Russell King - ARM Linux
2011-07-06 16:05               ` Christoph Lameter
2011-07-06 16:09                 ` Michal Nazarewicz
2011-07-06 16:19                   ` Christoph Lameter
2011-07-06 17:15                     ` Russell King - ARM Linux
2011-07-06 19:03                       ` Christoph Lameter
2011-07-06 17:02                 ` Russell King - ARM Linux
2011-07-06 16:31               ` Arnd Bergmann
2011-07-06 19:10                 ` Nicolas Pitre
2011-07-06 20:23                   ` [Linaro-mm-sig] " Arnd Bergmann
2011-07-07  5:29                     ` Nicolas Pitre
2011-07-06 14:56         ` Marek Szyprowski
2011-07-06 15:37           ` Russell King - ARM Linux
2011-07-06 15:47             ` Marek Szyprowski
2011-07-14 12:29   ` Marek Szyprowski
2011-07-05  7:41 ` [PATCH 7/8] ARM: integrate CMA with dma-mapping subsystem Marek Szyprowski
2011-07-05 11:50   ` Arnd Bergmann
2011-07-05  7:41 ` [PATCH 8/8] ARM: S5PV210: example of CMA private area for FIMC device on Goni board Marek Szyprowski
2011-07-05 11:51   ` Arnd Bergmann
2011-07-05 12:07 ` [PATCHv11 0/8] Contiguous Memory Allocator Arnd Bergmann
2011-07-05 12:28   ` Russell King - ARM Linux
2011-07-06 22:11   ` Andrew Morton
2011-07-07  7:36     ` Arnd Bergmann
2011-07-11 13:24     ` Marek Szyprowski

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='000d01cc4055$5e9ee050$1bdca0f0$%szyprowski@samsung.com' \
    --to=m.szyprowski@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=ankita@in.ibm.com \
    --cc=arnd@arndb.de \
    --cc=chunsang.jeong@linaro.org \
    --cc=corbet@lwn.net \
    --cc=dwalker@codeaurora.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=g.liakhovetski@gmx.de \
    --cc=jesse.barker@linaro.org \
    --cc=jkrzyszt@tis.icnet.pl \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linaro-mm-sig@lists.linaro.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=linux@arm.linux.org.uk \
    --cc=mel@csn.ul.ie \
    --cc=mina86@mina86.com \
    --cc=mitov@issp.bas.bg \
    /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).