ddrown / pps-gmtimer

Linux kernel module PPS Client Driver using OMAP Timer hardware
15 stars 14 forks source link

Kernel module error in Linux 3.12-rt #1

Closed asymingt closed 9 years ago

asymingt commented 9 years ago

Following your instructions, I've managed to get the pps-gmtimer module loaded and working with watch-pps in Linux 3.8. I didn't have much luck with a Linux 3.8-rt kernel, so I went straight to Linux 3.12-rt using these instructions: https://www.osadl.org/Profile-of-system-in-rack-7-slot-8.qa-profile-r7s8.0.html. Your kernel patch worked and the module compiled successfully.

Annoyingly, cape management has changed somewhat between 3.8 and 3.12. As a result the overlays you supplied didn't work on 3.12, so I edited am33xx-bone-common.dtsi directly. All the device handles popped up in the /sys/devices/ocp.3/pps_gmtimer.4 directory and modprobe pps-gmtimer worked like a charm. Although I notice that gm_timer is now called timer1.

On running watch-pps the kernel threw the following error:

Feb 23 07:41:40 arm kernel: [   59.879711] Process watch-pps (pid: 1868, stack limit = 0xdf4b0250)
Feb 23 07:41:40 arm kernel: [   59.879715] Stack: (0xdf4b1f18 to 0xdf4b2000)
Feb 23 07:41:40 arm kernel: [   59.879721] 1f00:                                                       c02ef220 df0ffe18
Feb 23 07:41:40 arm kernel: [   59.879731] 1f20: de2e0880 c01497c0 de2fb100 0031d1c0 00002000 de2fb100 0031d1c0 de2fb100
Feb 23 07:41:40 arm kernel: [   59.879739] 1f40: df4b0018 df4b1f80 00002000 00000000 bea51904 c00ef5cc de2fb100 0031d1c0
Feb 23 07:41:40 arm kernel: [   59.879748] 1f60: 00000000 00000000 de2fb100 00000000 0031d1c0 00002000 00000000 c00efce8
Feb 23 07:41:40 arm kernel: [   59.879756] 1f80: 00000000 00000000 00002000 00012008 0031d1c0 0002f740 00000003 c000dd64
Feb 23 07:41:40 arm kernel: [   59.879765] 1fa0: df4b0000 c000dbe0 00012008 0031d1c0 00000003 0031d1c0 00002000 00000400
Feb 23 07:41:40 arm kernel: [   59.879773] 1fc0: 00012008 0031d1c0 0002f740 00000003 00000003 00000000 0009d2e0 bea51904
Feb 23 07:41:40 arm kernel: [   59.879782] 1fe0: 00002000 bea51880 b6f67e13 b6e1840c 60000010 00000003 202c222a 7b564e45
Feb 23 07:41:40 arm kernel: [   59.879810] [<bf000118>] (capture_show+0x24/0x38 [pps_gmtimer]) from [<c02ef23c>] (dev_attr_show+0x1c/0x48)
Feb 23 07:41:40 arm kernel: [   59.879833] [<c02ef23c>] (dev_attr_show+0x1c/0x48) from [<c01497c0>] (sysfs_read_file+0xa4/0x12c)
Feb 23 07:41:40 arm kernel: [   59.879859] [<c01497c0>] (sysfs_read_file+0xa4/0x12c) from [<c00ef5cc>] (vfs_read+0xa4/0x168)
Feb 23 07:41:40 arm kernel: [   59.879874] [<c00ef5cc>] (vfs_read+0xa4/0x168) from [<c00efce8>] (SyS_read+0x38/0x68)
Feb 23 07:41:40 arm kernel: [   59.879892] [<c00efce8>] (SyS_read+0x38/0x68) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
Feb 23 07:41:40 arm kernel: [   59.879903] Code: 0a000001 e593101c e5912000 e5933020 (e593203c) 
Feb 23 07:41:40 arm kernel: [   59.882660] ---[ end trace 0000000000000002 ]---

I'm not sure how to go about resolving this. Can you give me any pointers?

Thanks!

ddrown commented 9 years ago

Does anything show up in dmesg before this? "dmesg | grep pps" I'm wondering if it is failing at request_by_node on init. Is timer1 the timer you wanted?

On February 23, 2015 1:58:01 AM CST, Andrew Symington notifications@github.com wrote:

Following your instructions, I've managed to get the pps-gmtimer module loaded and working with watch-pps in Linux 3.8. I didn't have much luck with a Linux 3.8-rt kernel, so I went straight to Linux 3.12-rt using these instructions: https://www.osadl.org/Profile-of-system-in-rack-7-slot-8.qa-profile-r7s8.0.html. Your kernel patch worked and the module compiled successfully.

