platform/x86:intel/pmc: Ignore all LTRs during suspend
Subsystems (2)
Xi Pardee
maintainerPATCH 1/1 platform/x86:intel/pmc: Ignore all LTRs during suspend
From: Xi Pardee <[email protected]>
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.
--- drivers/platform/x86/intel/pmc/core.c | 53 +++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 2 + 2 files changed, 55 insertions(+)
drivers/platform/x86/intel/pmc/core.c +53 -0
@@ -714,6 +714,49 @@ static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) }DEFINE_SHOW_ATTRIBUTE (pmc_core_s0ix_blocker); +static void pmc_core_ltr_ignore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc; +u32 ltr_ign; + + pmc = pmcdev->pmcs[i]; +if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); + pmc->ltr_ign =pmc_core_reg_read (pmc, pmc->map->ltr_ignore_offset); + +/* ltr_ignore_max is the max index value for ltr ignore register */ + ltr_ign = pmc->ltr_ign |GENMASK (pmc->map->ltr_ignore_max,0 ); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, ltr_ign); + } + +/* +* Ignoring ME during suspend is blocking platforms with ADL PCH to get to +* deeper S0IX substate. +*/ +pmc_core_send_ltr_ignore (pmcdev,6 ,0 ); +} + +static void pmc_core_ltr_restore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc; + + pmc = pmcdev->pmcs[i]; +if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, pmc->ltr_ign); + } +} +static inline u64 adjust_lpm_residency (struct pmc *pmc,u32 offset,const int lpm_adj_x2) {
@@ -1479,6 +1522,10 @@ static bool warn_on_s0ix_failures;module_param (warn_on_s0ix_failures, bool,0644 );MODULE_PARM_DESC (warn_on_s0ix_failures,"Check and warn for S0ix failures" ); +static bool ltr_ignore_all_suspend = true; +module_param (ltr_ignore_all_suspend, bool,0644 ); +MODULE_PARM_DESC (ltr_ignore_all_suspend,"Ignore all LTRs during suspend" ); +static __maybe_unused int pmc_core_suspend (struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev);
@@ -1488,6 +1535,9 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)if (pmcdev->suspend) pmcdev->suspend (pmcdev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_ignore_all (pmcdev); +/* Check if the syspend will actually use S0ix */ if (pm_suspend_via_firmware ())return 0 ;
@@ -1594,6 +1644,9 @@ static __maybe_unused int pmc_core_resume(struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_restore_all (pmcdev); +if (pmcdev->resume)return pmcdev->resume (pmcdev);
drivers/platform/x86/intel/pmc/core.h +2 -0
@@ -372,6 +372,7 @@ struct pmc_info {* @map: pointer to pmc_reg_map struct that contains platform * specific attributes * @lpm_req_regs: List of substate requirements +* @ltr_ign: Holds LTR ignore data while suspended * * pmc contains info about one power management controller device. */
@@ -380,6 +381,7 @@ struct pmc {void __iomem *regbase;const struct pmc_reg_map *map;u32 *lpm_req_regs; +u32 ltr_ign; };/**
Signature · 1 line
2.43.0
Ilpo Järvinen
maintainerQuoted 5 lines · Xi Pardee
From: Xi Pardee <[email protected]>
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.
This does not answer why? question.
Quoted 1 line
Suggested-by Rafael J. Wysocki<[email protected]>
Please add a space between the name and email.
This patch seems to have fallen through cracks and did not appear in the patchwork at all.
Quoted 20 lines
Signed-off-by Xi Pardee <[email protected]>--- drivers/platform/x86/intel/pmc/core.c | 53 +++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 2 + 2 files changed, 55 insertions(+)drivers/platform/x86/intel/pmc/core.c +6
-0@@ -714,6 +714,49 @@ static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) }DEFINE_SHOW_ATTRIBUTE (pmc_core_s0ix_blocker); +static void pmc_core_ltr_ignore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc;
drivers/platform/x86/intel/pmc/core.c static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) · line 732
Quoted 10 lines
drivers/platform/x86/intel/pmc/core.c +10
-0+u32 ltr_ign; + + pmc = pmcdev->pmcs[i]; +if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); + pmc->ltr_ign =pmc_core_reg_read (pmc, pmc->map->ltr_ignore_offset); + +/* ltr_ignore_max is the max index value for ltr ignore register */
ltr -> LTR
drivers/platform/x86/intel/pmc/core.c static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) · line 739
Quoted 7 lines
drivers/platform/x86/intel/pmc/core.c +7
-0+ ltr_ign = pmc->ltr_ign |GENMASK (pmc->map->ltr_ignore_max,0 ); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, ltr_ign); + } + +/* +* Ignoring ME during suspend is blocking platforms with ADL PCH to get to +* deeper S0IX substate.
S0ix
--
i.
Quoted 75 lines
drivers/platform/x86/intel/pmc/core.c +30
-0+*/ +pmc_core_send_ltr_ignore (pmcdev,6 ,0 ); +} + +static void pmc_core_ltr_restore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc; + + pmc = pmcdev->pmcs[i]; +if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, pmc->ltr_ign); + } +} +static inline u64 adjust_lpm_residency (struct pmc *pmc,u32 offset,const int lpm_adj_x2) {@@ -1479,6 +1522,10 @@ static bool warn_on_s0ix_failures;module_param (warn_on_s0ix_failures, bool,0644 );MODULE_PARM_DESC (warn_on_s0ix_failures,"Check and warn for S0ix failures" ); +static bool ltr_ignore_all_suspend = true; +module_param (ltr_ignore_all_suspend, bool,0644 ); +MODULE_PARM_DESC (ltr_ignore_all_suspend,"Ignore all LTRs during suspend" ); +static __maybe_unused int pmc_core_suspend (struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev);@@ -1488,6 +1535,9 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)if (pmcdev->suspend) pmcdev->suspend (pmcdev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_ignore_all (pmcdev); +/* Check if the syspend will actually use S0ix */ if (pm_suspend_via_firmware ())return 0 ;@@ -1594,6 +1644,9 @@ static __maybe_unused int pmc_core_resume(struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_restore_all (pmcdev); +if (pmcdev->resume)return pmcdev->resume (pmcdev);drivers/platform/x86/intel/pmc/core.h +2
-0@@ -372,6 +372,7 @@ struct pmc_info {* @map: pointer to pmc_reg_map struct that contains platform * specific attributes * @lpm_req_regs: List of substate requirements +* @ltr_ign: Holds LTR ignore data while suspended * * pmc contains info about one power management controller device. */ @@ -380,6 +381,7 @@ struct pmc {void __iomem *regbase;const struct pmc_reg_map *map;u32 *lpm_req_regs; +u32 ltr_ign; };/**
Xi Pardee
maintainerHi,
Quoted 8 lines · Ilpo Järvinen
Quoted 5 lines · Xi Pardee
From: Xi Pardee <[email protected]>
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.This does not answer why? question.
I will add the reason to commit message in next version.
Quoted 6 lines
Quoted 2 lines
Suggested-by Rafael J. Wysocki<[email protected]>Please add a space between the name and email.
This patch seems to have fallen through cracks and did not appear in the patchwork at all.
Will add a space between the name and email.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Xi Pardee <[email protected]>--- drivers/platform/x86/intel/pmc/core.c | 53 +++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 2 + 2 files changed, 55 insertions(+)drivers/platform/x86/intel/pmc/core.c +9
-0@@ -714,6 +714,49 @@ static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) }DEFINE_SHOW_ATTRIBUTE (pmc_core_s0ix_blocker); +static void pmc_core_ltr_ignore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc; +u32 ltr_ign; + + pmc = pmcdev->pmcs[i];
Quoted 8 lines
drivers/platform/x86/intel/pmc/core.c static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) · line 732
Quoted 7 lines
drivers/platform/x86/intel/pmc/core.c +7
-0+if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); + pmc->ltr_ign =pmc_core_reg_read (pmc, pmc->map->ltr_ignore_offset); + +/* ltr_ignore_max is the max index value for ltr ignore register */ ltr -> LTR
Will change it in next version.
Quoted 10 lines
drivers/platform/x86/intel/pmc/core.c static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused) · line 739
Quoted 8 lines
drivers/platform/x86/intel/pmc/core.c +7
-0+ ltr_ign = pmc->ltr_ign |GENMASK (pmc->map->ltr_ignore_max,0 ); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, ltr_ign); + } + +/* +* Ignoring ME during suspend is blocking platforms with ADL PCH to get to +* deeper S0IX substate. S0ix
Quoted 2 lines
--
i.
Will change it in next version.
Thanks!
Xi
Quoted 76 lines
Quoted 76 lines
drivers/platform/x86/intel/pmc/core.c +30
-0+*/ +pmc_core_send_ltr_ignore (pmcdev,6 ,0 ); +} + +static void pmc_core_ltr_restore_all (struct pmc_dev *pmcdev) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (pmcdev->pmcs); i++) { +struct pmc *pmc; + + pmc = pmcdev->pmcs[i]; +if (!pmc) +continue ; + +guard (mutex)(&pmcdev->lock); +pmc_core_reg_write (pmc, pmc->map->ltr_ignore_offset, pmc->ltr_ign); + } +} +static inline u64 adjust_lpm_residency (struct pmc *pmc,u32 offset,const int lpm_adj_x2) {@@ -1479,6 +1522,10 @@ static bool warn_on_s0ix_failures;module_param (warn_on_s0ix_failures, bool,0644 );MODULE_PARM_DESC (warn_on_s0ix_failures,"Check and warn for S0ix failures" ); +static bool ltr_ignore_all_suspend = true; +module_param (ltr_ignore_all_suspend, bool,0644 ); +MODULE_PARM_DESC (ltr_ignore_all_suspend,"Ignore all LTRs during suspend" ); +static __maybe_unused int pmc_core_suspend (struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev);@@ -1488,6 +1535,9 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)if (pmcdev->suspend) pmcdev->suspend (pmcdev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_ignore_all (pmcdev); +/* Check if the syspend will actually use S0ix */ if (pm_suspend_via_firmware ())return 0 ;@@ -1594,6 +1644,9 @@ static __maybe_unused int pmc_core_resume(struct device *dev) {struct pmc_dev *pmcdev =dev_get_drvdata (dev); +if (ltr_ignore_all_suspend) +pmc_core_ltr_restore_all (pmcdev); +if (pmcdev->resume)return pmcdev->resume (pmcdev);drivers/platform/x86/intel/pmc/core.h +2
-0@@ -372,6 +372,7 @@ struct pmc_info {* @map: pointer to pmc_reg_map struct that contains platform * specific attributes * @lpm_req_regs: List of substate requirements +* @ltr_ign: Holds LTR ignore data while suspended * * pmc contains info about one power management controller device. */ @@ -380,6 +381,7 @@ struct pmc {void __iomem *regbase;const struct pmc_reg_map *map;u32 *lpm_req_regs; +u32 ltr_ign; };/**