Freeing allocated memory linux kernel device driver module - linux

I am writing code for a linux kernel module that allocates space and stores some data in it, but the kmalloc allocation happens in the write function for the vfs api as i need the size of the buffer coming from the user application and i cannot access it outside the write function. where should i place the kfree() function? i cannot place it in under cleanup because it gives me an error whenever i try to uninstall the module.
ssize_t hcsr04_write(struct file *filp, const char *buffer, size_t length, loff_t * offset)
{
if (pulsecount < (5)){
pulseptr[pulsecount] = kmalloc(sizeof(buffer),GFP_ATOMIC);
sprintf (pulseptr[pulsecount],"%s",buffer);
pulsecount++;
}
else{
int j = 0;
while (j<4){
sprintf (pulseptr[j], "%s", (pulseptr[j+1]) ); // [5 , 20 , 30 , 70 , 50] ===> [20 , 30 , 70 , 50 , 50]
j++;
}
sprintf (pulseptr[4],"%s",buffer);
}
}
this is my write function.
static void __exit hcsr04_module_cleanup(void)
{
//if (pulseptr!= {NULL,NULL,NULL,NULL,NULL}){
kfree(pulseptr);
printk(KERN_INFO "Dynamic memory freed successfully.");
//}
//pulseptr = {NULL,NULL,NULL,NULL,NULL};
gpio_free( GPIO_OUT );
gpio_free( GPIO_IN );
hcsr04_lock = 0;
cdev_del(&hcsr04_cdev);
unregister_chrdev_region( hcsr04_dev, 1 );
kobject_put( hcsr04_kobject );
}
this is the cleanup function. if i execute rmmod command with the cleanup function like this i get the following error :
[ 93.294821] 8<--- cut here ---
[ 93.297928] Unable to handle kernel paging request at virtual address bcf03574
[ 93.305253] pgd = 3cdbb3d3
[ 93.307993] [bcf03574] *pgd=00000000
[ 93.311621] Internal error: Oops: 5 [#1] SMP ARM
[ 93.316301] Modules linked in: hcsr04(O-) nfc bnep bluetooth ecdh_generic ecc ipv6 hello(PO) g_serial libcomposite udc_core brcmfmac brcmutil sha256_generic libsha256 vc4 cfg80211 bcm2835_codec(C) rfkill bcm2835_isp(C) bcm2835_v4l2(C) v4l2_mem2mem cec bcm2835_mmal_vchiq(C) videobuf2_dma_contig snd_soc_core videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 snd_compress snd_pcm_dmaengine videobuf2_common snd_pcm videodev snd_timer mc snd raspberrypi_hwmon vc_sm_cma(C) uio_pdrv_genirq uio fixed
[ 93.360563] CPU: 0 PID: 478 Comm: rmmod Tainted: P C O 5.4.72-v7 #1
[ 93.368060] Hardware name: BCM2835
[ 93.371516] PC is at kfree+0x48/0x2bc
[ 93.375235] LR is at hcsr04_module_cleanup+0x18/0xcac [hcsr04]
[ 93.381148] pc : [<802fd004>] lr : [<7f17a36c>] psr: 20010013
[ 93.387501] sp : b80abf08 ip : b80abf38 fp : b80abf34
[ 93.392797] r10: 00000081 r9 : b80aa000 r8 : 801011c4
[ 93.398095] r7 : 7f17a36c r6 : 7e92dc38 r5 : 7f17c000 r4 : bcf03570
[ 93.404713] r3 : bab24000 r2 : 00000024 r1 : 00000000 r0 : 7f17c000
[ 93.411333] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 93.418568] Control: 10c5383d Table: 38d5806a DAC: 00000055
[ 93.424394] Process rmmod (pid: 478, stack limit = 0x274b04e4)
[ 93.430307] Stack: (0xb80abf08 to 0xb80ac000)
[ 93.434728] bf00: 801c8158 80989110 7f17c0c0 00000000 7e92dc38 00000081
[ 93.443026] bf20: 801011c4 b80aa000 b80abf4c b80abf38 7f17a36c 802fcfc8 7f17c0c0 00000000
[ 93.451324] bf40: b80abfa4 b80abf50 801ca940 7f17a360 72736368 00003430 00000000 80da6b10
[ 93.459621] bf60: 80101068 7e92cbe8 00000000 801011c4 b80aa000 00000006 b80abfac b80abf88
[ 93.467918] bf80: 80228294 8022938c 00000000 80e05f88 00000000 7e92de2c 00000000 b80abfa8
[ 93.476216] bfa0: 80101000 801ca7e0 00000000 7e92de2c 01677694 00000800 6a0f1b00 7e92dbe4
[ 93.484513] bfc0: 00000000 7e92de2c 7e92dc38 00000081 7e92df1f 7e92dc34 01677190 00000001
[ 93.492811] bfe0: 004e1f70 7e92dbec 004c866f 76f37218 60010030 01677694 00000000 00000000
[ 93.501100] Backtrace:
[ 93.503593] [<802fcfbc>] (kfree) from [<7f17a36c>] (hcsr04_module_cleanup+0x18/0xcac [hcsr04])
[ 93.512331] r9:b80aa000 r8:801011c4 r7:00000081 r6:7e92dc38 r5:00000000 r4:7f17c0c0
[ 93.520195] [<7f17a354>] (hcsr04_module_cleanup [hcsr04]) from [<801ca940>] (sys_delete_module+0x16c/0x244)
[ 93.530073] r5:00000000 r4:7f17c0c0
[ 93.533704] [<801ca7d4>] (sys_delete_module) from [<80101000>] (ret_fast_syscall+0x0/0x28)
[ 93.542084] Exception stack(0xb80abfa8 to 0xb80abff0)
[ 93.547209] bfa0: 00000000 7e92de2c 01677694 00000800 6a0f1b00 7e92dbe4
[ 93.555507] bfc0: 00000000 7e92de2c 7e92dc38 00000081 7e92df1f 7e92dc34 01677190 00000001
[ 93.563801] bfe0: 004e1f70 7e92dbec 004c866f 76f37218
[ 93.568922] r5:7e92de2c r4:00000000
[ 93.572549] Code: e3a02024 e5933000 e1a04624 e0243492 (e5943004)
[ 93.578730] ---[ end trace cff8773499967501 ]---
the error goes away once i comment out kfree

I Realised what i did wrong. I shouldve done kfree(pulseptr[0]) where 0 can be the index number of the memory locations i have allocated.

Related

How to analyze and debug a Linux kernel panic which occurs while running an application?

