From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 84592D80477 for ; Sat, 27 Jan 2024 07:55:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JrxZfl62jqqViaBXe/SgxKyQtBDEyTl6pkflKkJzJWI=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1706342157; v=1; b=kTclqdJhr+N1/Qs81XnBXKRamMNFXvJe0e9DPhY2rQjuvKJR46qVmMfrlfHk1VDcS5Hu5swQ vxw0PKFbO2TlnCIjx3A8LniigkieeRrfM8bufPRD+NBrpHNwWE7bbq95LT77UnquPAFTjWIrTsM I5DsKJIHwwaMoY0HwGXUFG3U= X-Received: by 127.0.0.2 with SMTP id 5GkHYY7687511x2txbiXXKF0; Fri, 26 Jan 2024 23:55:57 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.11762.1706342155723722889 for ; Fri, 26 Jan 2024 23:55:56 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9314034" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="9314034" X-Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 23:55:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="2862043" X-Received: from mdkinney-mobl.amr.corp.intel.com ([10.209.51.52]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 23:55:54 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Ray Ni Subject: [edk2-devel] [Patch 1/1] PcAtChipsetPkg/HpetTimerDxe: Fix nested interrupt time accuracy Date: Fri, 26 Jan 2024 23:55:50 -0800 Message-Id: <20240127075550.1295-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: f3wexWxin7zCElWLrSRzzO35x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=kTclqdJh; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4659 When HPET timer is used as the timer interrupt and nested interrupts into the HPET timer interrupt handler occur, the elapsed time passed into the DXE Core is sometime too large and this causes the DXE Core internal system time to run too fast. Fix the logic so the previous main counter value stored in the module global variable mPreviousMainCounter is always captured before the timer notification function is called. Without this change, mPreviousMainCounter is updated after the timer notification function is called and when nesting occurs, it updates with the value from the first level of nesting which is further back in time than the interrupt from the deepest level of nesting. This causes the next two timer interrupts to compute a TimerPeriod that is twice the actual time period since the last interrupt and this causes the DXE Core internal time to run faster than expected. Cc: Ray Ni Signed-off-by: Michael D Kinney --- PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c b/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c index 427572c2ff6d..e74777fbc6f4 100644 --- a/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c +++ b/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c @@ -387,11 +387,18 @@ TimerInterruptHandler ( 100000000 ); + // + // Save main counter value before calling notification function + // that may enable interrupts and allow interrupt nesting. + // + mPreviousMainCounter = MainCounter; + // // Call registered notification function passing in the time since the last // interrupt in 100 ns units. // mTimerNotifyFunction (TimerPeriod); + return; } // -- 2.40.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114648): https://edk2.groups.io/g/devel/message/114648 Mute This Topic: https://groups.io/mt/103992760/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-