Annoyingly, cape management has changed somewhat between 3.8 and 3.12. As a result the overlays you supplied didn't work on 3.12, so I edited am33xx-bone-common.dtsi directly. All the device handles popped up in the /sys/devices/ocp.3/pps_gmtimer.4 directory and modprobe pps-gmtimer worked like a charm. Although I notice that gm_timer is now called timer1.

On running watch-pps the kernel threw the following error:

Feb 23 07:41:40 arm kernel: [   59.879711] Process watch-pps (pid:
1868, stack limit = 0xdf4b0250)
Feb 23 07:41:40 arm kernel: [   59.879715] Stack: (0xdf4b1f18 to
0xdf4b2000)
Feb 23 07:41:40 arm kernel: [   59.879721] 1f00:                       
                              c02ef220 df0ffe18
Feb 23 07:41:40 arm kernel: [   59.879731] 1f20: de2e0880 c01497c0
de2fb100 0031d1c0 00002000 de2fb100 0031d1c0 de2fb100
Feb 23 07:41:40 arm kernel: [   59.879739] 1f40: df4b0018 df4b1f80
00002000 00000000 bea51904 c00ef5cc de2fb100 0031d1c0
Feb 23 07:41:40 arm kernel: [   59.879748] 1f60: 00000000 00000000
de2fb100 00000000 0031d1c0 00002000 00000000 c00efce8
Feb 23 07:41:40 arm kernel: [   59.879756] 1f80: 00000000 00000000
00002000 00012008 0031d1c0 0002f740 00000003 c000dd64
Feb 23 07:41:40 arm kernel: [   59.879765] 1fa0: df4b0000 c000dbe0
00012008 0031d1c0 00000003 0031d1c0 00002000 00000400
Feb 23 07:41:40 arm kernel: [   59.879773] 1fc0: 00012008 0031d1c0
0002f740 00000003 00000003 00000000 0009d2e0 bea51904
Feb 23 07:41:40 arm kernel: [   59.879782] 1fe0: 00002000 bea51880
b6f67e13 b6e1840c 60000010 00000003 202c222a 7b564e45
Feb 23 07:41:40 arm kernel: [   59.879810] [<bf000118>]
(capture_show+0x24/0x38 [pps_gmtimer]) from [<c02ef23c>]
(dev_attr_show+0x1c/0x48)
Feb 23 07:41:40 arm kernel: [   59.879833] [<c02ef23c>]
(dev_attr_show+0x1c/0x48) from [<c01497c0>]
(sysfs_read_file+0xa4/0x12c)
Feb 23 07:41:40 arm kernel: [   59.879859] [<c01497c0>]
(sysfs_read_file+0xa4/0x12c) from [<c00ef5cc>] (vfs_read+0xa4/0x168)
Feb 23 07:41:40 arm kernel: [   59.879874] [<c00ef5cc>]
(vfs_read+0xa4/0x168) from [<c00efce8>] (SyS_read+0x38/0x68)
Feb 23 07:41:40 arm kernel: [   59.879892] [<c00efce8>]
(SyS_read+0x38/0x68) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
Feb 23 07:41:40 arm kernel: [   59.879903] Code: 0a000001 e593101c
e5912000 e5933020 (e593203c) 
Feb 23 07:41:40 arm kernel: [   59.882660] ---[ end trace
0000000000000002 ]---

I'm not sure how to go about resolving this. Can you give me any pointers?

Thanks!


Reply to this email directly or view it on GitHub: https://github.com/ddrown/pps-gmtimer/issues/1

asymingt commented 9 years ago

Spot on -- the pps-gmtimer had silently thrown an error when I modprobed it:

[    7.724754] pinctrl-single 44e10800.pinmux: pin 44e109b4.0 already requested by 44e10800.pinmux; cannot claim for pps_gmtimer.4
[    7.792189] pinctrl-single 44e10800.pinmux: pin-109 (pps_gmtimer.4) status -22
[    7.820668] pinctrl-single 44e10800.pinmux: could not request pin 109 (44e109b4.0) from group pinmux_gps_pps_pins  on device pinctrl-single
[    7.908760] pps-gmtimer pps_gmtimer.4: Error applying setting, reverse things back
[    7.971981] pps-gmtimer: timer name=timer4 rate=24000000Hz
[    8.027483] pinctrl-single 44e10800.pinmux: pin 44e109b4.0 already requested by 44e10800.pinmux; cannot claim for pps_gmtimer.4
[    8.166618] pinctrl-single 44e10800.pinmux: pin-109 (pps_gmtimer.4) status -22
[    8.223904] pinctrl-single 44e10800.pinmux: could not request pin 109 (44e109b4.0) from group pinmux_gps_pps_pins  on device pinctrl-single
[    8.329553] pps-gmtimer pps_gmtimer.4: Error applying setting, reverse things back
[    8.380550] pps-gmtimer: pins are not configured from the driver
[    8.433023] pps-gmtimer: timer(timer4) switched to tclkin, rate=24000000Hz
[    8.488423] pps pps0: new PPS source timer4
[    8.540484] pps-gmtimer: clocksource: timer4 at 24000000 Hz

