From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/40] Complete set of clocksource/sched_clock patches
Date: Sun, 19 Dec 2010 12:55:08 +0000 [thread overview]
Message-ID: <20101219125508.GG3047@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <19725.64412.395353.947407@pilspetsen.it.uu.se>
On Sun, Dec 19, 2010 at 01:33:32PM +0100, Mikael Pettersson wrote:
> Here it is:
>
> Build ATAG
> ATAG_MEM: Overwrite ram_end with real_region_top=0x20000000, memsize=512 M
> ATAG_MEM=536870912 at 0xa0000000, MACH_TYPE=1101
> Using base address 0x00200000 and length 0x0018e3c0
> Uncompressing Linux... done, booting the kernel.
> Linux version 2.6.37-rc6 (mikpe at brewer) (gcc version 4.4.6 20101116 (prerelease) (GCC) ) #1 Sun Dec 19 12:58:45 CET 2010
> CPU: XScale-80219 [69052e30] revision 0 (ARMv5TE), cr=0000397f
> CPU: VIVT data cache, VIVT instruction cache
> Machine: Thecus N2100
> bootconsole [earlycon0] enabled
> Memory policy: ECC disabled, Data cache writeback
> pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
> pcpu-alloc: [0] 0
> Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
> Kernel command line: console=ttyS0,115200 ro root=/dev/sda1 mem=512M at 0xa0000000 earlyprintk
> PID hash table entries: 2048 (order: 1, 8192 bytes)
> Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
> Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
> Memory: 512MB = 512MB total
> Memory: 516424k/516424k available, 7864k reserved, 0K highmem
> Virtual kernel memory layout:
> vector : 0xffff0000 - 0xffff1000 ( 4 kB)
> fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
> DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
> vmalloc : 0xe0800000 - 0xfe000000 ( 472 MB)
> lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
> modules : 0xbf000000 - 0xc0000000 ( 16 MB)
> .init : 0xc0008000 - 0xc0022000 ( 104 kB)
> .text : 0xc0022000 - 0xc030d000 (2988 kB)
> .data : 0xc030e000 - 0xc0329d60 ( 112 kB)
> NR_IRQS:32
> sched_clock: 32 bits at 198MHz, resolution 5ns, wraps every 21691ms
> Unable to handle kernel NULL pointer dereference at virtual address 00000000
> pgd = c0004000
> [00000000] *pgd=00000000
> Internal error: Oops: 80000005 [#1]
> last sysfs file:
> Modules linked in:
> CPU: 0 Not tainted (2.6.37-rc6 #1)
> PC is at 0x0
> LR is at iop_timer_interrupt+0x20/0x28
> pc : [<00000000>] lr : [<c002b580>] psr: 400000d3
> sp : c030fe98 ip : c030fea8 fp : c030fea4
> r10: a001c494 r9 : 69052e30 r8 : c0315a8c
> r7 : 00000009 r6 : 00000000 r5 : 00000000 r4 : c0312fa0
> r3 : 00000000 r2 : 00000001 r1 : c0312fc8 r0 : c0312fc8
> Flags: nZcv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
> Control: 0000397f Table: a0004000 DAC: 00000017
> Process swapper (pid: 0, stack limit = 0xc030e270)
> Stack: (0xc030fe98 to 0xc0310000)
> fe80: c030fec4 c030fea8
> fea0: c005ebfc c002b56c c0315a68 00000009 00000200 60000053 c030fedc c030fec8
> fec0: c0060e78 c005ebdc 00000009 00000000 c030fef4 c030fee0 c002207c c0060dd8
> fee0: ffffffff c030ff2c c030ff6c c030fef8 c0022ba8 c002200c 00000000 00000001
> ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
> ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
> ff40: 52ef041b 00000001 c0312fa0 00000009 c001d9e4 c0311a58 a001c704 a001c494
> ff60: c030ff84 c030ff70 c005fa54 c005f598 c0312fa0 0bcd3d80 c030ffac c030ff88
> ff80: c000c3a4 c005fa38 c0315560 600000d3 c0330020 c0329d60 c001d9e8 c001d9e4
> ffa0: c030ffbc c030ffb0 c000bee4 c000c358 c030ffcc c030ffc0 c0009f54 c000bedc
> ffc0: c030fff4 c030ffd0 c0008a1c c0009f44 c000865c 00000000 00000000 c001d9e8
> ffe0: 0000397d c0329e64 00000000 c030fff8 a0008034 c00088b8 00000000 00000000
> Backtrace:
> [<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc)
> [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c)
> r7:60000053 r6:00000200 r5:00000009 r4:c0315a68
> [<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0)
> r5:00000000 r4:00000009
> [<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80)
> Exception stack(0xc030fef8 to 0xc030ff40)
> fee0: 00000000 00000001
> ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
> ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
> r5:c030ff2c r4:ffffffff
> [<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c)
> [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
> r5:0bcd3d80 r4:c0312fa0
> [<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
> r6:c001d9e4 r5:c001d9e8 r4:c0329d60
> [<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24)
> [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264)
> [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
> r5:c0329e64 r4:0000397d
> Code: bad PC value
> ---[ end trace 1b75b31a2719ed1c ]---
> Kernel panic - not syncing: Fatal exception in interrupt
> Backtrace:
> [<c0026314>] (dump_backtrace+0x0/0x118) from [<c025b65c>] (dump_stack+0x18/0x1c)
> r7:00000000 r6:c030e270 r5:c032a030 r4:c032a030
> [<c025b644>] (dump_stack+0x0/0x1c) from [<c025b6c4>] (panic+0x64/0x188)
> [<c025b660>] (panic+0x0/0x188) from [<c0026758>] (die+0x194/0x1d8)
> r3:00010000 r2:c030fcf8 r1:00001315 r0:c02ca1bf
> r7:00000000
> [<c00265c4>] (die+0x0/0x1d8) from [<c00285d8>] (__do_kernel_fault+0x6c/0x90)
> r8:00000000 r7:80000005 r6:00000000 r5:c030fe50 r4:00000000
> [<c002856c>] (__do_kernel_fault+0x0/0x90) from [<c00287b8>] (do_page_fault+0x1bc/0x1d4)
> r9:000000d3 r8:00000000 r7:00000000 r6:00000000 r5:c030fe50
> r4:c0310df8
> [<c00285fc>] (do_page_fault+0x0/0x1d4) from [<c0028868>] (do_translation_fault+0x24/0xac)
> [<c0028844>] (do_translation_fault+0x0/0xac) from [<c0022230>] (do_PrefetchAbort+0x3c/0xa0)
> r7:c030fe50 r6:00000000 r5:c0311e5c r4:00000005
> [<c00221f4>] (do_PrefetchAbort+0x0/0xa0) from [<c0022c90>] (__pabt_svc+0x50/0x80)
> Exception stack(0xc030fe50 to 0xc030fe98)
> fe40: c0312fc8 c0312fc8 00000001 00000000
> fe60: c0312fa0 00000000 00000000 00000009 c0315a8c 69052e30 a001c494 c030fea4
> fe80: c030fea8 c030fe98 c002b580 00000000 400000d3 ffffffff
> r7:00000009 r6:00000000 r5:c030fe84 r4:ffffffff
> [<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc)
> [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c)
> r7:60000053 r6:00000200 r5:00000009 r4:c0315a68
> [<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0)
> r5:00000000 r4:00000009
> [<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80)
> Exception stack(0xc030fef8 to 0xc030ff40)
> fee0: 00000000 00000001
> ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
> ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
> r5:c030ff2c r4:ffffffff
> [<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c)
> [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
> r5:0bcd3d80 r4:c0312fa0
> [<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
> r6:c001d9e4 r5:c001d9e8 r4:c0329d60
> [<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24)
> [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264)
> [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
> r5:c0329e64 r4:0000397d
>
> We take an early timer interrupt and call NULL in the
>
> evt->event_handler(evt);
>
> statement in iop_timer_interrupt(). Apparently the evt (dev_id) passed
> to the interrupt handler isn't initialized at this point.
evt is initialized, it's done statically:
static struct irqaction iop_timer_irq = {
.dev_id = &iop_clockevent,
};
What isn't initialized at this early point is evt->event_handler.
> The most visible change the sched_clock patches did in plat-iop was to add
> a call to init_sched_clock() at the very start of iop_init_time(), before
> the timer IRQ, clockevent, and clocksource have been set up. Moving that call
> to the very end of iop_init_time() [see below] made the kernel boot again,
> and the interactivity problems were also solved.
I think this is a bug just waiting to happen, and the sched_clock patch
just gives it a helping hand (by accidentally enabling interrupts early
- and that's something which also needs fixing.)
Here's the event device setup code:
write_tmr0(timer_ctl & ~IOP_TMR_EN);
setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq);
clockevents_calc_mult_shift(&iop_clockevent,
tick_rate, IOP_MIN_RANGE);
iop_clockevent.max_delta_ns =
clockevent_delta2ns(0xfffffffe, &iop_clockevent);
iop_clockevent.min_delta_ns =
clockevent_delta2ns(0xf, &iop_clockevent);
iop_clockevent.cpumask = cpumask_of(0);
clockevents_register_device(&iop_clockevent);
write_trr0(ticks_per_jiffy - 1);
write_tcr0(ticks_per_jiffy - 1);
write_tmr0(timer_ctl);
First thing is that although the timer is stopped before the IRQ is
registered, there is no clearing of any pending timer interrupt at that
time. As we don't know what state the timer was in, we can't be sure
that the interrupt isn't already pending.
Second thing is why is the timer being enabled by this code after it's
been registered. This is something which should be done by the
clockevents code when it's ready via the ->set_mode callback, not when
the platform decides to do so - otherwise you can call the interrupt
handler when evt->event_handler has not been setup.
So, I think this will solve the IOP misbehaviour. What I don't know
is what the cryptic txx0() suffixes on these write statements are
(what's the difference between trr and tcr? tcr = timer counter
register, trr = timer ? register? Does trr need to be written in
->set_mode (if so that's another bug in this code)?
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c
index 0ca000d..e937e5d 100644
--- a/arch/arm/plat-iop/time.c
+++ b/arch/arm/plat-iop/time.c
@@ -162,6 +162,7 @@ void __init iop_init_time(unsigned long tick_rate)
* Set up interrupting clockevent timer 0.
*/
write_tmr0(timer_ctl & ~IOP_TMR_EN);
+ write_tisr(1);
setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq);
clockevents_calc_mult_shift(&iop_clockevent,
tick_rate, IOP_MIN_RANGE);
@@ -171,9 +172,6 @@ void __init iop_init_time(unsigned long tick_rate)
clockevent_delta2ns(0xf, &iop_clockevent);
iop_clockevent.cpumask = cpumask_of(0);
clockevents_register_device(&iop_clockevent);
- write_trr0(ticks_per_jiffy - 1);
- write_tcr0(ticks_per_jiffy - 1);
- write_tmr0(timer_ctl);
/*
* Set up free-running clocksource timer 1.
next prev parent reply other threads:[~2010-12-19 12:55 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-17 11:32 [PATCH 0/40] Complete set of clocksource/sched_clock patches Russell King - ARM Linux
2010-12-17 11:35 ` [PATCH 01/40] ARM: AT91: update clock source registration Russell King - ARM Linux
2010-12-17 13:01 ` Jean-Christophe PLAGNIOL-VILLARD
2010-12-17 11:35 ` [PATCH 02/40] ARM: bcmring: " Russell King - ARM Linux
2010-12-17 11:36 ` [PATCH 03/40] ARM: davinci: " Russell King - ARM Linux
2010-12-21 19:23 ` Kevin Hilman
2010-12-17 11:36 ` [PATCH 04/40] ARM: integrator: " Russell King - ARM Linux
2010-12-17 11:37 ` [PATCH 05/40] ARM: ixp4xx: " Russell King - ARM Linux
2010-12-17 11:37 ` [PATCH 06/40] ARM: lpc32xx: " Russell King - ARM Linux
2010-12-17 11:37 ` [PATCH 07/40] ARM: mmp: " Russell King - ARM Linux
2010-12-17 11:38 ` [PATCH 08/40] ARM: MSM: " Russell King - ARM Linux
2010-12-17 21:23 ` David Brown
2010-12-17 11:38 ` [PATCH 09/40] ARM: netx: " Russell King - ARM Linux
2010-12-17 11:38 ` [PATCH 10/40] ARM: ns9xxx: " Russell King - ARM Linux
2010-12-17 11:39 ` [PATCH 11/40] ARM: omap: " Russell King - ARM Linux
2010-12-17 11:39 ` [PATCH 12/40] ARM: PXA: " Russell King - ARM Linux
2010-12-17 11:39 ` [PATCH 13/40] ARM: s5pv310: " Russell King - ARM Linux
2010-12-17 11:40 ` [PATCH 14/40] ARM: SA11x0: " Russell King - ARM Linux
2010-12-17 11:40 ` [PATCH 15/40] ARM: tcc8k: " Russell King - ARM Linux
2010-12-17 11:40 ` [PATCH 16/40] ARM: U300: " Russell King - ARM Linux
2010-12-17 11:41 ` [PATCH 17/40] ARM: nuc: " Russell King - ARM Linux
2010-12-17 13:21 ` Wan ZongShun
2010-12-17 11:41 ` [PATCH 18/40] ARM: iop: " Russell King - ARM Linux
2010-12-17 11:41 ` [PATCH 19/40] ARM: mxc: " Russell King - ARM Linux
2010-12-17 11:44 ` [PATCH 20/40] ARM: nomadik: " Russell King - ARM Linux
2010-12-17 11:44 ` [PATCH 21/40] ARM: spear: " Russell King - ARM Linux
2010-12-17 11:45 ` [PATCH 22/40] ARM: orion: " Russell King - ARM Linux
2010-12-17 11:46 ` [PATCH 23/40] ARM: stmp: " Russell King - ARM Linux
2010-12-17 11:46 ` [PATCH 24/40] ARM: realview/versatile: " Russell King - ARM Linux
2010-12-17 11:46 ` [PATCH 25/40] ARM: tegra: timer: Separate clocksource and sched_clock Russell King - ARM Linux
2010-12-17 11:47 ` [PATCH 26/40] ARM: ensure all sched_clock() implementations are notrace marked Russell King - ARM Linux
2010-12-17 11:47 ` [PATCH 27/40] Fix rounding in clocks_calc_mult_shift() Russell King - ARM Linux
2010-12-17 11:47 ` [PATCH 28/40] ARM: sched_clock: provide common infrastructure for sched_clock() Russell King - ARM Linux
2010-12-17 18:51 ` Nicolas Pitre
2010-12-17 19:05 ` Russell King - ARM Linux
2010-12-17 19:18 ` Russell King - ARM Linux
2010-12-17 19:34 ` Nicolas Pitre
2010-12-17 19:37 ` Nicolas Pitre
2010-12-17 19:40 ` Russell King - ARM Linux
2010-12-17 19:59 ` Nicolas Pitre
2010-12-17 11:48 ` [PATCH 29/40] ARM: ixp4xx: convert sched_clock() to use new infrastructure Russell King - ARM Linux
2010-12-17 11:48 ` [PATCH 30/40] ARM: mmp: " Russell King - ARM Linux
2010-12-17 11:48 ` [PATCH 31/40] ARM: pxa: " Russell King - ARM Linux
2010-12-17 11:49 ` [PATCH 32/40] ARM: sa1100: " Russell King - ARM Linux
2010-12-17 11:49 ` [PATCH 33/40] ARM: tegra: " Russell King - ARM Linux
2010-12-22 7:23 ` Olof Johansson
2010-12-22 23:06 ` Russell King - ARM Linux
2010-12-17 11:49 ` [PATCH 34/40] ARM: u300: " Russell King - ARM Linux
2010-12-19 22:26 ` Linus Walleij
2010-12-17 11:50 ` [PATCH 35/40] ARM: iop: " Russell King - ARM Linux
2010-12-19 10:56 ` Russell King - ARM Linux
2010-12-17 11:50 ` [PATCH 36/40] ARM: nomadik: " Russell King - ARM Linux
2010-12-19 22:25 ` Linus Walleij
2010-12-17 11:50 ` [PATCH 37/40] ARM: omap: " Russell King - ARM Linux
2010-12-17 11:51 ` [PATCH 38/40] ARM: orion: " Russell King - ARM Linux
2010-12-17 19:49 ` Nicolas Pitre
2010-12-17 11:51 ` [PATCH 39/40] ARM: versatile: " Russell King - ARM Linux
2010-12-17 11:51 ` [PATCH 40/40] ARM: vexpress: add sched_clock() for Versatile Express Russell King - ARM Linux
2010-12-17 14:04 ` [PATCH 0/40] Complete set of clocksource/sched_clock patches Santosh Shilimkar
2010-12-17 16:03 ` Will Deacon
2010-12-19 10:37 ` Mikael Pettersson
2010-12-19 10:52 ` Russell King - ARM Linux
2010-12-19 10:56 ` Russell King - ARM Linux
2010-12-19 12:16 ` Mikael Pettersson
2010-12-19 12:33 ` Mikael Pettersson
2010-12-19 12:55 ` Russell King - ARM Linux [this message]
2010-12-19 14:05 ` Mikael Pettersson
2010-12-19 14:49 ` Russell King - ARM Linux
2010-12-19 16:15 ` Mikael Pettersson
2010-12-20 3:32 ` Eric Miao
2010-12-20 22:48 ` Russell King - ARM Linux
2010-12-21 19:24 ` Kevin Hilman
2010-12-22 7:24 ` Olof Johansson
2010-12-22 10:59 ` Jamie Iles
2010-12-22 21:59 ` JD (Jiandong) Zheng
2011-01-08 9:05 ` Wan ZongShun
2011-01-08 9:23 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101219125508.GG3047@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).