From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.10806.1651936569329658282 for ; Sat, 07 May 2022 08:16:09 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=LwEwLRti; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651936569; x=1683472569; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=BiQrmlu0EdK/VRY/4n2kekzhLR8UJqlws4YRW6EC2gQ=; b=LwEwLRtiEidQBRlAJw3V0MVCA2/Dovo0KTyQxnXo5ry5OQIyIs9k2thn 4tm6zyx7NMFLzYFjEMatPW6Hx5Cp9eEvyRpLQSkB7S5LJ5whIO1McXLQX TklABZoA2CZDrdYC1C6PzAMd9VOOl98GgQqKjKMx0Ou4qAeaXBI5nk1Dh vgs1eFtohli24FyZ+0EKq8B8r9g/FZ63+lwnhvx6F2JbITfC/FkkBfxMA zk3jdMvxMu5z1YyHSzhiQMp1sa/l74wiAhMTJbWjiGIOKNcomStfdWiUk h1qb/yoh71eJa0hQpgTkt1x6HukFIuCMSrzNbSxWfn9oU1w4VRZohOnvw A==; X-IronPort-AV: E=McAfee;i="6400,9594,10340"; a="256211275" X-IronPort-AV: E=Sophos;i="5.91,207,1647327600"; d="scan'208";a="256211275" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 08:16:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,207,1647327600"; d="scan'208";a="586529322" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga008.jf.intel.com with ESMTP; 07 May 2022 08:16:07 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sat, 7 May 2022 08:16:06 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sat, 7 May 2022 08:16:06 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Sat, 7 May 2022 08:16:06 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.109) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sat, 7 May 2022 08:16:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AoQ6Z70xKBepKc0k1ILKHA6k020QAE6qudL6smF6kMvcwW2x+UcQ71T+Hz1H7zrNofo5DUmbfgaHn0tuDzVxEqDtvnN7ZLvBKVVOepmlVA+gW3fKzTxTh9PBMazuy5ohwTVbKVoejHjewZkvYqgiZuQf5aDmlcxfbkTNZ3N+1ICtzLeq1wIO/PKbMQaRcVSNCQUlcSbmbpIjz7ggKAtgxR2kCAuP7NEa9ep9Vn0EvJjEOVyTxzySezAp590FcVm4C3fez0+corYq9CYwrHgWsDu5DbHkHRtGK5fJQOWUvsSJFRjpdI77glQ3Sj5Z/WiSqHxMXoEO2R1Cyr5Wvc6hVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c47DYCZDidVxtyzJgAVDM+OUx/c5Yp0ZllCFLDQitWk=; b=D7pUzLI1fX8Au4dvNSYF/VFze9igBJQPXlrWaFtVVz6tynl0JSG3QoXt18n+NIK8SkfUDiKfF43C6TGYheJsPkdgU2VHCEgEG2zaYCHlthjzWUiTEjc6ZxmDHyIOZYhJDIDIpJIeSRlik4AqfFDItmaxMA6OGQdnx1BTh3ePVq7qh2b9l3qHqHd99CCtiqngdIXBviEAV7n0aM7EB0n3eGd2oyTlnYXmQmcY1286q5bCrVx1uzLLbZdM6mkxsYPNj13A/Uu5h8+cEZHk3lsquCSP73pKFZ86PxI24lfuoJAG/PF3YIBiX3hu+nuBCVFOkpVvRM/6CwaJ/4aJBtCc4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by DM5PR11MB1561.namprd11.prod.outlook.com (2603:10b6:4:a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13; Sat, 7 May 2022 15:16:04 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::2d8b:3e7f:83d7:1e56]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::2d8b:3e7f:83d7:1e56%8]) with mapi id 15.20.5206.028; Sat, 7 May 2022 15:16:04 +0000 From: "Ni, Ray" To: "Chao, Zhuoran" , "devel@edk2.groups.io" Subject: Re: [PATCH v3] PcAtChipsetPkg: Change the flow of PcRtcInit() Thread-Topic: [PATCH v3] PcAtChipsetPkg: Change the flow of PcRtcInit() Thread-Index: AQHYYfZl44yuFs9DYE+GdhxC8MmYPa0ThsKw Date: Sat, 7 May 2022 15:16:04 +0000 Message-ID: References: <1d9ab6d031b853fb580366834fd1809c84d321fd.1651915058.git.zhuoran.chao@intel.com> In-Reply-To: <1d9ab6d031b853fb580366834fd1809c84d321fd.1651915058.git.zhuoran.chao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4ad76b46-9217-4cdf-a9fb-08da303c80cd x-ms-traffictypediagnostic: DM5PR11MB1561:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1A8+/mkDEAI6+oezC82Vj1iZ2GLhDVm72BM6WWlJP8Cr4peGuyoBznj0f0mtQHyc12xTSESe2QHPIWmYtuNp82iqJdXkS8T5w2kLITL7gimURM0jI9OhQ4xCcVwg/wcmBBU8JMXHi4wUaxnZDVehkEdPENYCpQ/4d7KCWF01UqQfU9S6ZEbXy3K6sI51RPI3Q+kQUNlipRUrvQcus3mCTFzU7VhbLodHxRA+VTDibiXSKFTTCqkdXTIFQvg0coRINJHJzL9paNoDM7ebm8xsLFBqOMPrbIs3kKIcdFoS/dTyskXIcnPfuhwzrNJYlQnrzILnzdpTgD5RUWQSeraGS37YgLKaVHWJoWdtzm7GIQbTkKqCoiJXZuFKhbXUuwStr7MpKmtrZoYCVu95ylgjCiDs6YPnfIibJezIjjZCwLNdq/zm0qIT1+RLUddY3EP8MLokAhNSCi4SV9K/3Tbr2I3Kvnv29YB6wLX1uZphB0jeNeOBPvxI2lIQOr5gmYIt4IybCZim7lyXtslidgHM2xH08/OyZu0zynTiLX4ce+ZMD7HO7DO+JVTrXtYh081rXkXKX4SELDEdQysG2vKNv+WRwpW+tdhYj2QrJAdALFlZ2R58kbyEPZe8wngevdN3j/wdriidzp65E8W9ZBhkkBj/SqxJLmc4k+kJl/rgaAMuAh03UmR9PC81Y8Z4UGEEb5tYNZYi9pyJ3uC84DWSjMWeA0PYvGQRsKnyKP2mDGoyrbxnMvPK7DI98KmKzLFECWeG1sKqmTG0Or9P/Bnoxm252iI1vtcYXDLiFfRJMaQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(6029001)(366004)(2906002)(19627235002)(316002)(8676002)(33656002)(83380400001)(64756008)(71200400001)(66946007)(66476007)(66556008)(5660300002)(76116006)(66446008)(110136005)(508600001)(8936002)(52536014)(53546011)(7696005)(6506007)(26005)(9686003)(186003)(86362001)(38070700005)(38100700002)(55016003)(82960400001)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?r7dZ56Xs/Yi9WiFQli6P/KUfxNsu8tAuBZF6/0g2jCR1T9za60nzbd3hCDP1?= =?us-ascii?Q?aYoc3EZcTCcXC3pyRWvCBHut+jVrihl8pXxVZTM4kTmHCxca62eb6W/u3afY?= =?us-ascii?Q?A61paQz3v2KQNM+OciJjUV1yEBVtx90ihCWEiKYWbr+CuOOU4baI94O4A2Wf?= =?us-ascii?Q?TlqsFwrLpmOQd1S4RIXj/nZdWIh1JgSYlPjX59v0SzJIUMRYUOcsgc/ryZV6?= =?us-ascii?Q?NL5DOzyi/TsIwY+zw3Ew1yBmGcehJuxe+zd2zNPF2KSSgVYsAW2nI4U2YWG3?= =?us-ascii?Q?dpQemK2y0S5pSI2tF8lJ1D4EFpcqlzh16NIvp/vx7+CQECL5vgf652xOqhgn?= =?us-ascii?Q?NuvMX5MwwlWetGmlfV8QtsE2dNLV19I/sdu2AjnX8MEGmF8Nh4/cXsccpFS4?= =?us-ascii?Q?ntP9Z7Qff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r8WKBMK/DKP/k0c?= =?us-ascii?Q?ywwg5Sh6F/75fXW6kFAFLV0dyjINPEUTYa1qt24RM7eUob8W1cwNfkqIxNu8?= =?us-ascii?Q?o/07A2GrRYzJs8QKDT9CicUR3Ydt0fl+p3NaKbYMFHQpYl2Bgu4UOekUeCnJ?= =?us-ascii?Q?3xEkB524NY1ujsVoR8YYtbyu7Y6QNgbP1JK0S6NU9OO1o7H7EYf8b3EzBOLv?= =?us-ascii?Q?L6vvpd66CW8ZQi4BmnNIjDuYsI5W2D6IVOC6PAXIP2e7YTaJE2vSY0gAzyQ1?= =?us-ascii?Q?/zsZfV3fUw9siMvPPVnEPjnYxjwM/W6YA+iFVc9Dg7lmnbqY3h3EVhlkGKsQ?= =?us-ascii?Q?mgjoCkSRF5tq1h/kRArXw/N/8vfz48uhJiiM9JW/dBQEmj1J77fdfvolAdLM?= =?us-ascii?Q?RQjZQdHk4ayrDUtuS5k5QTmvyEpuRBXKAd7tqPUo1sdk8BNdrnjqeA2bpCn7?= =?us-ascii?Q?hnbePc3psQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ad76b46-9217-4cdf-a9fb-08da303c80cd X-MS-Exchange-CrossTenant-originalarrivaltime: 07 May 2022 15:16:04.2854 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MUUzNUD7Q1BuZBC60TipwYV7dfL+pz/9kLHZBx5d0Ijm8kb9zodKYdAAMU3fSaIOGTtpUsCT6S032iUikZPm0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1561 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Chao, Zhuoran > Sent: Saturday, May 7, 2022 5:40 PM > To: devel@edk2.groups.io > Cc: Chao, Zhuoran ; Ni, Ray > Subject: [PATCH v3] PcAtChipsetPkg: Change the flow of PcRtcInit() >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3913 >=20 > The original flow of PcRtcInit() is like: > 1. Guarantee atomic accesses to the RTC time registers and > read out the value. > 2. Program RTC register B. (adopt 12h mode or 24h mode. Current > bios code sets RTC to 24h mode by default). > 3. Then function ConvertRtcTimeToEfiTime converts the RTC time > value to their 24h mode by checking the hour format bit > (1:24h mode,0:12h mode). > And here lies the problem: Step3 will fail to adjust the value > if Step2 already sets RTC to 24h mode. The hour value in 12h mode > will not be converted to its 24h mode. > The solution is to program RTC register B a little later when all > the original RTC registers' value is retrieved, adjusted > and validated. >=20 > ConvertRtcTimeToEfiTime is modified to be more robust. >=20 > Cc: Ray Ni >=20 > Signed-off-by: Zhuoran Chao > --- > .../PcatRealTimeClockRuntimeDxe/PcRtc.c | 29 ++++++++++--------- > 1 file changed, 16 insertions(+), 13 deletions(-) >=20 > diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChi= psetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c > index 0fbfa4bcee..9242a2e826 100644 > --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c > +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c > @@ -269,13 +269,6 @@ PcRtcInit ( > Time.Month =3D RtcRead (RTC_ADDRESS_MONTH); > Time.Year =3D RtcRead (RTC_ADDRESS_YEAR); >=20 > - // > - // Set RTC configuration after get original time > - // The value of bit AIE should be reserved. > - // > - RegisterB.Data =3D FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (Regis= terB.Data & BIT5); > - RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data); > - > // > // Release RTC Lock. > // > @@ -330,6 +323,13 @@ PcRtcInit ( > Time.Daylight =3D 0; > } >=20 > + // > + // Set RTC configuration after get original time > + // The value of bit AIE should be reserved. > + // > + RegisterB.Data =3D FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (Regis= terB.Data & BIT5); > + RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data); > + > // > // Reset time value according to new RTC configuration > // > @@ -995,13 +995,16 @@ ConvertRtcTimeToEfiTime ( > BOOLEAN IsPM; > UINT8 Century; >=20 > - if ((Time->Hour & 0x80) !=3D 0) { > - IsPM =3D TRUE; > - } else { > - IsPM =3D FALSE; > - } > + // IsPM only makes sense for 12-hour format. > + if (RegisterB.Bits.Mil =3D=3D 0) { > + if ((Time->Hour & 0x80) !=3D 0) { > + IsPM =3D TRUE; > + } else { > + IsPM =3D FALSE; > + } >=20 > - Time->Hour =3D (UINT8)(Time->Hour & 0x7f); > + Time->Hour =3D (UINT8)(Time->Hour & 0x7f); > + } >=20 > if (RegisterB.Bits.Dm =3D=3D 0) { > Time->Year =3D CheckAndConvertBcd8ToDecimal8 ((UINT8)Time->Year); > -- > 2.31.1.windows.1