Hi!
I have a hardware board with PEX8311-AA66BC controller. It was connected on 816x EVM PCIe slot. Device have two memory region.
One for access to PLX registers and another for device own space. I recompile own kernel module for my board and try to insert it into the kernel.
But I have a "Segmentation Fault" error with such log:
root@c6a816x-evm:~# insmod ./armpex.ko
pex_init()
pex_probe(): VENDOR ID = 0x4953
pex_probe(): DEVICE ID = 0x5502
pex_probe(): IRQ = 0x30
pex_probe(): BAR0 = 0x20000000
pex_probe(): BAR3 = 0x20000200
pex_probe(): MEM0 - start = 20000000, end = 200001ff
pex_probe(): MEM3 - start = 20000200, end = 200002ff
pex_probe(): remapping physical address = 20000000 to caf78000.
pex_probe(): remapping physical address = 20000200 to caf7c200.
Unhandled fault: Precise External Abort on non-linefetch (0x1008) at 0xcaf78000
Internal error: : 1008 [#1]
last sysfs file: /sys/kernel/uevent_seqnum
Modules linked in: armpex(+) bufferclass_ti omaplfb pvrsrvkm TI81xx_hdmi(P) ti81xxfb vpss syslink ipv6
CPU: 0 Tainted: P (2.6.34 #1)
PC is at pex_probe+0x23c/0x250 [armpex]
LR is at release_console_sem+0x198/0x1ac
pc : [<bf1e7f78>] lr : [<c00537dc>] psr: 60000013
sp : c6b2ddd8 ip : c6b2dd10 fp : c6b2ddfc
r10: 00000000 r9 : c6b2c000 r8 : 00000000
r7 : c701d060 r6 : bf1e9c14 r5 : bf1e9c14 r4 : c701d000
r3 : caf78000 r2 : c03d3e00 r1 : bf1e8660 r0 : bf1e97d0
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c5387d Table: 87348019 DAC: 00000015
Process insmod (pid: 1158, stack limit = 0xc6b2c2e8)
Stack: (0xc6b2ddd8 to 0xc6b2e000)
ddc0: 00000000 c6b2dde8
dde0: c6b2de0c bf1e9934 bf1e9904 c701d000 c6b2de0c c6b2de00 c017eacc bf1e7d48
de00: c6b2de44 c6b2de10 c017ec8c c017eab8 c00e64b0 bf1e9904 c701d000 bf1e9a04
de20: c01ae788 c701d060 c701d060 bf1e9934 c6134a20 c03dd048 c6b2de64 c6b2de48
de40: c01ae8d0 c017ec30 c701d060 c701d094 bf1e9934 c6134a20 c6b2de84 c6b2de68
de60: c01ae9e4 c01ae834 00000000 c01ae97c bf1e9934 c6134a20 c6b2deac c6b2de88
de80: c01ae0fc c01ae988 c7037b38 c7050390 c0167c1c bf1e9904 bf1e9934 bf1e9934
dea0: c6b2debc c6b2deb0 c01ae73c c01ae0b8 c6b2deec c6b2dec0 c01ad9dc c01ae728
dec0: bf1e981c c03dd048 bf1e9904 c03dd048 bf1e9934 00000000 c0031b08 00000000
dee0: c6b2df14 c6b2def0 c01aecfc c01ad944 bf1e9904 c03dd048 bf1e9934 00000000
df00: c0031b08 c6b2c000 c6b2df34 c6b2df18 c017eee4 c01aec58 00000000 bf1e9af8
df20: bf1e7f8c 00000000 c6b2df4c c6b2df38 bf1e7fc4 c017eeb0 00000000 bf1e9af8
df40: c6b2df7c c6b2df50 c003135c bf1e7f98 00012018 c0031b08 c6b2df7c c6b2df68
df60: 00000000 bf1e9af8 00012008 00012018 c6b2dfa4 c6b2df80 c0078cdc c0031304
df80: c00a15a0 c00a14b8 00000000 00010000 00012018 00000080 00000000 c6b2dfa8
dfa0: c0031960 c0078c2c 00000000 00010000 00012018 0000d226 00012008 00000001
dfc0: 00000000 00010000 00012018 00000080 00012008 00000000 00000003 00000000
dfe0: be871efb be871c9c 00008f5c 400fd7d4 60000010 00012018 00000000 00000000
Backtrace:
[<bf1e7d3c>] (pex_probe+0x0/0x250 [armpex]) from [<c017eacc>] (local_pci_probe+0x20/0x24)
r6:c701d000 r5:bf1e9904 r4:bf1e9934
[<c017eaac>] (local_pci_probe+0x0/0x24) from [<c017ec8c>] (pci_device_probe+0x68/0x9c)
[<c017ec24>] (pci_device_probe+0x0/0x9c) from [<c01ae8d0>] (driver_probe_device+0xa8/0x154)
r8:c03dd048 r7:c6134a20 r6:bf1e9934 r5:c701d060 r4:c701d060
[<c01ae828>] (driver_probe_device+0x0/0x154) from [<c01ae9e4>] (__driver_attach+0x68/0x8c)
r7:c6134a20 r6:bf1e9934 r5:c701d094 r4:c701d060
[<c01ae97c>] (__driver_attach+0x0/0x8c) from [<c01ae0fc>] (bus_for_each_dev+0x50/0x84)
r7:c6134a20 r6:bf1e9934 r5:c01ae97c r4:00000000
[<c01ae0ac>] (bus_for_each_dev+0x0/0x84) from [<c01ae73c>] (driver_attach+0x20/0x28)
r6:bf1e9934 r5:bf1e9934 r4:bf1e9904
[<c01ae71c>] (driver_attach+0x0/0x28) from [<c01ad9dc>] (bus_add_driver+0xa4/0x22c)
[<c01ad938>] (bus_add_driver+0x0/0x22c) from [<c01aecfc>] (driver_register+0xb0/0x13c)
[<c01aec4c>] (driver_register+0x0/0x13c) from [<c017eee4>] (__pci_register_driver+0x40/0xb4)
r9:c6b2c000 r8:c0031b08 r7:00000000 r6:bf1e9934 r5:c03dd048
r4:bf1e9904
[<c017eea4>] (__pci_register_driver+0x0/0xb4) from [<bf1e7fc4>] (pex_init+0x38/0x64 [armpex])
r7:00000000 r6:bf1e7f8c r5:bf1e9af8 r4:00000000
[<bf1e7f8c>] (pex_init+0x0/0x64 [armpex]) from [<c003135c>] (do_one_initcall+0x64/0x1bc)
r5:bf1e9af8 r4:00000000
[<c00312f8>] (do_one_initcall+0x0/0x1bc) from [<c0078cdc>] (sys_init_module+0xbc/0x1ec)
r7:00012018 r6:00012008 r5:bf1e9af8 r4:00000000
[<c0078c20>] (sys_init_module+0x0/0x1ec) from [<c0031960>] (ret_fast_syscall+0x0/0x30)
r7:00000080 r6:00012018 r5:00010000 r4:00000000
Code: e5953004 e30907d0 e59f1010 e34b0f1e (e5932000)
---[ end trace b95bc34a9987dc18 ]---
Segmentation fault
I found a place on my code there error appears.
This is my pex_probe() function. (Simple version)
static int pex_probe( struct pci_dev *dev, const struct pci_device_id *id )
{
u32 *plx = NULL;
printk( "<0>%s(): VENDOR ID = 0x%x\n", __FUNCTION__, dev->vendor );
printk( "<0>%s(): DEVICE ID = 0x%x\n", __FUNCTION__, dev->device );
printk( "<0>%s(): IRQ = 0x%x\n", __FUNCTION__, dev->irq );
printk( "<0>%s(): BAR0 = 0x%x\n", __FUNCTION__, dev->resource[0].start );
printk( "<0>%s(): BAR3 = 0x%x\n", __FUNCTION__, dev->resource[3].start );
memRes0 = request_mem_region( dev->resource[0].start, dev->resource[0].end - dev->resource[0].start+1, "PLX Memory" );
if(!memRes0) {
printk( "<0>%s(): error in request_mem_region(%d, %p)\n", __FUNCTION__, 0, (void*)dev->resource[0].start );
} else {
printk( "<0>%s(): MEM0 - start = %x, end = %x\n", __FUNCTION__, memRes0->start, memRes0->end );
}
memRes3 = request_mem_region( dev->resource[3].start, dev->resource[3].end - dev->resource[3].start+1, "DEV Memory" );
if(!memRes3) {
printk( "<0>%s(): error in request_mem_region(%d, %p)\n", __FUNCTION__, 3, (void*)dev->resource[3].start );
} else {
printk( "<0>%s(): MEM3 - start = %x, end = %x\n", __FUNCTION__, memRes3->start, memRes3->end );
}
//remapping and save memory regions...
plxMemory = (unsigned char*)ioremap_nocache( dev->resource[0].start, dev->resource[0].end - dev->resource[0].start+1 );
if( !plxMemory ) {
pci_unregister_driver( &pci_drv );
printk("<0>%s(): error in ioremap_nocache(%p, 0x%x)\n", __FUNCTION__,
dev->resource[0].start,
dev->resource[0].end - dev->resource[0].start+1 );
return -ENOMEM;
}
printk( "<0>%s(): remapping physical address = %p to %p.\n", __FUNCTION__,
dev->resource[0].start, plxMemory );
devMemory = (unsigned char*)ioremap_nocache(dev->resource[3].start, dev->resource[3].end - dev->resource[3].start+1);
if( !devMemory ) {
pci_unregister_driver( &pci_drv );
printk("<0>%s(): error in ioremap_nocache(%p, 0x%x)\n", __FUNCTION__,
dev->resource[3].start,
dev->resource[3].end - dev->resource[3].start+1 );
return -ENOMEM;
}
printk( "<0>%s(): remapping physical address = %p to %p.\n", __FUNCTION__,
dev->resource[3].start, devMemory );
plx = (u32*)plxMemory;
printk( "<0>%s(): plx[0] = 0x%x\n", __FUNCTION__, plx[0] ); // Segmentation fault !!!
return 0;
}
Please help me to solve this problem.
P.S. This device and kernel module work on x86 without any errors.
Thank you.