linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Reserving small amounts of memory with mem= (MPC85xx, 2.6.15 arch/ppc)
@ 2008-06-12 16:18 Florian Boelstler
  2008-06-12 19:14 ` Sylvain Joyeau
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Boelstler @ 2008-06-12 16:18 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

I ran into problems reserving small amounts of memory using command line 
argument 'mem'.
Limiting a MPC8540 with 512MB physical available memory down to 256MB 
has been successfully done using U-Boot:

=> setenv bootargs console=ttyS0,115200 mem=256M
=> setenv initrd_high 10000000
=> bootm 0x02100000

## Booting image at 02100000 ...
    Image Name:   Linux 2.6.15
    Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
    Data Size:    6965022 Bytes =  6.6 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
    Image 0:  1099550 Bytes =  1 MB
    Image 1:  5865458 Bytes =  5.6 MB
    Verifying Checksum ... OK
    Uncompressing Multi-File Image ... OK
[...]
    Loading Ramdisk to 0fa68000, end 0ffffff2 ... OK

Memory CAM mapping: CAM0=256Mb, CAM1=0Mb, CAM2=0Mb residual: 0Mb
Linux version 2.6.15 (flo@escape) (gcc version 3.4.3) #21 PREEMPT Fri 
Nov 30 16:47:32 CET 2007
[...]

root@mpc0:/# cat /proc/meminfo
MemTotal:       257272 kB
MemFree:        226332 kB
[...]

When a larger size for 'mem' (say 508M for reserving 4M) and appropriate 
'initrd_high' is used, U-Boot is still able to load the ramdisk to its 
correct place in RAM. However Linux seems to not accept that memory 
region and removes the memory using mem_pieces_remove(), which leads to 
a crash since it cannot access area used for the ramdisk(?).
In that case output of "residual" for CAM mapping shows a value != 0.

My assumption is that these CAM mappings cannot be used for memory 
portions less than a certain size.
I need to dig into that, please correct me if I'm wrong.

Linux 2.6.15 build for arch/ppc on custom MPC8540 board (Linux BSP 
similar to MPC8540ads). U-Boot 1.2.0.

Thanks for any suggestions.

   Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Reserving small amounts of memory with mem= (MPC85xx, 2.6.15 arch/ppc)
  2008-06-12 16:18 Reserving small amounts of memory with mem= (MPC85xx, 2.6.15 arch/ppc) Florian Boelstler
@ 2008-06-12 19:14 ` Sylvain Joyeau
  2008-06-13 14:30   ` Florian Boelstler
  0 siblings, 1 reply; 5+ messages in thread
From: Sylvain Joyeau @ 2008-06-12 19:14 UTC (permalink / raw)
  To: Florian Boelstler; +Cc: linuxppc-embedded

Hi,

Residual memory size is what Linux couldn't map with its three CAM
entries. The main figure you can check is the sum of the three first
CAMs   plus residual is what you specified (CAM0+CAM1+CAM2+residuak =3D=3D
'mem'). It's not weird to get a residual !=3D 0 when specified memory
size isn't a good combination of power of 2.
Stupid question: have you tried mem=3D512M and a correct RAM disk address ?
No more comments...

--
sj

2008/6/12 Florian Boelstler <euphoria@arcor.de>:
> Hi,
>
> I ran into problems reserving small amounts of memory using command line
> argument 'mem'.
> Limiting a MPC8540 with 512MB physical available memory down to 256MB has
> been successfully done using U-Boot:
>
> =3D> setenv bootargs console=3DttyS0,115200 mem=3D256M
> =3D> setenv initrd_high 10000000
> =3D> bootm 0x02100000
>
> ## Booting image at 02100000 ...
>   Image Name:   Linux 2.6.15
>   Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
>   Data Size:    6965022 Bytes =3D  6.6 MB
>   Load Address: 00000000
>   Entry Point:  00000000
>   Contents:
>   Image 0:  1099550 Bytes =3D  1 MB
>   Image 1:  5865458 Bytes =3D  5.6 MB
>   Verifying Checksum ... OK
>   Uncompressing Multi-File Image ... OK
> [...]
>   Loading Ramdisk to 0fa68000, end 0ffffff2 ... OK
>
> Memory CAM mapping: CAM0=3D256Mb, CAM1=3D0Mb, CAM2=3D0Mb residual: 0Mb
> Linux version 2.6.15 (flo@escape) (gcc version 3.4.3) #21 PREEMPT Fri Nov=
 30
> 16:47:32 CET 2007
> [...]
>
> root@mpc0:/# cat /proc/meminfo
> MemTotal:       257272 kB
> MemFree:        226332 kB
> [...]
>
> When a larger size for 'mem' (say 508M for reserving 4M) and appropriate
> 'initrd_high' is used, U-Boot is still able to load the ramdisk to its
> correct place in RAM. However Linux seems to not accept that memory regio=
n
> and removes the memory using mem_pieces_remove(), which leads to a crash
> since it cannot access area used for the ramdisk(?).
> In that case output of "residual" for CAM mapping shows a value !=3D 0.
>
> My assumption is that these CAM mappings cannot be used for memory portio=
ns
> less than a certain size.
> I need to dig into that, please correct me if I'm wrong.
>
> Linux 2.6.15 build for arch/ppc on custom MPC8540 board (Linux BSP simila=
r
> to MPC8540ads). U-Boot 1.2.0.
>
> Thanks for any suggestions.
>
>  Florian
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>



--=20
------------------
Sylvain JOYEAU
Freelance Engineer
Software RT-OS R&D
sylvain.joyeau@gmail.com
T=E9l: +33-(0)667 477 052
"A good idea is one side of the coin. The other side is the practical
usefulness". J. Liedke.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Reserving small amounts of memory with mem= (MPC85xx,   2.6.15 arch/ppc)
  2008-06-12 19:14 ` Sylvain Joyeau
