RE: [PATCH] platform/x86: amd-pmc: Validate entry into the deepest state on resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[Public]



> -----Original Message-----
> From: Hans de Goede <hdegoede@xxxxxxxxxx>
> Sent: Wednesday, March 9, 2022 09:49
> To: Limonciello, Mario <Mario.Limonciello@xxxxxxx>; Mark Gross
> <mgross@xxxxxxxxxxxxxxx>; open list:X86 PLATFORM DRIVERS <platform-
> driver-x86@xxxxxxxxxxxxxxx>
> Cc: S-k, Shyam-sundar <Shyam-sundar.S-k@xxxxxxx>; Goswami, Sanket
> <Sanket.Goswami@xxxxxxx>
> Subject: Re: [PATCH] platform/x86: amd-pmc: Validate entry into the
> deepest state on resume
> 
> Hi,
> 
> On 3/9/22 15:44, Mario Limonciello wrote:
> > 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 <mario.limonciello@xxxxxxx>
> 
> 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.

> Regards,
> 
> Hans
> 
> 
> 
> > ---
> >  drivers/platform/x86/amd-pmc.c | 29 ++++++++++++++++++++++++++---
> >  1 file changed, 26 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-
> pmc.c
> > index 05b4bac38920..e117404e1bb1 100644
> > --- a/drivers/platform/x86/amd-pmc.c
> > +++ b/drivers/platform/x86/amd-pmc.c
> > @@ -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;
> >  }
> >




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux