From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Sanket.Goswami@amd.com, platform-driver-x86@vger.kernel.org,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [PATCH v4 05/11] platform/x86/amd/pmc: Define enum for S2D/PMC msg_port and add helper function
Date: Thu, 7 Nov 2024 12:43:15 +0200 (EET) [thread overview]
Message-ID: <ab525157-a530-ac5e-8f57-2d18e2a62d6f@linux.intel.com> (raw)
In-Reply-To: <20241107072714.943423-6-Shyam-sundar.S-k@amd.com>
On Thu, 7 Nov 2024, Shyam Sundar S K wrote:
> To distinguish between the PMC message port and the S2D (Spill to DRAM)
> message port, replace the use of 0 and 1 with an enum.
>
> To avoid printing the S2D or PMC port multiple times in debug print,
> add new routine to retrieve the message port information, which can be
> used to print the right msg_port getting used.
>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> 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/mp1_stb.c | 8 ++++----
> drivers/platform/x86/amd/pmc/pmc.c | 15 ++++++++++-----
> drivers/platform/x86/amd/pmc/pmc.h | 5 +++++
> 3 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmc/mp1_stb.c b/drivers/platform/x86/amd/pmc/mp1_stb.c
> index 5c03ac92558f..9ee629db9af9 100644
> --- a/drivers/platform/x86/amd/pmc/mp1_stb.c
> +++ b/drivers/platform/x86/amd/pmc/mp1_stb.c
> @@ -155,7 +155,7 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
> dev_err(dev->dev, "error writing to STB: %d\n", ret);
>
> /* Spill to DRAM num_samples uses separate SMU message port */
> - dev->msg_port = 1;
> + dev->msg_port = MSG_PORT_S2D;
>
> ret = amd_pmc_send_cmd(dev, 0, &val, STB_FORCE_FLUSH_DATA, 1);
> if (ret)
> @@ -172,7 +172,7 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
> /* Get the num_samples to calculate the last push location */
> ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->s2d_msg_id, true);
> /* Clear msg_port for other SMU operation */
> - dev->msg_port = 0;
> + dev->msg_port = MSG_PORT_PMC;
> if (ret) {
> dev_err(dev->dev, "error: S2D_NUM_SAMPLES not supported : %d\n", ret);
> return ret;
> @@ -267,7 +267,7 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
> }
>
> /* Spill to DRAM feature uses separate SMU message port */
> - dev->msg_port = 1;
> + dev->msg_port = MSG_PORT_S2D;
>
> amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, dev->s2d_msg_id, true);
> if (size != S2D_TELEMETRY_BYTES_MAX)
> @@ -285,7 +285,7 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
> stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
>
> /* Clear msg_port for other SMU operation */
> - dev->msg_port = 0;
> + dev->msg_port = MSG_PORT_PMC;
>
> dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, dev->dram_size);
> if (!dev->stb_virt_addr)
> diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
> index 7726a05091a5..ce0050699a5a 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.c
> +++ b/drivers/platform/x86/amd/pmc/pmc.c
> @@ -449,11 +449,16 @@ static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
> &amd_pmc_idlemask_fops);
> }
>
> +static char *amd_pmc_print_msg_port(struct amd_pmc_dev *dev)
Change name as this doesn't print anything.
> +{
> + return dev->msg_port ? "S2D" : "PMC";
== ...
Although a switch/case might be preferrable here (return "invalid" or
something in default branch).
> +}
> +
> static void amd_pmc_dump_registers(struct amd_pmc_dev *dev)
> {
> u32 value, message, argument, response;
>
> - if (dev->msg_port) {
> + if (dev->msg_port == MSG_PORT_S2D) {
> message = AMD_S2D_REGISTER_MESSAGE;
> argument = AMD_S2D_REGISTER_ARGUMENT;
> response = AMD_S2D_REGISTER_RESPONSE;
> @@ -464,13 +469,13 @@ static void amd_pmc_dump_registers(struct amd_pmc_dev *dev)
> }
>
> value = amd_pmc_reg_read(dev, response);
> - dev_dbg(dev->dev, "AMD_%s_REGISTER_RESPONSE:%x\n", dev->msg_port ? "S2D" : "PMC", value);
> + dev_dbg(dev->dev, "AMD_%s_REGISTER_RESPONSE:%x\n", amd_pmc_print_msg_port(dev), value);
>
> value = amd_pmc_reg_read(dev, argument);
> - dev_dbg(dev->dev, "AMD_%s_REGISTER_ARGUMENT:%x\n", dev->msg_port ? "S2D" : "PMC", value);
> + dev_dbg(dev->dev, "AMD_%s_REGISTER_ARGUMENT:%x\n", amd_pmc_print_msg_port(dev), value);
>
> value = amd_pmc_reg_read(dev, message);
> - dev_dbg(dev->dev, "AMD_%s_REGISTER_MESSAGE:%x\n", dev->msg_port ? "S2D" : "PMC", value);
> + dev_dbg(dev->dev, "AMD_%s_REGISTER_MESSAGE:%x\n", amd_pmc_print_msg_port(dev), value);
> }
>
> int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret)
> @@ -480,7 +485,7 @@ int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool r
>
> mutex_lock(&dev->lock);
>
> - if (dev->msg_port) {
> + if (dev->msg_port == MSG_PORT_S2D) {
> message = AMD_S2D_REGISTER_MESSAGE;
> argument = AMD_S2D_REGISTER_ARGUMENT;
> response = AMD_S2D_REGISTER_RESPONSE;
> diff --git a/drivers/platform/x86/amd/pmc/pmc.h b/drivers/platform/x86/amd/pmc/pmc.h
> index 188284feca72..8252d3a52849 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.h
> +++ b/drivers/platform/x86/amd/pmc/pmc.h
> @@ -14,6 +14,11 @@
> #include <linux/types.h>
> #include <linux/mutex.h>
>
> +enum s2d_msg_port {
> + MSG_PORT_PMC,
> + MSG_PORT_S2D,
> +};
> +
> struct amd_mp2_dev {
> void __iomem *mmio;
> void __iomem *vslbase;
>
--
i.
next prev parent reply other threads:[~2024-11-07 10:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 7:27 [PATCH v4 00/11] platform/x86/amd/pmc: Updates to AMD PMC driver Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 01/11] platform/x86/amd/pmc: Move STB block into amd_pmc_s2d_init() Shyam Sundar S K
2024-11-07 10:40 ` Ilpo Järvinen
2024-11-07 15:32 ` Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 02/11] platform/x86/amd/pmc: Invoke amd_pmc_s2d_init() Post Debugfs Registration Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 03/11] platform/x86/amd/pmc: Move STB functionality to a new file for better code organization Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 04/11] platform/x86/amd/pmc: Update function names to align with new STB file Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 05/11] platform/x86/amd/pmc: Define enum for S2D/PMC msg_port and add helper function Shyam Sundar S K
2024-11-07 10:43 ` Ilpo Järvinen [this message]
2024-11-07 7:27 ` [PATCH v4 06/11] platform/x86/amd/pmc: Isolate STB code changes to a new file Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 07/11] platform/x86/amd/pmc: Use ARRAY_SIZE() to fill num_ips information Shyam Sundar S K
2024-11-07 10:44 ` Ilpo Järvinen
2024-11-07 7:27 ` [PATCH v4 08/11] platform/x86/amd/pmc: Update IP information structure for newer SoCs Shyam Sundar S K
2024-11-07 11:02 ` Ilpo Järvinen
2024-11-07 15:34 ` Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 09/11] platform/x86/amd/pmc: Update S2D message id for 1Ah Family 70h model Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 10/11] platform/x86/amd/pmc: Add STB support for AMD Desktop variants Shyam Sundar S K
2024-11-07 7:27 ` [PATCH v4 11/11] MAINTAINERS: Change AMD PMC driver status to "Supported" Shyam Sundar S K
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=ab525157-a530-ac5e-8f57-2d18e2a62d6f@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=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