public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: omap4: Fix omap_barriers_init for generic ioremap changes
Date: Thu, 12 Jan 2012 20:27:12 +0000	[thread overview]
Message-ID: <20120112202712.GC16726@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAMQu2gw+cYgY-Pn=3wbYBVxtGULvRG9H326-z_aHP+yMeD8RLg@mail.gmail.com>

On Thu, Jan 12, 2012 at 09:20:38PM +0100, Shilimkar, Santosh wrote:
> On Thu, Jan 12, 2012 at 9:11 PM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > On Thu, Jan 12, 2012 at 08:04:43PM +0000, Russell King - ARM Linux wrote:
> >> On Thu, Jan 12, 2012 at 10:42:57AM -0800, Tony Lindgren wrote:
> >> > Commit 73829af71fdb8655e7ba4b5a2a6612ad34a75a11
> >> > (Merge branch 'vmalloc' of git://git.linaro.org/people/nico/linux
> >> > into devel-stable) merged generic ioremap changes.
> >> >
> >> > Commit 137d105d50f6e6c373c1aa759f59045e6239cf66
> >> > (ARM: OMAP4: Fix errata i688 with MPU interconnect barriers)
> >> > added a workaround for omap4.
> >> >
> >> > In order for the errata to work, we now need the following
> >> > patch or else we'll get:
> >> >
> >> > kernel BUG at mm/vmalloc.c:1134!
> >>
> >> Oh my, I've just read this, and I'm extremely annoyed that this even hit
> >> mainline in the first place. ?It's utter crap.
> >>
> >> It's trying to use memblock to allocate memory _AFTER_ that memory has
> >> been passed on from memblock's control to other allocators. ?Calling
> >> memblock_alloc() at *any* initcall is Bad News (it _may_ appear to work
> >> but there's no way for memblock_alloc to tell anything else that the
> >> memory is being re-used.)
> >>
> >> Calling it and then trying to reserve it at ->map_io time is also Bad
> >> News - the memory at that point has already been mapped, and if you're
> >> expecting to be able to remap it with different attributes, you're going
> >> to double-map it with differing attributes. ?You lose.
> >>
> >> Not only that, but it's an abuse of the various callback functions into
> >> machine code. ?Don't do it.
> >>
> >> By all means, allocate the memory via memblock, but do it in the ->reserve
> >> callback. ?It's *exactly* what that callback is there for. ?The map it in
> >> the ->map_io callback.
> >>
> >> Don't try to be clever and abuse these callbacks. ?They aren't named just
> >> for fun and my delectation. ?They have *specific* purposes. ?Stick to
> >> those purposes in them and don't try to be clever, or you'll be moaned at.
> >>
> >> So, NAK. ?NAK for the original patch too. ?Do it properly.
> >
> > It seems I missed this detail when I quickly read through the original
> > patch last September, which is rather unfortunate.
> >
> > That doesn't stop this being completely the wrong approach though - and
> > being very very broken as it currently stands.
> 
> May be I have missed you point but I thought below
> should remove the initial mapping.
> 
> memblock_free(paddr, size);
> memblock_remove(paddr, size);

Yes - but _only_ in the ->reserve callback, which was specifically added
to allow this to happen.  It is _only_ possible in _that_ callback and
nowhere else.

And, as I've said, memblock_alloc() elsewhere[*] is _potentially_ _dangerous_
because although it succeeds, the memory has _already_ been handed off to
other kernel allocators, and memblock no longer has control over how the
memory it holds will be used.

> This patch actually got under various versions. Indeed the
> first version did implement the ->reserve callback method
> but then it kept changing and you might have lost track of it.

Which "it" kept changing ?  The ->reserve callback hasn't, neither has
the above condition - and neither will it change.

As I've said, it's the whole point why the ->reserve callback as added: to
allow platforms to mark various regions of RAM as reserved, and remove
regions of RAM from the kernel's control _before_ they get mapped by the
kernel.



* - actually, the latest memblock_alloc() can be called is the map_io
callback, but at that point a call to memblock_free() would be buggy.
So lets not dilute the message.  ->reserve ONLY.

  reply	other threads:[~2012-01-12 20:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 18:42 [PATCH] arm: omap4: Fix omap_barriers_init for generic ioremap changes Tony Lindgren
2012-01-12 19:26 ` Shilimkar, Santosh
2012-01-12 19:44 ` Nicolas Pitre
2012-01-12 19:48   ` Nicolas Pitre
2012-01-12 19:59     ` Tony Lindgren
2012-01-13 14:05       ` Russell King - ARM Linux
2012-01-13 15:04         ` Russell King - ARM Linux
2012-01-13 16:44           ` Tony Lindgren
2012-01-13 17:12         ` Felipe Contreras
2012-01-12 20:04 ` Russell King - ARM Linux
2012-01-12 20:11   ` Russell King - ARM Linux
2012-01-12 20:20     ` Shilimkar, Santosh
2012-01-12 20:27       ` Russell King - ARM Linux [this message]
2012-01-12 20:32         ` Shilimkar, Santosh
2012-01-12 21:00           ` Russell King - ARM Linux
2012-01-13 10:35             ` Shilimkar, Santosh

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=20120112202712.GC16726@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox