* [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
@ 2025-08-20 11:50 Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 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; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 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 30359c239ba8 ("platform/x86: int3472: Increase ov08x40 handshake GPIO delay to 45 ms")'
v4:
-----
- Rephrase commit messages
- Simply the code with loop + helper functions
- rename variable names for consistency
v3:
-----
- Add amd_pmf_set_ta_custom_bios_input() and amd_pmf_get_ta_custom_bios_input() to simply handling
- Address other remarks by Ilpo on v2.
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 | 76 ++++++++++++++++++++++----
drivers/platform/x86/amd/pmf/spc.c | 77 ++++++++++++++++++++++-----
drivers/platform/x86/amd/pmf/tee-if.c | 22 +++++++-
4 files changed, 213 insertions(+), 24 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Tested-by: Yijun Shen <Yijun.Shen@Dell.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.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 4f626ebcb619..b29f92183b2a 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] 12+ messages in thread
* [PATCH v4 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Tested-by: Yijun Shen <Yijun.Shen@Dell.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmf/pmf.h | 15 +++++-----
drivers/platform/x86/amd/pmf/spc.c | 48 +++++++++++++++++++++++-------
2 files changed, 44 insertions(+), 19 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 1a5a8d70c360..79defe2c91e6 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 {
@@ -690,8 +690,7 @@ struct ta_pmf_condition_info {
u32 power_slider;
u32 lid_state;
bool user_present;
- u32 bios_input1;
- u32 bios_input2;
+ u32 bios_input_1[2];
u32 monitor_count;
u32 rsvd2[2];
u32 bat_design;
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 1d90f9382024..869b4134513f 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -70,8 +70,20 @@ static const char *ta_slider_as_str(unsigned int state)
}
}
+static u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
+{
+ switch (index) {
+ case 0 ... 1:
+ return in->ev_info.bios_input_1[index];
+ default:
+ return 0;
+ }
+}
+
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{
+ int i;
+
dev_dbg(dev->dev, "==== TA inputs START ====\n");
dev_dbg(dev->dev, "Slider State: %s\n", ta_slider_as_str(in->ev_info.power_slider));
dev_dbg(dev->dev, "Power Source: %s\n", amd_pmf_source_as_str(in->ev_info.power_source));
@@ -90,29 +102,43 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
dev_dbg(dev->dev, "Platform type: %s\n", platform_type_as_str(in->ev_info.platform_type));
dev_dbg(dev->dev, "Laptop placement: %s\n",
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);
+ for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
+ dev_dbg(dev->dev, "Custom BIOS input%d: %u\n", i + 1,
+ amd_pmf_get_ta_custom_bios_inputs(in, i));
dev_dbg(dev->dev, "==== TA inputs END ====\n");
}
#else
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
#endif
+/*
+ * This helper function sets the appropriate BIOS input value in the TA enact
+ * table based on the provided index. We need this approach because the custom
+ * BIOS input array is not continuous, due to the existing TA structure layout.
+ */
+static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int index, u32 value)
+{
+ switch (index) {
+ case 0 ... 1:
+ in->ev_info.bios_input_1[index] = value;
+ break;
+ default:
+ return;
+ }
+}
+
static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
struct ta_pmf_enact_table *in)
{
+ unsigned 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))
+ continue;
+ amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
}
/* Clear pending requests after handling */
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 | 5 +++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 79defe2c91e6..2fcdc2493552 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 {
@@ -714,7 +722,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_2[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 869b4134513f..06b7760b2a8b 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -75,6 +75,8 @@ static u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int
switch (index) {
case 0 ... 1:
return in->ev_info.bios_input_1[index];
+ case 2 ... 9:
+ return in->ev_info.bios_input_2[index - 2];
default:
return 0;
}
@@ -122,6 +124,9 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
case 0 ... 1:
in->ev_info.bios_input_1[index] = value;
break;
+ case 2 ... 9:
+ in->ev_info.bios_input_2[index - 2] = value;
+ break;
default:
return;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (2 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 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; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 2fcdc2493552..f5e874b10f0f 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -750,6 +750,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] 12+ messages in thread
* [PATCH v4 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (3 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-28 15:36 ` Ilpo Järvinen
2025-08-20 11:50 ` [PATCH v4 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, 1 reply; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 f5e874b10f0f..b705461a6ff8 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,
@@ -792,6 +808,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] 12+ messages in thread
* [PATCH v4 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (4 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-28 15:35 ` Ilpo Järvinen
2025-08-20 11:50 ` [PATCH v4 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
` (2 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 | 20 +++++++++++++++++
drivers/platform/x86/amd/pmf/spc.c | 29 +++++++++++++++++++------
3 files changed, 75 insertions(+), 7 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 b705461a6ff8..54bd33104ded 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -188,6 +188,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 +398,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 {
@@ -836,6 +855,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 06b7760b2a8b..f50cfd37b480 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -132,22 +132,37 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
}
}
-static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
- struct ta_pmf_enact_table *in)
+static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 pending_req,
+ const struct amd_pmf_pb_bitmap *inputs,
+ const u32 *custom_policy, struct ta_pmf_enact_table *in)
{
- unsigned int i;
-
- if (!pdev->req.pending_req)
- return;
+ int i;
for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
- if (!(pdev->req.pending_req & custom_bios_inputs[i].bit_mask))
+ if (!(pending_req & inputs[i].bit_mask))
continue;
amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
}
+}
+
+static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
+ struct ta_pmf_enact_table *in)
+{
+ if (!(pdev->req.pending_req || pdev->req1.pending_req))
+ return;
+
+ 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, pdev->req1.pending_req, custom_bios_inputs_v1,
+ pdev->req1.custom_policy, in);
+ } else {
+ amd_pmf_update_bios_inputs(pdev, pdev->req.pending_req, custom_bios_inputs,
+ pdev->req.custom_policy, in);
+ }
/* 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] 12+ messages in thread
* [PATCH v4 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (5 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 54bd33104ded..52538adba5e5 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -353,6 +353,10 @@ enum power_modes_v2 {
POWER_MODE_V2_MAX,
};
+struct pmf_bios_inputs_prev {
+ u32 custom_bios_inputs[10];
+};
+
struct amd_pmf_dev {
void __iomem *regbase;
void __iomem *smu_virt_addr;
@@ -399,6 +403,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 f50cfd37b480..463683860db9 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -142,12 +142,18 @@ static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 pending_req
if (!(pending_req & inputs[i].bit_mask))
continue;
amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
+ pdev->cb_prev.custom_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)
{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
+ amd_pmf_set_ta_custom_bios_input(in, 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] 12+ messages in thread
* [PATCH v4 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (6 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
Call the amd_pmf_invoke_cmd_enact() function to manage early pending
requests and their associated custom BIOS inputs. 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.
Also, add a new common routine amd_pmf_handle_early_preq() to handle early
BIOS pending requests for both v1 and v2 variants.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 | 6 ++++--
3 files changed, 25 insertions(+), 4 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 52538adba5e5..0787077c4896 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -404,6 +404,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 {
@@ -884,5 +885,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 b29f92183b2a..6e8116bef4f6 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;
@@ -577,8 +577,10 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
ret = amd_pmf_start_policy_engine(dev);
dev_dbg(dev->dev, "start policy engine ret: %d\n", ret);
status = ret == TA_PMF_TYPE_SUCCESS;
- if (status)
+ if (status) {
+ dev->cb_flag = true;
break;
+ }
amd_pmf_tee_deinit(dev);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (7 preceding siblings ...)
2025-08-20 11:50 ` [PATCH v4 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
@ 2025-08-20 11:50 ` Shyam Sundar S K
8 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2025-08-20 11:50 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K, Yijun Shen
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>
Tested-by: Yijun Shen <Yijun.Shen@Dell.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 463683860db9..63e64e8658ec 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -143,6 +143,7 @@ static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 pending_req
continue;
amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
pdev->cb_prev.custom_bios_inputs[i] = custom_policy[i];
+ dev_dbg(pdev->dev, "Custom BIOS Input[%d]: %u\n", i, custom_policy[i]);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
2025-08-20 11:50 ` [PATCH v4 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-08-28 15:35 ` Ilpo Järvinen
0 siblings, 0 replies; 12+ messages in thread
From: Ilpo Järvinen @ 2025-08-28 15:35 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun Shen, Yijun Shen
On Wed, 20 Aug 2025, Shyam Sundar S K wrote:
> 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>
> Tested-by: Yijun Shen <Yijun.Shen@Dell.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 | 20 +++++++++++++++++
> drivers/platform/x86/amd/pmf/spc.c | 29 +++++++++++++++++++------
> 3 files changed, 75 insertions(+), 7 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);
> + }
There's quite much overlap here and in the other similar case above so I
think the better structure would be:
if (!pmf_dev->smart_pc_enabled)
return;
switch (pmf_dev->pmf_if_version) {
case PMF_IF_V1:
if (!is_apmf_bios_input_notifications_supported(pmf_dev))
break;
fallthough;
case PMF_IF_V2:
acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY,
apmf_event_handlers[pmf_dev->pmf_if_version]);
break;
default:
break;
}
(While the v2 conversion could be made in own patch, I think these seem
isolated enough that diff should be clean enough without a separate
conversion patch.)
> }
>
> 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 b705461a6ff8..54bd33104ded 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -188,6 +188,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 +398,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 {
> @@ -836,6 +855,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 06b7760b2a8b..f50cfd37b480 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -132,22 +132,37 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
> }
> }
>
> -static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
> - struct ta_pmf_enact_table *in)
> +static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, u32 pending_req,
> + const struct amd_pmf_pb_bitmap *inputs,
> + const u32 *custom_policy, struct ta_pmf_enact_table *in)
> {
> - unsigned int i;
> -
> - if (!pdev->req.pending_req)
> - return;
> + int i;
Why this change? Generally, it's preferred to have 0...n counting for loop
iterators as unsigned int.
>
> for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
> - if (!(pdev->req.pending_req & custom_bios_inputs[i].bit_mask))
> + if (!(pending_req & inputs[i].bit_mask))
> continue;
> amd_pmf_set_ta_custom_bios_input(in, i, pdev->req.custom_policy[i]);
> }
> +}
> +
> +static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
> + struct ta_pmf_enact_table *in)
> +{
> + if (!(pdev->req.pending_req || pdev->req1.pending_req))
> + return;
> +
> + 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, pdev->req1.pending_req, custom_bios_inputs_v1,
> + pdev->req1.custom_policy, in);
> + } else {
Here you're not checking PMF_IF_V2, is that omission intentional?
This too would be better as switch.
> + amd_pmf_update_bios_inputs(pdev, pdev->req.pending_req, custom_bios_inputs,
> + pdev->req.custom_policy, in);
> + }
>
> /* 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)
>
--
i.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
2025-08-20 11:50 ` [PATCH v4 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-08-28 15:36 ` Ilpo Järvinen
0 siblings, 0 replies; 12+ messages in thread
From: Ilpo Järvinen @ 2025-08-28 15:36 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun Shen, Yijun Shen
On Wed, 20 Aug 2025, Shyam Sundar S K wrote:
> 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>
> Tested-by: Yijun Shen <Yijun.Shen@Dell.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 f5e874b10f0f..b705461a6ff8 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)
> +
Extra empty line.
> /* 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,
> @@ -792,6 +808,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);
>
--
i.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-08-28 15:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 11:50 [PATCH v4 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
2025-08-28 15:36 ` Ilpo Järvinen
2025-08-20 11:50 ` [PATCH v4 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
2025-08-28 15:35 ` Ilpo Järvinen
2025-08-20 11:50 ` [PATCH v4 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-08-20 11:50 ` [PATCH v4 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).