All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rohit Vaswani <rvaswani@codeaurora.org>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>,
	linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: local timers: Unmask interrupt before new TVAL is set
Date: Tue, 14 Aug 2012 11:49:01 -0700	[thread overview]
Message-ID: <502A9D9D.7070901@codeaurora.org> (raw)
In-Reply-To: <cdb51f00bafa8151a880d8cc7898631e@localhost>

On 8/11/2012 3:17 AM, Marc Zyngier wrote:
> On Fri, 10 Aug 2012 14:57:34 -0700, Rohit Vaswani
> <rvaswani@codeaurora.org>
> wrote:
>> Level triggered interrupt is deasserted when a new TVAL is written
>> only when the interrupt is unmasked. Make sure that the interrupt
>> is unmasked in CTL register before TVAL is written.
>> If this order is not followed, there are chances that on some
>> hardware you would not receive any timer interrupts.
>>
>> Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
>> ---
>>   arch/arm/kernel/arch_timer.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
>> index dd58035..1d0d9df 100644
>> --- a/arch/arm/kernel/arch_timer.c
>> +++ b/arch/arm/kernel/arch_timer.c
>> @@ -126,8 +126,8 @@ static int arch_timer_set_next_event(unsigned long
> evt,
>>   	ctrl |= ARCH_TIMER_CTRL_ENABLE;
>>   	ctrl &= ~ARCH_TIMER_CTRL_IT_MASK;
>>   
>> -	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
>>   	arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>> +	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
> But by doing so, you're opening a window where TVAL can be negative (from
> a previous timer trigger) and the interrupt unmasked, which would lead to
> an immediate trigger, before TVAL is updated with the new value.
>
> Does your hardware deassert the interrupt even when the enable bit is not
> set? If so, would the following sequence work?
>
>          ctrl &= ~(ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK);
>          arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>
> 	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
>
>          ctrl |= ARCH_TIMER_CTRL_ENABLE;
>          arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>
> Thanks,
>
>          M.
Thanks Marc, this works. I will re-send the patch with these changes.

Thanks,
Rohit Vaswani

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

WARNING: multiple messages have this Message-ID (diff)
From: rvaswani@codeaurora.org (Rohit Vaswani)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: local timers: Unmask interrupt before new TVAL is set
Date: Tue, 14 Aug 2012 11:49:01 -0700	[thread overview]
Message-ID: <502A9D9D.7070901@codeaurora.org> (raw)
In-Reply-To: <cdb51f00bafa8151a880d8cc7898631e@localhost>

On 8/11/2012 3:17 AM, Marc Zyngier wrote:
> On Fri, 10 Aug 2012 14:57:34 -0700, Rohit Vaswani
> <rvaswani@codeaurora.org>
> wrote:
>> Level triggered interrupt is deasserted when a new TVAL is written
>> only when the interrupt is unmasked. Make sure that the interrupt
>> is unmasked in CTL register before TVAL is written.
>> If this order is not followed, there are chances that on some
>> hardware you would not receive any timer interrupts.
>>
>> Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
>> ---
>>   arch/arm/kernel/arch_timer.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
>> index dd58035..1d0d9df 100644
>> --- a/arch/arm/kernel/arch_timer.c
>> +++ b/arch/arm/kernel/arch_timer.c
>> @@ -126,8 +126,8 @@ static int arch_timer_set_next_event(unsigned long
> evt,
>>   	ctrl |= ARCH_TIMER_CTRL_ENABLE;
>>   	ctrl &= ~ARCH_TIMER_CTRL_IT_MASK;
>>   
>> -	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
>>   	arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>> +	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
> But by doing so, you're opening a window where TVAL can be negative (from
> a previous timer trigger) and the interrupt unmasked, which would lead to
> an immediate trigger, before TVAL is updated with the new value.
>
> Does your hardware deassert the interrupt even when the enable bit is not
> set? If so, would the following sequence work?
>
>          ctrl &= ~(ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK);
>          arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>
> 	arch_timer_reg_write(ARCH_TIMER_REG_TVAL, evt);
>
>          ctrl |= ARCH_TIMER_CTRL_ENABLE;
>          arch_timer_reg_write(ARCH_TIMER_REG_CTRL, ctrl);
>
> Thanks,
>
>          M.
Thanks Marc, this works. I will re-send the patch with these changes.

Thanks,
Rohit Vaswani

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2012-08-14 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 21:57 [PATCH 1/2] ARM: local timers: Unmask interrupt before new TVAL is set Rohit Vaswani
2012-08-10 21:57 ` Rohit Vaswani
2012-08-11 10:17 ` Marc Zyngier
2012-08-11 10:17   ` Marc Zyngier
2012-08-11 10:17   ` Marc Zyngier
2012-08-14 18:49   ` Rohit Vaswani [this message]
2012-08-14 18:49     ` Rohit Vaswani

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=502A9D9D.7070901@codeaurora.org \
    --to=rvaswani@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marc.zyngier@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.