From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5099F22283514 for ; Tue, 6 Mar 2018 05:18:22 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id z12so20929736wrg.4 for ; Tue, 06 Mar 2018 05:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=2zfTgYV/PzzZw8sM4yF1MdxXODrroFppyIRWWrIsTXw=; b=C4e6cbD+BMBgq4XiLy4iLztabZAaRG/Yrnjy4jTGNNPeAkozm20o03oKHzqG6YjGfG +5AywPcTvJrnKLMfze0JwaPUnFEPRng2jliSvyjjrFrubaqzDyFDmo5XqtpKOi7o4ixd NQOBYtdc6k7QxJ+ikLq/2DjHWPjrXRn0lu81M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2zfTgYV/PzzZw8sM4yF1MdxXODrroFppyIRWWrIsTXw=; b=K4HJo3lOVTArrurNkcrQ72kBldmGyhiJq9yv31ZxCcFHoELPUqPVU0Q1+l+rHu+3gM MhiWeyAQAormWwcAZ0YpjPaFbM0OBmL+9V/rpgyn9HUqqpVQf7bhg7iUmaap+rki4Nxf Zvv1L77C7RYMfUNjFyAQo11peN89tDHdDFq4Tu6qK7iRjNRqK7lSdbpcjur4XzGOs63S KQ4pZoeOZDCUUc2BXwqEoEIR/K41UA8JCByskLsO4/It3E7U2wfJj1VvB/+3bIhFzVV+ QUCVss2jEEtFY96HFBU8VKZ24KGRNXg1MlTKLgQ9NknWj6cjFxNO2CrjwvbIm1S6E3or 1U3w== X-Gm-Message-State: APf1xPD6XbOg8BXP5FFWU6bWj9hLb6M8c/xW5oogOra3BPvQQ46wShHo qLaxzoFWa63FBWe4e/4xJ/EPwteFITU= X-Google-Smtp-Source: AG47ELvAsk7w560+wYivXvyqV/Ymx0rKesTgJ3rvFR8VpfZr0KkJZgyWBwfnRH9TVOt4QdC/l+WmIQ== X-Received: by 10.223.153.230 with SMTP id y93mr15345357wrb.215.1520342675068; Tue, 06 Mar 2018 05:24:35 -0800 (PST) Received: from localhost.localdomain ([160.168.113.39]) by smtp.gmail.com with ESMTPSA id f127sm7673346wmg.46.2018.03.06.05.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 05:24:34 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, marc.zyngier@arm.com Date: Tue, 6 Mar 2018 13:24:24 +0000 Message-Id: <20180306132424.25961-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [PATCH] ArmPkg/TimerDxe: Always perform an EOI, even for spurious interrupts X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2018 13:18:23 -0000 From: Marc Zyngier The generic timer driver only EOIs the timer interrupt if the ISTATUS bit is set. This is completely fine if you pretend that spurious interrupts do not exist. But as a matter of fact, they do, and the first one will leave the interrupt activated at the GIC level, making sure that no other interrupt can make it anymore. Making sure that each interrupt Ack is paired with an EOI is the way to go. Oh, and enabling the interrupt each time it is taken is completely pointless. We entered this function for a good reason... Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marc Zyngier Reviewed-by: Ard Biesheuvel --- ArmPkg/Drivers/TimerDxe/TimerDxe.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c index 2416c90f5545..33d7c922221f 100644 --- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c +++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c @@ -306,12 +306,13 @@ 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) { - // Signal end of interrupt early to help avoid losing subsequent ticks from long duration handlers - gInterrupt->EndOfInterrupt (gInterrupt, Source); - if (mTimerNotifyFunction) { mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod); } @@ -339,9 +340,6 @@ TimerInterruptHandler ( ArmGenericTimerEnableTimer (); } - // Enable timer interrupts - gInterrupt->EnableInterruptSource (gInterrupt, Source); - gBS->RestoreTPL (OriginalTPL); } -- 2.11.0