From: Zhang Rui <rui.zhang@intel.com>
To: linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org
Cc: rjw@rjwysocki.net, alexandre.belloni@free-electrons.com,
gabriele.mzt@gmail.com, rui.zhang@intel.com
Subject: [PATCH 3/3] rtc: cmos: introduce quirks to enable use_acpi_alarm mode
Date: Mon, 26 Mar 2018 21:58:03 +0800 [thread overview]
Message-ID: <1522072683-3968-3-git-send-email-rui.zhang@intel.com> (raw)
In-Reply-To: <1522072683-3968-1-git-send-email-rui.zhang@intel.com>
Use ACPI for RTC Alarm only for Intel platforms
1. with Low Power S0 support
2. with HPET RTC emulation enabled
3. no earlier than 2015
Note that, during the test, it is found that this patch
1. works in 4.15-rc kernel
2. hangs the platform after suspend-to-idle for 2 or 3 times, in 4.15.0
3. works again in 4.16-rc3 kernel.
4. works in the latest 4.15.12 stable kernel.
Thus although this patch breaks 4.15.0 kernel for some unknown reason,
still, it is safe for both upstream and backport.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/rtc/rtc-cmos.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index bcf86e1..75c4bdc 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -43,6 +43,8 @@
#include <linux/of_platform.h>
#ifdef CONFIG_X86
#include <asm/i8259.h>
+#include <asm/processor.h>
+#include <linux/dmi.h>
#endif
/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
@@ -1183,6 +1185,28 @@ static void rtc_wake_off(struct device *dev)
acpi_disable_event(ACPI_EVENT_RTC, 0);
}
+#ifdef CONFIG_X86
+/* Enable use_acpi_alarm mode for Intel platforms no earlier than 2015 */
+static void use_acpi_alarm_quirks(void)
+{
+ int year;
+
+ if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
+ return;
+
+ if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
+ return;
+
+ if (!is_hpet_enabled())
+ return;
+
+ if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year >= 2015)
+ use_acpi_alarm = true;
+}
+#else
+static inline void use_acpi_alarm_quirks(void) { }
+#endif
+
/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
* its device node and pass extra config data. This helps its driver use
* capabilities that the now-obsolete mc146818 didn't have, and informs it
@@ -1195,6 +1219,8 @@ static void cmos_wake_setup(struct device *dev)
if (acpi_disabled)
return;
+ use_acpi_alarm_quirks();
+
rtc_wake_setup(dev);
acpi_rtc_info.wake_on = rtc_wake_on;
acpi_rtc_info.wake_off = rtc_wake_off;
--
2.7.4
next prev parent reply other threads:[~2018-03-26 13:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 13:58 [PATCH 1/3] rtc: cmos: allow using ACPI for RTC alarm instead of HPET Zhang Rui
2018-03-26 13:58 ` [PATCH 2/3] rtc: cmos: acknowledge ACPI driven wake alarms upon resume Zhang Rui
2018-03-26 13:58 ` Zhang Rui [this message]
2018-04-19 14:05 ` [PATCH 1/3] rtc: cmos: allow using ACPI for RTC alarm instead of HPET Alexandre Belloni
2018-04-20 5:59 ` Zhang Rui
2018-04-20 6:46 ` Alexandre Belloni
2018-04-24 13:15 ` Zhang Rui
2018-04-24 13:30 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522072683-3968-3-git-send-email-rui.zhang@intel.com \
--to=rui.zhang@intel.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=gabriele.mzt@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).