platform/x86/intel/pmc: Disable ACPI PM timer during suspend on Panther Lake
Subsystems (2)
PATCH 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.
--- drivers/platform/x86/intel/pmc/core.h | 2 ++ drivers/platform/x86/intel/pmc/ptl.c | 35 ++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.h +2 -0
@@ -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 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 +34 -1
@@ -6,6 +6,7 @@* Copyright (c) 2025, Intel Corporation. */ +#include <linux/io.h> #include <linux/pci.h> #include "core.h"
@@ -548,6 +549,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 +562,38 @@ static void ptl_d3_fixup(void)pmc_core_set_device_d3 (PTL_NPU_PCI_DEV ); } +static void ptl_set_acpi_pm_timer_on_suspend (struct pmc_dev *pmcdev,bool suspend) +{ +struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN ]; +bool enabled; +u8 val; + +if (!pmc || !pmc->regbase) +return ; + +if (!suspend && !pmcdev->pm_timer_enabled) +return ; + + val =readb (pmc->regbase +ACPI_TMR_CTL_OFFSET ); + enabled = !(val &ACPI_TIM_DIS ); +if (suspend && enabled) +writeb (val |ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET ); +else if (!suspend) +writeb (val & ~ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET ); + + pmcdev->pm_timer_enabled = suspend && enabled; +} + +static void ptl_suspend (struct pmc_dev *pmcdev) +{ +ptl_set_acpi_pm_timer_on_suspend (pmcdev, true); +cnl_suspend (pmcdev); +} +static int ptl_resume (struct pmc_dev *pmcdev) {ptl_d3_fixup (); +ptl_set_acpi_pm_timer_on_suspend (pmcdev, false);return cnl_resume (pmcdev); }
@@ -576,7 +609,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.385.gd3acb90ef8-goog
Ilpo Järvinen
maintainerQuoted 56 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) inptl_suspend()and re-enable it inptl_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 commit5fa607880168because it acquiredpmcdev->lockfrom theacpi_pmclocksource suspend callback insidetick_freeze()atomic context, toggle the register inptl_suspend()andptl_resume()without takingpmcdev->lock.Signed-off-by Tzung-Bi Shih <[email protected]>--- drivers/platform/x86/intel/pmc/core.h | 2 ++ drivers/platform/x86/intel/pmc/ptl.c | 35 ++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-)drivers/platform/x86/intel/pmc/core.h +2
-0@@ -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 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 +1
-0@@ -6,6 +6,7 @@* Copyright (c) 2025, Intel Corporation. */ +#include <linux/io.h> #include <linux/pci.h> #include "core.h"
drivers/platform/x86/intel/pmc/ptl.c static const u8 ptl_pmc_list[] = {PMC_IDX_MAIN}; · line 553
Quoted 5 lines
drivers/platform/x86/intel/pmc/ptl.c +2
-0@@ -548,6 +549,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)
Please add include for this as well.
Quoted 16 lines
drivers/platform/x86/intel/pmc/ptl.c +9
-0+/* * Set power state of select devices that do not have drivers to D3 * so that they do not block Package C entry. @@ -558,9 +562,38 @@ static void ptl_d3_fixup(void)pmc_core_set_device_d3 (PTL_NPU_PCI_DEV ); } +static void ptl_set_acpi_pm_timer_on_suspend (struct pmc_dev *pmcdev,bool suspend) +{ +struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN ]; +bool enabled; +u8 val; + +if (!pmc || !pmc->regbase) +return ;
drivers/platform/x86/intel/pmc/ptl.c static void ptl_d3_fixup(void) · line 582
Quoted 10 lines
drivers/platform/x86/intel/pmc/ptl.c +10
-0+ +if (!suspend && !pmcdev->pm_timer_enabled) +return ; + + val =readb (pmc->regbase +ACPI_TMR_CTL_OFFSET ); + enabled = !(val &ACPI_TIM_DIS ); +if (suspend && enabled) +writeb (val |ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET ); +else if (!suspend) +writeb (val & ~ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET );
Change val on a separate line for clarity.
How about using this alternative:
old_val = val; if (...) val |= ACPI_TIM_DIS; else if (...) val &= ~ACPI_TIM_DIS; if (val != old_val) writeb(...);
?
Quoted 27 lines
drivers/platform/x86/intel/pmc/ptl.c +12
-1+ + pmcdev->pm_timer_enabled = suspend && enabled; +} + +static void ptl_suspend (struct pmc_dev *pmcdev) +{ +ptl_set_acpi_pm_timer_on_suspend (pmcdev, true); +cnl_suspend (pmcdev); +} +static int ptl_resume (struct pmc_dev *pmcdev) {ptl_d3_fixup (); +ptl_set_acpi_pm_timer_on_suspend (pmcdev, false);return cnl_resume (pmcdev); }@@ -576,7 +609,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
i.
Quoted 16 lines · Ilpo Järvinen
Quoted 16 lines
drivers/platform/x86/intel/pmc/ptl.c +1
-0@@ -6,6 +6,7 @@* Copyright (c) 2025, Intel Corporation. */ +#include <linux/io.h> #include <linux/pci.h> #include "core.h" @@ -548,6 +549,9 @@ static const u8 ptl_pmc_list[] = {PMC_IDX_MAIN};#define PTL_NPU_PCI_DEV 0xb03e#define PTL_IPU_PCI_DEV 0xb05d
Quoted 4 lines
drivers/platform/x86/intel/pmc/ptl.c static const u8 ptl_pmc_list[] = {PMC_IDX_MAIN}; · line 553
Quoted 2 lines
drivers/platform/x86/intel/pmc/ptl.c +2
-0+#define ACPI_TMR_CTL_OFFSET 0x18fc +#define ACPI_TIM_DIS BIT(1)Please add include for this as well.
Ack, fixed in v2.
Quoted 23 lines
Quoted 8 lines
drivers/platform/x86/intel/pmc/ptl.c +8
-0+static void ptl_set_acpi_pm_timer_on_suspend (struct pmc_dev *pmcdev,bool suspend) +{ +struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN ]; +bool enabled; +u8 val; + +if (!pmc || !pmc->regbase) +return ;drivers/platform/x86/intel/pmc/ptl.c static void ptl_d3_fixup(void) · line 582
Quoted 10 lines
drivers/platform/x86/intel/pmc/ptl.c +10
-0+ +if (!suspend && !pmcdev->pm_timer_enabled) +return ; + + val =readb (pmc->regbase +ACPI_TMR_CTL_OFFSET ); + enabled = !(val &ACPI_TIM_DIS ); +if (suspend && enabled) +writeb (val |ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET ); +else if (!suspend) +writeb (val & ~ACPI_TIM_DIS , pmc->regbase +ACPI_TMR_CTL_OFFSET );Change val on a separate line for clarity.
How about using this alternative:
Quoted 7 lines
old_val = val; if (...) val |= ACPI_TIM_DIS; else if (...) val &= ~ACPI_TIM_DIS; if (val != old_val) writeb(...);
Ack, tried something similar in v2.