Skip to content

Commit cedf233

Browse files
xpardee-createjwrdegoede
authored andcommitted
platform/x86: intel/pmc: Ignore all LTRs during suspend
Add support to ignore all LTRs before suspend and restore the previous LTR values after suspend. This feature could be turned off with module parameter ltr_ignore_all_suspend. LTR value is a mechanism for a device to indicate tolerance to access the corresponding resource. When system suspends, the resource is not available and therefore the LTR value could be ignored. Ignoring all LTR values prevents problematic device from blocking the system to get to the deepest package state during suspend. Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Xi Pardee <xi.pardee@intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240906184016.268153-1-xi.pardee@linux.intel.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent f5dd17e commit cedf233

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

drivers/platform/x86/intel/pmc/core.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,49 @@ static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused)
714714
}
715715
DEFINE_SHOW_ATTRIBUTE(pmc_core_s0ix_blocker);
716716

717+
static void pmc_core_ltr_ignore_all(struct pmc_dev *pmcdev)
718+
{
719+
unsigned int i;
720+
721+
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); i++) {
722+
struct pmc *pmc;
723+
u32 ltr_ign;
724+
725+
pmc = pmcdev->pmcs[i];
726+
if (!pmc)
727+
continue;
728+
729+
guard(mutex)(&pmcdev->lock);
730+
pmc->ltr_ign = pmc_core_reg_read(pmc, pmc->map->ltr_ignore_offset);
731+
732+
/* ltr_ignore_max is the max index value for LTR ignore register */
733+
ltr_ign = pmc->ltr_ign | GENMASK(pmc->map->ltr_ignore_max, 0);
734+
pmc_core_reg_write(pmc, pmc->map->ltr_ignore_offset, ltr_ign);
735+
}
736+
737+
/*
738+
* Ignoring ME during suspend is blocking platforms with ADL PCH to get to
739+
* deeper S0ix substate.
740+
*/
741+
pmc_core_send_ltr_ignore(pmcdev, 6, 0);
742+
}
743+
744+
static void pmc_core_ltr_restore_all(struct pmc_dev *pmcdev)
745+
{
746+
unsigned int i;
747+
748+
for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); i++) {
749+
struct pmc *pmc;
750+
751+
pmc = pmcdev->pmcs[i];
752+
if (!pmc)
753+
continue;
754+
755+
guard(mutex)(&pmcdev->lock);
756+
pmc_core_reg_write(pmc, pmc->map->ltr_ignore_offset, pmc->ltr_ign);
757+
}
758+
}
759+
717760
static inline u64 adjust_lpm_residency(struct pmc *pmc, u32 offset,
718761
const int lpm_adj_x2)
719762
{
@@ -1485,6 +1528,10 @@ static bool warn_on_s0ix_failures;
14851528
module_param(warn_on_s0ix_failures, bool, 0644);
14861529
MODULE_PARM_DESC(warn_on_s0ix_failures, "Check and warn for S0ix failures");
14871530

1531+
static bool ltr_ignore_all_suspend = true;
1532+
module_param(ltr_ignore_all_suspend, bool, 0644);
1533+
MODULE_PARM_DESC(ltr_ignore_all_suspend, "Ignore all LTRs during suspend");
1534+
14881535
static __maybe_unused int pmc_core_suspend(struct device *dev)
14891536
{
14901537
struct pmc_dev *pmcdev = dev_get_drvdata(dev);
@@ -1494,6 +1541,9 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)
14941541
if (pmcdev->suspend)
14951542
pmcdev->suspend(pmcdev);
14961543

1544+
if (ltr_ignore_all_suspend)
1545+
pmc_core_ltr_ignore_all(pmcdev);
1546+
14971547
/* Check if the syspend will actually use S0ix */
14981548
if (pm_suspend_via_firmware())
14991549
return 0;
@@ -1600,6 +1650,9 @@ static __maybe_unused int pmc_core_resume(struct device *dev)
16001650
{
16011651
struct pmc_dev *pmcdev = dev_get_drvdata(dev);
16021652

1653+
if (ltr_ignore_all_suspend)
1654+
pmc_core_ltr_restore_all(pmcdev);
1655+
16031656
if (pmcdev->resume)
16041657
return pmcdev->resume(pmcdev);
16051658

drivers/platform/x86/intel/pmc/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ struct pmc_info {
372372
* @map: pointer to pmc_reg_map struct that contains platform
373373
* specific attributes
374374
* @lpm_req_regs: List of substate requirements
375+
* @ltr_ign: Holds LTR ignore data while suspended
375376
*
376377
* pmc contains info about one power management controller device.
377378
*/
@@ -380,6 +381,7 @@ struct pmc {
380381
void __iomem *regbase;
381382
const struct pmc_reg_map *map;
382383
u32 *lpm_req_regs;
384+
u32 ltr_ign;
383385
};
384386

385387
/**

0 commit comments

Comments
 (0)