How to
think about issue like this? Maybe come back to original code modifiations, and
try to refine code just input. Unfortunately, it can't track the base reason
why this error occur, which could just enumerate possible answers and try to
get the proper correct one. I think the right way facing this issue is
"tracing back".
1.
Definate what address it is?
DMA
mapping address? vmalloc/ioremap space? or user space? In my case, it's DMA
mapping area.
2. Use
debugger to clarify what you think about.
Connect
ICE to board, and display virtual address 0xffc05000, that is unavailable,
which make kernel report this error.
3. Be
sure which module this address belong to?
printk
dma allocated address of some modules which use dma to transfer data. uart 0xffc00000
or 0xffc01000, usp 0xffc02000, 0xffc03000, 0xffc04000. Though 1kB size when
alloc, but 4KB address aligned by kernel. No 0xffc05000, why?
4. Go
into the function tty_insert_flip_string(), in which memcpy cause the error
(read from oops by kernel). Only way I can do is clarify parameters I pass to
memcpy. In tty function, dma address is increased by 0x700 to oxffc05000, which
is original 0xffc00000. why 0x700, not 0x200 we expected?
5.
TTY_BUFFER_PAGE equal to 0x700, goal=min(size-copied, TTY_BUFFER_PAGE), size
maybe the wrong value. So next print out varialbe size. Oh, no 0xf8740000,
negtive value. Search rx_dma_len in serial driver, only here modified this
variable
rx_dma_len
= RX_DMA_BUF_SIZE - get_dma_residue(rx_dma_chan).
6.
Conclude: problem caused by get_dma_residue.