Re: ioremap and vmalloc

2008-09-21 Thread Benjamin Herrenschmidt
On Fri, 2008-09-19 at 18:45 +0200, Sébastien Chrétien wrote:
 if I write :
 ioremap(0x2000,0x4) and ioremap(0x2000,0x5)
 
 Will it crash ?

To give you a rough idea, unless you tweak things like TASK_SIZE,
KERNELBASE, CONFIG_LOWMEM_SIZE, etc... and depending on what CPU you
use, you can generally count on approx. 200M of virtual space for
vmalloc/ioremap, or a bit less. I would additionally recommend against
mapping a significant portion of that for your devices as the kernel
will need space for its own use by vmalloc.

You can increase the amount available here by lowering TASK_SIZE to 2G
and KERNELBASE as well, and keeping CONFIG_LOWMEM_SIZE clamped to
something like 256M. That will give you a good GB of virtual space if I
can still count correctly.

(Note, having just looked at the MMU init code for 32 bits, I almost had
to puke, Kumar, Josh, we really need to clean that shit up one of these
days).

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: ioremap and vmalloc

2008-09-19 Thread Grant Likely
On Fri, Sep 19, 2008 at 01:15:20PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
 Hello,
 
 When I use ioremap, the second time, I obtain this message :
 
 allocation failed: out of vmalloc space - use vmalloc=size to increase
 size.
 What can I do in order to fix this problem ?

How large are the regions that you are ioremapping?  The kernel sets
aside a fixed amount of the virtual address space for ioremaps, and if
you exhaust that then more ioremaps will stop working.

g.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Sébastien Chrétien

The first is ioremap(0x2000,0x1000);
The second is ioremap(0x8000,0x1000);
Is it too long

Grant Likely a écrit :

On Fri, Sep 19, 2008 at 01:15:20PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
  

Hello,

When I use ioremap, the second time, I obtain this message :

allocation failed: out of vmalloc space - use vmalloc=size to increase
size.
What can I do in order to fix this problem ?



How large are the regions that you are ioremapping?  The kernel sets
aside a fixed amount of the virtual address space for ioremaps, and if
you exhaust that then more ioremaps will stop working.

g.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

  

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Josh Boyer
On Fri, Sep 19, 2008 at 06:34:06PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
 The first is ioremap(0x2000,0x1000);
 The second is ioremap(0x8000,0x1000);
 Is it too long

The error message you are getting should have been a very strong hint that
the answer is yes.

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Grant Likely
On Fri, Sep 19, 2008 at 06:34:06PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
 The first is ioremap(0x2000,0x1000);
 The second is ioremap(0x8000,0x1000);
 Is it too long

Well, you're trying to allocate two 256MB regions.  That is very large.
What kind of device are you trying to map?

g.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Josh Boyer
On Fri, Sep 19, 2008 at 06:45:01PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
 if I write :
 ioremap(0x2000,0x4) and ioremap(0x2000,0x5)

 Will it crash ?

I have no idea.  You haven't given us enough information to really answer
that.

Basic information needed would be: 

1) What board/chip
2) What kernel version
3) What are you actually trying to do
4) What driver are you using
5) If you are writing your own, where is the code for it

etc.

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Grant Likely
On Fri, Sep 19, 2008 at 10:58 AM, Josh Boyer [EMAIL PROTECTED] wrote:
 On Fri, Sep 19, 2008 at 06:45:01PM +0200, 
 =?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
 if I write :
 ioremap(0x2000,0x4) and ioremap(0x2000,0x5)

 Will it crash ?

 I have no idea.  You haven't given us enough information to really answer
 that.

But I can say that the second ioremap() call makes the first ioremap()
both redundant and inefficient.  You're using exactly the same base
address so the same region is getting mapped twice.  Since the second
call uses a bigger region than the first then the kernel will probably
need to allocate another chunk of virtual address space to map it
instead of reusing the first mapping.

g.


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Sébastien Chrétien

if I write :
ioremap(0x2000,0x4) and ioremap(0x2000,0x5)

Will it crash ?

Josh Boyer a écrit :

On Fri, Sep 19, 2008 at 06:34:06PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
  

The first is ioremap(0x2000,0x1000);
The second is ioremap(0x8000,0x1000);
Is it too long



The error message you are getting should have been a very strong hint that
the answer is yes.

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

  

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Sébastien Chrétien

I made a mistake. The right code is :

ioremap(0x2000,0x4) and ioremap(0x8000,0x5)



Grant Likely a écrit :

On Fri, Sep 19, 2008 at 10:58 AM, Josh Boyer [EMAIL PROTECTED] wrote:
  

On Fri, Sep 19, 2008 at 06:45:01PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:


if I write :
ioremap(0x2000,0x4) and ioremap(0x2000,0x5)

Will it crash ?
  

I have no idea.  You haven't given us enough information to really answer
that.



But I can say that the second ioremap() call makes the first ioremap()
both redundant and inefficient.  You're using exactly the same base
address so the same region is getting mapped twice.  Since the second
call uses a bigger region than the first then the kernel will probably
need to allocate another chunk of virtual address space to map it
instead of reusing the first mapping.

g.


  

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: ioremap and vmalloc

2008-09-19 Thread Sébastien Chrétien

The chip that I am using is a MPC7448.
The Kernel version is 2.6.26.
I am developping my own driver.
I am making some tests

Josh Boyer a écrit :

On Fri, Sep 19, 2008 at 06:45:01PM +0200, 
=?ISO-8859-1?Q?S=E9bastien_Chr=E9tien_ wrote:
  

if I write :
ioremap(0x2000,0x4) and ioremap(0x2000,0x5)

Will it crash ?



I have no idea.  You haven't given us enough information to really answer
that.

Basic information needed would be: 


1) What board/chip
2) What kernel version
3) What are you actually trying to do
4) What driver are you using
5) If you are writing your own, where is the code for it

etc.

josh

  

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev