platform/x86: amd-pmc: Validate entry into the deepest state on resume
PATCH 1/1 platform/x86: amd-pmc: Validate entry into the deepest state on resume
Currently the only way to discover if a system went into the deepest sleep state is to read from sysfs after you finished suspend.
To better illustrate to users that problems have occurred, check as part of resume and display a warning.
--- drivers/platform/x86/amd-pmc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/platform/x86/amd-pmc.c +26 -3
@@ -171,6 +171,28 @@ struct smu_metrics {u64 timecondition_notmet_totaltime[SOC_SUBSYSTEM_IP_MAX ]; } __packed; +static int get_metrics_table (struct amd_pmc_dev *pdev,struct smu_metrics *table) +{ +if (pdev->cpu_id ==AMD_CPU_ID_PCO ) +return -ENODEV ; +memcpy_fromio (table, pdev->smu_virt_addr,sizeof (struct smu_metrics )); +return 0 ; +} + +static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) +{ +struct smu_metrics table; + +if (get_metrics_table (pdev, &table)) +return ; + +if (!table.s0i3_last_entry_status) +dev_warn (pdev->dev,"Last suspend didn't reach deepest state\n" ); +else +dev_dbg (pdev->dev,"Last suspend in deepest state for %lluus\n" , + table.timein_s0i3_lastcapture); +} +#ifdef CONFIG_DEBUG_FS static int smu_fw_info_show (struct seq_file *s,void *unused) {
@@ -178,11 +200,9 @@ static int smu_fw_info_show(struct seq_file *s, void *unused)struct smu_metrics table;int idx; -if (dev->cpu_id ==AMD_CPU_ID_PCO ) +if (get_metrics_table (dev, &table))return -EINVAL ; -memcpy_fromio (&table, dev->smu_virt_addr,sizeof (struct smu_metrics )); -seq_puts (s,"\n=== SMU Statistics ===\n" );seq_printf (s,"Table Version: %d\n" , table.table_version);seq_printf (s,"Hint Count: %d\n" , table.hint_count);
@@ -571,6 +591,9 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)if (enable_stb)amd_pmc_write_stb (pdev,AMD_PMC_STB_PREDEF +1 ); +/* Notify on failed entry */ +amd_pmc_validate_deepest (pdev); +return 0 ; }
Signature · 1 line
2.34.1
Hi,
Quoted 7 lines · Mario Limonciello
Currently the only way to discover if a system went into the deepest sleep state is to read from sysfs after you finished suspend.
To better illustrate to users that problems have occurred, check as part of resume and display a warning.
Signed-off-by Mario Limonciello <[email protected]>
Has this also been tested on system which use S3 suspend rather then s2idle ?
Regards,
Hans
Quoted 60 lines
--- drivers/platform/x86/amd-pmc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)drivers/platform/x86/amd-pmc.c +26
-3@@ -171,6 +171,28 @@ struct smu_metrics {u64 timecondition_notmet_totaltime[SOC_SUBSYSTEM_IP_MAX ]; } __packed; +static int get_metrics_table (struct amd_pmc_dev *pdev,struct smu_metrics *table) +{ +if (pdev->cpu_id ==AMD_CPU_ID_PCO ) +return -ENODEV ; +memcpy_fromio (table, pdev->smu_virt_addr,sizeof (struct smu_metrics )); +return 0 ; +} + +static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) +{ +struct smu_metrics table; + +if (get_metrics_table (pdev, &table)) +return ; + +if (!table.s0i3_last_entry_status) +dev_warn (pdev->dev,"Last suspend didn't reach deepest state\n" ); +else +dev_dbg (pdev->dev,"Last suspend in deepest state for %lluus\n" , + table.timein_s0i3_lastcapture); +} +#ifdef CONFIG_DEBUG_FS static int smu_fw_info_show (struct seq_file *s,void *unused) {@@ -178,11 +200,9 @@ static int smu_fw_info_show(struct seq_file *s, void *unused)struct smu_metrics table;int idx; -if (dev->cpu_id ==AMD_CPU_ID_PCO ) +if (get_metrics_table (dev, &table))return -EINVAL ; -memcpy_fromio (&table, dev->smu_virt_addr,sizeof (struct smu_metrics )); -seq_puts (s,"\n=== SMU Statistics ===\n" );seq_printf (s,"Table Version: %d\n" , table.table_version);seq_printf (s,"Hint Count: %d\n" , table.hint_count);@@ -571,6 +591,9 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)if (enable_stb)amd_pmc_write_stb (pdev,AMD_PMC_STB_PREDEF +1 ); +/* Notify on failed entry */ +amd_pmc_validate_deepest (pdev); +return 0 ; }
[Public]
Quoted 17 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, March 9, 2022 09:49
To: Limonciello, Mario <[email protected]>; Mark Gross <[email protected]>; open list:X86 PLATFORM DRIVERS <platform- [email protected]>
Cc: S-k, Shyam-sundar <[email protected]>; Goswami, Sanket <[email protected]>
Subject: Re: [PATCH] platform/x86: amd-pmc: Validate entry into the deepest state on resumeHi,
Quoted 3 lines · Mario Limonciello
Currently the only way to discover if a system went into the deepest sleep state is to read from sysfs after you finished suspend.
Quoted 8 lines
Quoted 4 lines
To better illustrate to users that problems have occurred, check as part of resume and display a warning.
Signed-off-by Mario Limonciello <[email protected]>Has this also been tested on system which use S3 suspend rather then s2idle ?
S3 suspend won't export ACPI device that causes amd-pmc to probe so this code won't ever run.
Quoted 74 lines
Regards,
Hans
drivers/platform/x86/amd-
Quoted 5 lines
--- drivers/platform/x86/amd-pmc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)drivers/platform/x86/amd- renamed from drivers/platform/x86/amd-pmc.c +0
-0
pmc.cdrivers/platform/x86/amd-pmc.c struct smu_metrics { · line 174
Quoted 8 lines
index
05b4bac38920..e117404e1bb1100644drivers/platform/x86/amd-pmc.c +1
-0@@ -171,6 +171,28 @@ struct smu_metrics {u64 timecondition_notmet_totaltime[SOC_SUBSYSTEM_IP_MAX ]; } __packed; +static int get_metrics_table(struct amd_pmc_dev *pdev, struct
smu_metrics*table)drivers/platform/x86/amd-pmc.c struct smu_metrics {
Quoted 4 lines
drivers/platform/x86/amd-pmc.c +4
-0+{ +if (pdev->cpu_id ==AMD_CPU_ID_PCO ) +return -ENODEV ; + memcpy_fromio(table, pdev->smu_virt_addr, sizeof(struct
smu_metrics));drivers/platform/x86/amd-pmc.c struct smu_metrics {
Quoted 12 lines
drivers/platform/x86/amd-pmc.c +12
-0+return 0 ; +} + +static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) +{ +struct smu_metrics table; + +if (get_metrics_table (pdev, &table)) +return ; + +if (!table.s0i3_last_entry_status) + dev_warn(pdev->dev, "Last suspend didn't reach deepeststate\n");
drivers/platform/x86/amd-pmc.c struct smu_metrics { · line 192
Quoted 2 lines
drivers/platform/x86/amd-pmc.c +2
-0+else + dev_dbg(pdev->dev, "Last suspend in deepest state for%lluus\n",
drivers/platform/x86/amd-pmc.c static int smu_fw_info_show(struct seq_file *s,
Quoted 7 lines
drivers/platform/x86/amd-pmc.c +3
-0+ table.timein_s0i3_lastcapture); +} +#ifdef CONFIG_DEBUG_FS static int smu_fw_info_show (struct seq_file *s,void *unused) {@@ -178,11 +200,9 @@ static int smu_fw_info_show(struct seq_file *s,void *unused)
drivers/platform/x86/amd-pmc.c static int smu_fw_info_show(struct seq_file *s, void *unused)
Quoted 8 lines
drivers/platform/x86/amd-pmc.c +1
-2struct smu_metrics table;int idx; -if (dev->cpu_id ==AMD_CPU_ID_PCO ) +if (get_metrics_table (dev, &table))return -EINVAL ; - memcpy_fromio(&table, dev->smu_virt_addr, sizeof(struct
smu_metrics));drivers/platform/x86/amd-pmc.c static int __maybe_unused
Quoted 5 lines
drivers/platform/x86/amd-pmc.c +0
-1-seq_puts (s,"\n=== SMU Statistics ===\n" );seq_printf (s,"Table Version: %d\n" , table.table_version);seq_printf (s,"Hint Count: %d\n" , table.hint_count);@@ -571,6 +591,9 @@ static int __maybe_unused
amd_pmc_resume(struct device *dev)Quoted 9 lines
drivers/platform/x86/amd-pmc.c +3
-0if (enable_stb)amd_pmc_write_stb (pdev,AMD_PMC_STB_PREDEF +1 ); +/* Notify on failed entry */ +amd_pmc_validate_deepest (pdev); +return 0 ; }