* [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
@ 2025-05-09 7:26 Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
` (11 more replies)
0 siblings, 12 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 d430124bac58 ("platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices")'
Shyam Sundar S K (10):
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: Use amd_pmf_update_bios_inputs() helper
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 | 60 +++++++++++++++++++-
drivers/platform/x86/amd/pmf/pmf.h | 80 ++++++++++++++++++++++++---
drivers/platform/x86/amd/pmf/spc.c | 51 +++++++++++++----
drivers/platform/x86/amd/pmf/tee-if.c | 19 ++++++-
4 files changed, 191 insertions(+), 19 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-06-10 16:12 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 02/10] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
` (10 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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.
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 e6bdee68ccf3..4665e68e5c07 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 a1e43873a07b..679c5bf5faca 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -145,6 +145,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] 19+ messages in thread
* [PATCH 02/10] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
` (9 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 4665e68e5c07..eceed2348165 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] 19+ messages in thread
* [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 02/10] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-06-10 15:58 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 04/10] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
` (8 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 | 19 ++++++++++++++++++-
drivers/platform/x86/amd/pmf/spc.c | 13 ++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index eceed2348165..17b46085726e 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,16 @@ struct ta_pmf_condition_info {
u32 workload_type;
u32 display_type;
u32 display_state;
- u32 rsvd5[150];
+ u32 rsvd5_1[17];
+ u32 bios_input3;
+ u32 bios_input4;
+ u32 bios_input5;
+ u32 bios_input6;
+ u32 bios_input7;
+ u32 bios_input8;
+ u32 bios_input9;
+ u32 bios_input10;
+ 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..dfb8036671a0 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_input3);
+ dev_dbg(dev->dev, "Custom BIOS input4: %u\n", in->ev_info.bios_input4);
+ dev_dbg(dev->dev, "Custom BIOS input5: %u\n", in->ev_info.bios_input5);
+ dev_dbg(dev->dev, "Custom BIOS input6: %u\n", in->ev_info.bios_input6);
+ dev_dbg(dev->dev, "Custom BIOS input7: %u\n", in->ev_info.bios_input7);
+ dev_dbg(dev->dev, "Custom BIOS input8: %u\n", in->ev_info.bios_input8);
+ dev_dbg(dev->dev, "Custom BIOS input9: %u\n", in->ev_info.bios_input9);
+ dev_dbg(dev->dev, "Custom BIOS input10: %u\n", in->ev_info.bios_input10);
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_input3, &in->ev_info.bios_input4, &in->ev_info.bios_input5,
+ &in->ev_info.bios_input6, &in->ev_info.bios_input7, &in->ev_info.bios_input8,
+ &in->ev_info.bios_input9, &in->ev_info.bios_input10};
int i;
if (!pdev->req.pending_req)
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/10] platform/x86/amd/pmf: Update ta_pmf_action structure member
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (2 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
` (7 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 17b46085726e..27458a7c221b 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -758,6 +758,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] 19+ messages in thread
* [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (3 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 04/10] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-06-10 16:01 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 06/10] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
` (6 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 | 7 +++++++
drivers/platform/x86/amd/pmf/pmf.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index f75f7ecd8cd9..ab63582c9d0b 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 & GENMASK(16, 7));
+}
+
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,8 @@ 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 27458a7c221b..2deae43aca63 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -377,6 +377,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 {
@@ -799,6 +800,7 @@ int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
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);
+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] 19+ messages in thread
* [PATCH 06/10] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (4 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper Shyam Sundar S K
` (5 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 | 35 +++++++++++++++++++++++++++++
drivers/platform/x86/amd/pmf/spc.c | 21 ++++++++++++++++-
3 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index ab63582c9d0b..1521988c1002 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;
@@ -447,6 +464,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);
@@ -509,6 +537,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 2deae43aca63..de095b434d32 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -119,6 +119,8 @@ struct cookie_header {
#define APTS_MAX_STATES 16
+#define CUSTOM_BIOS_INPUT_MAX 10
+
/* APTS PMF BIOS Interface */
struct amd_pmf_apts_output {
u16 table_version;
@@ -186,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;
@@ -378,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 {
@@ -642,6 +663,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,
@@ -828,6 +862,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 dfb8036671a0..be6ffb823efc 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)
{
@@ -115,7 +127,7 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
&in->ev_info.bios_input9, &in->ev_info.bios_input10};
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++) {
@@ -123,8 +135,15 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
*bios_inputs[i] = pdev->req.custom_policy[i];
}
+ 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] 19+ messages in thread
* [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (5 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 06/10] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-06-10 15:56 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 08/10] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
` (4 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen,
Shyam Sundar S K
Use amd_pmf_update_bios_inputs() helper function to update the custom
BIOS inputs.
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/spc.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index be6ffb823efc..0cd50d342b11 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -125,15 +125,12 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
&in->ev_info.bios_input3, &in->ev_info.bios_input4, &in->ev_info.bios_input5,
&in->ev_info.bios_input6, &in->ev_info.bios_input7, &in->ev_info.bios_input8,
&in->ev_info.bios_input9, &in->ev_info.bios_input10};
- int i;
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)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/10] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (6 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
` (3 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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.
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/pmf.h | 5 +++++
drivers/platform/x86/amd/pmf/spc.c | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index de095b434d32..d9e6467be852 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[CUSTOM_BIOS_INPUT_MAX];
+};
+
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 0cd50d342b11..8fd745598ad3 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];
+ }
}
}
@@ -125,6 +127,10 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
&in->ev_info.bios_input3, &in->ev_info.bios_input4, &in->ev_info.bios_input5,
&in->ev_info.bios_input6, &in->ev_info.bios_input7, &in->ev_info.bios_input8,
&in->ev_info.bios_input9, &in->ev_info.bios_input10};
+ 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] 19+ messages in thread
* [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (7 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 08/10] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-06-10 16:19 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 10/10] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
` (2 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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.
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 | 18 ++++++++++++++++--
drivers/platform/x86/amd/pmf/pmf.h | 2 ++
drivers/platform/x86/amd/pmf/tee-if.c | 3 ++-
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 1521988c1002..a3319ac89fd1 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -339,8 +339,15 @@ 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;
+ }
+
+ if (pmf_dev->cb_flag) {
+ amd_pmf_invoke_cmd_enact(pmf_dev);
+ pmf_dev->cb_flag = false;
+ }
}
static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
@@ -351,8 +358,15 @@ 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;
+ }
+
+ if (pmf_dev->cb_flag) {
+ amd_pmf_invoke_cmd_enact(pmf_dev);
+ pmf_dev->cb_flag = false;
+ }
}
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 d9e6467be852..71cc94bdbd32 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 {
@@ -891,5 +892,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 679c5bf5faca..249683509635 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -223,7 +223,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;
@@ -559,6 +559,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] 19+ messages in thread
* [PATCH 10/10] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (8 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
@ 2025-05-09 7:26 ` Shyam Sundar S K
2025-05-12 8:13 ` [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shen, Yijun
2025-05-12 17:26 ` Mario Limonciello
11 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-05-09 7:26 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 a3319ac89fd1..c1a5921e6ac2 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -344,6 +344,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);
+
if (pmf_dev->cb_flag) {
amd_pmf_invoke_cmd_enact(pmf_dev);
pmf_dev->cb_flag = false;
@@ -363,6 +365,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);
+
if (pmf_dev->cb_flag) {
amd_pmf_invoke_cmd_enact(pmf_dev);
pmf_dev->cb_flag = false;
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 8fd745598ad3..3cb93ab9b673 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] 19+ messages in thread
* RE: [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (9 preceding siblings ...)
2025-05-09 7:26 ` [PATCH 10/10] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
@ 2025-05-12 8:13 ` Shen, Yijun
2025-05-12 17:26 ` Mario Limonciello
11 siblings, 0 replies; 19+ messages in thread
From: Shen, Yijun @ 2025-05-12 8:13 UTC (permalink / raw)
To: Shyam Sundar S K, hdegoede@redhat.com,
ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org, Patil.Reddy@amd.com,
mario.limonciello@amd.com
Internal Use - Confidential
> -----Original Message-----
> From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Sent: Friday, May 9, 2025 3:27 PM
> To: hdegoede@redhat.com; ilpo.jarvinen@linux.intel.com
> Cc: platform-driver-x86@vger.kernel.org; Patil.Reddy@amd.com;
> mario.limonciello@amd.com; Shen, Yijun <Yijun_Shen@Dell.com>; Shyam
> Sundar S K <Shyam-sundar.S-k@amd.com>
> Subject: [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS
> Input Handling
>
>
> [EXTERNAL EMAIL]
>
> 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 d430124bac58
> ("platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices")'
Verified this patch series on the issued system.
Tested-By: Yijun Shen <Yijun.Shen@Dell.com>
>
> Shyam Sundar S K (10):
> 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: Use amd_pmf_update_bios_inputs() helper
> 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 | 60 +++++++++++++++++++-
> drivers/platform/x86/amd/pmf/pmf.h | 80 ++++++++++++++++++++++++---
> drivers/platform/x86/amd/pmf/spc.c | 51 +++++++++++++----
> drivers/platform/x86/amd/pmf/tee-if.c | 19 ++++++-
> 4 files changed, 191 insertions(+), 19 deletions(-)
>
> --
> 2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
` (10 preceding siblings ...)
2025-05-12 8:13 ` [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shen, Yijun
@ 2025-05-12 17:26 ` Mario Limonciello
11 siblings, 0 replies; 19+ messages in thread
From: Mario Limonciello @ 2025-05-12 17:26 UTC (permalink / raw)
To: Shyam Sundar S K, hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, Patil.Reddy, Yijun.Shen
On 5/9/2025 2:26 AM, Shyam Sundar S K wrote:
> 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 d430124bac58 ("platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices")'
>
> Shyam Sundar S K (10):
> 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: Use amd_pmf_update_bios_inputs() helper
> 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 | 60 +++++++++++++++++++-
> drivers/platform/x86/amd/pmf/pmf.h | 80 ++++++++++++++++++++++++---
> drivers/platform/x86/amd/pmf/spc.c | 51 +++++++++++++----
> drivers/platform/x86/amd/pmf/tee-if.c | 19 ++++++-
> 4 files changed, 191 insertions(+), 19 deletions(-)
>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper
2025-05-09 7:26 ` [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper Shyam Sundar S K
@ 2025-06-10 15:56 ` Ilpo Järvinen
0 siblings, 0 replies; 19+ messages in thread
From: Ilpo Järvinen @ 2025-06-10 15:56 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen
On Fri, 9 May 2025, Shyam Sundar S K wrote:
> Use amd_pmf_update_bios_inputs() helper function to update the custom
> BIOS inputs.
>
> 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/spc.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index be6ffb823efc..0cd50d342b11 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -125,15 +125,12 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
> &in->ev_info.bios_input3, &in->ev_info.bios_input4, &in->ev_info.bios_input5,
> &in->ev_info.bios_input6, &in->ev_info.bios_input7, &in->ev_info.bios_input8,
> &in->ev_info.bios_input9, &in->ev_info.bios_input10};
> - int i;
>
> 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);
Why is this in own patch and not in the one introducing
amd_pmf_update_bios_inputs() ?
> if (pdev->smart_pc_enabled && pdev->pmf_if_version == PMF_IF_V1 &&
> is_apmf_bios_input_notifications_supported(pdev)) {
>
--
i.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
2025-05-09 7:26 ` [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-06-10 15:58 ` Ilpo Järvinen
0 siblings, 0 replies; 19+ messages in thread
From: Ilpo Järvinen @ 2025-06-10 15:58 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen, Sanket Goswami
On Fri, 9 May 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 | 19 ++++++++++++++++++-
> drivers/platform/x86/amd/pmf/spc.c | 13 ++++++++++++-
> 2 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index eceed2348165..17b46085726e 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,16 @@ struct ta_pmf_condition_info {
> u32 workload_type;
> u32 display_type;
> u32 display_state;
> - u32 rsvd5[150];
> + u32 rsvd5_1[17];
> + u32 bios_input3;
> + u32 bios_input4;
> + u32 bios_input5;
> + u32 bios_input6;
> + u32 bios_input7;
> + u32 bios_input8;
> + u32 bios_input9;
> + u32 bios_input10;
These really ought to be an array so the copy-paste madness can be
reduced in the code.
> + 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..dfb8036671a0 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_input3);
> + dev_dbg(dev->dev, "Custom BIOS input4: %u\n", in->ev_info.bios_input4);
> + dev_dbg(dev->dev, "Custom BIOS input5: %u\n", in->ev_info.bios_input5);
> + dev_dbg(dev->dev, "Custom BIOS input6: %u\n", in->ev_info.bios_input6);
> + dev_dbg(dev->dev, "Custom BIOS input7: %u\n", in->ev_info.bios_input7);
> + dev_dbg(dev->dev, "Custom BIOS input8: %u\n", in->ev_info.bios_input8);
> + dev_dbg(dev->dev, "Custom BIOS input9: %u\n", in->ev_info.bios_input9);
> + dev_dbg(dev->dev, "Custom BIOS input10: %u\n", in->ev_info.bios_input10);
> 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_input3, &in->ev_info.bios_input4, &in->ev_info.bios_input5,
> + &in->ev_info.bios_input6, &in->ev_info.bios_input7, &in->ev_info.bios_input8,
> + &in->ev_info.bios_input9, &in->ev_info.bios_input10};
> int i;
>
> if (!pdev->req.pending_req)
>
--
i.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
2025-05-09 7:26 ` [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-06-10 16:01 ` Ilpo Järvinen
0 siblings, 0 replies; 19+ messages in thread
From: Ilpo Järvinen @ 2025-06-10 16:01 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen
On Fri, 9 May 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>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/platform/x86/amd/pmf/acpi.c | 7 +++++++
> drivers/platform/x86/amd/pmf/pmf.h | 2 ++
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index f75f7ecd8cd9..ab63582c9d0b 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 & GENMASK(16, 7));
Name that GENMASK() although I wonder if custom_bios_inputs_v1 you
introduced later on should be reused here to do this check. It would keep
the code in cync
> +}
> +
> 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,8 @@ static int apmf_if_verify_interface(struct amd_pmf_dev *pdev)
>
> pdev->pmf_if_version = output.version;
>
> + pdev->notifications = output.notification_mask;
Extra space
> +
> return 0;
> }
>
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 27458a7c221b..2deae43aca63 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -377,6 +377,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 {
> @@ -799,6 +800,7 @@ int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
> 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);
> +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] 19+ messages in thread
* Re: [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
2025-05-09 7:26 ` [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
@ 2025-06-10 16:12 ` Ilpo Järvinen
2025-06-17 7:15 ` Shyam Sundar S K
0 siblings, 1 reply; 19+ messages in thread
From: Ilpo Järvinen @ 2025-06-10 16:12 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen
[-- Attachment #1: Type: text/plain, Size: 2952 bytes --]
On Fri, 9 May 2025, Shyam Sundar S K wrote:
> 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>
> 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 e6bdee68ccf3..4665e68e5c07 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 a1e43873a07b..679c5bf5faca 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -145,6 +145,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;
> +
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
...But with the caveat that you should start to consider something more
clever here as most of these cases are essentially just copy-paste code
with very minor variations in a single parameters and offset in
dev->prev_data so it would be nice if the similar cases could be handled
with once generic code fragment (I don't count dev_dbg variations).
> case PMF_POLICY_SYSTEM_STATE:
> switch (val) {
> case 0:
>
--
i.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
2025-05-09 7:26 ` [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
@ 2025-06-10 16:19 ` Ilpo Järvinen
0 siblings, 0 replies; 19+ messages in thread
From: Ilpo Järvinen @ 2025-06-10 16:19 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen
On Fri, 9 May 2025, Shyam Sundar S K wrote:
> 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.
>
> 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 | 18 ++++++++++++++++--
> drivers/platform/x86/amd/pmf/pmf.h | 2 ++
> drivers/platform/x86/amd/pmf/tee-if.c | 3 ++-
> 3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index 1521988c1002..a3319ac89fd1 100644
> --- a/drivers/platform/x86/amd/pmf/acpi.c
> +++ b/drivers/platform/x86/amd/pmf/acpi.c
> @@ -339,8 +339,15 @@ 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;
> + }
> +
> + if (pmf_dev->cb_flag) {
> + amd_pmf_invoke_cmd_enact(pmf_dev);
> + pmf_dev->cb_flag = false;
> + }
> }
>
> static void apmf_event_handler_v1(acpi_handle handle, u32 event, void *data)
> @@ -351,8 +358,15 @@ 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;
> + }
> +
> + if (pmf_dev->cb_flag) {
> + amd_pmf_invoke_cmd_enact(pmf_dev);
> + pmf_dev->cb_flag = false;
> + }
Why isn't there another function which can be called by both???
> }
>
> 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 d9e6467be852..71cc94bdbd32 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 */
Please more the comment more to right, preferrably align it with the
previous line.
> };
>
> struct apmf_sps_prop_granular_v2 {
> @@ -891,5 +892,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 679c5bf5faca..249683509635 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -223,7 +223,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;
> @@ -559,6 +559,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:
>
--
i.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
2025-06-10 16:12 ` Ilpo Järvinen
@ 2025-06-17 7:15 ` Shyam Sundar S K
0 siblings, 0 replies; 19+ messages in thread
From: Shyam Sundar S K @ 2025-06-17 7:15 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
mario.limonciello, Yijun.Shen
On 6/10/2025 21:42, Ilpo Järvinen wrote:
> On Fri, 9 May 2025, Shyam Sundar S K wrote:
>
>> 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>
>> 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 e6bdee68ccf3..4665e68e5c07 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 a1e43873a07b..679c5bf5faca 100644
>> --- a/drivers/platform/x86/amd/pmf/tee-if.c
>> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
>> @@ -145,6 +145,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;
>> +
>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>
> ...But with the caveat that you should start to consider something more
> clever here as most of these cases are essentially just copy-paste code
> with very minor variations in a single parameters and offset in
> dev->prev_data so it would be nice if the similar cases could be handled
> with once generic code fragment (I don't count dev_dbg variations).
Agree. The code has grown over a period of time and it needs a rework.
I will work on them and submit as a separate series.
Meanwhile, I sent out v2. Please have a look.
Thanks,
Shyam
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-06-17 7:16 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 7:26 [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 01/10] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-06-10 16:12 ` Ilpo Järvinen
2025-06-17 7:15 ` Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 02/10] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 03/10] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
2025-06-10 15:58 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 04/10] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 05/10] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
2025-06-10 16:01 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 06/10] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 07/10] platform/x86/amd/pmf: Use amd_pmf_update_bios_inputs() helper Shyam Sundar S K
2025-06-10 15:56 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 08/10] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
2025-05-09 7:26 ` [PATCH 09/10] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-06-10 16:19 ` Ilpo Järvinen
2025-05-09 7:26 ` [PATCH 10/10] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
2025-05-12 8:13 ` [PATCH 00/10] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shen, Yijun
2025-05-12 17:26 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox