Subject: Re: how to allocate 9MB of memory in kernel ?

From: Arnd Bergmann <[email-masked]>
Date: Tue, 22 Jul 2008 11:31:32 +0200

On Tuesday 22 July 2008, Misbah khan wrote:
> I am getting kernel panic while trying these as suggested by you ,the
> following points will elaborate my concern :-

Please post the entire driver, when you only post fragments that
don't compile, we can't really help you.

> i am allocating memory using vmalloc and remaping to the SDRAM area as :-
> 
> buf_area = vmalloc(sizeof(circularbuffer_S));
>         if(!buf_area)
>         {
>                 printk(KERN_ALERT"vmalloc failed \n");
>                 return -1;
>         }
> 
>         buf_area = (circularbuffer_S *)ioremap(7700000,900000);
>         if(!buf_area)
>         {
>                 printk(KERN_ALERT"ioremap failed \n");
>                 return -1;
>         }

You really need to decide whether you want to allocate memory or
want to remap an I/O range. ioremap is *only* for I/O ranges
on SoC or similar devices, and when you have that, you don't allocate
memory. Besides, the addresses you pass are really strange,
e.g. 900,000 bytes are not 9MB. Normally, you would get the
I/O address from the device tree, using of_iomap(), and then
use of_translate_address/remap_pfn_range to map it to user
space.

	Arnd <><