X86 platform drivers
 help / color / mirror / Atom feed
From: "Limonciello, Mario" <mario.limonciello@amd.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	hdegoede@redhat.com, markgross@kernel.org
Cc: Sanket.Goswami@amd.com, platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 2/4] platform/x86/amd/pmc: Read SMU version at the time of probe
Date: Fri, 11 Aug 2023 07:04:52 -0500	[thread overview]
Message-ID: <744416dd-b860-4ad9-b731-857fd53fbb4e@amd.com> (raw)
In-Reply-To: <20230811112116.2279419-3-Shyam-sundar.S-k@amd.com>



On 8/11/2023 6:21 AM, Shyam Sundar S K wrote:
> Currently the SMU version is being read at multiple places, unify all
> of them and get the SMU version at the time of probe.
> 
> Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
>   drivers/platform/x86/amd/pmc/pmc.c | 39 +++++-------------------------
>   1 file changed, 6 insertions(+), 33 deletions(-)
> 

It's actually quite intentional that the SMU version isn't read at probe 
but rather at first use.  The reason is that it increased boot time in a 
measurable way.

> diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
> index c1e788b67a74..043451fabbbe 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.c
> +++ b/drivers/platform/x86/amd/pmc/pmc.c
> @@ -405,12 +405,6 @@ static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *at
>   {
>   	struct amd_pmc_dev *dev = dev_get_drvdata(d);
>   
> -	if (!dev->major) {
> -		int rc = amd_pmc_get_smu_version(dev);
> -
> -		if (rc)
> -			return rc;
> -	}
>   	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
>   }
>   
> @@ -419,12 +413,6 @@ static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
>   {
>   	struct amd_pmc_dev *dev = dev_get_drvdata(d);
>   
> -	if (!dev->major) {
> -		int rc = amd_pmc_get_smu_version(dev);
> -
> -		if (rc)
> -			return rc;
> -	}
>   	return sysfs_emit(buf, "%u\n", dev->smu_program);
>   }
>   
> @@ -526,16 +514,9 @@ static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
>   				 struct seq_file *s)
>   {
>   	u32 val;
> -	int rc;
>   
>   	switch (pdev->cpu_id) {
>   	case AMD_CPU_ID_CZN:
> -		/* we haven't yet read SMU version */
> -		if (!pdev->major) {
> -			rc = amd_pmc_get_smu_version(pdev);
> -			if (rc)
> -				return rc;
> -		}
>   		if (pdev->major > 56 || (pdev->major >= 55 && pdev->minor >= 37))
>   			val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_CZN);
>   		else
> @@ -717,13 +698,6 @@ static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
>   static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev)
>   {
>   	struct device *d;
> -	int rc;
> -
> -	if (!pdev->major) {
> -		rc = amd_pmc_get_smu_version(pdev);
> -		if (rc)
> -			return rc;
> -	}
>   
>   	if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
>   		return 0;
> @@ -749,13 +723,6 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
>   	struct rtc_time tm;
>   	int rc;
>   
> -	/* we haven't yet read SMU version */
> -	if (!pdev->major) {
> -		rc = amd_pmc_get_smu_version(pdev);
> -		if (rc)
> -			return rc;
> -	}
> -
>   	if (pdev->major < 64 || (pdev->major == 64 && pdev->minor < 53))
>   		return 0;
>   
> @@ -1059,6 +1026,12 @@ static int amd_pmc_probe(struct platform_device *pdev)
>   
>   	mutex_init(&dev->lock);
>   
> +	err = amd_pmc_get_smu_version(dev);
> +	if (err) {
> +		dev_err(dev->dev, "error reading SMU version\n");
> +		goto err_pci_dev_put;
> +	}
> +
>   	if (enable_stb && amd_pmc_is_stb_supported(dev)) {
>   		err = amd_pmc_s2d_init(dev);
>   		if (err)

  reply	other threads:[~2023-08-11 12:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 11:21 [PATCH 0/4] Updates to amd-pmc driver Shyam Sundar S K
2023-08-11 11:21 ` [PATCH 1/4] platform/x86/amd/pmc: Move PMC driver to separate directory Shyam Sundar S K
2023-08-11 11:21 ` [PATCH 2/4] platform/x86/amd/pmc: Read SMU version at the time of probe Shyam Sundar S K
2023-08-11 12:04   ` Limonciello, Mario [this message]
2023-08-22  4:05     ` Shyam Sundar S K
2023-08-11 11:21 ` [PATCH 3/4] platform/x86/amd/pmc: Add PMFW command id to support S2D force flush Shyam Sundar S K
2023-08-11 11:21 ` [PATCH 4/4] platform/x86/amd/pmc: Add dump_custom_stb module parameter Shyam Sundar S K
2023-08-21 12:57 ` [PATCH 0/4] Updates to amd-pmc driver Hans de Goede
2023-08-21 17:52   ` Hans de Goede
2023-08-22  4:11     ` Shyam Sundar S K
2023-08-22 15:31       ` Hans de Goede

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=744416dd-b860-4ad9-b731-857fd53fbb4e@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Sanket.Goswami@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=markgross@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox