From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DA97C433B4 for ; Wed, 19 May 2021 09:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B7CC610CC for ; Wed, 19 May 2021 09:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345295AbhESJWq (ORCPT ); Wed, 19 May 2021 05:22:46 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3422 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345147AbhESJWD (ORCPT ); Wed, 19 May 2021 05:22:03 -0400 Received: from dggems702-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FlS2S0wFVzCv61; Wed, 19 May 2021 17:17:52 +0800 (CST) Received: from dggeml751-chm.china.huawei.com (10.1.199.150) by dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 19 May 2021 17:20:38 +0800 Received: from huawei.com (10.44.142.101) by dggeml751-chm.china.huawei.com (10.1.199.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 19 May 2021 17:20:38 +0800 From: Sang Yan To: , , , , , CC: , , , Subject: [PATCH] rtc: Fix hwclock write fail problem in x86 arch Date: Wed, 19 May 2021 17:19:08 +0800 Message-ID: <20210519091908.513593-1-sangyan@huawei.com> X-Mailer: git-send-email 2.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.44.142.101] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeml751-chm.china.huawei.com (10.1.199.150) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jingxian He When RTC_ALWAYS_BCD is set as 1, the function mc146818_set_time ignores the reading value of RTC_CONTROL register, and assumes that RTC always operates in binary mode. However, the mc146818 development manual says that: if !(CMOS_READ(RTC_CONTROL) & 0x04), then the rtc time is in binary mode; if (CMOS_READ(RTC_CONTROL) & 0x04), then the rtc time is in bcd mode. We use 'hwclock -w' to set the RTC from the system time at our x86 machines, and we find that when (CMOS_READ(RTC_CONTROL) & 0x04) is equal to 1, 'hwclock -w' will fail to set the RTC. We change the RTC_ALWAYS_BCD to 0 to parse the rtc time according to the read value of RTC_CONTROL register. Signed-off-by: Jingxian He Signed-off-by: Jie He --- arch/x86/include/asm/mc146818rtc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h index 9719800..63cf0d5 100644 --- a/arch/x86/include/asm/mc146818rtc.h +++ b/arch/x86/include/asm/mc146818rtc.h @@ -10,7 +10,7 @@ #ifndef RTC_PORT #define RTC_PORT(x) (0x70 + (x)) -#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ +#define RTC_ALWAYS_BCD 0 #endif #if defined(CONFIG_X86_32) -- 2.9.5