All of lore.kernel.org
 help / color / mirror / Atom feed
From: maramaopercheseimorto@gmail.com (Alberto Panizzo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera
Date: Mon, 06 Dec 2010 11:14:52 +0100	[thread overview]
Message-ID: <1291630492.3151.14.camel@realization> (raw)
In-Reply-To: <20101206083306.GI10693@pengutronix.de>

On lun, 2010-12-06 at 09:33 +0100, Uwe Kleine-K?nig wrote:
> Hello Alberto,
> 
> On Wed, Nov 24, 2010 at 09:02:14AM +0100, Uwe Kleine-K?nig wrote:
> > On Tue, Nov 23, 2010 at 03:17:13PM +0100, Uwe Kleine-K?nig wrote:
> > > On Tue, Nov 23, 2010 at 03:08:49PM +0100, Alberto Panizzo wrote:
> > > > Hi Uwe,
> > > > On mar, 2010-11-23 at 11:26 +0100, Uwe Kleine-K?nig wrote:
> > > > > Hello Russell,
> > > > > 
> > > > > On Tue, Nov 23, 2010 at 10:12:11AM +0000, Russell King - ARM Linux wrote:
> > > > > > On Tue, Nov 23, 2010 at 10:43:02AM +0100, Uwe Kleine-K?nig wrote:
> > > > > > > There is no need to memzero the buffer because dma_alloc_coherent zeros
> > > > > > > the memory for us.
> > > > > > > 
> > > > > > > This fixes:
> > > > > > > 
> > > > > > > 	BUG: Your driver calls ioremap() on system memory.  This leads
> > > > > > > 	<4>to architecturally unpredictable behaviour on ARMv6+, and ioremap()
> > > > > > > 	<4>will fail in the next kernel release.  Please fix your driver.
> > > > > > > 
> > > > > > > Tested-by: Michael Grzeschik <mgr@pengutronix.de>
> > > > > > > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> > > > > > > ---
> > > > > > > Hello,
> > > > > > > 
> > > > > > > it seems to work this way, still I'd like to have some feedback if this
> > > > > > > is done right.  Russell?
> > > > > > 
> > > > > > Yes and probably no.  Yes, it's architecturally correct because the memory
> > > > > > will be mapped only once, thereby avoiding the aliasing issue.
> > > > > > 
> > > > > > Probably no, because the memory is mapped strongly as device memory by
> > > > > > ioremap.  ISTR whether memory remains accessible when mapped as a device
> > > > > > is not something covered by the architecture, but I guess is more to do
> > > > > > with how the interconnect on the SoC is setup.
> > > > > > 
> > > > > > In other words, we probably have gremlins lurking in
> > > > > > dma_declare_coherent_memory() which could bite us at a later date.
> > > > > That is, the patch is OK as such, right?
> > > > > 
> > > > > Best regards
> > > > > Uwe
> > > > > 
> > > > 
> > > > I'm trying to achieve the camera support for the i.MX31 3-Stack board.
> > > > The camera driver is in an early stage and results are not as expected
> > > > (I have to solve some timing issues). 
> > > > Adding the dma reservation code as you do in this patch results in 
> > > > system freeze when the capture chain is activated..
> > > Hmm, system freeze as is Sysrq doesn't work anymore?
> > > 
> > > Sysrq-L comes to mind, or CONFIG_DETECT_HUNG_TASK=y together with the
> > > various lock debug options!?
> > Anything new from your side?  I wonder if this is only a problem in your
> > driver.  Can I take a look at your driver?
> ping
> 
> I'd like to have this patch in Sascha's for-.38 patch.  Sascha, what do
> you think?
> 
> Uwe
> 

Uwe, the following function works for me:
+static void __init mx31_3ds_reserve(void)
+{
+       long ret;
+       /* reserve MX3_CAMERA_BUF_SIZE for mx3-camera */
+       mx3_camera_base = memblock_alloc(MX3_CAMERA_BUF_SIZE,
+                       /* ??? */ MX3_CAMERA_BUF_SIZE);
+       memblock_free(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
+       memblock_remove(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
+       if (!mx3_camera_base) {
+               pr_err("%s: Wrong base allocation\n", __func__);
+               return;
+       }
+       ret = memblock_reserve(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
+       if (ret) {
+               pr_err("%s: Memory not reserved\n", __func__);
+               return;
+       }
+}

The basic Idea is: why a region allocated, freed and removed can
be declared safely as dma memory for the camera in a second time?
Instead, I used the reserve API on the previous region so I am
sure that region is not used by someone else before declaring it
ad dma region for camera.

The ugly part of this code is that memblock_reserve want a base address
that I have to decide before and I am supposing that the base address
resulting from the allocate/free/remove operations, can be safely fed 
to it.

Without this reservation all tries to use gstreamer on the camera
device results in system freeze.

With a reservation of 8M I am able to end a double buffer pipeline
of a rgb565 1600x1200 image.

[  472.010000] mx3-camera mx3-camera.0: __videobuf_mmap_mapper
[  472.050000] mx3-camera mx3-camera.0: dma_alloc_coherent data is at addr c9000000 (size 3842048)
[  472.080000] mx3-camera mx3-camera.0: mmap c71ea2a0: q=c7194f08 4068a000-40a34000 (3a9800) pgoff 00087800 buf 0
[  472.100000] mx3-camera mx3-camera.0: vm_open c71ea2a0 [count=0,vma=4068a000-40a34000]
[  472.130000] mx3-camera mx3-camera.0: __videobuf_mmap_mapper
[  472.180000] mx3-camera mx3-camera.0: dma_alloc_coherent data is at addr c9400000 (size 3842048)
[  472.200000] mx3-camera mx3-camera.0: mmap c7114b20: q=c7194f08 40ace000-40e78000 (3a9800) pgoff 00087c00 buf 1
[  472.230000] mx3-camera mx3-camera.0: vm_open c7114b20 [count=0,vma=40ace000-40e78000]
[  472.250000] mx3-camera mx3-camera.0: __videobuf_iolock memory method MMAP
[  472.270000] mx3-camera mx3-camera.0: __videobuf_iolock memory method MMAP

Best Regards,

-- 
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)

  reply	other threads:[~2010-12-06 10:14 UTC|newest]

Thread overview: 209+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07  9:44 [PATCH] ARM: allow, but warn, when issuing ioremap() on RAM Felipe Contreras
2010-10-07  9:44 ` Felipe Contreras
2010-10-07 11:51 ` Baruch Siach
2010-10-07 11:51   ` Baruch Siach
2010-10-07 12:29   ` [PATCH v2] " Felipe Contreras
2010-10-07 12:29     ` Felipe Contreras
2010-10-07 18:00     ` Uwe Kleine-König
2010-10-07 18:00       ` Uwe Kleine-König
2010-10-07 19:22 ` [PATCH] " Russell King - ARM Linux
2010-10-07 19:22   ` Russell King - ARM Linux
2010-10-08  9:32   ` Felipe Contreras
2010-10-08  9:32     ` Felipe Contreras
2010-10-08 17:53     ` Russell King - ARM Linux
2010-10-08 17:53       ` Russell King - ARM Linux
2010-10-08 19:37       ` Felipe Contreras
2010-10-08 19:37         ` Felipe Contreras
2010-10-08 23:04         ` Russell King - ARM Linux
2010-10-08 23:04           ` Russell King - ARM Linux
2010-10-08 23:25           ` Greg KH
2010-10-08 23:25             ` Greg KH
2010-10-08 23:44             ` Russell King - ARM Linux
2010-10-08 23:44               ` Russell King - ARM Linux
2010-10-09  0:00               ` Greg KH
2010-10-09  0:00                 ` Greg KH
2010-10-09  0:25                 ` Russell King - ARM Linux
2010-10-09  0:25                   ` Russell King - ARM Linux
2010-10-09  0:54                   ` Greg KH
2010-10-09  0:54                     ` Greg KH
2010-10-09  2:41                   ` Nicolas Pitre
2010-10-09  2:41                     ` Nicolas Pitre
2010-10-09  3:04                     ` Greg KH
2010-10-09  3:04                       ` Greg KH
2010-10-09  9:32                       ` Felipe Contreras
2010-10-09  9:32                         ` Felipe Contreras
2010-10-11 10:05                     ` Catalin Marinas
2010-10-11 10:05                       ` Catalin Marinas
2010-10-11 10:39                       ` Felipe Contreras
2010-10-11 10:39                         ` Felipe Contreras
2010-10-11 10:52                         ` Russell King - ARM Linux
2010-10-11 10:52                           ` Russell King - ARM Linux
2010-10-11 11:23                         ` Catalin Marinas
2010-10-11 11:23                           ` Catalin Marinas
2010-10-11 12:03                           ` Felipe Contreras
2010-10-11 12:03                             ` Felipe Contreras
2010-10-11 12:30                             ` Catalin Marinas
2010-10-11 12:30                               ` Catalin Marinas
2010-10-11 22:53                               ` Nicolas Pitre
2010-10-11 22:53                                 ` Nicolas Pitre
2010-10-14 15:02                               ` Felipe Contreras
2010-10-14 15:02                                 ` Felipe Contreras
2010-10-14 17:18                                 ` Catalin Marinas
2010-10-14 17:18                                   ` Catalin Marinas
2010-10-14 17:44                                   ` Felipe Contreras
2010-10-14 17:44                                     ` Felipe Contreras
2010-10-11 11:01                       ` Pawel Moll
2010-10-11 11:01                         ` Pawel Moll
2010-10-11 11:03                         ` Catalin Marinas
2010-10-11 11:03                           ` Catalin Marinas
2010-10-16  2:39                 ` Benjamin Herrenschmidt
2010-10-16  2:39                   ` Benjamin Herrenschmidt
2010-10-16  9:43                   ` Felipe Contreras
2010-10-16  9:43                     ` Felipe Contreras
2010-10-09  0:10               ` Russell King - ARM Linux
2010-10-09  0:10                 ` Russell King - ARM Linux
2010-10-09  0:56               ` Felipe Contreras
2010-10-09  0:56                 ` Felipe Contreras
2010-10-09  9:21                 ` Russell King - ARM Linux
2010-10-09  9:21                   ` Russell King - ARM Linux
2010-10-09 10:28                   ` Felipe Contreras
2010-10-09 10:28                     ` Felipe Contreras
2010-10-09 11:11                     ` Arnd Bergmann
2010-10-09 11:11                       ` Arnd Bergmann
2010-10-09 11:43                       ` Dave Airlie
2010-10-09 11:43                         ` Dave Airlie
2010-10-09 11:55                         ` Christoph Hellwig
2010-10-09 11:55                           ` Christoph Hellwig
2010-10-09 12:17                           ` Felipe Contreras
2010-10-09 12:17                             ` Felipe Contreras
2010-10-09 12:10                         ` Felipe Contreras
2010-10-09 12:10                           ` Felipe Contreras
2010-10-09 14:37                           ` Russell King - ARM Linux
2010-10-09 14:37                             ` Russell King - ARM Linux
2010-10-09 16:18                             ` Felipe Contreras
2010-10-09 16:18                               ` Felipe Contreras
2010-10-09 11:44                       ` Uwe Kleine-König
2010-10-09 11:44                         ` Uwe Kleine-König
2010-10-09 12:05                         ` Russell King - ARM Linux
2010-10-09 12:05                           ` Russell King - ARM Linux
2010-10-09 11:59                       ` Felipe Contreras
2010-10-09 11:59                         ` Felipe Contreras
2010-10-09 14:43                         ` Arnd Bergmann
2010-10-09 14:43                           ` Arnd Bergmann
2010-10-09 18:59                           ` Guennadi Liakhovetski
2010-10-09 18:59                             ` Guennadi Liakhovetski
2010-10-10  1:52                   ` Felipe Contreras
2010-10-10  1:52                     ` Felipe Contreras
2010-10-11  8:35                     ` Uwe Kleine-König
2010-10-11  8:35                       ` Uwe Kleine-König
2010-10-11  9:02                       ` Russell King - ARM Linux
2010-10-11  9:02                         ` Russell King - ARM Linux
2010-10-11  9:24                         ` Uwe Kleine-König
2010-10-11  9:24                           ` Uwe Kleine-König
2010-10-11 10:08                           ` Felipe Contreras
2010-10-11 10:08                             ` Felipe Contreras
2010-10-11 10:15                             ` Russell King - ARM Linux
2010-10-11 10:15                               ` Russell King - ARM Linux
2010-10-11 15:25                     ` Russell King - ARM Linux
2010-10-11 15:25                       ` Russell King - ARM Linux
2010-10-14 14:47                       ` Felipe Contreras
2010-10-14 14:47                         ` Felipe Contreras
2010-10-19  8:13                       ` Colin Cross
2010-10-19  8:13                         ` Colin Cross
2010-10-19 18:12                         ` Russell King - ARM Linux
2010-10-19 18:12                           ` Russell King - ARM Linux
2010-10-19 19:21                         ` Russell King - ARM Linux
2010-10-19 19:21                           ` Russell King - ARM Linux
2010-11-23  9:43                       ` [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera Uwe Kleine-König
2010-11-23 10:12                         ` Russell King - ARM Linux
2010-11-23 10:26                           ` Uwe Kleine-König
2010-11-23 14:08                             ` Alberto Panizzo
2010-11-23 14:17                               ` Uwe Kleine-König
2010-11-24  8:02                                 ` Uwe Kleine-König
2010-12-06  8:33                                   ` Uwe Kleine-König
2010-12-06 10:14                                     ` Alberto Panizzo [this message]
2010-12-06 10:26                                       ` Russell King - ARM Linux
2010-12-06 11:37                                         ` Alberto Panizzo
2010-12-06 11:46                                           ` Russell King - ARM Linux
2010-12-06 14:09                                             ` Alberto Panizzo
2010-12-06 14:34                                               ` Russell King - ARM Linux
2010-12-06 14:54                                                 ` Alberto Panizzo
2010-12-06 16:54                                                   ` Alberto Panizzo
2010-11-23 10:39                           ` About multi-line printk and the need (not) to repeat loglevel markers [Was: Re: [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera] Uwe Kleine-König
2010-11-23 10:39                             ` Uwe Kleine-König
2010-11-23 10:58                             ` Uwe Kleine-König
2010-11-23 10:58                               ` Uwe Kleine-König
2010-11-23 22:16                               ` Linus Torvalds
2010-11-23 22:16                                 ` Linus Torvalds
2010-11-23 22:33                                 ` Russell King - ARM Linux
2010-11-23 22:33                                   ` Russell King - ARM Linux
2010-11-23 23:23                                   ` Joe Perches
2010-11-23 23:23                                     ` Joe Perches
2010-11-24  0:57                                   ` [PATCH] md: Fix single printks with multiple KERN_<level>s Joe Perches
2010-11-24  5:16                                     ` Neil Brown
2010-11-24  8:17                                 ` About multi-line printk and the need (not) to repeat loglevel markers [Was: Re: [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera] Uwe Kleine-König
2010-11-24  8:17                                   ` Uwe Kleine-König
2010-11-24  8:56                                   ` [PATCH 0/6] add some KERN_CONT markers to continuation lines Uwe Kleine-König
2010-11-24  8:57                                     ` [PATCH 1/6] ARM: " Uwe Kleine-König
2010-11-24  8:57                                       ` Uwe Kleine-König
2010-11-24  8:57                                     ` [PATCH 2/6] block: " Uwe Kleine-König
2010-11-24  8:57                                     ` [PATCH 3/6] net: " Uwe Kleine-König
2010-11-28 18:48                                       ` David Miller
2010-11-24  8:57                                     ` [PATCH 4/6] init: " Uwe Kleine-König
2010-11-24  8:57                                     ` [PATCH 5/6] mm: " Uwe Kleine-König
2010-11-24  8:57                                       ` Uwe Kleine-König
2011-02-28 15:17                                       ` Uwe Kleine-König
2011-02-28 15:17                                         ` Uwe Kleine-König
2011-03-01 21:46                                         ` Linus Torvalds
2011-03-01 21:46                                           ` Linus Torvalds
2011-03-02  5:28                                           ` Joe Perches
2011-03-02  5:28                                             ` Joe Perches
2010-11-24  8:57                                     ` [PATCH 6/6] tty/vt: " Uwe Kleine-König
2011-02-28 15:16                                       ` Uwe Kleine-König
2011-02-28 15:39                                         ` Greg KH
2011-02-28 15:50                                           ` Uwe Kleine-König
2011-02-28 16:04                                             ` Greg KH
2011-03-01  3:18                                       ` Greg KH
2010-11-24  9:09                                   ` About multi-line printk and the need (not) to repeat loglevel markers [Was: Re: [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera] Michał Mirosław
2010-11-24  9:09                                     ` Michał Mirosław
2010-11-23 22:54                         ` [PATCH] ARM: mx3/pcm037: properly allocate memory for mx3-camera Guennadi Liakhovetski
2010-10-09  0:45             ` [PATCH] ARM: allow, but warn, when issuing ioremap() on RAM Felipe Contreras
2010-10-09  0:45               ` Felipe Contreras
2010-10-09  8:56               ` Russell King - ARM Linux
2010-10-09  8:56                 ` Russell King - ARM Linux
2010-10-08 23:19       ` Greg KH
2010-10-08 23:19         ` Greg KH
2010-10-09  3:36         ` Nicolas Pitre
2010-10-09  3:36           ` Nicolas Pitre
2010-10-09 10:00           ` Felipe Contreras
2010-10-09 10:00             ` Felipe Contreras
2010-10-09 17:38             ` Nicolas Pitre
2010-10-09 17:38               ` Nicolas Pitre
2010-10-09 20:16               ` Felipe Contreras
2010-10-09 20:16                 ` Felipe Contreras
2010-10-13 16:17             ` Woodruff, Richard
2010-10-13 16:17               ` Woodruff, Richard
2010-10-14 13:48               ` Felipe Contreras
2010-10-14 13:48                 ` Felipe Contreras
2010-10-14 15:29                 ` Woodruff, Richard
2010-10-14 15:29                   ` Woodruff, Richard
2010-10-16  2:36       ` Benjamin Herrenschmidt
2010-10-16  2:36         ` Benjamin Herrenschmidt
2010-10-17 13:05         ` Woodruff, Richard
2010-10-17 13:05           ` Woodruff, Richard
2010-10-17 23:17           ` Benjamin Herrenschmidt
2010-10-17 23:17             ` Benjamin Herrenschmidt
2010-10-08 19:58   ` Andrew Morton
2010-10-08 19:58     ` Andrew Morton
2010-10-09 13:52 ` Russell King - ARM Linux
2010-10-09 13:52   ` Russell King - ARM Linux
2010-10-09 16:07   ` Felipe Contreras
2010-10-09 16:07     ` Felipe Contreras
2010-10-09 16:45     ` Russell King - ARM Linux
2010-10-09 16:45       ` Russell King - ARM Linux
2010-10-09 19:25       ` Felipe Contreras
2010-10-09 19:25         ` Felipe Contreras
2010-10-10 14:23       ` Pedanekar, Hemant
2010-10-10 14:23         ` Pedanekar, Hemant
2010-10-11  9:26       ` Catalin Marinas
2010-10-11  9:26         ` Catalin Marinas

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=1291630492.3151.14.camel@realization \
    --to=maramaopercheseimorto@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.