From: Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>
To: platform-driver-x86@vger.kernel.org
Cc: dvhart@infradead.org, andy@infradead.org,
linux-kernel@vger.kernel.org, rajneesh.bhardwaj@intel.com,
Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>
Subject: [PATCH v2 2/4] platform/x86: intel_telemetry: Fix suspend stats
Date: Tue, 21 Nov 2017 20:06:22 +0530 [thread overview]
Message-ID: <1511274984-6165-3-git-send-email-souvik.k.chakravarty@intel.com> (raw)
In-Reply-To: <1511274984-6165-1-git-send-email-souvik.k.chakravarty@intel.com>
Suspend stats are not reported consistently due to a limitation in the PMC
firmware. This limitation causes a delay in updating the s0ix counters and
residencies in the telemetry log upon s0ix exit. As a consequence, reading
these counters from the suspend-exit notifier may result in zero read.
This patch fixes this issue by cross-verifying the s0ix residencies from
the GCR TELEM registers in case the counters are not incremented in the
telemetry log after suspend.
This fixes https://bugzilla.kernel.org/show_bug.cgi?id=197833
We also remove unnecessary 'static' qualifiers from local variables.
Reported-and-tested-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
Signed-off-by: Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>
---
drivers/platform/x86/intel_telemetry_debugfs.c | 29 ++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
Changes since v1:
* Use pmc_ipc_gcr_readq API to read 64-bits at a time
diff --git a/drivers/platform/x86/intel_telemetry_debugfs.c b/drivers/platform/x86/intel_telemetry_debugfs.c
index 4249e826..d7e90fd 100644
--- a/drivers/platform/x86/intel_telemetry_debugfs.c
+++ b/drivers/platform/x86/intel_telemetry_debugfs.c
@@ -855,9 +855,9 @@ static int pm_suspend_prep_cb(void)
static int pm_suspend_exit_cb(void)
{
struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS];
- static u32 suspend_shlw_ctr_exit, suspend_deep_ctr_exit;
- static u64 suspend_shlw_res_exit, suspend_deep_res_exit;
struct telemetry_debugfs_conf *conf = debugfs_conf;
+ u32 suspend_shlw_ctr_exit, suspend_deep_ctr_exit;
+ u64 suspend_shlw_res_exit, suspend_deep_res_exit;
int ret, index;
if (!suspend_prep_ok)
@@ -890,6 +890,31 @@ static int pm_suspend_exit_cb(void)
goto out;
}
+ /*
+ * Due to some design limitations in the firmware, sometimes the
+ * counters do not get updated by the time we reach here. As a
+ * workaround, we try to see if this was a genuine case of sleep
+ * failure or not by cross-checking from PMC GCR registers directly.
+ */
+ if (suspend_shlw_ctr_exit == suspend_shlw_ctr_temp &&
+ suspend_deep_ctr_exit == suspend_deep_ctr_temp) {
+ ret = intel_pmc_gcr_readq(PMC_GCR_TELEM_SHLW_S0IX_REG,
+ &suspend_shlw_res_exit);
+ if (ret < 0)
+ goto out;
+
+ ret = intel_pmc_gcr_readq(PMC_GCR_TELEM_DEEP_S0IX_REG,
+ &suspend_deep_res_exit);
+ if (ret < 0)
+ goto out;
+
+ if (suspend_shlw_res_exit > suspend_shlw_res_temp)
+ suspend_shlw_ctr_exit++;
+
+ if (suspend_deep_res_exit > suspend_deep_res_temp)
+ suspend_deep_ctr_exit++;
+ }
+
suspend_shlw_ctr_exit -= suspend_shlw_ctr_temp;
suspend_deep_ctr_exit -= suspend_deep_ctr_temp;
suspend_shlw_res_exit -= suspend_shlw_res_temp;
--
2.7.4
next prev parent reply other threads:[~2017-11-21 6:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 14:36 [PATCH v2 0/4] platform/x86: intel_telemetry: Fix logs and formatting Souvik Kumar Chakravarty
2017-11-21 14:36 ` [PATCH v1 1/4] platform/x86: intel_pmc_ipc: Add readq API for GCR Souvik Kumar Chakravarty
2017-11-23 21:17 ` Andy Shevchenko
2017-11-21 14:36 ` Souvik Kumar Chakravarty [this message]
2017-11-22 22:09 ` [PATCH v2 2/4] platform/x86: intel_telemetry: Fix suspend stats kbuild test robot
2017-11-23 21:25 ` Andy Shevchenko
2017-11-24 2:51 ` Chakravarty, Souvik K
2017-11-21 14:36 ` [PATCH v2 3/4] platform/x86: intel_telemetry: Improve S0ix logs Souvik Kumar Chakravarty
2017-11-21 14:36 ` [PATCH v2 4/4] platform/x86: intel_telemetry: Remove redundancies Souvik Kumar Chakravarty
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=1511274984-6165-3-git-send-email-souvik.k.chakravarty@intel.com \
--to=souvik.k.chakravarty@intel.com \
--cc=andy@infradead.org \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rajneesh.bhardwaj@intel.com \
/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®