Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1726889pxj; Wed, 19 May 2021 12:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIv+MekQAQTLJC3CEuvT4gA22DWrkhavkM5kZZAg8zBvgPsxgA5cfucpS8oJ1OdWmPlWxV X-Received: by 2002:a05:6638:3395:: with SMTP id h21mr753300jav.44.1621452376781; Wed, 19 May 2021 12:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621452376; cv=none; d=google.com; s=arc-20160816; b=weHE2TOrIJoNppugQ5rwE4jJEtXcT/p27bE+58bur/JvrY8zhGNRnmu4+WPAAQgJvu oU2en5MuCn2yvwg4QG+bV7cOCo71bZBbmB0cL74Xzhpm/cb+/GyLyxCvFXuu7gq2Yl/l jiFki21yHzokteqALLsjX4EDwvCjQQYbQCt3QCfS+PPMsJzdAzfKmWqnQ0YPc9Mr772O Z8NSGD/fZiCIiExbvf9rLyIY9UGbI3IlvgEMq5cktozoYCGAGemFC6Ho6FQ47+CJQNBQ LueLyZ/szT95YbVui82TYf1csgQTGilp1jFAKBP0tfz+KRDzMGg7SFL6TmpQJXyF31/7 ZwkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=J5Qp40qDicUK9/rWH/OOibdAD+B1/SWmiWGI0ApY8zw=; b=mgEvIDI0ZbQjC0aKNKXMCpuSXQoh65+EwTdhga1mIZ96NK4QHbbKkVzF/Axhq5dITb AGApADm7BAMRBfCv9Qp8mljeo6ebIKpdJjhv9PgClCrZj8XvMbUI0cypGOf2xHRNEtzH 3+/WxWGpXPvWw1tPip9WcIj215QCMZhxe+K74Zhhf5FPapzC00WjmXTKbKwnIobqNFz4 hperlpMhe+K16t9kXi8XTKiX1S3YPYxri490ANmge9eFwtwJot9qQCmwzlulB1EsGGMY pfIp9Rt8M/9Lb3cu613zQoCz0NeJsfPBMqLdJ+bImpSc1L1XgCM/MyG0bEwfwZgphOoM vgcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si512622ilq.112.2021.05.19.12.26.03; Wed, 19 May 2021 12:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345373AbhESJWo (ORCPT + 99 others); Wed, 19 May 2021 05:22:44 -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