Skip to content

Commit 854abe2

Browse files
superm1jwrdegoede
authored andcommitted
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. Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 10b29dd commit 854abe2

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/platform/x86/amd-pmc.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,38 @@ static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
322322
return 0;
323323
}
324324

325+
static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)
326+
{
327+
if (pdev->cpu_id == AMD_CPU_ID_PCO)
328+
return -ENODEV;
329+
memcpy_fromio(table, pdev->smu_virt_addr, sizeof(struct smu_metrics));
330+
return 0;
331+
}
332+
333+
static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
334+
{
335+
struct smu_metrics table;
336+
337+
if (get_metrics_table(pdev, &table))
338+
return;
339+
340+
if (!table.s0i3_last_entry_status)
341+
dev_warn(pdev->dev, "Last suspend didn't reach deepest state\n");
342+
else
343+
dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n",
344+
table.timein_s0i3_lastcapture);
345+
}
346+
325347
#ifdef CONFIG_DEBUG_FS
326348
static int smu_fw_info_show(struct seq_file *s, void *unused)
327349
{
328350
struct amd_pmc_dev *dev = s->private;
329351
struct smu_metrics table;
330352
int idx;
331353

332-
if (dev->cpu_id == AMD_CPU_ID_PCO)
354+
if (get_metrics_table(dev, &table))
333355
return -EINVAL;
334356

335-
memcpy_fromio(&table, dev->smu_virt_addr, sizeof(struct smu_metrics));
336-
337357
seq_puts(s, "\n=== SMU Statistics ===\n");
338358
seq_printf(s, "Table Version: %d\n", table.table_version);
339359
seq_printf(s, "Hint Count: %d\n", table.hint_count);
@@ -689,6 +709,9 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
689709
cpu_latency_qos_update_request(&pdev->amd_pmc_pm_qos_req,
690710
PM_QOS_DEFAULT_VALUE);
691711

712+
/* Notify on failed entry */
713+
amd_pmc_validate_deepest(pdev);
714+
692715
return rc;
693716
}
694717

0 commit comments

Comments
 (0)