Perhaps I did not update the am335x-bone-common.dtsi file to correctly reserve the pins for the module. I was able to bump down <&uart5> to <&uart4> reference as per http://www.thing-printer.com/converting-device-tree-overlays-kernel-3-12. However, I think that I probably put the pps_gmtimer node in the wrong place: see line 81 of http://pastebin.com/z8JPVkyE.

Also, I'm not actually sure why timer1 appeared in place of gp_timer when moving from Linux 3.8 to 3.12. I worked off a base BeagleBone Black config from the official kernel, applied the RT patch set, configured to be fully preemptible, and added PPS support (which required disabling dynamic ticks). Here's the kernel config: http://pastebin.com/Z684RMdP. On a side note there is a whole different OMAP virtual clock system in 3.14, which prevents your patch set from working.

asymingt commented 9 years ago

OK -- I solved the pps-gmtimer module error. I had to remove the following snippet from am335x-bone-common.dtsi as it was conflicting with pps_gmtimer pinmux

    clkout2_pin: pinmux_clkout2_pin {
        pinctrl-single,pins = <
            0x1b4 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* xdma_event_intr1.clkout2 */
        >;
    };

This resulted in the following dmesg output

[   68.954729] pps-gmtimer: timer name=timer4 rate=24000000Hz
[   68.994496] pps-gmtimer: timer(timer4) switched to tclkin, rate=24000000Hz
[   69.073360] pps-gmtimer: clocksource: timer4 at 24000000 Hz

However, I'm still getting the following error on running watch-pps:

[  164.656925] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa044050
[  164.656939] Internal error: : 1028 [#1] PREEMPT SMP ARM
[  164.656967] Modules linked in: ipv6 usb_f_acm u_serial g_serial libcomposite snd_soc_omap snd_pcm_dmaengine pps_gmtimer(O)
[  164.656979] CPU: 0 PID: 1871 Comm: watch-pps Tainted: G           O 3.12.31-rt45 #6
[  164.656987] task: de1e86c0 ti: df790000 task.ti: df790000
[  164.657008] PC is at capture_show+0x24/0x38 [pps_gmtimer]
[  164.657029] LR is at dev_attr_show+0x1c/0x48
[  164.657036] pc : [<bf000118>]    lr : [<c02ef23c>]    psr: 60000013
[  164.657036] sp : df791f18  ip : de273000  fp : c0553438
[  164.657040] r10: 0031d1a8  r9 : 00002000  r8 : df791f80
[  164.657045] r7 : df7f5a18  r6 : df7f5a00  r5 : de2d95c0  r4 : bf000e94
[  164.657049] r3 : fa044014  r2 : 00000001  r1 : bf000e94  r0 : df0fee10
[  164.657056] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  164.657061] Control: 10c5387d  Table: 9e254019  DAC: 00000015
[  164.657065] Process watch-pps (pid: 1871, stack limit = 0xdf790250)
[  164.657070] Stack: (0xdf791f18 to 0xdf792000)
[  164.657076] 1f00:                                                       c02ef220 df0fee18
[  164.657085] 1f20: de2d95c0 c01497c0 de1f8c00 0031d1a8 00002000 de1f8c00 0031d1a8 de1f8c00
[  164.657094] 1f40: df790018 df791f80 00002000 00000000 beabe914 c00ef5cc de1f8c00 0031d1a8
[  164.657102] 1f60: 00000000 00000000 de1f8c00 00000000 0031d1a8 00002000 00000000 c00efce8
[  164.657111] 1f80: 00000000 00000000 00002000 00012008 0031d1a8 0002f738 00000003 c000dd64
[  164.657119] 1fa0: df790000 c000dbe0 00012008 0031d1a8 00000003 0031d1a8 00002000 00000400
[  164.657128] 1fc0: 00012008 0031d1a8 0002f738 00000003 00000003 00000000 0009d2d0 beabe914
[  164.657136] 1fe0: 00002000 beabe890 b6edde13 b6d8e40c 60000010 00000003 e1a00006 ebfffffe
[  164.657165] [<bf000118>] (capture_show+0x24/0x38 [pps_gmtimer]) from [<c02ef23c>] (dev_attr_show+0x1c/0x48)
[  164.657189] [<c02ef23c>] (dev_attr_show+0x1c/0x48) from [<c01497c0>] (sysfs_read_file+0xa4/0x12c)
[  164.657215] [<c01497c0>] (sysfs_read_file+0xa4/0x12c) from [<c00ef5cc>] (vfs_read+0xa4/0x168)
[  164.657228] [<c00ef5cc>] (vfs_read+0xa4/0x168) from [<c00efce8>] (SyS_read+0x38/0x68)
[  164.657246] [<c00efce8>] (SyS_read+0x38/0x68) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
[  164.657257] Code: 0a000001 e593101c e5912000 e5933020 (e593203c) 
[  164.660006] ---[ end trace 0000000000000002 ]---
ddrown commented 9 years ago

