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,
Yijun.Shen@Dell.com, Sanket.Goswami@amd.com
Subject: Re: [PATCH v3 2/7] platform/x86/amd/pmf: cache BIOS output values for user-space metrics via util IOCTL
Date: Wed, 25 Mar 2026 16:08:38 +0200 (EET) [thread overview]
Message-ID: <91669d3d-00f7-b360-6a9d-dc79952dae0e@linux.intel.com> (raw)
In-Reply-To: <20260301131124.1370565-3-Shyam-sundar.S-k@amd.com>
On Sun, 1 Mar 2026, Shyam Sundar S K wrote:
> Add a bios_output[] cache to amd_pmf_dev 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.
>
> The bios_output array is initialized to zero during device probe, and
> bounds checking is added to prevent potential buffer overflows when
> caching values.
>
> 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/core.c | 3 +++
> drivers/platform/x86/amd/pmf/pmf.h | 1 +
> drivers/platform/x86/amd/pmf/tee-if.c | 9 ++++++++-
> drivers/platform/x86/amd/pmf/util.c | 15 +++++++++++++++
> include/uapi/linux/amd-pmf.h | 22 +++++++++++++++++++++-
> 5 files changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> index 919d02f30aae..b5cab7c937ce 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -634,6 +634,9 @@ static int amd_pmf_probe(struct platform_device *pdev)
>
> pmf_device = dev->dev;
>
> + /* Initialize BIOS output cache for util layer */
> + memset(dev->bios_output, 0, sizeof(dev->bios_output));
You allocate dev with devm_kzalloc() so why is this necessary?
> +
> err = amd_pmf_cdev_register(dev);
> if (err)
> dev_warn(dev->dev, "failed to register util interface: %d\n", err);
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 6f61076a9386..0d879f0fd8e2 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -442,6 +442,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[10];
> };
>
> 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..f749115bf970 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -98,10 +98,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)) {
Add include.
> + dev_warn(pdev->dev, "BIOS output index %u out of bounds\n", bios_idx);
Add include.
> + 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);
Somewhat unrelated to the change here, the include for BIT() is also
missing (linux/bits.h). But I don't mind if you stick its addition into
this patch since you're anyway touching this line.
> + 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/drivers/platform/x86/amd/pmf/util.c b/drivers/platform/x86/amd/pmf/util.c
> index c6837caa44e0..59a125deb6b6 100644
> --- a/drivers/platform/x86/amd/pmf/util.c
> +++ b/drivers/platform/x86/amd/pmf/util.c
> @@ -22,6 +22,9 @@ static int amd_pmf_get_bios_idx(u32 control_code)
> if (control_code >= IOCTL_BIOS_INPUT_1 && control_code <= IOCTL_BIOS_INPUT_10)
> return control_code - IOCTL_BIOS_INPUT_1;
>
> + if (control_code >= IOCTL_BIOS_OUTPUT_1 && control_code <= IOCTL_BIOS_OUTPUT_10)
> + return control_code - IOCTL_BIOS_OUTPUT_1;
> +
> return -EINVAL;
> }
>
> @@ -34,6 +37,15 @@ static long long amd_pmf_populate_bios_input(struct ta_pmf_enact_table *in, u32
> return (idx < 2) ? in->ev_info.bios_input_1[idx] : in->ev_info.bios_input_2[idx - 2];
> }
>
> +static long long amd_pmf_populate_bios_output(struct amd_pmf_dev *pdev, u32 control_code)
> +{
> + u32 idx;
> +
> + idx = amd_pmf_get_bios_idx(control_code);
> +
> + return pdev->bios_output[idx];
> +}
> +
> static long long amd_pmf_device_state(struct ta_pmf_enact_table *in, u32 control_code)
> {
> switch (control_code) {
> @@ -101,6 +113,9 @@ static int amd_pmf_populate_data(struct device *dev, void __user *argp)
> case IOCTL_SOCKET_POWER:
> output.val = in->ev_info.socket_power;
> break;
> + case IOCTL_BIOS_OUTPUT_1 ... IOCTL_BIOS_OUTPUT_10:
> + output.val = amd_pmf_populate_bios_output(pdev, output.control_code);
> + break;
> default:
> return -EINVAL;
> }
> diff --git a/include/uapi/linux/amd-pmf.h b/include/uapi/linux/amd-pmf.h
> index d29431c67eaa..f93767248169 100644
> --- a/include/uapi/linux/amd-pmf.h
> +++ b/include/uapi/linux/amd-pmf.h
> @@ -60,6 +60,16 @@
> * @IOCTL_MAX_C0_RES: Query maximum C0 residency
> * @IOCTL_SOCKET_POWER: Query current socket power consumption
> * @IOCTL_TA_BIN_VER: Query Trusted Application binary version
> + * @IOCTL_BIOS_OUTPUT_1: Query BIOS output parameter 1
> + * @IOCTL_BIOS_OUTPUT_2: Query BIOS output parameter 2
> + * @IOCTL_BIOS_OUTPUT_3: Query BIOS output parameter 3
> + * @IOCTL_BIOS_OUTPUT_4: Query BIOS output parameter 4
> + * @IOCTL_BIOS_OUTPUT_5: Query BIOS output parameter 5
> + * @IOCTL_BIOS_OUTPUT_6: Query BIOS output parameter 6
> + * @IOCTL_BIOS_OUTPUT_7: Query BIOS output parameter 7
> + * @IOCTL_BIOS_OUTPUT_8: Query BIOS output parameter 8
> + * @IOCTL_BIOS_OUTPUT_9: Query BIOS output parameter 9
> + * @IOCTL_BIOS_OUTPUT_10: Query BIOS output parameter 10
> *
> * These control codes are used with the IOCTL_PMF_POPULATE_DATA ioctl
> * to specify which metrics data to retrieve from the AMD PMF driver.
> @@ -90,7 +100,17 @@ enum pmf_ioctl_id {
> IOCTL_AVG_C0_RES = 36,
> IOCTL_MAX_C0_RES,
> IOCTL_SOCKET_POWER = 50,
> - IOCTL_TA_BIN_VER
> + IOCTL_TA_BIN_VER,
> + IOCTL_BIOS_OUTPUT_1,
> + IOCTL_BIOS_OUTPUT_2,
> + IOCTL_BIOS_OUTPUT_3,
> + IOCTL_BIOS_OUTPUT_4,
> + IOCTL_BIOS_OUTPUT_5,
> + IOCTL_BIOS_OUTPUT_6,
> + IOCTL_BIOS_OUTPUT_7,
> + IOCTL_BIOS_OUTPUT_8,
> + IOCTL_BIOS_OUTPUT_9,
> + IOCTL_BIOS_OUTPUT_10
> };
>
> /**
>
--
i.
next prev parent reply other threads:[~2026-03-25 14:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 13:11 [PATCH v3 0/7] platform/x86/amd/pmf: Introduce PMF util layer with userspace interface Shyam Sundar S K
2026-03-01 13:11 ` [PATCH v3 1/7] platform/x86/amd/pmf: Add util layer and userspace misc device interface Shyam Sundar S K
2026-03-01 18:45 ` Randy Dunlap
2026-03-03 15:22 ` Shyam Sundar S K
2026-03-25 13:16 ` Ilpo Järvinen
2026-03-25 13:18 ` Ilpo Järvinen
2026-03-25 14:05 ` Ilpo Järvinen
2026-03-30 12:12 ` Shyam Sundar S K
2026-03-30 15:10 ` Ilpo Järvinen
2026-03-01 13:11 ` [PATCH v3 2/7] platform/x86/amd/pmf: cache BIOS output values for user-space metrics via util IOCTL Shyam Sundar S K
2026-03-25 14:08 ` Ilpo Järvinen [this message]
2026-03-01 13:11 ` [PATCH v3 3/7] platform/x86/amd/pmf: Add feature discovery support to util interface Shyam Sundar S K
2026-03-25 14:07 ` Ilpo Järvinen
2026-03-30 11:41 ` Shyam Sundar S K
2026-03-01 13:11 ` [PATCH v3 4/7] platform/x86/amd/pmf: Store commonly used enums in the header file Shyam Sundar S K
2026-03-25 13:34 ` Ilpo Järvinen
2026-03-01 13:11 ` [PATCH v3 5/7] platform/x86/amd/pmf: Move debug helper functions to UAPI header Shyam Sundar S K
2026-03-25 13:39 ` Ilpo Järvinen
2026-03-30 11:45 ` Shyam Sundar S K
2026-03-01 13:11 ` [PATCH v3 6/7] platform/x86/amd/pmf: Introduce AMD PMF testing tool for driver metrics and features Shyam Sundar S K
2026-03-25 13:54 ` Ilpo Järvinen
2026-03-25 15:07 ` Mario Limonciello
2026-03-26 10:20 ` Ilpo Järvinen
2026-03-30 11:42 ` Shyam Sundar S K
2026-03-01 13:11 ` [PATCH v3 7/7] Documentation/ABI: add testing entry for AMD PMF misc device interface Shyam Sundar S K
2026-03-25 13:58 ` Ilpo Järvinen
2026-03-25 15:08 ` Mario Limonciello
2026-03-26 10:14 ` Ilpo Järvinen
2026-03-02 19:36 ` [PATCH v3 0/7] platform/x86/amd/pmf: Introduce PMF util layer with userspace interface Mario Limonciello
2026-03-03 15:23 ` 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=91669d3d-00f7-b360-6a9d-dc79952dae0e@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Sanket.Goswami@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=Yijun.Shen@Dell.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