linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Kumar Gala <kumar.gala@freescale.com>
Cc: linuxppc-dev list <linuxppc-dev@ozlabs.org>,
	linuxppc-embedded@ozlabs.org
Subject: Re: RFC: Deprecating io_block_mapping
Date: Wed, 25 May 2005 17:04:19 +1000	[thread overview]
Message-ID: <1117004659.6395.103.camel@gaston> (raw)
In-Reply-To: <0015d371e12596fecdefd971b4fb1e5a@freescale.com>


> Can one of you explain why this is necessary.  I believe it I just dont 
> understand.  I think this is one of the abuses of io_block_mapping().  
> People, myself included, realize some of the caveats implied by calling 
> io_block_mapping().

Well, there are 2 different things here. io_block_mapping "moving"
ioremap_bot, and my idea of having io_block_mapping "using" it...

So basically, the vmalloc/ioremap space starts at the end of the memory
linear mapping, and ends at ... ioremap_bot :)

This value is initially set to the "top" of the space useable for
vmalloc/ioremap. It's possible however to do "early" ioremap's (that is
before the vmalloc subsystem is initialized, and thus before we can
dynamically allocate virtual regions). In this case, ioremap just moves
ioremap_bot down and uses the space between the new and the previous
value.

In order to avoid having "block" mappings done by io_block_mapping()
collide with ioremap/vmalloc space, io_block_mapping() also has this bit
of code:

	if (virt > KERNELBASE && virt < ioremap_bot)
		ioremap_bot = ioremap_base = virt;

Which will "move down" ioremap_bot as well if a block mapping ends up in
the kernel area.

Now, my idea is that I dislike the io_block_mapping() interface because
we have to provide the virtual address. Which means, it forces us to
create hard coded v->p mappings, and I consider hard coding virtual
addresses a bad thing (for lots of reasons, including the TASK_SIZE
one).

Thus, I think we could "extend" io_block_mapping() to be able to take
"0" for virt, and return a virtual address. That would be 100%
compatible with existing code. When taking "0" for virt,
io_block_mapping would just allocate virtual space like early
ioremap_bot does, by moving ioremap_bot downward (with appropriate
aligment restrictions). By returning the actual virtual address used, it
makes possible for the caller to know it :)

That way, io_block_mapping() _can_ be used without hard coding virtual
addresses, which would then be documented as the "preferred" thing to
do, and would avoid some of the headaches.

Now, there may be a slight issue with when is ioremap_bot initialized...

It is in bss, so it is 0 by default (which isn't really suitable). It's
only initialized in MMU_init(). Thus there is a problem using it before
MMU_init(). Does that ever happen ? If it does, things are broken, since
the test "virt < ioremap_bot" will always be false anyway, and thus
io_block_mapping() will "fail" to move down ioremap_bot, thus
potentially letting the kernel allocate vmalloc/ioremap space that
overlap the block mapping.

Dan's point about io_block_mapping() supposedly "initializing"
ioremap_bot is bogus, unless I misunderstood him.

Ben.

  reply	other threads:[~2005-05-25  7:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-25  1:30 RFC: Deprecating io_block_mapping Benjamin Herrenschmidt
2005-05-25  2:17 ` Kumar Gala
2005-05-25  2:21   ` Benjamin Herrenschmidt
2005-05-25  2:30     ` Kumar Gala
2005-05-25  5:00       ` Dan Malek
2005-05-25  6:07         ` Pantelis Antoniou
2005-05-25  5:14     ` Dan Malek
2005-05-25  5:20       ` Benjamin Herrenschmidt
2005-05-25  5:49         ` Dan Malek
2005-05-25  6:00           ` Benjamin Herrenschmidt
2005-05-25  6:08             ` Kumar Gala
2005-05-25  7:04               ` Benjamin Herrenschmidt [this message]
2005-05-25 16:36                 ` Dan Malek
2005-05-25 21:44                   ` Benjamin Herrenschmidt
2005-05-26  6:00                     ` Dan Malek
2005-05-26  6:20                       ` Eugene Surovegin
2005-05-26 19:00                         ` Dan Malek
2005-05-26 21:54                           ` Benjamin Herrenschmidt
2005-05-26  6:41                       ` Benjamin Herrenschmidt
2005-05-26 19:32                         ` Dan Malek
2005-05-26 22:10                           ` Benjamin Herrenschmidt
2005-05-26 20:30                         ` Mark A. Greer
2005-05-26 22:13                           ` Benjamin Herrenschmidt
2005-05-26 22:16                             ` Mark A. Greer
2005-05-26 16:31                       ` Matt Porter
2005-05-26 16:54                         ` Eugene Surovegin
2005-05-25  4:48   ` Dan Malek
2005-05-25  4:45 ` Dan Malek
2005-05-25  5:15   ` Benjamin Herrenschmidt

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=1117004659.6395.103.camel@gaston \
    --to=benh@kernel.crashing.org \
    --cc=kumar.gala@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=linuxppc-embedded@ozlabs.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;
as well as URLs for NNTP newsgroup(s).