From nobody Mon Feb 9 04:15:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87083+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87083+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646032992; cv=none; d=zohomail.com; s=zohoarc; b=g9uhxgsV6nF+mWEebI7kWNuFJ5ETwkqkE+JtpaCAwGDDp1cn31Oe7hCZca2/bAQBnfR4xX2AceUTzHqF92kLcabyYIyr4+7WES0BM76dshAGwcuyypBW4vXQjWXD78GBdtEewcg2rL6xQ7HGaix/UZSBq9/Zg3/MKUG9Z8KpAHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646032992; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FwO9/X8bQOBkBqCS3GtiiuE6tgm5L8NPKjTY2iFrvx0=; b=Qvf4G8Vfts4ico/ZsEd1ecLpxCdbHepinCMJDIY9NXPoolpe468quWS5lEqJO8Rzhi5H9w7VaoK1O3LQ57wVuLYb/NIcK+u3zRWKnhtzKHPtybg8rtC2Nnr4lKAfAAojry/wbNBrPaCbN3QO1ROQw157XM0FcEpJGCrSOoFK5FY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87083+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646032992169417.4866040266909; Sun, 27 Feb 2022 23:23:12 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6sE6YY1788612xntXGW4xRrs; Sun, 27 Feb 2022 23:23:11 -0800 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.17591.1646032955417624285 for ; Sun, 27 Feb 2022 23:23:05 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="252553202" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="252553202" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2022 23:23:05 -0800 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="534341423" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2022 23:23:03 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Jiewen Yao , Gerd Hoffmann , Anthony Perard , Julien Grall , Eric Dong , Ray Ni Subject: [edk2-devel] [PATCH V7 36/37] UefiCpuPkg: Setting initial-count register as the last step Date: Mon, 28 Feb 2022 15:21:08 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,min.m.xu@intel.com X-Gm-Message-State: l6CN70A4lhjdv0X9EI0NAYTsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646032991; bh=qjkYR4F5pv2c7AtQKYNbZz+nCPZXlyZlK7K8a+mlFhc=; h=Cc:Date:From:Reply-To:Subject:To; b=Sg/4K+grR4fQH86S2LpR+Yf2ZgCCyJObgTuk2gfF0CgsF5WNV88REvG6czFjX0S0KGZ iPjHSQ5RxmUOP5h7QakwC4niBIaQWjZYqTBh/6KCT/qbHAdZGSlONUMs2ysDlocNcNdLk +hO9reJWJRTVDgag/0dEHgkbAVBSpQk5BA0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646032992993100007 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3711 Per SDM, changing the mode of APIC timer (from one-shot to periodic or vice versa) by writing to the timer LVT entry does not start the timer. To start the timer, it is necessary to write to the initial-count register. If initial-count is wrote before mode change, it's possible that timer expired before the mode change. Thus failing the periodic mode. Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Anthony Perard Cc: Julien Grall Cc: Eric Dong Cc: Ray Ni Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- .../Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/U= efiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c index 2d17177df12b..f26d9c93894f 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -967,11 +967,6 @@ InitializeApicTimer ( // InitializeLocalApicSoftwareEnable (TRUE); =20 - // - // Program init-count register. - // - WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); - if (DivideValue !=3D 0) { ASSERT (DivideValue <=3D 128); ASSERT (DivideValue =3D=3D GetPowerOfTwo32 ((UINT32)DivideValue)); @@ -996,6 +991,11 @@ InitializeApicTimer ( LvtTimer.Bits.Mask =3D 0; LvtTimer.Bits.Vector =3D Vector; WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); + + // + // Program init-count register. + // + WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); } =20 /** --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87083): https://edk2.groups.io/g/devel/message/87083 Mute This Topic: https://groups.io/mt/89446188/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-