* [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
@ 2025-06-17 7:14 Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
This patch series includes the following changes to the PMF driver:
- Implement support for modifying PMF PPT and PPT APU thresholds
- Enable custom BIOS input support for AMD_CPU_ID_PS
- Add the is_apmf_bios_input_notifications_supported() helper function
- Correct the handling mechanism for custom BIOS inputs
- Maintain a record of past custom BIOS inputs
- Process early custom BIOS inputs
- Initiate enact() earlier to address the initial custom BIOS input
Changes based on review-ilpo-next with tip
'commit 73f0f2b52c5e ("platform/x86: wmi: Fix WMI device naming issue")'
v2:
-----
- Use array to store the BIOS inputs instead of individual variables
- Remove additional spaces
- Replace GEN_MASK() with a meaningful macro
- Merge patch6 and 7 into a single one
- add amd_pmf_handle_early_preq() common routine for early pending request
Shyam Sundar S K (9):
platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU
thresholds
platform/x86/amd/pmf: Fix the custom bios input handling mechanism
platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
platform/x86/amd/pmf: Update ta_pmf_action structure member
platform/x86/amd/pmf: Add helper to verify BIOS input notifications
are enable/disable
platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the
policies
platform/x86/amd/pmf: Call enact function sooner to process early
pending requests
platform/x86/amd/pmf: Add debug logs for pending requests and custom
BIOS inputs
drivers/platform/x86/amd/pmf/acpi.c | 62 +++++++++++++++++++++-
drivers/platform/x86/amd/pmf/pmf.h | 75 ++++++++++++++++++++++++---
drivers/platform/x86/amd/pmf/spc.c | 52 +++++++++++++++----
drivers/platform/x86/amd/pmf/tee-if.c | 19 ++++++-
4 files changed, 189 insertions(+), 19 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
The most recent PMF Trusted Application includes enhanced features that
allow for modifications to PMF thermal parameters such as PPT and PPT APU.
This update introduces the necessary driver support to utilize these
capabilities.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/pmf.h | 4 ++++
drivers/platform/x86/amd/pmf/tee-if.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 45b60238d527..1a5a8d70c360 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -93,6 +93,8 @@ struct cookie_header {
#define PMF_POLICY_BIOS_OUTPUT_1 10
#define PMF_POLICY_BIOS_OUTPUT_2 11
#define PMF_POLICY_P3T 38
+#define PMF_POLICY_PMF_PPT 54
+#define PMF_POLICY_PMF_PPT_APU_ONLY 55
#define PMF_POLICY_BIOS_OUTPUT_3 57
#define PMF_POLICY_BIOS_OUTPUT_4 58
#define PMF_POLICY_BIOS_OUTPUT_5 59
@@ -677,6 +679,8 @@ struct pmf_action_table {
u32 stt_skintemp_apu; /* in C */
u32 stt_skintemp_hs2; /* in C */
u32 p3t_limit; /* in mW */
+ u32 pmf_ppt; /* in mW */
+ u32 pmf_ppt_apu_only; /* in mW */
};
/* Input conditions */
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index d3bd12ad036a..870857574f0d 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -147,6 +147,22 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
}
break;
+ case PMF_POLICY_PMF_PPT:
+ if (dev->prev_data->pmf_ppt != val) {
+ amd_pmf_send_cmd(dev, SET_PMF_PPT, false, val, NULL);
+ dev_dbg(dev->dev, "update PMF PPT: %u\n", val);
+ dev->prev_data->pmf_ppt = val;
+ }
+ break;
+
+ case PMF_POLICY_PMF_PPT_APU_ONLY:
+ if (dev->prev_data->pmf_ppt_apu_only != val) {
+ amd_pmf_send_cmd(dev, SET_PMF_PPT_APU_ONLY, false, val, NULL);
+ dev_dbg(dev->dev, "update PMF PPT APU ONLY: %u\n", val);
+ dev->prev_data->pmf_ppt_apu_only = val;
+ }
+ break;
+
case PMF_POLICY_SYSTEM_STATE:
switch (val) {
case 0:
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-30 13:16 ` Ilpo Järvinen
2025-06-17 7:14 ` [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
` (6 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Sanket Goswami
Originally, the 'amd_pmf_get_custom_bios_inputs()' function was written
under the assumption that the BIOS would only send a single pending
request for the driver to process. However, following OEM enablement, it
became clear that multiple pending requests for custom BIOS inputs might
be sent at the same time, a scenario that the current code logic does not
support when it comes to handling multiple custom BIOS inputs.
To address this, the code logic needs to be improved to not only manage
multiple simultaneous custom BIOS inputs but also to ensure it is scalable
for future additional inputs.
Cc: Patil Rajesh Reddy <Patil.Reddy@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/pmf/pmf.h | 12 ++++++------
drivers/platform/x86/amd/pmf/spc.c | 15 ++++++---------
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 1a5a8d70c360..696b170255e0 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -623,14 +623,14 @@ enum ta_slider {
TA_MAX,
};
-enum apmf_smartpc_custom_bios_inputs {
- APMF_SMARTPC_CUSTOM_BIOS_INPUT1,
- APMF_SMARTPC_CUSTOM_BIOS_INPUT2,
+struct amd_pmf_pb_bitmap {
+ const char *name;
+ u32 bit_mask;
};
-enum apmf_preq_smartpc {
- NOTIFY_CUSTOM_BIOS_INPUT1 = 5,
- NOTIFY_CUSTOM_BIOS_INPUT2,
+static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
+ {"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(5)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(6)},
};
enum platform_type {
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 1d90f9382024..e72c11aba31d 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -101,18 +101,15 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
struct ta_pmf_enact_table *in)
{
+ u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
+ int i;
+
if (!pdev->req.pending_req)
return;
- switch (pdev->req.pending_req) {
- case BIT(NOTIFY_CUSTOM_BIOS_INPUT1):
- in->ev_info.bios_input1 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT1];
- break;
- case BIT(NOTIFY_CUSTOM_BIOS_INPUT2):
- in->ev_info.bios_input2 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT2];
- break;
- default:
- dev_dbg(pdev->dev, "Invalid preq for BIOS input: 0x%x\n", pdev->req.pending_req);
+ for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
+ if (pdev->req.pending_req & custom_bios_inputs[i].bit_mask)
+ *bios_inputs[i] = pdev->req.custom_policy[i];
}
/* Clear pending requests after handling */
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-30 13:18 ` Ilpo Järvinen
2025-06-17 7:14 ` [PATCH v2 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
` (5 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Sanket Goswami
The existing amd_pmf driver is limited to supporting just two custom BIOS
inputs. However, with the updates to the latest PMF TA, there's a
requirement to broaden this capacity to handle 10 inputs, aligning with
the TA firmware's capabilities.
The necessary logic should be implemented to facilitate this expansion of
functionality.
Cc: Patil Rajesh Reddy <Patil.Reddy@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/pmf/pmf.h | 12 +++++++++++-
drivers/platform/x86/amd/pmf/spc.c | 13 ++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 696b170255e0..10d658dd66cf 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -631,6 +631,14 @@ struct amd_pmf_pb_bitmap {
static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
{"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(5)},
{"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(6)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT3", BIT(7)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT4", BIT(8)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT5", BIT(9)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT6", BIT(10)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT7", BIT(11)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT8", BIT(12)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT9", BIT(13)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT10", BIT(14)},
};
enum platform_type {
@@ -715,7 +723,9 @@ struct ta_pmf_condition_info {
u32 workload_type;
u32 display_type;
u32 display_state;
- u32 rsvd5[150];
+ u32 rsvd5_1[17];
+ u32 bios_input[8];
+ u32 rsvd5[125];
};
struct ta_pmf_load_policy_table {
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index e72c11aba31d..167b7455d6b0 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -92,6 +92,14 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
laptop_placement_as_str(in->ev_info.device_state));
dev_dbg(dev->dev, "Custom BIOS input1: %u\n", in->ev_info.bios_input1);
dev_dbg(dev->dev, "Custom BIOS input2: %u\n", in->ev_info.bios_input2);
+ dev_dbg(dev->dev, "Custom BIOS input3: %u\n", in->ev_info.bios_input[0]);
+ dev_dbg(dev->dev, "Custom BIOS input4: %u\n", in->ev_info.bios_input[1]);
+ dev_dbg(dev->dev, "Custom BIOS input5: %u\n", in->ev_info.bios_input[2]);
+ dev_dbg(dev->dev, "Custom BIOS input6: %u\n", in->ev_info.bios_input[3]);
+ dev_dbg(dev->dev, "Custom BIOS input7: %u\n", in->ev_info.bios_input[4]);
+ dev_dbg(dev->dev, "Custom BIOS input8: %u\n", in->ev_info.bios_input[5]);
+ dev_dbg(dev->dev, "Custom BIOS input9: %u\n", in->ev_info.bios_input[6]);
+ dev_dbg(dev->dev, "Custom BIOS input10: %u\n", in->ev_info.bios_input[7]);
dev_dbg(dev->dev, "==== TA inputs END ====\n");
}
#else
@@ -101,7 +109,10 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
struct ta_pmf_enact_table *in)
{
- u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
+ u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2,
+ &in->ev_info.bios_input[0], &in->ev_info.bios_input[1], &in->ev_info.bios_input[2],
+ &in->ev_info.bios_input[3], &in->ev_info.bios_input[4], &in->ev_info.bios_input[5],
+ &in->ev_info.bios_input[6], &in->ev_info.bios_input[7]};
int i;
if (!pdev->req.pending_req)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (2 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
The latest PMF TA has been updated with the additional structure members
for internal evaluation. Since this same structure is utilized in the
driver, it also needs to be updated on the driver side. Otherwise, there
will be a mismatch in the byte sizes when copying data from shared memory.
Suggested-by: Yijun Shen <Yijun.Shen@dell.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/pmf.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 10d658dd66cf..b65fd5310fe0 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -751,6 +751,7 @@ struct ta_pmf_enact_table {
struct ta_pmf_action {
u32 action_index;
u32 value;
+ u32 spl_arg;
};
/* Output actions from TA */
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (3 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
Implement a helper function to check if BIOS input notifications are
enabled or disabled.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/acpi.c | 6 ++++++
drivers/platform/x86/amd/pmf/pmf.h | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index f75f7ecd8cd9..4982311ac045 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -161,6 +161,11 @@ int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index)
return !!(pdev->supported_func & BIT(index - 1));
}
+int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev)
+{
+ return !!(pdev->notifications & CUSTOM_BIOS_INPUT_BITS);
+}
+
int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
struct amd_pmf_apts_granular_output *data, u32 apts_idx)
{
@@ -385,6 +390,7 @@ static int apmf_if_verify_interface(struct amd_pmf_dev *pdev)
pdev->pmf_if_version = output.version;
+ pdev->notifications = output.notification_mask;
return 0;
}
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index b65fd5310fe0..4d612ac02ea9 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -118,6 +118,8 @@ struct cookie_header {
#define PMF_IF_V2 2
#define APTS_MAX_STATES 16
+#define CUSTOM_BIOS_INPUT_BITS GENMASK(16, 7)
+
/* APTS PMF BIOS Interface */
struct amd_pmf_apts_output {
@@ -377,6 +379,7 @@ struct amd_pmf_dev {
struct resource *res;
struct apmf_sbios_req_v2 req; /* To get custom bios pending request */
struct mutex cb_mutex;
+ u32 notifications;
};
struct apmf_sps_prop_granular_v2 {
@@ -641,6 +644,19 @@ static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
{"NOTIFY_CUSTOM_BIOS_INPUT10", BIT(14)},
};
+static const struct amd_pmf_pb_bitmap custom_bios_inputs_v1[] __used = {
+ {"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(7)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(8)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT3", BIT(9)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT4", BIT(10)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT5", BIT(11)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT6", BIT(12)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT7", BIT(13)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT8", BIT(14)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT9", BIT(15)},
+ {"NOTIFY_CUSTOM_BIOS_INPUT10", BIT(16)},
+};
+
enum platform_type {
PTYPE_UNKNOWN = 0,
LID_CLOSE,
@@ -793,6 +809,7 @@ int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);
int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer);
int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag);
u32 fixp_q88_fromint(u32 val);
+int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev);
/* SPS Layer */
int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (4 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
The PMF ACPI Specification (APMF) has been revised to version 1.3 to allow
for additional custom BIOS inputs, enabling OEMs to have more precise
thermal management of the system. This update includes adding support to
the driver using the new data structure received from the BIOS through the
existing APMF interfaces.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/acpi.c | 33 +++++++++++++++++++++++++++++
drivers/platform/x86/amd/pmf/pmf.h | 22 +++++++++++++++++++
drivers/platform/x86/amd/pmf/spc.c | 26 ++++++++++++++++++-----
3 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 4982311ac045..4b8529c9bdd4 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -320,6 +320,11 @@ int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v
return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
}
+int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req)
{
return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS,
@@ -338,6 +343,18 @@ static void apmf_event_handler_v2(acpi_handle handle, u32 event, void *data)
dev_err(pmf_dev->dev, "Failed to get v2 SBIOS requests: %d\n", ret);
}
+static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
+{
+ struct amd_pmf_dev *pmf_dev = data;
+ int ret;
+
+ guard(mutex)(&pmf_dev->cb_mutex);
+
+ ret = apmf_get_sbios_requests_v1(pmf_dev, &pmf_dev->req1);
+ if (ret)
+ dev_err(pmf_dev->dev, "Failed to get v1 SBIOS requests: %d\n", ret);
+}
+
static void apmf_event_handler(acpi_handle handle, u32 event, void *data)
{
struct amd_pmf_dev *pmf_dev = data;
@@ -446,6 +463,17 @@ int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
apmf_event_handler(ahandle, 0, pmf_dev);
}
+ if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V1 &&
+ is_apmf_bios_input_notifications_supported(pmf_dev)) {
+ status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
+ apmf_event_handler_v1, pmf_dev);
+ if (ACPI_FAILURE(status)) {
+ dev_err(pmf_dev->dev,
+ "failed to install notify handler v1 for custom BIOS inputs\n");
+ return -ENODEV;
+ }
+ }
+
if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V2) {
status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
apmf_event_handler_v2, pmf_dev);
@@ -508,6 +536,11 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V2)
acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler_v2);
+
+ if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V1 &&
+ is_apmf_bios_input_notifications_supported(pmf_dev)) {
+ acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler_v1);
+ }
}
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 4d612ac02ea9..6f8a275390f9 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -121,6 +121,8 @@ struct cookie_header {
#define CUSTOM_BIOS_INPUT_BITS GENMASK(16, 7)
+#define CUSTOM_BIOS_INPUT_MAX 10
+
/* APTS PMF BIOS Interface */
struct amd_pmf_apts_output {
u16 table_version;
@@ -188,6 +190,24 @@ struct apmf_sbios_req {
u8 skin_temp_hs2;
} __packed;
+/* As per APMF spec 1.3 */
+struct apmf_sbios_req_v1 {
+ u16 size;
+ u32 pending_req;
+ u8 rsvd;
+ u8 cql_event;
+ u8 amt_event;
+ u32 fppt;
+ u32 sppt;
+ u32 sppt_apu_only;
+ u32 spl;
+ u32 stt_min_limit;
+ u8 skin_temp_apu;
+ u8 skin_temp_hs2;
+ u8 enable_cnqf;
+ u32 custom_policy[10];
+} __packed;
+
struct apmf_sbios_req_v2 {
u16 size;
u32 pending_req;
@@ -380,6 +400,7 @@ struct amd_pmf_dev {
struct apmf_sbios_req_v2 req; /* To get custom bios pending request */
struct mutex cb_mutex;
u32 notifications;
+ struct apmf_sbios_req_v1 req1;
};
struct apmf_sps_prop_granular_v2 {
@@ -837,6 +858,7 @@ void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t time_elapsed_ms);
int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req);
+int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req);
int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req);
void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event);
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 167b7455d6b0..7179c3cf6280 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -106,6 +106,18 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
#endif
+static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 *bios_inputs[],
+ const struct amd_pmf_pb_bitmap *inputs, u32 pending_req,
+ const u32 *custom_policy)
+{
+ int i;
+
+ for (i = 0; i < CUSTOM_BIOS_INPUT_MAX; i++) {
+ if (pending_req & inputs[i].bit_mask)
+ *bios_inputs[i] = custom_policy[i];
+ }
+}
+
static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
struct ta_pmf_enact_table *in)
{
@@ -113,18 +125,22 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
&in->ev_info.bios_input[0], &in->ev_info.bios_input[1], &in->ev_info.bios_input[2],
&in->ev_info.bios_input[3], &in->ev_info.bios_input[4], &in->ev_info.bios_input[5],
&in->ev_info.bios_input[6], &in->ev_info.bios_input[7]};
- int i;
- if (!pdev->req.pending_req)
+ if (!(pdev->req.pending_req || pdev->req1.pending_req))
return;
- for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
- if (pdev->req.pending_req & custom_bios_inputs[i].bit_mask)
- *bios_inputs[i] = pdev->req.custom_policy[i];
+ amd_pmf_update_bios_inputs(pdev, bios_inputs, custom_bios_inputs, pdev->req.pending_req,
+ pdev->req.custom_policy);
+
+ if (pdev->smart_pc_enabled && pdev->pmf_if_version == PMF_IF_V1 &&
+ is_apmf_bios_input_notifications_supported(pdev)) {
+ amd_pmf_update_bios_inputs(pdev, bios_inputs, custom_bios_inputs_v1,
+ pdev->req1.pending_req, pdev->req1.custom_policy);
}
/* Clear pending requests after handling */
memset(&pdev->req, 0, sizeof(pdev->req));
+ memset(&pdev->req1, 0, sizeof(pdev->req1));
}
static void amd_pmf_get_c0_residency(u16 *core_res, size_t size, struct ta_pmf_enact_table *in)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (5 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
The current code fails to send multiple BIOS input data to the PMF-TA
for policy condition evaluation. Only the most recent BIOS input data is
properly sent to the PMF-TA, while previous inputs are overwritten with
the zeros.
To address this issue, the BIOS input data should be stored and passed on
to the PMF-TA.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/pmf.h | 5 +++++
drivers/platform/x86/amd/pmf/spc.c | 9 ++++++++-
2 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 6f8a275390f9..e10b8fe68e67 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -355,6 +355,10 @@ enum power_modes_v2 {
POWER_MODE_V2_MAX,
};
+struct pmf_bios_inputs_prev {
+ u32 custom_bios_inputs[CUSTOM_BIOS_INPUT_MAX];
+};
+
struct amd_pmf_dev {
void __iomem *regbase;
void __iomem *smu_virt_addr;
@@ -401,6 +405,7 @@ struct amd_pmf_dev {
struct mutex cb_mutex;
u32 notifications;
struct apmf_sbios_req_v1 req1;
+ struct pmf_bios_inputs_prev cb_prev; /* To preserve custom BIOS inputs */
};
struct apmf_sps_prop_granular_v2 {
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 7179c3cf6280..97dd6025b4dc 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -113,8 +113,10 @@ static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 *bios_input
int i;
for (i = 0; i < CUSTOM_BIOS_INPUT_MAX; i++) {
- if (pending_req & inputs[i].bit_mask)
+ if (pending_req & inputs[i].bit_mask) {
*bios_inputs[i] = custom_policy[i];
+ pdev->cb_prev.custom_bios_inputs[i] = custom_policy[i];
+ }
}
}
@@ -126,6 +128,11 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
&in->ev_info.bios_input[3], &in->ev_info.bios_input[4], &in->ev_info.bios_input[5],
&in->ev_info.bios_input[6], &in->ev_info.bios_input[7]};
+ int i;
+
+ for (i = 0; i < CUSTOM_BIOS_INPUT_MAX; i++)
+ *bios_inputs[i] = pdev->cb_prev.custom_bios_inputs[i];
+
if (!(pdev->req.pending_req || pdev->req1.pending_req))
return;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (6 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
Call the amd_pmf_invoke_cmd_enact() function to manage early pending
requests and their associated custom BIOS inputs. Additionally, add a
return statement for cases of failure.
The PMF driver will adjust power settings according to custom BIOS inputs
after assessing the policy conditions.
Additionally, add a new common routine amd_pmf_handle_early_preq() to
handle early bios pending requests for both v1 and v2 variants.
Cc: Yijun Shen <Yijun.Shen@dell.com>
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/acpi.c | 21 +++++++++++++++++++--
drivers/platform/x86/amd/pmf/pmf.h | 2 ++
drivers/platform/x86/amd/pmf/tee-if.c | 3 ++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 4b8529c9bdd4..7f95a8b6c1a7 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -331,6 +331,15 @@ int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req
req, sizeof(*req));
}
+static void amd_pmf_handle_early_preq(struct amd_pmf_dev *pdev)
+{
+ if (!pdev->cb_flag)
+ return;
+
+ amd_pmf_invoke_cmd_enact(pdev);
+ pdev->cb_flag = false;
+}
+
static void apmf_event_handler_v2(acpi_handle handle, u32 event, void *data)
{
struct amd_pmf_dev *pmf_dev = data;
@@ -339,8 +348,12 @@ static void apmf_event_handler_v2(acpi_handle handle, u32 event, void *data)
guard(mutex)(&pmf_dev->cb_mutex);
ret = apmf_get_sbios_requests_v2(pmf_dev, &pmf_dev->req);
- if (ret)
+ if (ret) {
dev_err(pmf_dev->dev, "Failed to get v2 SBIOS requests: %d\n", ret);
+ return;
+ }
+
+ amd_pmf_handle_early_preq(pmf_dev);
}
static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
@@ -351,8 +364,12 @@ static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
guard(mutex)(&pmf_dev->cb_mutex);
ret = apmf_get_sbios_requests_v1(pmf_dev, &pmf_dev->req1);
- if (ret)
+ if (ret) {
dev_err(pmf_dev->dev, "Failed to get v1 SBIOS requests: %d\n", ret);
+ return;
+ }
+
+ amd_pmf_handle_early_preq(pmf_dev);
}
static void apmf_event_handler(acpi_handle handle, u32 event, void *data)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index e10b8fe68e67..9f49ac38776e 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -406,6 +406,7 @@ struct amd_pmf_dev {
u32 notifications;
struct apmf_sbios_req_v1 req1;
struct pmf_bios_inputs_prev cb_prev; /* To preserve custom BIOS inputs */
+ bool cb_flag; /* To handle first custom BIOS input */
};
struct apmf_sps_prop_granular_v2 {
@@ -887,5 +888,6 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq
/* Smart PC - TA interfaces */
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
+int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev);
#endif /* PMF_H */
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 870857574f0d..178cf090da8c 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -225,7 +225,7 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
}
}
-static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
+int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
{
struct ta_pmf_shared_memory *ta_sm = NULL;
struct ta_pmf_enact_result *out = NULL;
@@ -582,6 +582,7 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
switch (ret) {
case TA_PMF_TYPE_SUCCESS:
status = true;
+ dev->cb_flag = true;
break;
case TA_ERROR_CRYPTO_INVALID_PARAM:
case TA_ERROR_CRYPTO_BIN_TOO_LARGE:
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (7 preceding siblings ...)
2025-06-17 7:14 ` [PATCH v2 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
@ 2025-06-17 7:14 ` Shyam Sundar S K
8 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:14 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
This patch adds debug logging capabilities to monitor early pending
requests and their associated custom BIOS inputs during runtime.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/acpi.c | 4 ++++
drivers/platform/x86/amd/pmf/spc.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 7f95a8b6c1a7..edb785325c58 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -353,6 +353,8 @@ static void apmf_event_handler_v2(acpi_handle handle, u32 event, void *data)
return;
}
+ dev_dbg(pmf_dev->dev, "Pending request (preq): 0x%x\n", pmf_dev->req.pending_req);
+
amd_pmf_handle_early_preq(pmf_dev);
}
@@ -369,6 +371,8 @@ static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
return;
}
+ dev_dbg(pmf_dev->dev, "Pending request (preq1): 0x%x\n", pmf_dev->req1.pending_req);
+
amd_pmf_handle_early_preq(pmf_dev);
}
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 97dd6025b4dc..1a165df5142e 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -117,6 +117,7 @@ static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 *bios_input
*bios_inputs[i] = custom_policy[i];
pdev->cb_prev.custom_bios_inputs[i] = custom_policy[i];
}
+ dev_dbg(pdev->dev, "Custom BIOS Input[%d]: %u\n", i, *bios_inputs[i]);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
2025-06-17 7:14 ` [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
@ 2025-06-30 13:16 ` Ilpo Järvinen
2025-07-23 6:48 ` Shyam Sundar S K
0 siblings, 1 reply; 13+ messages in thread
From: Ilpo Järvinen @ 2025-06-30 13:16 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen, Sanket Goswami
On Tue, 17 Jun 2025, Shyam Sundar S K wrote:
> Originally, the 'amd_pmf_get_custom_bios_inputs()' function was written
> under the assumption that the BIOS would only send a single pending
> request for the driver to process. However, following OEM enablement, it
> became clear that multiple pending requests for custom BIOS inputs might
> be sent at the same time, a scenario that the current code logic does not
> support when it comes to handling multiple custom BIOS inputs.
>
> To address this, the code logic needs to be improved to not only manage
> multiple simultaneous custom BIOS inputs but also to ensure it is scalable
> for future additional inputs.
>
> Cc: Patil Rajesh Reddy <Patil.Reddy@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/pmf/pmf.h | 12 ++++++------
> drivers/platform/x86/amd/pmf/spc.c | 15 ++++++---------
> 2 files changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 1a5a8d70c360..696b170255e0 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -623,14 +623,14 @@ enum ta_slider {
> TA_MAX,
> };
>
> -enum apmf_smartpc_custom_bios_inputs {
> - APMF_SMARTPC_CUSTOM_BIOS_INPUT1,
> - APMF_SMARTPC_CUSTOM_BIOS_INPUT2,
> +struct amd_pmf_pb_bitmap {
> + const char *name;
> + u32 bit_mask;
> };
>
> -enum apmf_preq_smartpc {
> - NOTIFY_CUSTOM_BIOS_INPUT1 = 5,
> - NOTIFY_CUSTOM_BIOS_INPUT2,
> +static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
> + {"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(5)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(6)},
> };
>
> enum platform_type {
> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index 1d90f9382024..e72c11aba31d 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -101,18 +101,15 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
> static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
> struct ta_pmf_enact_table *in)
> {
> + u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
> + int i;
> +
> if (!pdev->req.pending_req)
> return;
>
> - switch (pdev->req.pending_req) {
> - case BIT(NOTIFY_CUSTOM_BIOS_INPUT1):
> - in->ev_info.bios_input1 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT1];
> - break;
> - case BIT(NOTIFY_CUSTOM_BIOS_INPUT2):
> - in->ev_info.bios_input2 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT2];
> - break;
> - default:
> - dev_dbg(pdev->dev, "Invalid preq for BIOS input: 0x%x\n", pdev->req.pending_req);
> + for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
> + if (pdev->req.pending_req & custom_bios_inputs[i].bit_mask)
> + *bios_inputs[i] = pdev->req.custom_policy[i];
Hi,
After seeing this version, I think there's better way to solve the
discontinous layout problem.
Could you instead add a helper amd_pmf_set_ta_bios_input() or something
along those lines. With that, you don't need to add that local array at
all. I'd also convert bios_input1/2 to array so both are arrays (I
understand you cannot change the layout and merge the arrays). The
helper can then pick which of the arrays it should set to based on the
index.
And briefly mention in the helper's function comment, that we need to do
this because the layout does not have continuous area for bios inputs.
That seems simpler approach than this local array approach.
--
i.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
2025-06-17 7:14 ` [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-06-30 13:18 ` Ilpo Järvinen
0 siblings, 0 replies; 13+ messages in thread
From: Ilpo Järvinen @ 2025-06-30 13:18 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen, Sanket Goswami
On Tue, 17 Jun 2025, Shyam Sundar S K wrote:
> The existing amd_pmf driver is limited to supporting just two custom BIOS
> inputs. However, with the updates to the latest PMF TA, there's a
> requirement to broaden this capacity to handle 10 inputs, aligning with
> the TA firmware's capabilities.
>
> The necessary logic should be implemented to facilitate this expansion of
> functionality.
>
> Cc: Patil Rajesh Reddy <Patil.Reddy@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/pmf/pmf.h | 12 +++++++++++-
> drivers/platform/x86/amd/pmf/spc.c | 13 ++++++++++++-
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 696b170255e0..10d658dd66cf 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -631,6 +631,14 @@ struct amd_pmf_pb_bitmap {
> static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
> {"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(5)},
> {"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(6)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT3", BIT(7)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT4", BIT(8)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT5", BIT(9)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT6", BIT(10)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT7", BIT(11)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT8", BIT(12)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT9", BIT(13)},
> + {"NOTIFY_CUSTOM_BIOS_INPUT10", BIT(14)},
> };
>
> enum platform_type {
> @@ -715,7 +723,9 @@ struct ta_pmf_condition_info {
> u32 workload_type;
> u32 display_type;
> u32 display_state;
> - u32 rsvd5[150];
> + u32 rsvd5_1[17];
> + u32 bios_input[8];
> + u32 rsvd5[125];
> };
>
> struct ta_pmf_load_policy_table {
> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index e72c11aba31d..167b7455d6b0 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -92,6 +92,14 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
> laptop_placement_as_str(in->ev_info.device_state));
> dev_dbg(dev->dev, "Custom BIOS input1: %u\n", in->ev_info.bios_input1);
> dev_dbg(dev->dev, "Custom BIOS input2: %u\n", in->ev_info.bios_input2);
> + dev_dbg(dev->dev, "Custom BIOS input3: %u\n", in->ev_info.bios_input[0]);
> + dev_dbg(dev->dev, "Custom BIOS input4: %u\n", in->ev_info.bios_input[1]);
> + dev_dbg(dev->dev, "Custom BIOS input5: %u\n", in->ev_info.bios_input[2]);
> + dev_dbg(dev->dev, "Custom BIOS input6: %u\n", in->ev_info.bios_input[3]);
> + dev_dbg(dev->dev, "Custom BIOS input7: %u\n", in->ev_info.bios_input[4]);
> + dev_dbg(dev->dev, "Custom BIOS input8: %u\n", in->ev_info.bios_input[5]);
> + dev_dbg(dev->dev, "Custom BIOS input9: %u\n", in->ev_info.bios_input[6]);
> + dev_dbg(dev->dev, "Custom BIOS input10: %u\n", in->ev_info.bios_input[7]);
You know, this can use loop. :-D
If you do a similar getter that abstracts the discontinuity from the
caller as I suggested for the setter side in the other patch, this too can
become a single loop.
> dev_dbg(dev->dev, "==== TA inputs END ====\n");
> }
> #else
> @@ -101,7 +109,10 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
> static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
> struct ta_pmf_enact_table *in)
> {
> - u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
> + u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2,
> + &in->ev_info.bios_input[0], &in->ev_info.bios_input[1], &in->ev_info.bios_input[2],
> + &in->ev_info.bios_input[3], &in->ev_info.bios_input[4], &in->ev_info.bios_input[5],
> + &in->ev_info.bios_input[6], &in->ev_info.bios_input[7]};
> int i;
>
> if (!pdev->req.pending_req)
>
--
i.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
2025-06-30 13:16 ` Ilpo Järvinen
@ 2025-07-23 6:48 ` Shyam Sundar S K
0 siblings, 0 replies; 13+ messages in thread
From: Shyam Sundar S K @ 2025-07-23 6:48 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen, Sanket Goswami
Hi Ilpo,
On 6/30/2025 18:46, Ilpo Järvinen wrote:
> On Tue, 17 Jun 2025, Shyam Sundar S K wrote:
>
>> Originally, the 'amd_pmf_get_custom_bios_inputs()' function was written
>> under the assumption that the BIOS would only send a single pending
>> request for the driver to process. However, following OEM enablement, it
>> became clear that multiple pending requests for custom BIOS inputs might
>> be sent at the same time, a scenario that the current code logic does not
>> support when it comes to handling multiple custom BIOS inputs.
>>
>> To address this, the code logic needs to be improved to not only manage
>> multiple simultaneous custom BIOS inputs but also to ensure it is scalable
>> for future additional inputs.
>>
>> Cc: Patil Rajesh Reddy <Patil.Reddy@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/pmf/pmf.h | 12 ++++++------
>> drivers/platform/x86/amd/pmf/spc.c | 15 ++++++---------
>> 2 files changed, 12 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
>> index 1a5a8d70c360..696b170255e0 100644
>> --- a/drivers/platform/x86/amd/pmf/pmf.h
>> +++ b/drivers/platform/x86/amd/pmf/pmf.h
>> @@ -623,14 +623,14 @@ enum ta_slider {
>> TA_MAX,
>> };
>>
>> -enum apmf_smartpc_custom_bios_inputs {
>> - APMF_SMARTPC_CUSTOM_BIOS_INPUT1,
>> - APMF_SMARTPC_CUSTOM_BIOS_INPUT2,
>> +struct amd_pmf_pb_bitmap {
>> + const char *name;
>> + u32 bit_mask;
>> };
>>
>> -enum apmf_preq_smartpc {
>> - NOTIFY_CUSTOM_BIOS_INPUT1 = 5,
>> - NOTIFY_CUSTOM_BIOS_INPUT2,
>> +static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
>> + {"NOTIFY_CUSTOM_BIOS_INPUT1", BIT(5)},
>> + {"NOTIFY_CUSTOM_BIOS_INPUT2", BIT(6)},
>> };
>>
>> enum platform_type {
>> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
>> index 1d90f9382024..e72c11aba31d 100644
>> --- a/drivers/platform/x86/amd/pmf/spc.c
>> +++ b/drivers/platform/x86/amd/pmf/spc.c
>> @@ -101,18 +101,15 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
>> static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
>> struct ta_pmf_enact_table *in)
>> {
>> + u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
>> + int i;
>> +
>> if (!pdev->req.pending_req)
>> return;
>>
>> - switch (pdev->req.pending_req) {
>> - case BIT(NOTIFY_CUSTOM_BIOS_INPUT1):
>> - in->ev_info.bios_input1 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT1];
>> - break;
>> - case BIT(NOTIFY_CUSTOM_BIOS_INPUT2):
>> - in->ev_info.bios_input2 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT2];
>> - break;
>> - default:
>> - dev_dbg(pdev->dev, "Invalid preq for BIOS input: 0x%x\n", pdev->req.pending_req);
>> + for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
>> + if (pdev->req.pending_req & custom_bios_inputs[i].bit_mask)
>> + *bios_inputs[i] = pdev->req.custom_policy[i];
>
> Hi,
>
> After seeing this version, I think there's better way to solve the
> discontinous layout problem.
>
> Could you instead add a helper amd_pmf_set_ta_bios_input() or something
> along those lines. With that, you don't need to add that local array at
> all. I'd also convert bios_input1/2 to array so both are arrays (I
> understand you cannot change the layout and merge the arrays). The
> helper can then pick which of the arrays it should set to based on the
> index.
>
> And briefly mention in the helper's function comment, that we need to do
> this because the layout does not have continuous area for bios inputs.
>
> That seems simpler approach than this local array approach.
>
Thank you for the feedback and apologies for the long delay in sending
a new version. I have sent out v3, please have a look.
Thanks,
Shyam
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-07-23 6:48 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
2025-06-30 13:16 ` Ilpo Järvinen
2025-07-23 6:48 ` Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
2025-06-30 13:18 ` Ilpo Järvinen
2025-06-17 7:14 ` [PATCH v2 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-06-17 7:14 ` [PATCH v2 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.