From patchwork Thu Dec 19 07:51:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 3375431 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2869BC0D4A for ; Thu, 19 Dec 2013 07:56:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3515820647 for ; Thu, 19 Dec 2013 07:56:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5549A2011F for ; Thu, 19 Dec 2013 07:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753194Ab3LSHzA (ORCPT ); Thu, 19 Dec 2013 02:55:00 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]:38021 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753159Ab3LSHy6 (ORCPT ); Thu, 19 Dec 2013 02:54:58 -0500 Received: by mail-pb0-f49.google.com with SMTP id jt11so802040pbb.8 for ; Wed, 18 Dec 2013 23:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7qIIbSSQtPxr2PBW9rdytsOkX5chfiLAivwMR81jT6g=; b=Y52bexcuIqqXFeL2gGDThPU0l9kEKG/S1wQnNG1Sh+2Ldn+QNt3XeAxsrUaf+2E650 A66jiI6ijocmNdyNEDH6Bocp4JbeQzEFcKX7a0fAhyRKtjyzNchhxKNh55ICRUdoFi3p XNcqr2jgBDfhOFmigDXMi2r/yOiKkGoQfE/4eWREZJJ9PIeEQqMLk2vZdYibv5qML687 wH8O4hAN5/R55YKIQyqFKpdz+mff3ToiYleq2hzpGmocVLD/dQ2cae6MGiQKrCgGMNIl LRIuOg/aAmkRjHO/sv3ZotCb6eP+eYvhVGOuClK3pKH61pXEW6Q37LkeB58HqqueyjmD lxSQ== X-Received: by 10.68.232.196 with SMTP id tq4mr76391pbc.166.1387439697861; Wed, 18 Dec 2013 23:54:57 -0800 (PST) Received: from localhost.localdomain ([130.57.30.250]) by mx.google.com with ESMTPSA id qp15sm5173154pbb.2.2013.12.18.23.54.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 18 Dec 2013 23:54:56 -0800 (PST) From: "Lee, Chun-Yi" To: "Rafael J. Wysocki" , Alessandro Zummo , "H. Peter Anvin" , Matt Fleming , Matthew Garrett Cc: Elliott@hp.com, samer.el-haj-mahmoud@hp.com, Oliver Neukum , werner@suse.com, trenn@suse.de, JBeulich@suse.com, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, x86@kernel.org, "linux-efi@vger.kernel.org" , linux-acpi@vger.kernel.org, "Lee, Chun-Yi" Subject: [RFC PATCH 11/14] rtc: switch to get/set rtc time to efi functions if CMOS RTC Not Present git set. Date: Thu, 19 Dec 2013 15:51:52 +0800 Message-Id: <1387439515-8926-12-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1387439515-8926-1-git-send-email-jlee@suse.com> References: <1387439515-8926-1-git-send-email-jlee@suse.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When CMOS RTC Not Present git set in FADT, system should not access CMOS interface for time. This patch move get/set rtc time function from CMOS to EFI runtime on x86_64 machine. And, it also set the BUG_ON check in rtc_cmos_read/write function to avoid access it. Signed-off-by: Lee, Chun-Yi --- arch/x86/kernel/rtc.c | 8 ++++++++ include/asm-generic/rtc.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 9b6c568..a54cd09 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -117,6 +117,10 @@ unsigned char rtc_cmos_read(unsigned char addr) { unsigned char val; + BUG_ON(acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC && + addr <= RTC_YEAR); + lock_cmos_prefix(addr); outb(addr, RTC_PORT(0)); val = inb(RTC_PORT(1)); @@ -128,6 +132,10 @@ EXPORT_SYMBOL(rtc_cmos_read); void rtc_cmos_write(unsigned char val, unsigned char addr) { + BUG_ON(acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC && + addr <= RTC_YEAR); + lock_cmos_prefix(addr); outb(addr, RTC_PORT(0)); outb(val, RTC_PORT(1)); diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h index fa86f24..4ba8aa6 100644 --- a/include/asm-generic/rtc.h +++ b/include/asm-generic/rtc.h @@ -16,6 +16,8 @@ #include #include #include +#include +#include #define RTC_PIE 0x40 /* periodic interrupt enable */ #define RTC_AIE 0x20 /* alarm interrupt enable */ @@ -51,6 +53,16 @@ static inline unsigned int __get_rtc_time(struct rtc_time *time) unsigned int real_year; #endif + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { +#if defined(CONFIG_EFI) && defined(CONFIG_X86_64) + printk_once(KERN_INFO "efi: get rtc time by EFI\n"); + return efi_read_time(time); +#else + BUG(); +#endif + } + /* * read RTC once any update in progress is done. The update * can take just over 2ms. We wait 20ms. There is no need to @@ -123,6 +135,16 @@ static inline int __set_rtc_time(struct rtc_time *time) unsigned int real_yrs, leap_yr; #endif + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { +#if defined(CONFIG_EFI) && defined(CONFIG_X86_64) + printk_once(KERN_INFO "efi: set rtc time by EFI\n"); + return efi_set_time(time); +#else + BUG(); +#endif + } + yrs = time->tm_year; mon = time->tm_mon + 1; /* tm_mon starts at zero */ day = time->tm_mday;