Check your TCLKIN. Below is the comment in the code: /* if tclkin has no clock, writes to the timer registers will stall and you will get a message like:

asymingt commented 9 years ago

Spot on. It has to do with the transition to the common clock format in more recent kernels.

I have posted the issue here: http://e2e.ti.com/support/arm/sitara_arm/f/791/p/406121/1439644#1439644

UPDATE: I discovered that the clock initialisation seems to have been moved to a new location in the kernel (https://github.com/torvalds/linux/blob/v3.18-rc7/drivers/clk/ti/clk-33xx.c). Tomorrow I'm going to try and change line 119 from clkout2_ck to tclkin_ck to see if that resolves my issue.

asymingt commented 9 years ago

Yes, this solved the issue in combination with the changes that I posted on the TI forum.

tominaga-satotoshi commented 9 years ago

Hi Andrew,

I've posted the similar question to TI E2E site. http://e2e.ti.com/support/arm/sitara_arm/f/791/p/406121/1439644#1439644

I want to connect external clock to TCLKIN, using RT patched TI SDK 7.00.00.00 (kernel 3.12), cclock33xx_data.c does not exist. I've already modified sources as you described except your description on cclock3xxx_data.c. I can't access the diff because the link is expired. Currently, I'm facing the same clock register access problem as you posted. Unhandled fault: external abort on non-linefetch (0x1028)

So, it is very helpful for me to know how you modified to avoid the fault.

Regards, TOMINAGA 'Tommy' Satoshi

asymingt commented 9 years ago

Hi Tominaga

I have forked pps-gmtimer and added my patch set to a folder kernel_3.12+. Please let me know if it works for you, and I will submit a pull request to this repo to have it merged.

Here's the link: https://github.com/asymingt/pps-gmtimer

Cheers Andrew

tominaga-satotoshi commented 9 years ago

Hi Andrew,

Sorry that my reply is late. Thank you for your information.

I applied your patch in kernel_3.12+ directory, unfortunately the result is the same. I'm using BeagleBone Black. Is your patch effective to the system? In dmesg, the system is described as [ 0.000000] Machine: Generic AM33XX (Flattened Device Tree), model: ...

The kernel module still crashed at the first read access to the clock register. The crash occurs at the following line in the following summarized init function. omap_dm_timer_set_load(timer_ptr, 1, 0xFFFFFFFF - (gt_rate/RATE_DIV)); /* set timer interval */

static struct omap_dm_timer *timer_ptr;
static int __init dmtimer_init(void)
{
    :
    timer_ptr = omap_dm_timer_request();
    :
    omap_dm_timer_set_source(timer_ptr, OMAP_TIMER_SRC_EXT_CLK);    /* use tclkin_ck */
    :
    timer_irq = omap_dm_timer_get_irq(timer_ptr);
    :
    ret = request_irq(timer_irq, dm_timer_irq_handler, IRQF_DISABLED | IRQF_TIMER, "dm_timer_irq", &cookie);
    :
    gt_fclk = omap_dm_timer_get_fclk(timer_ptr);
    gt_rate = clk_get_rate(gt_fclk);
    :
    /* CRASHED AT THE FOLLOWING LINE */
    omap_dm_timer_set_load(timer_ptr, 1, 0xFFFFFFFF - (gt_rate/RATE_DIV));  /* set timer interval */
    :

Debug write in some init functions shows,

If you have any idea to prevent crash when clock register access, please let me know.

Best regards, TOMINAGA 'Tommy' Satoshi

tominaga-satotoshi commented 9 years ago

Hi Andrew,

Sorry that I just find that my mistake causes the module crash.

Because I mistook my external clock configuration, tclkin_ck signal is not properly provided. With correct settings, my kernel module works fine.

FYI, the following patches do not needed in my environment.

Thank you again for your support.

Regards, TOMINAGA 'Tommy' Satoshi

asymingt commented 9 years ago

Hi Tommy

That's good to hear :) The patch set that I provided is actually for 3.18, and it will need some significant work to move to 4.0. I'm glad you got it working on 3.12 though. Have fun!

Cheers Andrew