All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mario Limonciello <mario.limonciello@amd.com>, Shyam-sundar.S-k@amd.com
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86/amd/pmf: Fix CnQF and auto-mode after resume
Date: Mon, 15 May 2023 14:59:00 +0200	[thread overview]
Message-ID: <247af7d9-f6b1-def5-a138-780f567f48cb@redhat.com> (raw)
In-Reply-To: <20230513011408.958-1-mario.limonciello@amd.com>

Hi,

On 5/13/23 03:14, Mario Limonciello wrote:
> After suspend/resume cycle there is an error message and auto-mode
> or CnQF stops working.
> 
> [ 5741.447511] amd-pmf AMDI0100:00: SMU cmd failed. err: 0xff
> [ 5741.447523] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_RESPONSE:ff
> [ 5741.447527] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_ARGUMENT:7
> [ 5741.447531] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_MESSAGE:16
> [ 5741.447540] amd-pmf AMDI0100:00: [AUTO_MODE] avg power: 0 mW mode: QUIET
> 
> This is because the DRAM address used for accessing metrics table
> needs to be refreshed after a suspend resume cycle. Add a resume
> callback to reset this again.
> 
> Fixes: 1a409b35c995 ("platform/x86/amd/pmf: Get performance metrics from PMFW")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Thank you for your patch, I've applied this patch to my fixes
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes

Note it will show up in my fixes branch once I've pushed my
local branch there, which might take a while.

I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.

Regards,

Hans



> ---
>  drivers/platform/x86/amd/pmf/core.c | 32 ++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> index d5bb775dadcf..ee5f124f78b6 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -245,24 +245,29 @@ static const struct pci_device_id pmf_pci_ids[] = {
>  	{ }
>  };
>  
> -int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
> +static void amd_pmf_set_dram_addr(struct amd_pmf_dev *dev)
>  {
>  	u64 phys_addr;
>  	u32 hi, low;
>  
> -	INIT_DELAYED_WORK(&dev->work_buffer, amd_pmf_get_metrics);
> +	phys_addr = virt_to_phys(dev->buf);
> +	hi = phys_addr >> 32;
> +	low = phys_addr & GENMASK(31, 0);
> +
> +	amd_pmf_send_cmd(dev, SET_DRAM_ADDR_HIGH, 0, hi, NULL);
> +	amd_pmf_send_cmd(dev, SET_DRAM_ADDR_LOW, 0, low, NULL);
> +}
>  
> +int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
> +{
>  	/* Get Metrics Table Address */
>  	dev->buf = kzalloc(sizeof(dev->m_table), GFP_KERNEL);
>  	if (!dev->buf)
>  		return -ENOMEM;
>  
> -	phys_addr = virt_to_phys(dev->buf);
> -	hi = phys_addr >> 32;
> -	low = phys_addr & GENMASK(31, 0);
> +	INIT_DELAYED_WORK(&dev->work_buffer, amd_pmf_get_metrics);
>  
> -	amd_pmf_send_cmd(dev, SET_DRAM_ADDR_HIGH, 0, hi, NULL);
> -	amd_pmf_send_cmd(dev, SET_DRAM_ADDR_LOW, 0, low, NULL);
> +	amd_pmf_set_dram_addr(dev);
>  
>  	/*
>  	 * Start collecting the metrics data after a small delay
> @@ -273,6 +278,18 @@ int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
>  	return 0;
>  }
>  
> +static int amd_pmf_resume_handler(struct device *dev)
> +{
> +	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
> +
> +	if (pdev->buf)
> +		amd_pmf_set_dram_addr(pdev);
> +
> +	return 0;
> +}
> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmf_pm, NULL, amd_pmf_resume_handler);
> +
>  static void amd_pmf_init_features(struct amd_pmf_dev *dev)
>  {
>  	int ret;
> @@ -413,6 +430,7 @@ static struct platform_driver amd_pmf_driver = {
>  		.name = "amd-pmf",
>  		.acpi_match_table = amd_pmf_acpi_ids,
>  		.dev_groups = amd_pmf_driver_groups,
> +		.pm = pm_sleep_ptr(&amd_pmf_pm),
>  	},
>  	.probe = amd_pmf_probe,
>  	.remove_new = amd_pmf_remove,


      reply	other threads:[~2023-05-15 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-13  1:14 [PATCH] platform/x86/amd/pmf: Fix CnQF and auto-mode after resume Mario Limonciello
2023-05-15 12:59 ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=247af7d9-f6b1-def5-a138-780f567f48cb@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.