Skip to contentSkip to conversation

platform/x86/intel/pmc: Disable ACPI PM timer during suspend on Panther Lake

PATCH Superseded Tzung-Bi Shih 2 participants 3 messages Nov 12 – Nov 18

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 platform/x86/intel/pmc: Disable ACPI PM timer during suspend on Panther Lake

The ACPI PM timer is used to drive the ACPI Watchdog Action Table (wdat_wdt) hardware watchdog. When the ACPI PM timer is enabled by firmware on Panther Lake, leaving it running during s2idle prevents the SoC from entering its deepest S0i2.2 substate (staying in S0i2.1).

Since the watchdog is stopped during system suspend, the ACPI PM timer does not need to remain active while suspended. Disable the timer via ACPI_TMR_CTL (PWRMBASE + 0x18fc) in ptl_suspend() and re-enable it in ptl_resume() only if it was active prior to suspend.

Unlike commit e86c8186d03a ("platform/x86:intel/pmc: Enable the ACPI PM Timer to be turned off when suspended"), which was reverted in commit 5fa607880168 because it acquired pmcdev->lock from the acpi_pm clocksource suspend callback inside tick_freeze() atomic context, toggle the register in ptl_suspend() and ptl_resume() without taking pmcdev->lock.

---
v3:
- Rebase to next-20261111.

v2: https://lore.kernel.org/all/[email protected]
- Include <linux/bits.h> for BIT().
- Rename ptl_set_acpi_pm_timer_on_suspend() -> ptl_set_acpi_pm_timer().
- Update register values on separate lines.

v1: https://lore.kernel.org/all/[email protected]

---
 drivers/platform/x86/intel/pmc/core.h |  2 ++
 drivers/platform/x86/intel/pmc/ptl.c  | 40 ++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.h +2 -0
