X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: Hans de Goede <hansg@kernel.org>,
	platform-driver-x86@vger.kernel.org,  mario.limonciello@amd.com,
	Sanket.Goswami@amd.com
Subject: Re: [PATCH v5 2/8] platform/x86/amd/pmf: store BIOS output values for user-space metrics via util IOCTL
Date: Fri, 22 May 2026 16:28:23 +0300 (EEST)	[thread overview]
Message-ID: <a5ed6736-a854-d219-a6b5-29f55542221e@linux.intel.com> (raw)
In-Reply-To: <20260520185424.770772-3-Shyam-sundar.S-k@amd.com>

On Thu, 21 May 2026, Shyam Sundar S K wrote:

> Add a bios_output[] to amd_pmf_dev struct and store the latest values for
> BIOS output policies when applying PMF policies. This enables the AMD PMF
> util layer to expose these BIOS outputs alongside selected thermal and
> power metrics to user space via /dev/amdpmf_interface and a new IOCTL,
> supporting real-time monitoring tools such as SystemDeck.
> 
> 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/pmf/pmf.h    |  2 ++
>  drivers/platform/x86/amd/pmf/tee-if.c | 11 ++++++++++-
>  include/uapi/linux/amd-pmf.h          |  1 +
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 6f61076a9386..ffe74ebc46f8 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -130,6 +130,7 @@ struct cookie_header {
>  #define GET_CMD		true
>  
>  #define METRICS_TABLE_ID	7
> +#define BIOS_OUTPUT_MAX		10
>  
>  typedef void (*apmf_event_handler_t)(acpi_handle handle, u32 event, void *data);
>  
> @@ -442,6 +443,7 @@ struct amd_pmf_dev {
>  	struct pmf_cbi_ring_buffer cbi_buf;
>  	struct mutex cbi_mutex;		     /* Protects ring buffer access */
>  	struct mutex metrics_mutex;
> +	u32 bios_output[BIOS_OUTPUT_MAX];
>  };
>  
>  struct apmf_sps_prop_granular_v2 {
> diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
> index 7ccd93f506b2..be8062c6691d 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -8,7 +8,9 @@
>   * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
>   */
>  
> +#include <linux/array_size.h>
>  #include <linux/debugfs.h>
> +#include <linux/dev_printk.h>
>  #include <linux/tee_drv.h>
>  #include <linux/uuid.h>
>  #include "pmf.h"
> @@ -98,10 +100,17 @@ static int amd_pmf_get_bios_output_idx(u32 action_idx)
>  static void amd_pmf_update_bios_output(struct amd_pmf_dev *pdev, struct ta_pmf_action *action)
>  {
>  	u32 bios_idx;
> +	int ret;
>  
>  	bios_idx = amd_pmf_get_bios_output_idx(action->action_index);
> +	if (bios_idx >= ARRAY_SIZE(pdev->bios_output)) {

amd_pmf_get_bios_output_idx() can return -EINVAL but it is never checked 
(a pre-existing problem) and value is directly going to an unsigned type 
(noted by sashiko).

> +		dev_warn(pdev->dev, "BIOS output index %u out of bounds\n", bios_idx);
> +		return;
> +	}
>  
> -	amd_pmf_smartpc_apply_bios_output(pdev, action->value, BIT(bios_idx), bios_idx);
> +	ret = amd_pmf_smartpc_apply_bios_output(pdev, action->value, BIT(bios_idx), bios_idx);
> +	if (!ret)
> +		pdev->bios_output[bios_idx] = action->value;
>  }
>  
>  static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out)
> diff --git a/include/uapi/linux/amd-pmf.h b/include/uapi/linux/amd-pmf.h
> index c7099e7f463f..d29a4abe1145 100644
> --- a/include/uapi/linux/amd-pmf.h
> +++ b/include/uapi/linux/amd-pmf.h
> @@ -55,6 +55,7 @@ struct amd_pmf_info {
>  
>  	/* BIOS parameters */
>  	__u32 bios_input[AMD_PMF_BIOS_PARAMS_MAX];
> +	__u32 bios_output[AMD_PMF_BIOS_PARAMS_MAX];
>  };
>  
>  #endif /* _UAPI_LINUX_AMD_PMF_H */
> 

-- 
 i.


  reply	other threads:[~2026-05-22 13:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 18:54 [PATCH v5 0/8] platform/x86/amd/pmf: Introduce PMF util layer with userspace interface Shyam Sundar S K
2026-05-20 18:54 ` [PATCH v5 1/8] platform/x86/amd/pmf: Add util layer and userspace character device interface Shyam Sundar S K
2026-05-22 13:21   ` Ilpo Järvinen
2026-05-20 18:54 ` [PATCH v5 2/8] platform/x86/amd/pmf: store BIOS output values for user-space metrics via util IOCTL Shyam Sundar S K
2026-05-22 13:28   ` Ilpo Järvinen [this message]
2026-05-20 18:54 ` [PATCH v5 3/8] platform/x86/amd/pmf: Add feature discovery support to util interface Shyam Sundar S K
2026-05-22 13:29   ` Ilpo Järvinen
2026-05-20 18:54 ` [PATCH v5 4/8] platform/x86/amd/pmf: Store commonly used enums in the header file Shyam Sundar S K
2026-05-22 13:31   ` Ilpo Järvinen
2026-05-20 18:54 ` [PATCH v5 5/8] platform/x86/amd/pmf: Move debug helper functions to UAPI header Shyam Sundar S K
2026-05-21 11:02   ` Ilpo Järvinen
2026-05-27  9:37     ` Shyam Sundar S K
2026-05-22 13:35   ` Ilpo Järvinen
2026-05-20 18:54 ` [PATCH v5 6/8] platform/x86/amd/pmf: Implement util layer ioctl handler Shyam Sundar S K
2026-05-21 10:58   ` Ilpo Järvinen
2026-05-27 10:15     ` Shyam Sundar S K
2026-05-27 11:09       ` Ilpo Järvinen
2026-05-22 13:44   ` Ilpo Järvinen
2026-05-20 18:54 ` [PATCH v5 7/8] platform/x86/amd/pmf: Introduce AMD PMF testing tool for driver metrics and features Shyam Sundar S K
2026-05-20 18:54 ` [PATCH v5 8/8] Documentation/ABI: add testing entry for AMD PMF character device interface Shyam Sundar S K
2026-05-21 11:07   ` Ilpo Järvinen
2026-05-27  9:35     ` 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=a5ed6736-a854-d219-a6b5-29f55542221e@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Sanket.Goswami@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hansg@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox