Hi all,
I have a video capture program running on an i.MX27, with Linux 2.6.29.6.
The program works well for a 480x272 video, but when I try capturing a 640x480 video I get an issue with mmap() :
Camera picture: 640x480
picture size: 614400
############# buffer 0
############# length 614400 = 0x96000
############# offset 0 = 0x0
############# nmap... Unable to handle kernel NULL pointer dereference at virtual address 00000098
pgd = c3eb8000
[00000098] *pgd=a3d99031, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] PREEMPT
Modules linked in: fpga_csi mx27_camera soc_camera videodev v4l1_compat videobuf_dma_contig videobuf_core fpgaloader
CPU: 0 Not tainted (2.6.29.6 #1)
PC is at dev_driver_string+0xc/0x44
LR is at __videobuf_mmap_mapper+0x1d4/0x218 [videobuf_dma_contig]
pc : [<c0202764>] lr : [<bf00e5f0>] psr: 60000013
sp : c3dbfe50 ip : c3dbfe60 fp : c3dbfe5c
r10: c3dcdde0 r9 : 00000096 r8 : 00096000
r7 : c3cc37c0 r6 : c333f84c r5 : c4b07004 r4 : c3dcdde0
r3 : ffffffff r2 : c050a018 r1 : c0469acc r0 : 00000000
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 0005317f Table: a3eb8000 DAC: 00000015
Process capture_13-05-3 (pid: 578, stack limit = 0xc3dbe268)
Stack: (0xc3dbfe50 to 0xc3dc0000)
fe40: c3dbfe8c c3dbfe60 bf00e5f0 c0202768
fe60: 00000000 00000001 c3dbfebc c3dbfe78 c4b07004 c3dcdde0 404a2000 c3d27060
fe80: c3dbfea4 c3dbfe90 bf008430 bf00e42c c3dcda88 c3dcda8c c3dbfeb4 c3dbfea8
fea0: bf026510 bf0083f4 c3dbfec4 c3dbfeb8 bf017238 bf026508 c3dbff2c c3dbfec8
fec0: c00964ec bf0171f8 000000ff 00000000 c3d5e2c0 00000000 00000000 c3dbfee8
fee0: c3dcda70 40538000 00000000 00000001 c3d52230 00000000 c3d5e2c0 c3dbe000
ff00: c3dbff2c c3dbe000 00096000 00000007 c3d5e2c0 c3d27060 00000000 00000096
ff20: c3dbff74 c3dbff30 c00968c8 c00961b8 000000ff 00000000 c3dbff64 c3dbff48
ff40: 00000001 000000ff c3dbff64 00000001 c3dbe000 00000000 c3d5e2c0 00096000
ff60: c3dbe000 00000003 c3dbffa4 c3dbff78 c002b7fc c00966f4 00000001 00000000
ff80: 0000000a 00000000 0000c350 000000c0 c0028008 00000000 00000000 c3dbffa8
ffa0: c0027e60 c002b794 0000000a 00000000 00000000 00096000 00000003 00000001
ffc0: 0000000a 00000000 0000c350 000000c0 0003c1f8 bedf48f8 0003ca30 00000001
ffe0: 00000000 bedf47a0 00009570 400a03f4 60000010 00000000 00000000 00000000
Backtrace:
[<c0202758>] (dev_driver_string+0x0/0x44) from [<bf00e5f0>] (__videobuf_mmap_mapper+0x1d4/0x218 [videobuf_dma_contig])
[<bf00e41c>] (__videobuf_mmap_mapper+0x0/0x218 [videobuf_dma_contig]) from [<bf008430>] (videobuf_mmap_mapper+0x4c/0x90 [videobuf_core])
r7:c3d27060 r6:404a2000 r5:c3dcdde0 r4:c4b07004
[<bf0083e4>] (videobuf_mmap_mapper+0x0/0x90 [videobuf_core]) from [<bf026510>] (soc_camera_mmap+0x18/0x1c [soc_camera])
r5:c3dcda8c r4:c3dcda88
[<bf0264f8>] (soc_camera_mmap+0x0/0x1c [soc_camera]) from [<bf017238>] (v4l2_mmap+0x50/0x58 [videodev])
[<bf0171e8>] (v4l2_mmap+0x0/0x58 [videodev]) from [<c00964ec>] (mmap_region+0x344/0x53c)
[<c00961a8>] (mmap_region+0x0/0x53c) from [<c00968c8>] (do_mmap_pgoff+0x1e4/0x300)
[<c00966e4>] (do_mmap_pgoff+0x0/0x300) from [<c002b7fc>] (do_mmap2+0x78/0xc0)
[<c002b784>] (do_mmap2+0x0/0xc0) from [<c0027e60>] (ret_fast_syscall+0x0/0x2c)
Code: eafffff7 e1a0c00d e92dd800 e24cb004 (e5903098)
---[ end trace b3cc3bcff6e0e1be ]---
I've managed to reproduce this issue with a 480x272 capture by changing BITSTREAM_BUF_SIZE (in vpu_codec.h).
I ran several tests and here are the results :
BITSTREAM_BUF_SIZE value | 480x272 | 640x480 |
---|---|---|
>= 0x220000 | VIDIOC_S_FMT error | mmap() fails |
0x210000 | mmap() fails | |
... | ||
0x197000 | ||
0x196000 | VIDIOC_S_FMT error | |
... | ||
... | ||
... | ||
0x120000 | ||
0x119000 | capture works | |
... | ||
0x101000 | ||
<= 0x100000 | mmap() fails |
As you can see on my marvelous table, capture doesn't work for any BITSTREAM_BUF_SIZE value.
The VIDIOC_S_FMT error is :
VIDIOC_S_FMT error 12, Cannot allocate memory
It's returned by dma_alloc_coherent() from the function mx27_camera_set_bus_param() in file mx27_camera.c.
I set some debug output when the capture works (for 480x272) :
Camera picture: 480x272
picture size: 261120
buffer 0
length 262144 = 0x40000
offset 0 = 0x0
nmap... SUCCESS
buffer 1
length 262144 = 0x40000
offset 262144 = 0x40000
nmap... SUCCESS
buffer 2
length 262144 = 0x40000
offset 524288 = 0x80000
nmap... SUCCESS
buffer 3
length 262144 = 0x40000
offset 786432 = 0xc0000
nmap... SUCCESS
OK
I need to run the capture with a 640x480 resolution, and I'm stuck on this issue. My knowledge of linux drivers is limited so I really need some help.
My question is: How can I resolve this mmap() issue ?
Thank you
Solved! Go to Solution.
Problem solved !
The DMA zone wasn't large enough for 640x480, so it raised the error :
But q->dev wasn't defined, hence the Oops
I increased the DMA zone size (arch/arm/plat-mxc/include/mach/memory.h) and now it works.
Thank you
Problem solved !
The DMA zone wasn't large enough for 640x480, so it raised the error :
But q->dev wasn't defined, hence the Oops
I increased the DMA zone size (arch/arm/plat-mxc/include/mach/memory.h) and now it works.
Thank you
What kernel and BSP are you using?
Are you using the latest one provided by Freescale?
LDK_IMX27_R1_1 : i.MX27PDK: Linux Source Code Files Release 1.01.
If you're using other BSP/kernel, is it possible to test using the BSP above?
Rgds
Rogerio
Hello Rogerio,
I'm using kernel 2.6.29.6, with the last Armadeus BSP : http://sourceforge.net/projects/armadeus/files/armadeus/armadeus-5.2/
I don't think I can use an other BSP because my program needs some packages and drivers from the Armadeus BSP.
Please try kernel 3.9.
Ok, I understand,
If you could reproduce using the Freescale BSP and its unit tests instead your application (located at rootfs/unit-test), it would be great to validate the use case and try to debug your current kernel.
Does your current rootfs have the unit tests?
Rgds
Rogerio
No more information from customer