Received: from eggs.gnu.org ([2001:4830:134:3::10]:45131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOqSG-0006p2-CX for qemu-devel@nongnu.org; Mon, 10 Aug 2015 13:01:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOqSA-0007Rq-1P for qemu-devel@nongnu.org; Mon, 10 Aug 2015 13:01:44 -0400 Received: from zose-mta05.web4all.fr ([185.49.20.50]:35816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOqS9-0007RU-NO for qemu-devel@nongnu.org; Mon, 10 Aug 2015 13:01:37 -0400 Message-ID: <55C8D8EF.4090304@tribudubois.net> Date: Mon, 10 Aug 2015 19:01:35 +0200 From: Jean-Christophe DUBOIS MIME-Version: 1.0 References: <84eb5a74233f317b36f41963e465851328972355.1437080501.git.jcd@tribudubois.net> <55C8CE07.2060705@tribudubois.net> In-Reply-To: Content-Type: multipart/alternative; boundary="------------020507020402030908070109" Subject: Re: [Qemu-devel] [PATCH v13 13/19] i.MX: KZM now uses the standalone i.MX31 SOC support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , QEMU Developers This is a multi-part message in MIME format. --------------020507020402030908070109 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Le 10/08/2015 18:23, Peter Maydell a =C3=A9crit : > On 10 August 2015 at 17:15, Jean-Christophe DUBOIS wrote: >> Le 07/08/2015 15:45, Peter Maydell a =C3=A9crit : >> >> On 16 July 2015 at 22:21, Jean-Christophe Dubois >> wrote: >> memory_region_allocate_system_memory() needs to be called once and >> only once by a board init. You're going to end up calling it twice her= e. >> >> >> Actually, I may be calling it up 3 time because there is also an inter= nal >> (16KB) memory range that is allocated during the SOC init (fsl-imx31.c >> file). > Small blocks of stuff like 16KB are not the "main lump of RAM", so > should not be initialized with memory_region_allocate_system_memory(). > Use memory_region_init_ram() followed by vmstate_register_ram_global() > for that sort of small RAM region. OK, I'll do it but it seems to me that in our case=20 memory_region_allocate_system_memory() basically do: * memory_region_init_ram() * vmstate_register_ram_global() > >> Now as my memory (the 3 memory banks) is (partially) discontiguous ho= w am I >> suppose to init all of it in one call? > Your main RAM will be all contiguous, the only reason it would be > discontiguous is if you were trying to model 128MB + 128MB, > which you can't specify anyway with a single 'this much memory' ram_siz= e > argument. Yes, It will make things a little more complex for the alias memory (if=20 any). I'll work something up. > >> And if memory_region_allocate_system_memory() should really be called = only >> once, why is it not enforced in this function? After all, >> memory_region_allocate_system_memory() only calls memory_region_init_r= am() >> and vmstate_register_ram_global() in one step ... > It does a lot more complicated things than that, potentially. For NUMA platforms, it seems. But in our simple case it seems that it=20 doesn't do a lot more. But OK, I'll change things. > I agree that it ought to assert the once-and-only-once property; > in fact I suggested on IRC last week that that would be a good > plan, since it's an easy mistake to make. > > thanks > -- PMM > --------------020507020402030908070109 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Le 10/08/2015 18:23, Peter Maydell a =C3=A9crit=C2=A0:
On 10 August 2015 at 17:15, Jean-Christophe DUBOIS <=
a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:jcd@tribudubois.net"><=
;jcd@tribudubois.net> wrote:
Le 07/08/2015 15:45, Peter Maydell a =C3=A9crit :

On 16 July 2015 at 22:21, Jean-Christophe Dubois <jcd@tribudubois.net>=
;
wrote:

      
memory_region_allocate_system_memory() needs to be called once and
only once by a board init. You're going to end up calling it twice here.


Actually, I may be calling it up 3 time because there is also an internal
(16KB) memory range that is allocated during the SOC init (fsl-imx31.c
file).
Small blocks of stuff like 16KB are not the "main lump of RAM", so
should not be initialized with memory_region_allocate_system_memory().
Use memory_region_init_ram() followed by vmstate_register_ram_global()
for that sort of small RAM region.

OK, I'll do it but it seems to me that in our case memory_region_allocate_system_memory() basically do:
  • memory_region_init_ram()
  • vmstate_register_ram_global()

Now as my memory (the 3 memory banks) is  (partial=
ly) discontiguous how am I
suppose to init all of it in one call?
Your main RAM will be all contiguous, the only reason it would be
discontiguous is if you were trying to model 128MB + 128MB,
which you can't specify anyway with a single 'this much memory' ram_size
argument.

Yes, It will make things a little more complex for the alias memory (if any).
I'll work something up.
=C2=A0

And if memory_region_allocate_system_memory() shou=
ld really be called only
once, why is it not enforced in this function? After all,
memory_region_allocate_system_memory() only calls memory_region_init_ram(=
)
and vmstate_register_ram_global() in one step ...
It does a lot more complicated things than that, potentially.

For NUMA platforms, it seems. But in our simple case it seems that it doesn't do a lot more. But OK, I'll change things.

I agree that it ought to assert the once-and-only-once property;
in fact I suggested on IRC last week that that would be a good
plan, since it's an easy mistake to make.

thanks
-- PMM


--------------020507020402030908070109--