From: HyeongJun An <sammiee5311@gmail.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Hans de Goede <hansg@kernel.org>,
Rajneesh Bhardwaj <irenic.rajneesh@gmail.com>,
"David E . Box" <david.e.box@linux.intel.com>,
Xi Pardee <xi.pardee@linux.intel.com>,
Mario Limonciello <mario.limonciello@amd.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
HyeongJun An <sammiee5311@gmail.com>
Subject: [PATCH] platform/x86/intel/pmc: Don't truncate HW sleep time to 32 bits
Date: Tue, 17 Nov 2026 10:29:06 +0900 [thread overview]
Message-ID: <20261117012906.1637402-1-sammiee5311@gmail.com> (raw)
The pmc_core_is_s0ix_failed() casts the S0ix residency delta to u32
before it calls pm_report_hw_sleep_time(). The delta is already in
microseconds, so any suspend longer than 71.6 minutes is reported
modulo 2^32 us. But the limit set by pm_report_max_hw_sleep() is 2^32
counter ticks, which is 145.6 hours with the 122 us step.
On a Tiger Lake laptop, one suspend raised the LPIT S0ix residency by
22559 s, but last_hw_sleep reads 1085 s. The LPIT value modulo 2^32 us
is 1084 s.
The cast also hid a wrap of the 32-bit counter during a suspend.
Without it, the u64 difference of the scaled values becomes huge.
To fix this, drop the cast and add one counter period when the
counter wrapped.
Fixes: ddd66d634735 ("platform/x86/intel/pmc: core: Report duration of time in HW sleep state")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
Prepared with Claude Code (Claude Opus 5.5). Tested on x86_64 (Dell
Latitude 9420, Tiger Lake). After a 13.1 h suspend, last_hw_sleep reads
47063.5 s and the LPIT S0ix residency 47061.9 s. The counter wrap path
was only checked in a simulation.
drivers/platform/x86/intel/pmc/core.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
index 71be313bdf0e..0190160a4c0b 100644
--- a/drivers/platform/x86/intel/pmc/core.c
+++ b/drivers/platform/x86/intel/pmc/core.c
@@ -2052,12 +2052,17 @@ static inline bool pmc_core_is_deepest_pkgc_failed(struct pmc_dev *pmcdev)
static inline bool pmc_core_is_s0ix_failed(struct pmc_dev *pmcdev)
{
- u64 s0ix_counter;
+ struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
+ u64 s0ix_counter, hw_sleep;
- if (pmc_core_dev_state_get(pmcdev->pmcs[PMC_IDX_MAIN], &s0ix_counter))
+ if (pmc_core_dev_state_get(pmc, &s0ix_counter))
return false;
- pm_report_hw_sleep_time((u32)(s0ix_counter - pmcdev->s0ix_counter));
+ /* The 32-bit residency counter can wrap during a long suspend */
+ hw_sleep = s0ix_counter - pmcdev->s0ix_counter;
+ if (s0ix_counter < pmcdev->s0ix_counter)
+ hw_sleep += pmc_core_adjust_slp_s0_step(pmc, 1) << 32;
+ pm_report_hw_sleep_time(hw_sleep);
if (s0ix_counter == pmcdev->s0ix_counter)
return true;
--
2.43.0
reply other threads:[~2026-11-17 1:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261117012906.1637402-1-sammiee5311@gmail.com \
--to=sammiee5311@gmail.com \
--cc=david.e.box@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=irenic.rajneesh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=xi.pardee@linux.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®