index e55164e5807f..8aae69775ab3 100644
@@ -487,6 +487,7 @@ struct pmc {
  * @s0ix_counter:	S0ix residency (step adjusted)
  * @suspend:		Function to perform platform specific suspend
  * @resume:		Function to perform platform specific resume
+ * @pm_timer_enabled:	Whether the ACPI PM timer was enabled before suspend
  *
  * @pkgc_ltr_blocker_counters: Array of PKGC LTR blocker counters
  * @pkgc_ltr_blocker_offset: Offset to PKGC LTR blockers in telemetry region
@@ -506,6 +507,7 @@ struct pmc_dev {
 	u64 s0ix_counter;
 	void (*suspend)(struct pmc_dev *pmcdev);
 	int (*resume)(struct pmc_dev *pmcdev);
+	bool pm_timer_enabled;
 
 	u64 *pkgc_res_cnt;
 	u8 num_of_pkgc;
drivers/platform/x86/intel/pmc/ptl.c +39 -1
index a7d5d4f77934..3cb063944007 100644
@@ -6,6 +6,8 @@
  * Copyright (c) 2025, Intel Corporation.
  */
 
+#include <linux/bits.h>
+#include <linux/io.h>
 #include <linux/pci.h>
 
 #include "core.h"
@@ -548,6 +550,9 @@ static const u8 ptl_pmc_list[] = {PMC_IDX_MAIN};
 #define PTL_NPU_PCI_DEV                0xb03e
 #define PTL_IPU_PCI_DEV                0xb05d
 
+#define ACPI_TMR_CTL_OFFSET            0x18fc
+#define ACPI_TIM_DIS                   BIT(1)
+
 /*
  * Set power state of select devices that do not have drivers to D3
  * so that they do not block Package C entry.
@@ -558,9 +563,42 @@ static void ptl_d3_fixup(void)
 	pmc_core_set_device_d3(PTL_NPU_PCI_DEV);
 }
 
+static void ptl_set_acpi_pm_timer(struct pmc_dev *pmcdev, bool suspend)
+{
+	struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
+	u8 val, old_val;
+
+	if (!pmc || !pmc->regbase)
+		return;
+
+	if (!suspend && !pmcdev->pm_timer_enabled)
+		return;
+
+	val = readb(pmc->regbase + ACPI_TMR_CTL_OFFSET);
+	old_val = val;
+
+	if (suspend) {
+		pmcdev->pm_timer_enabled = !(old_val & ACPI_TIM_DIS);
+		if (pmcdev->pm_timer_enabled)
+			val |= ACPI_TIM_DIS;
+	} else {
+		val &= ~ACPI_TIM_DIS;
+	}
+
+	if (val != old_val)
+		writeb(val, pmc->regbase + ACPI_TMR_CTL_OFFSET);
+}
+
+static void ptl_suspend(struct pmc_dev *pmcdev)
+{
+	ptl_set_acpi_pm_timer(pmcdev, true);
+	cnl_suspend(pmcdev);
+}
+
 static int ptl_resume(struct pmc_dev *pmcdev)
 {
 	ptl_d3_fixup();
+	ptl_set_acpi_pm_timer(pmcdev, false);
 	return cnl_resume(pmcdev);
 }
 
@@ -576,7 +614,7 @@ struct pmc_dev_info ptl_pmc_dev = {
 	.regmap_list = ptl_pmc_info_list,
 	.map = &ptl_pcdp_reg_map,
 	.sub_req_show = &pmc_core_substate_blk_req_fops,
-	.suspend = cnl_suspend,
+	.suspend = ptl_suspend,
 	.resume = ptl_resume,
 	.init = ptl_core_init,
 	.sub_req = pmc_core_pmt_get_blk_sub_req,
Signature · 1 line
2.56.0.567.gdb80ae8cd5-goog
maintainer
#1 lore raw

Hi Tzung-Bi,

Thanks for the v3. Avoiding  pmcdev->lock  and the tick_freeze()  atomic context resolves the problem behind the revert in 5fa607880168, and the save and restore logic looks correct.

Two requests:

1. Ordering vs. the  acpi_pm  clocksource.
• The reverted code toggled the timer from the clocksource's own callbacks. These run inside  timekeeping_suspend()  after the last read and inside  timekeeping_resume()  before the first read, so the counter is never read while stopped.
• Here the timer is stopped in  suspend_late  and restarted in resume_early . That is before  timekeeping_forward_now()  on suspend and after  tk_clock_read()  on resume.
• If  acpi_pm  is the active clocksource, for example when TSC is unstable, timekeeping can read a stopped counter, and ktime_get()  stops advancing from  suspend_late  on.
• Have you tested with  clocksource=acpi_pm ? If TSC is always used on PTL, please say so in the commit message.
2. Evidence for S0i2.2.
• Please share S0i2.1 and S0i2.2 residency with and without the patch.
• Include the platform, firmware and kernel version, and say whether firmware enabled the timer and  wdat_wdt  was active.

Also, does WCL, which reuses the PTL ops, need the same fix?

Thanks,
Xi

Quoted 128 lines · Tzung-Bi Shih

The ACPI PM timer is used to drive the ACPI Watchdog Action Table (wdat_wdt) hardware watchdog. When the ACPI PM timer is enabled by firmware on Panther Lake, leaving it running during s2idle prevents the SoC from entering its deepest S0i2.2 substate (staying in S0i2.1).

Since the watchdog is stopped during system suspend, the ACPI PM timer does not need to remain active while suspended. Disable the timer via ACPI_TMR_CTL (PWRMBASE + 0x18fc) in ptl_suspend() and re-enable it in ptl_resume() only if it was active prior to suspend.

Unlike commit e86c8186d03a ("platform/x86:intel/pmc: Enable the ACPI PM Timer to be turned off when suspended"), which was reverted in commit 5fa607880168 because it acquired pmcdev->lock from the acpi_pm clocksource suspend callback inside tick_freeze() atomic context, toggle the register in ptl_suspend() and ptl_resume() without taking pmcdev->lock.

---
v3:
- Rebase to next-20261111.

v2: https://lore.kernel.org/all/[email protected]
- Include <linux/bits.h> for BIT().
- Rename ptl_set_acpi_pm_timer_on_suspend() -> ptl_set_acpi_pm_timer().
- Update register values on separate lines.

v1: https://lore.kernel.org/all/[email protected]

---
  drivers/platform/x86/intel/pmc/core.h |  2 ++
  drivers/platform/x86/intel/pmc/ptl.c  | 40 ++++++++++++++++++++++++++-
  2 files changed, 41 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.h +2 -0
index e55164e5807f..8aae69775ab3 100644
@@ -487,6 +487,7 @@ struct pmc {
   * @s0ix_counter:	S0ix residency (step adjusted)
   * @suspend:		Function to perform platform specific suspend
   * @resume:		Function to perform platform specific resume
+ * @pm_timer_enabled:	Whether the ACPI PM timer was enabled before suspend
   *
   * @pkgc_ltr_blocker_counters: Array of PKGC LTR blocker counters
   * @pkgc_ltr_blocker_offset: Offset to PKGC LTR blockers in telemetry region
@@ -506,6 +507,7 @@ struct pmc_dev {
  	u64 s0ix_counter;
  	void (*suspend)(struct pmc_dev *pmcdev);
  	int (*resume)(struct pmc_dev *pmcdev);
+	bool pm_timer_enabled;
 
  	u64 *pkgc_res_cnt;
  	u8 num_of_pkgc;
drivers/platform/x86/intel/pmc/ptl.c +39 -1
index a7d5d4f77934..3cb063944007 100644
@@ -6,6 +6,8 @@
   * Copyright (c) 2025, Intel Corporation.
   */
 
+#include <linux/bits.h>
+#include <linux/io.h>
  #include <linux/pci.h>
 
  #include "core.h"
@@ -548,6 +550,9 @@ static const u8 ptl_pmc_list[] = {PMC_IDX_MAIN};
  #define PTL_NPU_PCI_DEV                0xb03e
  #define PTL_IPU_PCI_DEV                0xb05d
 
+#define ACPI_TMR_CTL_OFFSET            0x18fc
+#define ACPI_TIM_DIS                   BIT(1)
+
  /*
   * Set power state of select devices that do not have drivers to D3
   * so that they do not block Package C entry.
@@ -558,9 +563,42 @@ static void ptl_d3_fixup(void)
  	pmc_core_set_device_d3(PTL_NPU_PCI_DEV);
  }
 
+static void ptl_set_acpi_pm_timer(struct pmc_dev *pmcdev, bool suspend)
+{
+	struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
+	u8 val, old_val;
+
+	if (!pmc || !pmc->regbase)
+		return;
+
+	if (!suspend && !pmcdev->pm_timer_enabled)
+		return;
+
+	val = readb(pmc->regbase + ACPI_TMR_CTL_OFFSET);
+	old_val = val;
+
+	if (suspend) {
+		pmcdev->pm_timer_enabled = !(old_val & ACPI_TIM_DIS);
+		if (pmcdev->pm_timer_enabled)
+			val |= ACPI_TIM_DIS;
+	} else {
+		val &= ~ACPI_TIM_DIS;
+	}
+
+	if (val != old_val)
+		writeb(val, pmc->regbase + ACPI_TMR_CTL_OFFSET);
+}
+
+static void ptl_suspend(struct pmc_dev *pmcdev)
+{
+	ptl_set_acpi_pm_timer(pmcdev, true);
+	cnl_suspend(pmcdev);
+}
+
  static int ptl_resume(struct pmc_dev *pmcdev)
  {
  	ptl_d3_fixup();
+	ptl_set_acpi_pm_timer(pmcdev, false);
  	return cnl_resume(pmcdev);
  }
 
@@ -576,7 +614,7 @@ struct pmc_dev_info ptl_pmc_dev = {
  	.regmap_list = ptl_pmc_info_list,
  	.map = &ptl_pcdp_reg_map,
  	.sub_req_show = &pmc_core_substate_blk_req_fops,
-	.suspend = cnl_suspend,
+	.suspend = ptl_suspend,
  	.resume = ptl_resume,
  	.init = ptl_core_init,
  	.sub_req = pmc_core_pmt_get_blk_sub_req,
#2 lore raw
Quoted 8 lines · Xi Pardee

Hi Tzung-Bi,

Thanks for the v3. Avoiding  pmcdev->lock  and the tick_freeze()  atomic context resolves the problem behind the revert in 5fa607880168, and the save and restore logic looks correct.

Two requests:

Quoted 13 lines

1. Ordering vs. the  acpi_pm  clocksource.
• The reverted code toggled the timer from the clocksource's own callbacks. These run inside  timekeeping_suspend()  after the last read and inside timekeeping_resume()  before the first read, so the counter is never read while stopped.
• Here the timer is stopped in  suspend_late  and restarted in resume_early . That is before  timekeeping_forward_now()  on suspend and after tk_clock_read()  on resume.
• If  acpi_pm  is the active clocksource, for example when TSC is unstable, timekeeping can read a stopped counter, and ktime_get()  stops advancing from  suspend_late  on.
• Have you tested with  clocksource=acpi_pm ? If TSC is always used on PTL, please say so in the commit message.

Good catch. I haven't tested with clocksource=acpi_pm since our test kernel has CONFIG_X86_PM_TIMER=n and uses TSC.

To preserve proper ordering when CONFIG_X86_PM_TIMER=y, in v4 I will move the lockless toggle helper into pmc_core and register it via acpi_pmtmr_register_suspend_resume_callback() when CONFIG_X86_PM_TIMER=y (falling back to pmc_core_suspend()/pmc_core_resume() when disabled).

I will send out v4 after re-running the s2idle test with the updated patches.

Quoted 4 lines

2. Evidence for S0i2.2.
• Please share S0i2.1 and S0i2.2 residency with and without the patch.
• Include the platform, firmware and kernel version, and say whether firmware enabled the timer and  wdat_wdt  was active.

Here are the current results from v3 on a Panther Lake Android desktop device (coreboot with CONFIG_USE_PM_ACPI_TIMER=y, kernel 6.18 with CONFIG_X86_PM_TIMER=n, wdat_wdt not active):

- Without patch:

    S0i2.1: 100.00% (345,477 ms), S0i2.2: 0.00% (0 ms)
- With patch:
    S0i2.1: 0.00% (11 ms), S0i2.2: 100.00% (338,628 ms)

I will include the residency results in the v4 commit message as well.

Quoted 2 lines

Also, does WCL, which reuses the PTL ops, need the same fix?

I'm not sure whether WCL has the same behavior, and I don't have WCL hardware to verify it. In v4, I'll move the support into pmc_core via opt-in fields in struct pmc_reg_map and enable it for Panther Lake, so WCL (or other platforms) can easily opt in if needed.