From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: hdegoede@redhat.com, markgross@kernel.org,
Sanket.Goswami@amd.com, mario.limonciello@amd.com,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v3 2/4] platform/x86/amd: pmc: Get STB DRAM size from PMFW
Date: Tue, 23 May 2023 11:15:45 +0300 (EEST) [thread overview]
Message-ID: <cb258d52-a44b-b342-2463-13483f988c64@linux.intel.com> (raw)
In-Reply-To: <20230516091308.3905113-3-Shyam-sundar.S-k@amd.com>
[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]
On Tue, 16 May 2023, Shyam Sundar S K wrote:
> Recent PMFW's have support for querying the STB DRAM size. Add this
> support to the driver.
>
> 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>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
> ---
> drivers/platform/x86/amd/pmc.c | 37 +++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index f28c295b47dd..e2439fda5c02 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -115,6 +115,7 @@ enum s2d_arg {
> S2D_PHYS_ADDR_LOW,
> S2D_PHYS_ADDR_HIGH,
> S2D_NUM_SAMPLES,
> + S2D_DRAM_SIZE,
> };
>
> struct amd_pmc_bit_map {
> @@ -147,6 +148,7 @@ struct amd_pmc_dev {
> u32 base_addr;
> u32 cpu_id;
> u32 active_ips;
> + u32 dram_size;
> /* SMU version information */
> u8 smu_program;
> u8 major;
> @@ -890,11 +892,39 @@ static const struct pci_device_id pmc_pci_ids[] = {
> { }
> };
>
> +static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)
> +{
> + int ret;
> +
> + switch (dev->cpu_id) {
> + case AMD_CPU_ID_YC:
> + if (!(dev->major > 90 || (dev->major == 90 && dev->minor > 39))) {
> + ret = -EINVAL;
> + goto err_dram_size;
> + }
> + break;
> + default:
> + ret = -EINVAL;
> + goto err_dram_size;
> + }
> +
> + ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, STB_SPILL_TO_DRAM, true);
> + if (ret || !dev->dram_size)
> + goto err_dram_size;
> +
> + return 0;
> +
> +err_dram_size:
> + dev_err(dev->dev, "DRAM size command not supported for this platform\n");
> + return ret;
> +}
> +
> static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
> {
> u32 phys_addr_low, phys_addr_hi;
> u64 stb_phys_addr;
> u32 size = 0;
> + int ret;
>
> /* Spill to DRAM feature uses separate SMU message port */
> dev->msg_port = 1;
> @@ -903,6 +933,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
> if (size != S2D_TELEMETRY_BYTES_MAX)
> return -EIO;
>
> + /* Get DRAM size */
> + ret = amd_pmc_get_dram_size(dev);
> + if (ret)
> + dev->dram_size = S2D_TELEMETRY_DRAMBYTES_MAX;
> +
> /* Get STB DRAM address */
> amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, true);
> amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, true);
> @@ -912,7 +947,7 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
> /* Clear msg_port for other SMU operation */
> dev->msg_port = 0;
>
> - dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, S2D_TELEMETRY_DRAMBYTES_MAX);
> + dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, dev->dram_size);
> if (!dev->stb_virt_addr)
> return -ENOMEM;
>
>
next prev parent reply other threads:[~2023-05-23 8:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 9:13 [PATCH v3 0/4] Updates to AMD PMC driver Shyam Sundar S K
2023-05-16 9:13 ` [PATCH v3 1/4] platform/x86/amd: pmc: Pass true/false to bool argument Shyam Sundar S K
2023-05-23 8:10 ` Ilpo Järvinen
2023-05-16 9:13 ` [PATCH v3 2/4] platform/x86/amd: pmc: Get STB DRAM size from PMFW Shyam Sundar S K
2023-05-23 8:15 ` Ilpo Järvinen [this message]
2023-05-16 9:13 ` [PATCH v3 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id Shyam Sundar S K
2023-05-23 8:26 ` Ilpo Järvinen
2023-05-25 9:46 ` Shyam Sundar S K
2023-05-25 9:50 ` Hans de Goede
2023-05-25 9:59 ` Ilpo Järvinen
2023-05-25 10:21 ` Shyam Sundar S K
2023-05-25 10:44 ` Ilpo Järvinen
2023-05-25 11:25 ` Shyam Sundar S K
2023-05-25 11:58 ` Ilpo Järvinen
2023-05-25 12:19 ` Shyam Sundar S K
2023-05-16 9:13 ` [PATCH v3 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine Shyam Sundar S K
2023-05-23 8:31 ` Ilpo Järvinen
2023-05-23 10:36 ` [PATCH v3 0/4] Updates to AMD PMC driver 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=cb258d52-a44b-b342-2463-13483f988c64@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Sanket.Goswami@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=hdegoede@redhat.com \
--cc=mario.limonciello@amd.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