@ 2008-06-13 14:30   ` Florian Boelstler
  2008-06-13 15:31     ` Scott Wood
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Boelstler @ 2008-06-13 14:30 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

thanks for your response.

Sylvain Joyeau wrote:
> Residual memory size is what Linux couldn't map with its three CAM
> entries. The main figure you can check is the sum of the three first
> CAMs   plus residual is what you specified (CAM0+CAM1+CAM2+residuak ==
> 'mem'). It's not weird to get a residual != 0 when specified memory
> size isn't a good combination of power of 2.

Again I tried mem=508M together with initrd_high @ 10000000. This time 
the kernel booted.
Shown mapping is: CAM0=256Mb, CAM1=64Mb, CAM2=64Mb residual: 124Mb, 
which is == 'mem'.

Available system memory is only 384 MB (CAM0+CAM1+CAM2), which explains 
why Linux "removed" the ramdisk, when it has been copied right below 
508M by U-Boot. Because at that time I was using initrd_high @ 1FC00000, 
which is outside of mapped RAM.

Is there an option to map less than 64M by a CAM entry?

> Stupid question: have you tried mem=512M and a correct RAM disk address ?
> No more comments...

I just did that (I don't get what you wanted to achieve with these 
settings, since this the default):

=> setenv bootargs console=ttyS0,115200 mem=512M
=> setenv initrd_high 20000000
=> bootm 0x02100000

## Booting image at 02100000 ...
    Image Name:   Linux 2.6.15
    Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
    Data Size:    6965022 Bytes =  6.6 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
    Image 0:  1099550 Bytes =  1 MB
    Image 1:  5865458 Bytes =  5.6 MB
    Verifying Checksum ... OK
    Uncompressing Multi-File Image ... OK
## Current stack ends at 0x1FFAECB8 => set upper limit to 0x00800000
[...]

## initrd at 0x0220C76C ... 0x027A475D (len=5865458=0x597FF2)
    Loading Ramdisk to 1fa16000, end 1ffadff2 ... OK
## Transferring control to Linux (at address 00000000) ...
Memory CAM mapping: CAM0=256Mb, CAM1=256Mb, CAM2=0Mb residual: 0Mb
Linux version 2.6.15 (flo@escape) (gcc version 3.4.3) #21 PREEMPT Fri 
Nov 30 16:47:32 CET 2007
[...]

Have a nice weekend,

   Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Reserving small amounts of memory with mem= (MPC85xx,   2.6.15 arch/ppc)
  2008-06-13 14:30   ` Florian Boelstler
@ 2008-06-13 15:31     ` Scott Wood
  2008-06-16 14:26       ` Florian Boelstler
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2008-06-13 15:31 UTC (permalink / raw)
  To: Florian Boelstler; +Cc: linuxppc-embedded

Florian Boelstler wrote:
> Available system memory is only 384 MB (CAM0+CAM1+CAM2), which explains 
> why Linux "removed" the ramdisk, when it has been copied right below 
> 508M by U-Boot. Because at that time I was using initrd_high @ 1FC00000, 
> which is outside of mapped RAM.
> 
> Is there an option to map less than 64M by a CAM entry?

CAM entries can be any power of 4 between 4K and 256M.  However, the 
code currently is hardcoded to use no more than 3 entries.  It shouldn't 
be too hard to change it to use a few more (see cam_mapin_ram(), 
mmu_mapin_ram(), and adjust_total_lowmem() in 
arch/powerpc/mm/fsl_booke_mmu.c).

Alternately, do you have highmem enabled?  That will let you access the 
rest of the RAM that the CAM doesn't map, though I don't know if an 
initrd in highmem works.

-Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Reserving small amounts of memory with mem= (MPC85xx,   2.6.15 arch/ppc)
  2008-06-13 15:31     ` Scott Wood
@ 2008-06-16 14:26       ` Florian Boelstler
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Boelstler @ 2008-06-16 14:26 UTC (permalink / raw)
  To: linuxppc-embedded

Scott Wood wrote:
> CAM entries can be any power of 4 between 4K and 256M.  However, the 
> code currently is hardcoded to use no more than 3 entries.

Ah, this explains a lot, thanks.

> Alternately, do you have highmem enabled?  That will let you access the 
> rest of the RAM that the CAM doesn't map, though I don't know if an 
> initrd in highmem works.

I didn't had highmem enabled so far. Now it is and Linux is able to 
allocate rest of memory.

It doesn't work if initrd is placed in highmem though. I just put it at 
the end of lowmem.

Cheers,

   Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-16 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-12 16:18 Reserving small amounts of memory with mem= (MPC85xx, 2.6.15 arch/ppc) Florian Boelstler
2008-06-12 19:14 ` Sylvain Joyeau
2008-06-13 14:30   ` Florian Boelstler
2008-06-13 15:31     ` Scott Wood
2008-06-16 14:26       ` Florian Boelstler

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).