Subject: [PATCHv3 09/10] clocksource: time-armada-370-xp: Divorce from local timer API

From: [email-masked] (Gregory CLEMENT)
Date: Wed, 20 Mar 2013 18:26:22 +0100

On 03/20/2013 06:20 PM, Stephen Boyd wrote:
> On 03/20/13 10:09, Gregory CLEMENT wrote:
>> On 03/13/2013 07:17 PM, Stephen Boyd wrote:
>>> Separate the armada 370xp local timers from the local timer API.
>>> This will allow us to remove ARM local timer support in the near
>>> future and makes this driver multi-architecture friendly.
>> At first view the code looks good, but when I applied your patch set on
>> linux-next, build it and run it on a Armada XP based board (AX3 with 2 cores),
>> it crashed:
> [...]
>> Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
>> Modules linked in:
>> CPU: 0    Not tainted  (3.9.0-rc3-next-20130319-00010-g728b448 #153)
>> PC is at 0xe92d45f0
>> LR is at armada_370_xp_timer_interrupt+0x3c/0x4c
>> pc : [<e92d45f0>]    lr : [<c023c2bc>]    psr: 600001d3
>> sp : c0635eb8  ip : 00000000  fp : c063c3f0
>> r10: 000003ff  r9 : 00000000  r8 : 00000010
>> r7 : c22b3c40  r6 : ef007c00  r5 : c0640fcc  r4 : c0053e30
>> r3 : e92d45f0  r2 : fffffffe  r1 : c22b3c40  r0 : c0053e30
>> Flags: nZCv  IRQs off  FIQs off  Mode SVC_32  ISA ARM  Segment kernel
>> Control: 10c53c7d  Table: 0000406a  DAC: 00000015
>> Process swapper/0 (pid: 0, stack limit = 0xc0634238)
>> Stack: (0xc0635eb8 to 0xc0636000)
>> 5ea0:                                                       ef004c80 c0063224
>> 5ec0: 00000010 00000010 00000000 c0660ac0 c0635f18 c005fcb8 c0632b90 c000ed94
>> 5ee0: c0313c60 60000153 00000001 c00085a8 c0313c54 c0313c60 60000153 ffffffff
>> 5f00: c0635f4c 00000000 562f5842 c06360c0 00000000 c000db60 0000001a ffff8ad0
>> 5f20: ffff8ad0 c06360c0 00000000 00000000 c04379c0 c22ad780 00000000 562f5842
>> 5f40: c06360c0 00000000 60000153 c0635f60 c0313c54 c0313c60 60000153 ffffffff
>> 5f60: 00000021 00000000 00000003 00000004 0000006e c065fcc0 c067924c c063ceb8
>> 5f80: c063cc84 c006d8c0 00000005 c065fcc0 c067924c c0421764 c22ad780 c063c42c
>> 5fa0: 562f5842 c063cca8 c06605c0 c04379c0 c22ad780 00000000 562f5842 00000000
>> 5fc0: 00000000 c0417754 ffffffff ffffffff c04172dc 00000000 00000000 c04379c0
>> 5fe0: 10c53c7d c063c414 c04379bc c063febc 0000406a 00008074 00000000 00000000
>> [<c023c2bc>] (armada_370_xp_timer_interrupt+0x3c/0x4c) from [<c0063224>] (handle_percpu_devid_irq+0x64/0x80)
>> [<c0063224>] (handle_percpu_devid_irq+0x64/0x80) from [<c005fcb8>] (generic_handle_irq+0x20/0x30)
>> [<c005fcb8>] (generic_handle_irq+0x20/0x30) from [<c000ed94>] (handle_IRQ+0x38/0x90)
>> [<c000ed94>] (handle_IRQ+0x38/0x90) from [<c00085a8>] (armada_370_xp_handle_irq+0xa4/0xb0)
>> [<c00085a8>] (armada_370_xp_handle_irq+0xa4/0xb0) from [<c000db60>] (__irq_svc+0x40/0x50)
>> Exception stack(0xc0635f18 to 0xc0635f60)
>> 5f00:                                                       0000001a ffff8ad0
>> 5f20: ffff8ad0 c06360c0 00000000 00000000 c04379c0 c22ad780 00000000 562f5842
>> 5f40: c06360c0 00000000 60000153 c0635f60 c0313c54 c0313c60 60000153 ffffffff
>> [<c000db60>] (__irq_svc+0x40/0x50) from [<c0313c60>] (calibrate_delay+0x378/0x528)
>> [<c0313c60>] (calibrate_delay+0x378/0x528) from [<c0417754>] (start_kernel+0x250/0x2dc)
>> [<c0417754>] (start_kernel+0x250/0x2dc) from [<00008074>] (0x8074)
>> Code: 1fe7deb7 cd5772dd fff5692e ed55f79e (7ed5a5f7)
>>
>>
>>
>> I am trying to figure out what happened.
> 
> Argh. Stupid casting again. Can you try this?

Our emails  must have crossed, your fix is also fine :)

> 
> ---8<----
> 
> diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
> index ee2e50c5..a9bf37a 100644
> --- a/drivers/clocksource/time-armada-370-xp.c
> +++ b/drivers/clocksource/time-armada-370-xp.c
> @@ -150,7 +150,7 @@ static irqreturn_t armada_370_xp_timer_interrupt(int irq, void *dev_id)
>         /*
>          * ACK timer interrupt and call event handler.
>          */
> -       struct clock_event_device *evt = *(struct clock_event_device **)dev_id;
> +       struct clock_event_device *evt = dev_id;
>  
>         writel(TIMER0_CLR_MASK, local_base + LCL_TIMER_EVENTS_STATUS);
>         evt->event_handler(evt);
> 

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com