kernel BUG while reading from SPI into static buffer

Mulyadi Santosa mulyadi.santosa at gmail.com
Fri May 13 10:32:23 EDT 2011


Hi....

On Fri, May 13, 2011 at 14:03, Felix Varghese <felixv1986 at gmail.com> wrote:
> Hi,
>
> I am trying to read some data via SPI on an a modified (custom SPI device
> attached) AT91SAM9G20-EK board. If I pass a local array buffer, declared as
> "char buffer[100];" as the rx_buf pointer for the spi transfer, the code
> works fine. But if I just change the declaration to "static char
> buffer[100]" instead, I get the following crash:
>
> kernel BUG at arch/arm/mm/dma-mapping.c:425!
> Unable to handle kernel NULL pointer dereference at virtual address 00000000


Hmm, I think this is the corresponding line:
BUG_ON(!virt_addr_valid(kaddr) || !virt_addr_valid(kaddr + size - 1)    );

alright...so it roughly says that the address (buffer) falls into
invalid virt address. And, virt_addr_valid is:
static inline int virt_addr_valid(const volatile void *kaddr)
{
        extern void *high_memory;  /* copied from <linux/mm.h> */
       return ((unsigned long)kaddr >= PAGE_OFFSET && kaddr < high_memory);
}

OK, a bit clear now.... so, I can say base on the above code snippet,
buffer...when declared as static, somehow falls into non
ZONE_NORMAL......i.e non directly mapped memory area...

Feel free to try to observer whether this statement is correct or
not... and you should check the address of "buffer" when declared as
static I guess....

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list