I'm getting kernel panics while running linux application on my custom hardware design. But another custom hardware which is similar to this can run this linux application without any problem. I did the memory calibration and stress app test for this board. But there was not any issue related to memory. So how can I debug this to clarify whether this is hardware or software problem. I could debug kernel and uboot using JTAG properly. But how can I pinpoint the issue for this kernel panic while running certain application ?
Here is the panic message (LOG)
[ 308.268356] Unable to handle kernel paging request at virtual address
54494156
[ 308.275647] pgd = 80004000
[ 308.278365] [54494156] *pgd=00000000
[ 308.281977] Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
[ 308.287904] Modules linked in: tw6869 mxc_v4l2_capture ipu_bg_overlay_sdc
ipu_still ipu_prp_enc videobuf2_dma_contig ipu_csi_enc videobuf2_memops
adv7610_video ipu_fg_overlay_sdc v4l2_int_device galcore(O)
[ 308.306375] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G O 4.1.15-2.0.0-
ga+yocto+gff4e28b #1
[ 308.309584] tw6869 0000:01:00.0: tw6869_querystd: vch1: unknown std
detected
[ 308.322648] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 308.329184] task: ce11bc00 ti: ce14c000 task.ti: ce14c000
[ 308.334598] PC is at 0x54494156
[ 308.337766] LR is at cpuidle_enter_state+0x90/0x350
[ 308.342650] pc : [<54494156>] lr : [<806d59b0>] psr: 800b00b3
[ 308.342650] sp : ce14df30 ip : 00000017 fp : ce14df8c
[ 308.354132] r10: 80e02508 r9 : 80e08ad0 r8 : 80d9b880
[ 308.359361] r7 : 00000001 r6 : 80e88160 r5 : 00000047 r4 : c04b271c
[ 308.365892] r3 : 54494157 r2 : 00000000 r1 : 80e08a80 r0 : 80d9b880
[ 308.372430] Flags: Nzcv IRQs off FIQs on Mode SVC_32 ISA Thumb Segment
kernel
[ 308.380004] Control: 10c5387d Table: 5f38404a DAC: 00000015
[ 308.385755] Process swapper/3 (pid: 0, stack limit = 0xce14c210)
[ 308.391768] Stack: (0xce14df30 to 0xce14e000)
[ 308.396135] df20: 00000000 d0f2c140 c04b271c 00000047
[ 308.404333] df40: 00000000 00000000 004832f1 00000000 c04b271c 00000047
00000000 dc8ba30f
[ 308.412537] df60: 80d97320 ce14c000 80e025e8 80e88160 d0f2bed0 80e08a74
80a02970 ce14dfa0
[ 308.420738] df80: ce14df9c ce14df90 806d5cc0 806d592c ce14dfdc ce14dfa0
80171a74 806d5ca8
[ 308.428939] dfa0: 80d9b880 80d9b880 00000000 80e02e00 80e025f0 80e878ea
00000001 80c09164
[ 308.437140] dfc0: 80d9aec8 80d97300 10c0387d 80e8d35c ce14dff4 ce14dfe0
8010fae0 801717d8
[ 308.445340] dfe0: 5e12c06a 00000015 00000000 ce14dff8 1010162c 8010f994
00000000 00000000
[ 308.453529] Backtrace:
[ 308.456036] [<806d5920>] (cpuidle_enter_state) from [<806d5cc0>]
(cpuidle_enter+0x24/0x28)
[ 308.464320] r10:ce14dfa0 r9:80a02970 r8:80e08a74 r7:d0f2bed0 r6:80e88160
r5:80e025e8
[ 308.472277] r4:ce14c000
[ 308.474868] [<806d5c9c>] (cpuidle_enter) from [<80171a74>]
(cpu_startup_entry+0x2a8/0x43c)
[ 308.483171] [<801717cc>] (cpu_startup_entry) from [<8010fae0>]
(secondary_start_kernel+0x158/0x164)
[ 308.492232] r7:80e8d35c
[ 308.494813] [<8010f988>] (secondary_start_kernel) from [<1010162c>]
(0x1010162c)
[ 308.502223] r5:00000015 r4:5e12c06a
[ 308.505862] Code: bad PC value
[ 308.508940] ---[ end trace 1d6a0d2b2019793f ]---
[ 308.513579] Kernel panic - not syncing: Attempted to kill the idle task!
[ 308.520313] CPU1: stopping
[ 308.523060] CPU: 1 PID: 37 Comm: cfinteractive Tainted: G D O 4.1.15-
2.0.0-ga+yocto+gff4e28b #1
[ 308.532731] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 308.539274] Backtrace:
[ 308.541792] [<8010c358>] (dump_backtrace) from [<8010c5d4>]
(show_stack+0x20/0x24)
[ 308.549379] r7:80e87b48 r6:80e45ca0 r5:00000000 r4:80e45ca0
[ 308.555168] [<8010c5b4>] (show_stack) from [<80919780>]
(dump_stack+0x7c/0xbc)
[ 308.562421] [<80919704>] (dump_stack) from [<80110038>]
(handle_IPI+0x2e4/0x2f8)
[ 308.569831] r7:80e87b48 r6:00000005 r5:80d99c34 r4:80d99c34
[ 308.575608] [<8010fd54>] (handle_IPI) from [<80101594>]
(gic_handle_irq+0x68/0x6c)
[ 308.583192] r10:00000002 r9:ce020000 r8:00000001 r7:f4a00100 r6:ce321b28
r5:80e02f7c
[ 308.591152] r4:f4a0010c r3:ce321b28
[ 308.594795] [<8010152c>] (gic_handle_irq) from [<8010d240>]
(__irq_svc+0x40/0x74)
[ 308.602295] Exception stack(0xce321b28 to 0xce321b70)
[ 308.607371] 1b20: 00000001 80bbbbd4 80e8f9c0 00000000 ffffe000 80e8f9c0
[ 308.615572] 1b40: 00000010 00000000 00000001 ce020000 00000002 ce321bd4
ce321b60 ce321b70
[ 308.623769] 1b60: 80493dc0 80137668 200f0113 ffffffff
[ 308.628833] r7:ce321b5c r6:ffffffff r5:200f0113 r4:80137668
[ 308.634617] [<801375b4>] (__do_softirq) from [<80137c20>]
(irq_exit+0xd0/0x10c)
[ 308.641940] r10:ce321c40 r9:ce020000 r8:00000001 r7:00000000 r6:00000010
r5:00000000
[ 308.649901] r4:80d99c34
[ 308.652491] [<80137b50>] (irq_exit) from [<8017beb4>]
(__handle_domain_irq+0x90/0xfc)
[ 308.660335] r5:00000000 r4:80d99c34
[ 308.663984] [<8017be24>] (__handle_domain_irq) from [<80101560>]
(gic_handle_irq+0x34/0x6c)
[ 308.672348] r10:00000004 r9:ce321d90 r8:00000001 r7:f4a00100 r6:ce321c40
r5:80e02f7c
[ 308.680311] r4:f4a0010c r3:ce321c40
[ 308.683954] [<8010152c>] (gic_handle_irq) from [<8010d240>]
(__irq_svc+0x40/0x74)
[ 308.691453] Exception stack(0xce321c40 to 0xce321c88)
[ 308.696528] 1c40: 00000003 d0f2f89c 00000003 00000003 80e02650 d0f13180
80e02e00 d0f13184
[ 308.704729] 1c60: 00000001 ce321d90 00000004 ce321cbc 00000003 ce321c88
801a739c 801a73cc
[ 308.712923] 1c80: 200f0013 ffffffff
[ 308.716425] r7:ce321c74 r6:ffffffff r5:200f0013 r4:801a73cc
[ 308.722208] [<801a715c>] (smp_call_function_many) from [<801a7468>]
(smp_call_function+0x48/0x88)
[ 308.731093] r10:ffffffff r9:ce321d88 r8:00000000 r7:00000000 r6:00000001
r5:ce321d90
[ 308.739054] r4:80110990
[ 308.741634] [<801a7420>] (smp_call_function) from [<801a74e0>]
(on_each_cpu+0x38/0x90)
[ 308.749564] r7:00000000 r6:00000001 r5:ce321d90 r4:80110990
[ 308.755342] [<801a74a8>] (on_each_cpu) from [<80110d2c>]
(twd_rate_change+0x38/0x40)
[ 308.763099] r7:00000000 r6:00000002 r5:ce321d88 r4:ffffffff
[ 308.768890] [<80110cf4>] (twd_rate_change) from [<801523c4>]
(notifier_call_chain+0x54/0x94)
[ 308.777357] [<80152370>] (notifier_call_chain) from [<80152894>]
(__srcu_notifier_call_chain+0x54/0x70)
[ 308.786763] r9:ce321d88 r8:00000002 r7:00000000 r6:00000000 r5:ce0a6184
r4:ce0a619c
[ 308.794650] [<80152840>] (__srcu_notifier_call_chain) from [<801528d8>]
(srcu_notifier_call_chain+0x28/0x30)
[ 308.804491] r10:00000000 r9:80e8a384 r8:00000002 r7:80e02508 r6:ce026000
r5:80e73b44
[ 308.812451] r4:ce0a6180
[ 308.815042] [<801528b0>] (srcu_notifier_call_chain) from [<80746114>]
(__clk_notify+0xa0/0xa8)
[ 308.823683] [<80746074>] (__clk_notify) from [<807461c4>]
(__clk_recalc_rates+0xa8/0xac)
[ 308.831786] r8:ce003f80 r7:00000001 r6:1daee080 r5:00000002 r4:ce026000
[ 308.838630] [<8074611c>] (__clk_recalc_rates) from [<80746198>]
(__clk_recalc_rates+0x7c/0xac)
[ 308.847254] r7:00000001 r6:3b5dc100 r5:00000002 r4:ce026000
[ 308.853030] [<8074611c>] (__clk_recalc_rates) from [<80746198>]
(__clk_recalc_rates+0x7c/0xac)
[ 308.861654] r7:00000001 r6:3b5dc100 r5:00000002 r4:ce026a80
[ 308.867438] [<8074611c>] (__clk_recalc_rates) from [<80748b50>]
(clk_core_set_parent+0x1bc/0x2dc)
[ 308.876324] r7:00000001 r6:00000000 r5:ce026380 r4:ce026400
[ 308.882102] [<80748994>] (clk_core_set_parent) from [<80748c9c>]
(clk_set_parent+0x2c/0x30)
[ 308.890467] r9:00000000 r8:179a7b00 r7:80e02508 r6:000f32a0 r5:00060ae0
r4:80eec6ac
[ 308.898357] [<80748c70>] (clk_set_parent) from [<806d4220>]
(imx6q_set_target+0x490/0x544)
[ 308.906653] [<806d3d90>] (imx6q_set_target) from [<806ca034>]
(__cpufreq_driver_target+0x184/0x2b0)
[ 308.915712] r10:00000000 r9:00000000 r8:80eec5e4 r7:00000000 r6:80e02508
r5:ce66b500
[ 308.923671] r4:00000000
[ 308.926253] [<806c9eb0>] (__cpufreq_driver_target) from [<806d2d44>]
(cpufreq_interactive_speedchange_task+0x264/0x354)
[ 308.937048] r10:80d9ae10 r9:80e02650 r8:80e02e00 r7:00000000 r6:000f32a0
r5:80d9ae10
[ 308.945007] r4:d0f1ee10
[ 308.947591] [<806d2ae0>] (cpufreq_interactive_speedchange_task) from
[<801514e4>] (kthread+0xfc/0x114)
[ 308.956911] r10:00000000 r9:00000000 r8:00000000 r7:806d2ae0 r6:00000000
r5:ce303480
[ 308.964870] r4:00000000
[ 308.967456] [<801513e8>] (kthread) from [<80108028>]
(ret_from_fork+0x14/0x2c)
[ 308.974692] r7:00000000 r6:00000000 r5:801513e8 r4:ce303480
[ 308.980460] CPU0: stopping
[ 308.983202] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G D O 4.1.15-2.0.0-
ga+yocto+gff4e28b #1
[ 308.992439] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 308.998981] Backtrace:
[ 309.001488] [<8010c358>] (dump_backtrace) from [<8010c5d4>]
(show_stack+0x20/0x24)
[ 309.009073] r7:80e87b48 r6:80e45ca0 r5:00000000 r4:80e45ca0
[ 309.014859] [<8010c5b4>] (show_stack) from [<80919780>]
(dump_stack+0x7c/0xbc)
[ 309.022112] [<80919704>] (dump_stack) from [<80110038>]
(handle_IPI+0x2e4/0x2f8)
[ 309.029522] r7:80e87b48 r6:00000005 r5:80d99c34 r4:80d99c34
[ 309.035298] [<8010fd54>] (handle_IPI) from [<80101594>]
(gic_handle_irq+0x68/0x6c)
[ 309.042881] r10:80e02508 r9:80e08b14 r8:d0f04ed0 r7:f4a00100 r6:80e01e98
r5:80e02f7c
[ 309.050843] r4:f4a0010c r3:80e01e98
[ 309.054488] [<8010152c>] (gic_handle_irq) from [<8010d240>]
(__irq_svc+0x40/0x74)
[ 309.061987] Exception stack(0x80e01e98 to 0x80e01ee0)
[ 309.067058] 1e80: 00000000 d0f084c0
[ 309.075261] 1ea0: dc8ba30f dc8ba30f cef8dbc4 00000047 80e88160 00000004
d0f04ed0 80e08b14
[ 309.083462] 1ec0: 80e02508 80e01f3c 80e01e80 80e01ee0 8091f2bc 806d59e0
600f0013 ffffffff
[ 309.091652] r7:80e01ecc r6:ffffffff r5:600f0013 r4:806d59e0
[ 309.097430] [<806d5920>] (cpuidle_enter_state) from [<806d5cc0>]
(cpuidle_enter+0x24/0x28)
[ 309.105708] r10:80e01f50 r9:80a02970 r8:80e08a74 r7:d0f04ed0 r6:80e88160
r5:80e025e8
[ 309.113667] r4:80e00000
[ 309.116248] [<806d5c9c>] (cpuidle_enter) from [<80171a74>]
(cpu_startup_entry+0x2a8/0x43c)
[ 309.124540] [<801717cc>] (cpu_startup_entry) from [<80917448>]
(rest_init+0x98/0x9c)
[ 309.132297] r7:80e02500
[ 309.134893] [<809173b0>] (rest_init) from [<80d00d9c>]
(start_kernel+0x404/0x424)
[ 309.142390] r5:80e8d000 r4:80e8d04c
[ 309.146037] [<80d00998>] (start_kernel) from [<1000807c>] (0x1000807c)
[ 309.152583] CPU2: stopping
[ 309.155327] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D O 4.1.15-2.0.0-
ga+yocto+gff4e28b #1
[ 309.164565] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 309.171106] Backtrace:
[ 309.173611] [<8010c358>] (dump_backtrace) from [<8010c5d4>]
(show_stack+0x20/0x24)
[ 309.181196] r7:80e87b48 r6:80e45ca0 r5:00000000 r4:80e45ca0
[ 309.186977] [<8010c5b4>] (show_stack) from [<80919780>]
(dump_stack+0x7c/0xbc)
[ 309.194230] [<80919704>] (dump_stack) from [<80110038>]
(handle_IPI+0x2e4/0x2f8)
[ 309.201639] r7:80e87b48 r6:00000005 r5:80d99c34 r4:80d99c34
[ 309.207417] [<8010fd54>] (handle_IPI) from [<80101594>]
(gic_handle_irq+0x68/0x6c)
[ 309.215001] r10:80e02508 r9:80e08b14 r8:d0f1eed0 r7:f4a00100 r6:ce14bee8
r5:80e02f7c
[ 309.222960] r4:f4a0010c r3:ce14bee8
[ 309.226604] [<8010152c>] (gic_handle_irq) from [<8010d240>]
(__irq_svc+0x40/0x74)
[ 309.234103] Exception stack(0xce14bee8 to 0xce14bf30)
[ 309.239179] bee0: 00000000 d0f224c0 dc8ba30f dc8ba30f ce933307 00000047
[ 309.247383] bf00: 80e88160 00000004 d0f1eed0 80e08b14 80e02508 ce14bf8c
ce14bed0 ce14bf30
[ 309.255578] bf20: 8091f2bc 806d59e0 600f0013 ffffffff
[ 309.260643] r7:ce14bf1c r6:ffffffff r5:600f0013 r4:806d59e0
[ 309.266420] [<806d5920>] (cpuidle_enter_state) from [<806d5cc0>]
(cpuidle_enter+0x24/0x28)
[ 309.274698] r10:ce14bfa0 r9:80a02970 r8:80e08a74 r7:d0f1eed0 r6:80e88160
r5:80e025e8
[ 309.282656] r4:ce14a000
[ 309.285237] [<806d5c9c>] (cpuidle_enter) from [<80171a74>]
(cpu_startup_entry+0x2a8/0x43c)
[ 309.293528] [<801717cc>] (cpu_startup_entry) from [<8010fae0>]
(secondary_start_kernel+0x158/0x164)
[ 309.302587] r7:80e8d35c
[ 309.305168] [<8010f988>] (secondary_start_kernel) from [<1010162c>]
(0x1010162c)
[ 309.312579] r5:00000015 r4:5e12c06a
[ 309.316221] ---[ end Kernel panic - not syncing: Attempted to kill the
idle task!
I must be thankful to you if you can guide me on this issue. Are there any methods for hardware debugging to pinpoint the issues related to this while running applications on linux ?
Regards,
Kulunu.

issues while porting clocks in linux kernel (4.9)

I am trying to port system clocks for custom SoC into linux kernel (4.9). I had setup a minimal lookup table with crystal Osc, pll & spi as below:
static struct clk_lookup clocks[] = {
CLKDEV_INIT(NULL, "ref", &ref_clk),
CLKDEV_INIT(NULL, "pll1", &pll1_clk),
CLKDEV_INIT(NULL, "apb_pclk", &apb_clk),
CLKDEV_INIT("spi0", NULL, &spi_clk),
};
and im trying to add clocks using func:
int __init clocks_init(void)
{
clkdev_add_table(clocks, ARRAY_SIZE(clocks));
};
But my booting fails while trying to setup clocks.
below is the error:
Unable to handle kernel NULL pointer dereference at virtual address 00000008
[ 0.000000]` pgd = c0004000
[ 0.000000] [00000008] *pgd=00000000
[ 0.000000] Internal error: Oops: 5 [#1] ARM
[ 0.000000] Modules linked in:
[ 0.000000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.22+ #22
[ 0.000000] Hardware name: CUSTOMSOC
[ 0.000000] task: c6898000 task.stack: c688e000
[ 0.000000] PC is at __clk_get_hw+0x1c/0x24
[ 0.000000] LR is at clkdev_add_table+0x40/0x78
[ 0.000000] pc : [<c025ce40>] lr : [<c025cda8>] psr: a0000053
[ 0.000000] sp : c688fe58 ip : c688fe68 fp : c688fe64
[ 0.000000] r10: 00000000 r9 : 0000003d r8 : c04867f0
[ 0.000000] r7 : c04ea720 r6 : c04ea714 r5 : 00000004 r4 : c04cbf50
[ 0.000000] r3 : 00000000 r2 : 00000000 r1 : 00000004 r0 : c04cbf98
[ 0.000000] Flags: NzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
[ 0.000000] Control: 00c5387d Table: c0004008 DAC: 00000055
[ 0.000000] Process swapper (pid: 1, stack limit = 0xc688e188)
[ 0.000000] Stack: (0xc688fe58 to 0xc6890000)
[ 0.000000] fe40: c688fe84 c688fe68
[ 0.000000] fe60: c025cda8 c025ce30 00000000 c8905000 c0501020 c04ae820 c688fea4 c688fe88
[ 0.000000] fe80: c048a6d8 c025cd74 00000000 c03004d4 c04ca798 c04cd718 c688febc c688fea8
[ 0.000000] fea0: c048a4a8 c048a62c c04c27f8 00000003 c688fecc c688fec0 c0486814 c048a49c
[ 0.000000] fec0: c688ff4c c688fed0 c0009a6c c04867fc c0483614 c02268b8 00000000 c0434e84
[ 0.000000] fee0: c6fffe00 c032ca2c c688ff4c c688fef8 c003e5f4 c0483604 c0050050 c00bb438
[ 0.000000] ff00: 00000000 c030f938 00000003 00000003 00000000 c04349c0 c03d2654 00000000
[ 0.000000] ff20: c688ff4c c04c27f8 00000003 c0501020 c04ae820 00000000 0000003d c04ae838
[ 0.000000] ff40: c688ff94 c688ff50 c0483ec0 c0009a2c 00000003 00000003 00000000 c04835f8
[ 0.000000] ff60: 9d322010 62802229 20a41903 00000000 c030cc94 00000000 00000000 00000000
[ 0.000000] ff80: 00000000 00000000 c688ffac c688ff98 c030ccac c0483d48 ffffffff 00000000
[ 0.000000] ffa0: 00000000 c688ffb0 c00107c8 c030cca0 00000000 00000000 00000000 00000000
[ 0.000000] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 0.000000] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 0114212a 8dce8aa8
[ 0.000000] [<c025ce40>] (__clk_get_hw) from [<c025cda8>] (clkdev_add_table+0x40/0x78)
[ 0.000000] [<c025cda8>] (clkdev_add_table) from [<c048a6d8>] (bbsoc_clocks_init+0xb8/0xec)
[ 0.000000] [<c048a6d8>] (clocks_init) from [<c048a4a8>] (bcm2835_init+0x18/0x74)
[ 0.000000] [<c048a4a8>] (board_init) from [<c0486814>] (customize_machine+0x24/0x30)
[ 0.000000] [<c0486814>] (customize_machine) from [<c0009a6c>] (do_one_initcall+0x4c/0x180)
[ 0.000000] [<c0009a6c>] (do_one_initcall) from [<c0483ec0>] (kernel_init_freeable+0x184/0x254)
[ 0.000000] [<c0483ec0>] (kernel_init_freeable) from [<c030ccac>] (kernel_init+0x18/0x114)
[ 0.000000] [<c030ccac>] (kernel_init) from [<c00107c8>] (ret_from_fork+0x14/0x2c)
[ 0.000000] Code: e52de004 e8bd4000 e3500000 15903000 (15930008)
[ 0.000000] ---[ end trace 671b49261be9dc6a ]---
[ 0.000000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
upon investigation func: __clk_get_hw(cl->clk);
is trying to access clk->core->hw (This is where exactly it is failing!)
struct clk_hw *__clk_get_hw(struct clk *clk)
{
return !clk ? NULL : clk->core->hw;
}
EXPORT_SYMBOL_GPL(__clk_get_hw);
Any suggestions on setting up clock configuration into linux kernel, would be highly helpful.
Thanks,
Vivek
Issue got resolved upon programming complete clock driver specific to SoC.
1. Firstly bus clock to be registered, it depends on input PLL clocks and the dividers or multipliers it has encountered. The info regarding dividers and multipliers can be found in sys-control registers. Once all the buses (ex: ahb, apb) got registered.
hw = clk_hw_register_fixed_rate(NULL, "ref", NULL, 0, 40MHZ); //setting
if (IS_ERR(hw))
pr_err("xtal clock not registered\n");
hw = clk_hw_register_fixed_rate(NULL, "pll_clk", "ref", 0, 800MHZ);
if (IS_ERR(hw))
pr_err("pll_clk not registered\n");
hw = clk_hw_register_fixed_rate(NULL, "ahb_clk", "pll_clk", 0, 100MHZ);
if (IS_ERR(hw))
pr_err("ahb_clk not registered\n");
peripheral oriented clock can be specified as, here i am trying to register dma clock. which is mounted on AHB bus.
static struct clk dma1_clk = {
.name = "xyz.dma",
.parent = &ahb_clk,
.rate = FREQ_200MHZ,
};
later the clock structure with respect peripheral can be registered as
hw = clk_hw_register_fixed_rate(NULL, c->dev_id, "ahb_clk", 0, temp_clk->rate);
if (IS_ERR(hw))
pr_err("Device Hw:%s not registered\n", c->dev_id);
ret = clk_hw_register_clkdev(hw, NULL, c->dev_id);
if (ret)
pr_err("Device:%s not registered\n", c->dev_id);
The clock infra setup for peripheral in SoC can be done through Device tree as well.
Thanks to #0andriy for responding over the post.
Thanks.

Linux Kernel Module : Delayed workqueue make the kernel crashed

I'm using Delayed Workqueue into a kernel module.
My module data structure is like this :
struct module_data {
...
struct workqueue_struct *check_hook_wq;
struct delayed_work check_hook;
...
};
My function for initialize the workqueue is like this :
void init_workqueue(struct module_data *wc)
{
wc->check_hook_wq = create_workqueue("Check_Hook");
INIT_DELAYED_WORK(&wc->check_hook, check_hook_handler);
}
Into "main" function, I do things like this (CHECK_HOOK_DELAY_MS = 5) :
void main(void)
{
...
init_workqueue(wc);
queue_delayed_work(wc->check_hook_wq, &wc->kipbx_check_hook, msecs_to_jiffies(CHECK_HOOK_DELAY_MS));
...
}
Everything works fine until there, but when the workqueue timer ends, the system crashes with the following error, and don't enter at all in my check_hook_handler function :
[ 330.206323] Unable to handle kernel paging request at virtual address 7f7f7f7e
[ 330.213568] pgd = c0004000
[ 330.216292] [7f7f7f7e] *pgd=00000000
root#solidrun-imx6:~# [ 330.219895] Internal error: Oops: 80000005 [#1] SMP ARM
[ 330.227035] Modules linked in: kipbx(O) dahdi(O)
[ 330.231736] CPU: 1 PID: 116 Comm: mmcqd/0 Tainted: G O 3.14.60+g4386797 #233
[ 330.239670] task: dc1c9b80 ti: ddece000 task.ti: ddece000
[ 330.245083] PC is at 0x7f7f7f7e
[ 330.248254] LR is at call_timer_fn+0x24/0x84
[ 330.252541] pc : [<7f7f7f7e>] lr : [<c00349f8>] psr: 200701b3
[ 330.252541] sp : ddecfe18 ip : 00000000 fp : 00200200
[ 330.264035] r10: 00000000 r9 : ddecfe48 r8 : 00000002
[ 330.269273] r7 : 7f7f7f7f r6 : 00000100 r5 : ddece000 r4 : ddece018
[ 330.275812] r3 : ddecfe18 r2 : 7f7f7f7f r1 : 7f7f7f7f r0 : 7f7f7f7f
[ 330.282355] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA Thumb Segment kernel
[ 330.289937] Control: 10c53c7d Table: 2854004a DAC: 00000015
[ 330.295697] Process mmcqd/0 (pid: 116, stack limit = 0xddece238)
[ 330.301717] Stack: (0xddecfe18 to 0xdded0000)
[ 330.306088] fe00: dc032000 7f7f7f7f
[ 330.314285] fe20: 7f7f7f7f d8c2e308 dc032000 7f7f7f7f 7f7f7f7f c0035190 d8c2e32c 00000001
[ 330.322483] fe40: c0a060c0 dc032814 ddecfe48 ddecfe48 ffffffff 00000020 c0a06084 ddece000
[ 330.330679] fe60: 00000100 ddece038 00000001 c0a06080 40000001 c002f23c cb0aee0c 0000004c
[ 330.338874] fe80: cb0aee0c 00000001 c0a06080 c0a00470 c0a60e00 0000000a c0754098 00007483
[ 330.347071] fea0: c0a060c0 00208840 00000000 ddece010 0000001d 00000000 f4a00100 00000001
[ 330.355266] fec0: dc37b410 00000000 00000000 c002f5b4 c0a00ee8 c000ec04 f4a0010c c0a0daa8
[ 330.363463] fee0: ddecff00 c00084e0 c07519c8 20070013 ffffffff ddecff34 00000001 c00121c0
[ 330.371658] ff00: dc37b410 60070013 dc37b410 000009c5 dc37b408 dc375240 ddece000 00000000
[ 330.379854] ff20: 00000001 dc37b410 00000000 00000000 00000000 ddecff48 c0436474 c07519c8
[ 330.388053] ff40: 20070013 ffffffff 00000000 dde95a00 dc37b408 c0436348 00000000 00000000
[ 330.396249] ff60: 00000000 c0046bc8 c0a872a4 00000000 00002e31 dc37b408 00000000 00000000
[ 330.404446] ff80: ddecff80 ddecff80 00000000 00000000 ddecff90 ddecff90 ddecffac dde95a00
[ 330.412641] ffa0: c0046af8 00000000 00000000 c000e3c0 00000000 00000000 00000000 00000000
[ 330.420836] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 330.429034] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 fffe6f9f effff8ef
[ 330.437252] [<c00349f8>] (call_timer_fn) from [<c0035190>] (run_timer_softirq+0x134/0x260)
[ 330.445546] [<c0035190>] (run_timer_softirq) from [<c002f23c>] (__do_softirq+0x138/0x23c)
[ 330.453749] [<c002f23c>] (__do_softirq) from [<c002f5b4>] (irq_exit+0xac/0xf4)
[ 330.461002] [<c002f5b4>] (irq_exit) from [<c000ec04>] (handle_IRQ+0x44/0x90)
[ 330.468080] [<c000ec04>] (handle_IRQ) from [<c00084e0>] (gic_handle_irq+0x2c/0x5c)
[ 330.475680] [<c00084e0>] (gic_handle_irq) from [<c00121c0>] (__irq_svc+0x40/0x50)
[ 330.483175] Exception stack(0xddecff00 to 0xddecff48)
[ 330.488247] ff00: dc37b410 60070013 dc37b410 000009c5 dc37b408 dc375240 ddece000 00000000
[ 330.496442] ff20: 00000001 dc37b410 00000000 00000000 00000000 ddecff48 c0436474 c07519c8
[ 330.504630] ff40: 20070013 ffffffff
[ 330.508156] [<c00121c0>] (__irq_svc) from [<c07519c8>] (_raw_spin_unlock_irqrestore+0x1c/0x20)
[ 330.516801] [<c07519c8>] (_raw_spin_unlock_irqrestore) from [<c0436474>] (mmc_queue_thread+0x12c/0x16c)
[ 330.526225] [<c0436474>] (mmc_queue_thread) from [<c0046bc8>] (kthread+0xd0/0xe8)
[ 330.533735] [<c0046bc8>] (kthread) from [<c000e3c0>] (ret_from_fork+0x14/0x34)
[ 330.540975] Code: bad PC value
[ 330.544053] ---[ end trace 5ea8c90639723bba ]---
[ 330.548685] Kernel panic - not syncing: Fatal exception in interrupt
[ 330.555059] CPU0: stopping
[ 330.557796] CPU: 0 PID: 30 Comm: kworker/0:1 Tainted: G D O 3.14.60+g4386797 #233
[ 330.566005] Workqueue: events od_dbs_timer
[ 330.570166] [<c0014c6c>] (unwind_backtrace) from [<c00116a4>] (show_stack+0x10/0x14)
[ 330.577949] [<c00116a4>] (show_stack) from [<c074c094>] (dump_stack+0x88/0x98)
[ 330.585199] [<c074c094>] (dump_stack) from [<c0013744>] (handle_IPI+0x14c/0x16c)
[ 330.592619] [<c0013744>] (handle_IPI) from [<c000850c>] (gic_handle_irq+0x58/0x5c)
[ 330.600214] [<c000850c>] (gic_handle_irq) from [<c00121c0>] (__irq_svc+0x40/0x50)
[ 330.607710] Exception stack(0xdc1fbcc0 to 0xdc1fbd08)
[ 330.612784] bcc0: 00000004 00000004 c0a0daac 00000003 dc1fbd24 00000001 dc1fbdcc 00000000
[ 330.620982] bce0: c075408c ffffffff 00000000 d83b0b40 00000002 dc1fbd08 c02abeec c00846ac
[ 330.629171] bd00: 000d0113 ffffffff
[ 330.632700] [<c00121c0>] (__irq_svc) from [<c00846ac>] (generic_exec_single+0x50/0xa0)
[ 330.640646] [<c00846ac>] (generic_exec_single) from [<c0084808>] (smp_call_function_single+0x10c/0x19c)
[ 330.650065] [<c0084808>] (smp_call_function_single) from [<c0084c8c>] (on_each_cpu+0x2c/0x48)
[ 330.658617] [<c0084c8c>] (on_each_cpu) from [<c00141b4>] (twd_rate_change+0x28/0x30)
[ 330.666392] [<c00141b4>] (twd_rate_change) from [<c004ad84>] (notifier_call_chain+0x44/0x84)
[ 330.674863] [<c004ad84>] (notifier_call_chain) from [<c004b10c>] (__srcu_notifier_call_chain+0x44/0x60)
[ 330.684285] [<c004b10c>] (__srcu_notifier_call_chain) from [<c004b140>] (srcu_notifier_call_chain+0x18/0x20)
[ 330.694148] [<c004b140>] (srcu_notifier_call_chain) from [<c0474424>] (__clk_notify+0x70/0x78)
[ 330.702790] [<c0474424>] (__clk_notify) from [<c04744c4>] (__clk_recalc_rates+0x98/0x9c)
[ 330.710909] [<c04744c4>] (__clk_recalc_rates) from [<c0474498>] (__clk_recalc_rates+0x6c/0x9c)
Do you have any idea where this problem can come from ?
There are many registers with value 7f7f7f7f (0x7f is actually a char),seems to be caused by overflow of stack or other memory regions.

integrating mpu9250 with imx6 board

I am trying to use mpu9250 3 axis accelerometer with imx6 board. I have taken invensense mpu 9265 device driver for Android from here, and successfully compiled the driver with Linux 3.18 kernel as a module (inv_mpu_iio). I have even changed dts file based on my requirement.
I have little knowledge about device trees but after searching I have done following changes to the dts file.
Edited dts file code snippet:
&i2c3 {
extaccelerometer: mpu9265#68{
compatible = "mpu9250";
reg = <0x68>;
interrupt-parent = <&gpio2>;
interrupts = <9>;
};
}
While booting the kernel on to the board I am stuck with the following error:
[ 10.730459] industrialio: module is from the staging directory, the quality is unknown, you have been warned.
[ 10.805020] random: nonblocking pool is initialized
[ 10.819012] kfifo_buf: module is from the staging directory, the quality is unknown, you have been warned.
[....] Waiting for /dev to be fully populated...[ 10.910701] inv_mpu_iio: module is from the staging directory, the quality is unknown, you have been.
[ 10.973279] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 10.981478] pgd = bdeac000
[ 10.984286] [00000000] *pgd=00000000
[ 10.987969] Internal error: Oops: 5 [#1] SMP ARM
[ 10.992628] Modules linked in: inv_mpu_iio(C+) kfifo_buf(C) industrialio(C) sky2
[ 11.000167] CPU: 3 PID: 333 Comm: modprobe Tainted: G C 3.18.0i2c-test+ #1
[ 11.008117] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 11.014695] task: bdfc0000 ti: bdd16000 task.ti: bdd16000
[ 11.020179] PC is at inv_mpu_probe+0x70/0xb6c [inv_mpu_iio]
[ 11.025769] LR is at 0x0
[ 11.028318] pc : [<7f029110>] lr : [<00000000>] psr: a0000013
[ 11.028318] sp : bdd17c98 ip : bdc5b484 fp : bdd17cdc
[ 11.039806] r10: 00000000 r9 : 00000004 r8 : 7f02fa34
[ 11.045064] r7 : bdc5b400 r6 : 00000001 r5 : befd7800 r4 : bdc5b000
[ 11.051643] r3 : 00000068 r2 : 00000000 r1 : 0000002f r0 : bdc5b000
[ 11.058250] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 11.065427] Control: 10c5387d Table: 4deac04a DAC: 00000015
[ 11.071241] Process modprobe (pid: 333, stack limit = 0xbdd16238)
[ 11.077417] Stack: (0xbdd17c98 to 0xbdd18000)
[ 11.081848] 7c80: bdd17ccc bdd17ca8
[ 11.090093] 7ca0: 801b0764 801acc5c befd7820 8041d804 befd7820 befd7820 00000000 7f031798
[ 11.098316] 7cc0: befd7800 7f031798 00000004 00000000 bdd17cfc bdd17ce0 8054ad94 7f0290ac
[ 11.106568] 7ce0: 81589ca8 befd7820 80cf1758 00000000 bdd17d34 bdd17d00 8040e504 8054acb4
[ 11.114854] 7d00: 8054ac94 80349964 7f031798 befd7820 7f031798 befd7854 00000000 7f037000
[ 11.123142] 7d20: 8152cc60 00000000 bdd17d54 bdd17d38 8040e7f4 8040e3cc bef307e4 00000000
[ 11.131438] 7d40: 7f031798 8040e750 bdd17d7c bdd17d58 8040c6fc 8040e75c bee18ac0 bef307d8
[ 11.139705] 7d60: be7535e0 7f031798 bdd2b480 80ccc070 bdd17d8c bdd17d80 8040de9c 8040c6a4
[ 11.147932] 7d80: bdd17db4 bdd17d90 8040da60 8040de80 7f030c18 bdd17da0 7f031798 80c76c58
[ 11.156173] 7da0: be7f95c0 80cea230 bdd17dcc bdd17db8 8040f1f0 8040d974 7f031774 80c76c58
[ 11.164408] 7dc0: bdd17de4 bdd17dd0 8054d384 8040f174 80c76c58 80c76c58 bdd17dfc bdd17de8
[ 11.172629] 7de0: 7f037018 8054d354 00000000 80c76c58 bdd17e7c bdd17e00 80008b20 7f03700c
[ 11.180852] 7e00: bdd17e44 bdd17e10 8013b4b4 8077f8a4 00000001 0000084f bdd17e44 000000db
[ 11.189069] 7e20: bdf1b100 c0c70000 00000001 be7f9440 8152cc60 00000001 bdd17e64 bdd17e48
[ 11.197330] 7e40: 801301d0 8013b26c bdd17f48 7f0320d4 7f0320c8 bdd17f48 7f0320d4 7f0320c8
[ 11.205568] 7e60: 80cea230 be7f9440 8152cc60 00000001 bdd17f3c bdd17e80 800a92e0 80008a70
[ 11.213776] 7e80: 7f0320d4 00007fff 800a64e8 bdd17f04 bdd17ebc c0c70000 00000000 c0d14dd8
[ 11.221973] 7ea0: bdd17ed4 76f91d50 00000202 7f0320c8 7f032214 7f032110 8006b448 80a4b86c
[ 11.230166] 7ec0: bdd17fa4 bdd17ed0 800141b0 8006b440 c0d4a000 00000000 00000000 00000000
[ 11.238357] 7ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 11.246548] 7f00: 00000000 00000000 00000000 00000000 20000013 000da17d 76d96000 76f91d50
[ 11.254741] 7f20: 00000080 8000fc44 bdd16000 00000000 bdd17fa4 bdd17f40 800a99e8 800a75e4
[ 11.262935] 7f40: 8000faa4 bdfc0000 c0c70000 000da17d c0d146f8 c0d1455f c0d48a98 0000b758
[ 11.271125] 7f60: 0000cf08 7f031e70 00000019 00000000 0000002c 0000002d 00000016 00000011
[ 11.279319] 7f80: 0000000b 00000000 00000000 00000000 784fb200 784fd698 00000000 bdd17fa8
[ 11.287509] 7fa0: 8000fa80 800a9940 00000000 784fb200 76d96000 000da17d 76f91d50 00000002
[ 11.295699] 7fc0: 00000000 784fb200 784fd698 00000080 00000000 76f91d50 000da17d 00000000
[ 11.303891] 7fe0: 00060000 7e936924 76f8bb07 76f0f264 60000010 76d96000 00000000 00000000
[ 11.312074] Backtrace:
[ 11.314586] [<7f0290a0>] (inv_mpu_probe [inv_mpu_iio]) from [<8054ad94>] (i2c_device_probe+0xec/0x150)
[ 11.323903] r10:00000000 r9:00000004 r8:7f031798 r7:befd7800 r6:7f031798 r5:00000000
[ 11.331840] r4:befd7820
[ 11.334417] [<8054aca8>] (i2c_device_probe) from [<8040e504>] (driver_probe_device+0x144/0x390)
[ 11.343126] r7:00000000 r6:80cf1758 r5:befd7820 r4:81589ca8
[ 11.348882] [<8040e3c0>] (driver_probe_device) from [<8040e7f4>] (__driver_attach+0xa4/0xa8)
[ 11.357328] r10:00000000 r9:8152cc60 r8:7f037000 r7:00000000 r6:befd7854 r5:7f031798
[ 11.365262] r4:befd7820
[ 11.367829] [<8040e750>] (__driver_attach) from [<8040c6fc>] (bus_for_each_dev+0x64/0x98)
[ 11.376017] r6:8040e750 r5:7f031798 r4:00000000 r3:bef307e4
[ 11.381771] [<8040c698>] (bus_for_each_dev) from [<8040de9c>] (driver_attach+0x28/0x30)
[ 11.389783] r6:80ccc070 r5:bdd2b480 r4:7f031798
[ 11.394473] [<8040de74>] (driver_attach) from [<8040da60>] (bus_add_driver+0xf8/0x218)
[ 11.402410] [<8040d968>] (bus_add_driver) from [<8040f1f0>] (driver_register+0x88/0x104)
[ 11.410510] r7:80cea230 r6:be7f95c0 r5:80c76c58 r4:7f031798
[ 11.416264] [<8040f168>] (driver_register) from [<8054d384>] (i2c_register_driver+0x3c/0xfc)
[ 11.424711] r5:80c76c58 r4:7f031774
[ 11.428362] [<8054d348>] (i2c_register_driver) from [<7f037018>] (inv_mpu_init+0x18/0x3c [inv_mpu_iio])
[ 11.437764] r5:80c76c58 r4:80c76c58
[ 11.441414] [<7f037000>] (inv_mpu_init [inv_mpu_iio]) from [<80008b20>] (do_one_initcall+0xbc/0x204)
[ 11.450554] r4:80c76c58 r3:00000000
[ 11.454193] [<80008a64>] (do_one_initcall) from [<800a92e0>] (load_module+0x1d08/0x235c)
[ 11.462294] r10:00000001 r9:8152cc60 r8:be7f9440 r7:80cea230 r6:7f0320c8 r5:7f0320d4
[ 11.470230] r4:bdd17f48
[ 11.472799] [<800a75d8>] (load_module) from [<800a99e8>] (SyS_init_module+0xb4/0x124)
[ 11.480638] r10:00000000 r9:bdd16000 r8:8000fc44 r7:00000080 r6:76f91d50 r5:76d96000
[ 11.488574] r4:000da17d
[ 11.491149] [<800a9934>] (SyS_init_module) from [<8000fa80>] (ret_fast_syscall+0x0/0x48)
[ 11.499247] r6:784fd698 r5:784fb200 r4:00000000
[ 11.503937] Code: e28cc004 e2847b01 e5c435e5 e595e0b4 (e8be000f)
[ 11.510195] ---[ end trace fcf671f516c808ac ]---
udevd[324]: '/sbin/modprobe -b i2c:mpu9250' [333] terminated by signal 11 (Segmentation fault)
As far as I understand, it says segmentation error has occurred during i2c device probe. I am not able to find where I have done a mistake. As I have little knowledge about dts file I am not sure whether I have edited dts file correctly or not. And as far as the driver is concerned, it got compiled correctly so I feel driver should not be an issue here.
Please help me out. I have to finish off this task by this end of this week.
Thank you in advance for your reply.

Linux ARM Abort oops from user space

On a ARM Cortex-A9 (Freescale iMX6SL) running Linux kernel 3.0.35, I am seeing a kernel oops with PC and LR (0x402aca32/0x402ac3cd) that is in user space. Mode is USER_32 and ISA is Thumb. There is no code on this system that executes in Thumb mode.
[ 597.195954] Unable to handle kernel paging request at virtual address 000a34d4
[ 597.205436] pgd = c35dc000
[ 597.208149] [000a34d4] *pgd=8c454831, *pte=8374c1cf, *ppte=8374ca3e
[ 597.214657] Internal error: Oops: 81f [#1] PREEMPT
[ 597.219609] Modules linked in: ...<snip>...
[ 597.243075] CPU: 0 Tainted: P W (3.0.35-aaaaaa #1)
[ 597.249162] PC is at 0x402aca32
[ 597.252304] LR is at 0x402ac3cd
[ 597.255448] pc : [<402aca32>] lr : [<402ac3cd>] psr: 60000030
[ 597.255453] sp : be8fc220 ip : 00000000 fp : 00000809
[ 597.266940] r10: 00000004 r9 : 40336ea0 r8 : 00000818
[ 597.272168] r7 : 4034c25c r6 : 00011b31 r5 : 00001250 r4 : 000a2cc8
[ 597.278698] r3 : 00000000 r2 : 000a34d0 r1 : 00011b30 r0 : 00000809
[ 597.285229] Flags: nZCv IRQs on FIQs on Mode USER_32 ISA Thumb Segment user
[ 597.292629] Control: 10c53c7d Table: 835dc059 DAC: 00000015
[ 597.298378] Process wancontrol (pid: 7551, stack limit = 0xce9f02e8)
[ 597.307890] ---[ end trace f50414d2a3d239df ]---
[ 597.312516] Kernel panic - not syncing: Fatal exception in interrupt
[ 597.325257] Backtrace:
[ 597.327567] [<c0135248>] (dump_backtrace+0x0/0x110) from [<c041e188>] (dump_stack+0x18/0x1c)
[ 597.336837] r6:c3088d20 r5:ce9f02e8 r4:c0537b48 r3:00000002
[ 597.342382] [<c041e170>] (dump_stack+0x0/0x1c) from [<c041e200>] (panic+0x74/0x194)
[ 597.350794] [<c041e18c>] (panic+0x0/0x194) from [<c01355b0>] (die+0x1a4/0x1e4)
[ 597.358402] r3:07ffff00 r2:ce9f1db8 r1:c0537f90 r0:c04ac8ba
[ 597.364044] r7:00000000
[ 597.366591] [<c013540c>] (die+0x0/0x1e4) from [<c013a7b0>] (__do_kernel_fault+0x6c/0x8c)
[ 597.375465] r8:00000000 r7:ce9f1fb0 r6:cee35900 r5:0000081f r4:000a34d4
[ 597.382060] [<c013a744>] (__do_kernel_fault+0x0/0x8c) from [<c013aa90>] (do_page_fault+0x2c0/0x2f0)
[ 597.391760] r8:cee35900 r7:000a34d4 r6:c3088d20 r5:ce9f1fb0 r4:00000001
[ 597.398438] r3:ce9f1fb0
[ 597.400909] [<c013a7d0>] (do_page_fault+0x0/0x2f0) from [<c012c1b8>] (do_DataAbort+0x38/0xa0)
[ 597.410178] [<c012c180>] (do_DataAbort+0x0/0xa0) from [<c0131a88>] (ret_from_exception+0x0/0x10)
[ 597.419298] Exception stack(0xce9f1fb0 to 0xce9f1ff8)
[ 597.424664] 1fa0: 00000809 00011b30 000a34d0 00000000
[ 597.434300] 1fc0: 000a2cc8 00001250 00011b31 4034c25c 00000818 40336ea0 00000004 00000809
[ 597.442488] 1fe0: 00000000 be8fc220 402ac3cd 402aca32 60000030 ffffffff
[ 597.455455] r8:00000818 r7:4034c25c r6:00011b31 r5:0000000f r4:0000040f
If code was executing in user space, it should get SEGV.
void arm_notify_die(const char *str, struct pt_regs *regs,
struct siginfo *info, unsigned long err, unsigned long trap)
{
if (user_mode(regs)) {
current->thread.error_code = err;
current->thread.trap_no = trap;
force_sig_info(info->si_signo, info, current);
} else {
die(str, regs, err);
}
}
Why does it go into die()?
This happens repeatedly with the same backtrace for the same address 0x000a34d4. I can't say the stack has been hosed because the values look the same in different instances of this kernel oops.

Resources