Re: how to allocate 9MB of memory in kernel ?
From: Arnd Bergmann <arnd@arndb.de>
Date: 2008-07-22 09:31:41
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 :-
=20
buf_area =3D vmalloc(sizeof(circularbuffer_S));
=A0=A0=A0=A0=A0=A0=A0=A0if(!buf_area)
=A0=A0=A0=A0=A0=A0=A0=A0{
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0printk(KERN_ALERT"vmalloc=failed \n");
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -1; =A0=A0=A0=A0=A0=A0=A0=A0} =20 =A0=A0=A0=A0=A0=A0=A0=A0buf_area =3D (circularbuffer_S *)ioremap(7700000,=
900000);
=A0=A0=A0=A0=A0=A0=A0=A0if(!buf_area)
=A0=A0=A0=A0=A0=A0=A0=A0{
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0printk(KERN_ALERT"ioremap=failed \n");
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -1; =A0=A0=A0=A0=A0=A0=A0=A0}
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 <><