From: "Jeff Fan" <fanjianfeng@byosoft.com.cn>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
ashishsingha <ashishsingha@nvidia.com>,
"Marc Zyngier" <maz@kernel.org>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Shanker Donthineni" <sdonthineni@nvidia.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Leif Lindholm" <leif@nuviainc.com>
Subject: Re: [edk2-devel] [PATCH v2] ArmPkg/TimerDxe: Delay End Of Interrupt Signal
Date: Wed, 13 Oct 2021 10:32:16 +0800 [thread overview]
Message-ID: <2021101310221882906110@byosoft.com.cn> (raw)
In-Reply-To: CO6PR12MB53965504E8AE2DE8830E3F46BAB69@CO6PR12MB5396.namprd12.prod.outlook.com
[-- Attachment #1: Type: text/plain, Size: 4477 bytes --]
OVMF did a similare change on Time Driver, please refer to https://github.com/tianocore/edk2/commit/239b50a863704f7960525799eda82de061c7c458
I do not think this will be apply for ArmPkg/TimerDxe.
If one real issue happened on platform, it seems that interrupt was reenabled by reigstered timer event functions.
Jeff
From: Ashish Singhal via groups.io
Date: 2021-10-12 23:38
To: Marc Zyngier; Ard Biesheuvel; Shanker Donthineni
CC: edk2-devel-groups-io; Leif Lindholm; Ard Biesheuvel
Subject: Re: [edk2-devel] [PATCH v2] ArmPkg/TimerDxe: Delay End Of Interrupt Signal
+ Shaker
From: Ashish Singhal <ashishsingha@nvidia.com>
Sent: Tuesday, October 12, 2021 8:56:58 AM
To: Marc Zyngier <maz@kernel.org>; Ard Biesheuvel <ardb@kernel.org>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Leif Lindholm <leif@nuviainc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [PATCH v2] ArmPkg/TimerDxe: Delay End Of Interrupt Signal
Marc,
In the document ARM062-1010708621-30 (AArch64 Programmer's Guides Generic Timer), towards the end of section 3.4 it says: "When writing an interrupt handler for the timers, it is important that software clears the interrupt before deactivating the interrupt in the GIC. Otherwise, the GIC will re-signal the same interrupt again."
My change was in accordance with this. We only clear the interrupt when we update the compare value but were signaling EOI before that going against the guidance in the document.
Thanks
Ashish
From: Marc Zyngier <maz@kernel.org>
Sent: Tuesday, October 12, 2021 2:57 AM
To: Ard Biesheuvel <ardb@kernel.org>; Ashish Singhal <ashishsingha@nvidia.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Leif Lindholm <leif@nuviainc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [PATCH v2] ArmPkg/TimerDxe: Delay End Of Interrupt Signal
External email: Use caution opening links or attachments
On Mon, 11 Oct 2021 23:24:38 +0100,
Ard Biesheuvel <ardb@kernel.org> wrote:
>
> (+ Marc)
>
> On Mon, 11 Oct 2021 at 23:40, Ashish Singhal <ashishsingha@nvidia.com> wrote:
> >
> > In an interrupt handler for the timers, it is important that
> > software clears the interrupt before deactivating the interrupt
> > in the GIC. Otherwise the GIC will re-signal the same interrupt
> > again.
> >
> > Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
>
> Please don't spam us with almost identical versions of the same patch
> without even documenting what the difference is.
>
>
> > ---
> > ArmPkg/Drivers/TimerDxe/TimerDxe.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
> > index 0370620fae..46e5bbf287 100644
> > --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c
> > +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
> > @@ -300,10 +300,6 @@ TimerInterruptHandler (
> > //
> > OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
> >
> > - // Signal end of interrupt early to help avoid losing subsequent ticks
> > - // from long duration handlers
> > - gInterrupt->EndOfInterrupt (gInterrupt, Source);
> > -
> > // Check if the timer interrupt is active
> > if ((ArmGenericTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {
> >
> > @@ -335,6 +331,11 @@ TimerInterruptHandler (
> > ArmInstructionSynchronizationBarrier ();
> > }
> >
> > + // In an interrupt handler for the timers, it is important that software clears the interrupt
> > + // before deactivating the interrupt in the GIC. Otherwise the GIC will re-signal the same
> > + // interrupt again.
> > + gInterrupt->EndOfInterrupt (gInterrupt, Source);
> > +
> > gBS->RestoreTPL (OriginalTPL);
> > }
> >
This isn't a requirement if you haven't re-enabled interrupts in
PSTATE (and the TPL being raised seems to indicate that interrupts are
actively masked here).
The timer is a level interrupt, and lowering the level takes time. If
your GIC implementation is good, it will notice that the lowering of
the level quickly, before you can reach the point where you re-enable
interrupts. If it is slow (or badly emulated if this is actually done
in a hypervisor), you'll get a spurious interrupt.
In any case, moving the EOI around doesn't make things any better. You
are just moving the goal post, without additional guarantees that the
level has been retired.
As a consequence, I don't think this patch makes much sense.
M.
--
Without deviation from the norm, progress is not possible.
[-- Attachment #2: Type: text/html, Size: 9402 bytes --]
next prev parent reply other threads:[~2021-10-13 2:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 21:40 [PATCH v2] ArmPkg/TimerDxe: Delay End Of Interrupt Signal Ashish Singhal
2021-10-11 22:24 ` Ard Biesheuvel
[not found] ` <87h7dmpqn2.wl-maz@kernel.org>
2021-10-12 14:56 ` Ashish Singhal
2021-10-12 15:38 ` Ashish Singhal
2021-10-13 2:32 ` Jeff Fan [this message]
2021-10-14 4:54 ` [edk2-devel] " Ashish Singhal
[not found] ` <87czoap7rg.wl-maz@kernel.org>
2021-10-12 16:11 ` Ashish Singhal
[not found] ` <87bl3up5t2.wl-maz@kernel.org>
2021-10-12 16:32 ` Ashish Singhal
2021-10-12 17:07 ` Ashish Singhal
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-list 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=2021101310221882906110@byosoft.com.cn \
--to=devel@edk2.groups.io \
/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