From: Derek Basehore <dbasehore@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>,
x86@kernel.org, platform-driver-x86@vger.kernel.org,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org, Derek Basehore <dbasehore@chromium.org>
Subject: [PATCH v5 3/5] x86, apic: Add freeze event support
Date: Fri, 7 Jul 2017 17:03:01 -0700 [thread overview]
Message-ID: <20170708000303.21863-3-dbasehore@chromium.org> (raw)
In-Reply-To: <20170708000303.21863-1-dbasehore@chromium.org>
This adds support to the clock event devices created by apic to use
freeze events. The apic is able to run a timer during freeze with near
zero power impact on modern CPUs such as skylake. This will allow
S0ix, suspend-to-idle, to be validated on Intel CPUs that support it.
This is needed because bugs with power settings on the SoC can prevent
S0ix entry. There is also no way to check this before idling all of
the CPUs.
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
---
arch/x86/kernel/apic/apic.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 98b3dd8cf2bf..adc69d2f11ce 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -480,6 +480,26 @@ static int lapic_next_deadline(unsigned long delta,
return 0;
}
+static int lapic_event_expired(struct clock_event_device *evt)
+{
+ u32 cct;
+
+ cct = apic_read(APIC_TMCCT);
+ return cct == 0 ? 1 : 0;
+}
+
+static int lapic_deadline_expired(struct clock_event_device *evt)
+{
+ u64 msr;
+
+ /*
+ * When the timer interrupt is triggered, the register is cleared, so a
+ * non-zero value indicates a pending timer event.
+ */
+ rdmsrl(MSR_IA32_TSC_DEADLINE, msr);
+ return msr == 0 ? 1 : 0;
+}
+
static int lapic_timer_shutdown(struct clock_event_device *evt)
{
unsigned int v;
@@ -534,7 +554,8 @@ static struct clock_event_device lapic_clockevent = {
.name = "lapic",
.features = CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
- | CLOCK_EVT_FEAT_DUMMY,
+ | CLOCK_EVT_FEAT_DUMMY
+ | CLOCK_EVT_FEAT_FREEZE_NONSTOP,
.shift = 32,
.set_state_shutdown = lapic_timer_shutdown,
.set_state_periodic = lapic_timer_set_periodic,
@@ -644,6 +665,7 @@ static void setup_APIC_timer(void)
levt->features &= ~(CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_DUMMY);
levt->set_next_event = lapic_next_deadline;
+ levt->event_expired = lapic_deadline_expired;
clockevents_config_and_register(levt,
tsc_khz * (1000 / TSC_DIVISOR),
0xF, ~0UL);
--
2.13.2.725.g09c95d1e9-goog
next prev parent reply other threads:[~2017-07-08 0:03 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 0:02 [PATCH v5 1/5] x86: stub out pmc function Derek Basehore
2017-07-08 0:03 ` [PATCH v5 2/5] tick: Add freeze timer events Derek Basehore
2017-07-08 16:05 ` Andy Shevchenko
2017-07-10 21:11 ` dbasehore .
2017-07-10 12:53 ` Rafael J. Wysocki
2017-07-12 21:25 ` Thomas Gleixner
2017-07-13 1:18 ` dbasehore .
2017-07-13 4:54 ` Thomas Gleixner
2017-07-13 7:32 ` Peter Zijlstra
2017-07-13 15:09 ` Rafael J. Wysocki
2017-07-13 22:58 ` dbasehore .
2017-07-15 12:39 ` Rafael J. Wysocki
2017-07-18 0:30 ` dbasehore .
2017-07-18 1:33 ` Rafael J. Wysocki
2017-07-18 3:52 ` dbasehore .
2017-07-18 6:40 ` Thomas Gleixner
2017-07-18 20:09 ` dbasehore .
2017-07-18 21:53 ` Thomas Gleixner
2017-07-18 22:03 ` dbasehore .
2017-07-18 22:22 ` Thomas Gleixner
2017-07-18 22:37 ` dbasehore .
2017-07-18 22:39 ` Thomas Gleixner
2017-07-08 0:03 ` Derek Basehore [this message]
2017-07-13 5:13 ` [PATCH v5 3/5] x86, apic: Add freeze event support Thomas Gleixner
2017-07-08 0:03 ` [PATCH v5 4/5] freeze: Add error reporting Derek Basehore
2017-07-08 0:03 ` [PATCH v5 5/5] intel_idle: Add S0ix validation Derek Basehore
2017-07-09 7:13 ` kbuild test robot
2017-07-10 13:33 ` Rafael J. Wysocki
2017-07-10 21:57 ` dbasehore .
2017-07-10 22:09 ` Rafael J. Wysocki
2017-07-10 22:24 ` dbasehore .
2017-07-11 14:57 ` Rafael J. Wysocki
2017-07-11 15:43 ` Len Brown
2017-07-12 22:16 ` Thomas Gleixner
2017-07-12 23:14 ` dbasehore .
2017-07-13 5:11 ` Thomas Gleixner
2017-07-13 22:49 ` dbasehore .
2017-07-13 1:06 ` dbasehore .
2017-07-08 16:00 ` [PATCH v5 1/5] x86: stub out pmc function Andy Shevchenko
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=20170708000303.21863-3-dbasehore@chromium.org \
--to=dbasehore@chromium.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rajneesh.bhardwaj@intel.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®