X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
@ 2025-09-01 11:01 Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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 ee1cb9b0e6a8 ("platform/x86/amd/hsmp: Replace dev_err() with dev_info() for non-fatal errors")'

v5:
-----
- Use unsigned int instead of int
- Use switch and fallthrough mechanism for install/uninstall acpi handlers
  v1 and v2. 
- Use a switch case for amd_pmf_update_bios_inputs()

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   | 87 +++++++++++++++++++++++++--
 drivers/platform/x86/amd/pmf/pmf.h    | 77 +++++++++++++++++++++---
 drivers/platform/x86/amd/pmf/spc.c    | 80 +++++++++++++++++++++---
 drivers/platform/x86/amd/pmf/tee-if.c | 22 ++++++-
 4 files changed, 240 insertions(+), 26 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v5 RESEND 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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] 15+ messages in thread

* [PATCH v5 RESEND 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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] 15+ messages in thread

* [PATCH v5 RESEND 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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] 15+ messages in thread

* [PATCH v5 RESEND 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (2 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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] 15+ messages in thread

* [PATCH v5 RESEND 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (3 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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  | 16 ++++++++++++++++
 2 files changed, 22 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..6ddd1a6e9115 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -118,6 +118,7 @@ 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 +378,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 +643,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 +807,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] 15+ messages in thread

* [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (4 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-10 10:31   ` Ilpo Järvinen
  2025-09-01 11:01 ` [PATCH v5 RESEND 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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 | 58 ++++++++++++++++++++++++++---
 drivers/platform/x86/amd/pmf/pmf.h  | 22 +++++++++++
 drivers/platform/x86/amd/pmf/spc.c  | 36 +++++++++++++++---
 3 files changed, 105 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 4982311ac045..41c34c26ceec 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;
@@ -427,6 +444,11 @@ int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_
 	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
 }
 
+static apmf_event_handler_t apmf_event_handlers[] = {
+	[PMF_IF_V1] = apmf_event_handler_v1,
+	[PMF_IF_V2] = apmf_event_handler_v2,
+};
+
 int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
 {
 	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
@@ -446,13 +468,26 @@ 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_V2) {
+	if (!pmf_dev->smart_pc_enabled)
+		return -EINVAL;
+
+	switch (pmf_dev->pmf_if_version) {
+	case PMF_IF_V1:
+		if (!is_apmf_bios_input_notifications_supported(pmf_dev))
+			break;
+		fallthrough;
+	case PMF_IF_V2:
 		status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
-						     apmf_event_handler_v2, pmf_dev);
+				apmf_event_handlers[pmf_dev->pmf_if_version], pmf_dev);
 		if (ACPI_FAILURE(status)) {
-			dev_err(pmf_dev->dev, "failed to install notify handler for custom BIOS inputs\n");
+			dev_err(pmf_dev->dev,
+				"failed to install notify handler v%d for custom BIOS inputs\n",
+				pmf_dev->pmf_if_version);
 			return -ENODEV;
 		}
+		break;
+	default:
+		break;
 	}
 
 	return 0;
@@ -506,8 +541,21 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
 	    is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS))
 		acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler);
 
-	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)
+		return;
+
+	switch (pmf_dev->pmf_if_version) {
+	case PMF_IF_V1:
+		if (!is_apmf_bios_input_notifications_supported(pmf_dev))
+			break;
+		fallthrough;
+	case PMF_IF_V2:
+		acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY,
+					   apmf_event_handlers[pmf_dev->pmf_if_version]);
+		break;
+	default:
+		break;
+	}
 }
 
 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 6ddd1a6e9115..647993e94674 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -120,6 +120,8 @@ struct cookie_header {
 #define APTS_MAX_STATES		16
 #define CUSTOM_BIOS_INPUT_BITS	GENMASK(16, 7)
 
+typedef void (*apmf_event_handler_t)(acpi_handle handle, u32 event, void *data);
+
 /* APTS PMF BIOS Interface */
 struct amd_pmf_apts_output {
 	u16 table_version;
@@ -187,6 +189,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;
@@ -379,6 +399,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 {
@@ -835,6 +856,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..1b612e79a3d8 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -132,22 +132,46 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
 	}
 }
 
+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;
+
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
+		if (!(pending_req & inputs[i].bit_mask))
+			continue;
+		amd_pmf_set_ta_custom_bios_input(in, i, custom_policy[i]);
+	}
+}
+
 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 || pdev->req1.pending_req))
+		return;
 
-	if (!pdev->req.pending_req)
+	if (!pdev->smart_pc_enabled)
 		return;
 
-	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]);
+	switch (pdev->pmf_if_version) {
+	case PMF_IF_V1:
+		if (!is_apmf_bios_input_notifications_supported(pdev))
+			return;
+		amd_pmf_update_bios_inputs(pdev, pdev->req1.pending_req, custom_bios_inputs_v1,
+					   pdev->req1.custom_policy, in);
+		break;
+	case PMF_IF_V2:
+		amd_pmf_update_bios_inputs(pdev, pdev->req.pending_req, custom_bios_inputs,
+					   pdev->req.custom_policy, in);
+		break;
+	default:
+		break;
 	}
 
 	/* 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] 15+ messages in thread

* [PATCH v5 RESEND 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (5 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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 647993e94674..6d2579f8cff4 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -354,6 +354,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;
@@ -400,6 +404,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 1b612e79a3d8..aeead2477a07 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, 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)
 {
+	unsigned 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] 15+ messages in thread

* [PATCH v5 RESEND 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (6 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-01 11:01 ` [PATCH v5 RESEND 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
  2025-09-11  8:51 ` [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Ilpo Järvinen
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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 41c34c26ceec..1ae2323f3197 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 6d2579f8cff4..bd19f2a6bc78 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -405,6 +405,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 {
@@ -885,5 +886,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] 15+ messages in thread

* [PATCH v5 RESEND 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (7 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
@ 2025-09-01 11:01 ` Shyam Sundar S K
  2025-09-11  8:51 ` [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Ilpo Järvinen
  9 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-01 11:01 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 1ae2323f3197..13c4fec2c7ef 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 aeead2477a07..85192c7536b8 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, 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] 15+ messages in thread

* Re: [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
  2025-09-01 11:01 ` [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
@ 2025-09-10 10:31   ` Ilpo Järvinen
  2025-09-10 13:58     ` Shyam Sundar S K
  0 siblings, 1 reply; 15+ messages in thread
From: Ilpo Järvinen @ 2025-09-10 10:31 UTC (permalink / raw)
  To: Shyam Sundar S K
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello, Yijun Shen, Yijun Shen

On Mon, 1 Sep 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 | 58 ++++++++++++++++++++++++++---
>  drivers/platform/x86/amd/pmf/pmf.h  | 22 +++++++++++
>  drivers/platform/x86/amd/pmf/spc.c  | 36 +++++++++++++++---
>  3 files changed, 105 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index 4982311ac045..41c34c26ceec 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;
> @@ -427,6 +444,11 @@ int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_
>  	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
>  }
>  
> +static apmf_event_handler_t apmf_event_handlers[] = {
> +	[PMF_IF_V1] = apmf_event_handler_v1,
> +	[PMF_IF_V2] = apmf_event_handler_v2,
> +};
> +
>  int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
>  {
>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
> @@ -446,13 +468,26 @@ 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_V2) {
> +	if (!pmf_dev->smart_pc_enabled)
> +		return -EINVAL;

Hi,

Is this change okay? Previously this function returned 0 in this case.

-- 
 i.

> +
> +	switch (pmf_dev->pmf_if_version) {
> +	case PMF_IF_V1:
> +		if (!is_apmf_bios_input_notifications_supported(pmf_dev))
> +			break;
> +		fallthrough;
> +	case PMF_IF_V2:
>  		status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
> -						     apmf_event_handler_v2, pmf_dev);
> +				apmf_event_handlers[pmf_dev->pmf_if_version], pmf_dev);
>  		if (ACPI_FAILURE(status)) {
> -			dev_err(pmf_dev->dev, "failed to install notify handler for custom BIOS inputs\n");
> +			dev_err(pmf_dev->dev,
> +				"failed to install notify handler v%d for custom BIOS inputs\n",
> +				pmf_dev->pmf_if_version);
>  			return -ENODEV;
>  		}
> +		break;
> +	default:
> +		break;
>  	}
>  
>  	return 0;
> @@ -506,8 +541,21 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
>  	    is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS))
>  		acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler);
>  
> -	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)
> +		return;
> +
> +	switch (pmf_dev->pmf_if_version) {
> +	case PMF_IF_V1:
> +		if (!is_apmf_bios_input_notifications_supported(pmf_dev))
> +			break;
> +		fallthrough;
> +	case PMF_IF_V2:
> +		acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY,
> +					   apmf_event_handlers[pmf_dev->pmf_if_version]);
> +		break;
> +	default:
> +		break;
> +	}
>  }
>  
>  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 6ddd1a6e9115..647993e94674 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -120,6 +120,8 @@ struct cookie_header {
>  #define APTS_MAX_STATES		16
>  #define CUSTOM_BIOS_INPUT_BITS	GENMASK(16, 7)
>  
> +typedef void (*apmf_event_handler_t)(acpi_handle handle, u32 event, void *data);
> +
>  /* APTS PMF BIOS Interface */
>  struct amd_pmf_apts_output {
>  	u16 table_version;
> @@ -187,6 +189,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;
> @@ -379,6 +399,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 {
> @@ -835,6 +856,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..1b612e79a3d8 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -132,22 +132,46 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
>  	}
>  }
>  
> +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;
> +
> +	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
> +		if (!(pending_req & inputs[i].bit_mask))
> +			continue;
> +		amd_pmf_set_ta_custom_bios_input(in, i, custom_policy[i]);
> +	}
> +}
> +
>  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 || pdev->req1.pending_req))
> +		return;
>  
> -	if (!pdev->req.pending_req)
> +	if (!pdev->smart_pc_enabled)
>  		return;
>  
> -	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]);
> +	switch (pdev->pmf_if_version) {
> +	case PMF_IF_V1:
> +		if (!is_apmf_bios_input_notifications_supported(pdev))
> +			return;
> +		amd_pmf_update_bios_inputs(pdev, pdev->req1.pending_req, custom_bios_inputs_v1,
> +					   pdev->req1.custom_policy, in);
> +		break;
> +	case PMF_IF_V2:
> +		amd_pmf_update_bios_inputs(pdev, pdev->req.pending_req, custom_bios_inputs,
> +					   pdev->req.custom_policy, in);
> +		break;
> +	default:
> +		break;
>  	}
>  
>  	/* 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)
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
  2025-09-10 10:31   ` Ilpo Järvinen
@ 2025-09-10 13:58     ` Shyam Sundar S K
  2025-09-11  6:59       ` Ilpo Järvinen
  0 siblings, 1 reply; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-10 13:58 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello, Yijun Shen

Hi Ilpo,

On 9/10/2025 16:01, Ilpo Järvinen wrote:
> On Mon, 1 Sep 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 | 58 ++++++++++++++++++++++++++---
>>  drivers/platform/x86/amd/pmf/pmf.h  | 22 +++++++++++
>>  drivers/platform/x86/amd/pmf/spc.c  | 36 +++++++++++++++---
>>  3 files changed, 105 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
>> index 4982311ac045..41c34c26ceec 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;
>> @@ -427,6 +444,11 @@ int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_
>>  	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
>>  }
>>  
>> +static apmf_event_handler_t apmf_event_handlers[] = {
>> +	[PMF_IF_V1] = apmf_event_handler_v1,
>> +	[PMF_IF_V2] = apmf_event_handler_v2,
>> +};
>> +
>>  int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
>>  {
>>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
>> @@ -446,13 +468,26 @@ 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_V2) {
>> +	if (!pmf_dev->smart_pc_enabled)
>> +		return -EINVAL;
> 
> Hi,
> 
> Is this change okay? Previously this function returned 0 in this case.
> 

Yes - this change is okay and was introduced to address your v4
remarks w.r.t to code optimization.

This function still returns 0 upon success but this additional check
is to make sure we don't enter the underlying code block for smart pc
if the feature is not enabled.

Thanks,
Shyam


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
  2025-09-10 13:58     ` Shyam Sundar S K
@ 2025-09-11  6:59       ` Ilpo Järvinen
  2025-09-11  7:38         ` Shyam Sundar S K
  0 siblings, 1 reply; 15+ messages in thread
From: Ilpo Järvinen @ 2025-09-11  6:59 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: 4233 bytes --]

On Wed, 10 Sep 2025, Shyam Sundar S K wrote:
> On 9/10/2025 16:01, Ilpo Järvinen wrote:
> > On Mon, 1 Sep 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 | 58 ++++++++++++++++++++++++++---
> >>  drivers/platform/x86/amd/pmf/pmf.h  | 22 +++++++++++
> >>  drivers/platform/x86/amd/pmf/spc.c  | 36 +++++++++++++++---
> >>  3 files changed, 105 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> >> index 4982311ac045..41c34c26ceec 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;
> >> @@ -427,6 +444,11 @@ int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_
> >>  	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
> >>  }
> >>  
> >> +static apmf_event_handler_t apmf_event_handlers[] = {
> >> +	[PMF_IF_V1] = apmf_event_handler_v1,
> >> +	[PMF_IF_V2] = apmf_event_handler_v2,
> >> +};
> >> +
> >>  int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
> >>  {
> >>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
> >> @@ -446,13 +468,26 @@ 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_V2) {
> >> +	if (!pmf_dev->smart_pc_enabled)
> >> +		return -EINVAL;
> > 
> > Hi,
> > 
> > Is this change okay? Previously this function returned 0 in this case.
> > 
> 
> Yes - this change is okay and was introduced to address your v4
> remarks w.r.t to code optimization.
> 
> This function still returns 0 upon success but this additional check
> is to make sure we don't enter the underlying code block for smart pc
> if the feature is not enabled.

Code flow within this function is fine but this doesn't answer my main 
concern related to the returned value. Is it okay for this function to 
return -EINVAL if smart pc feature is not enabled? Previously this 
function returned 0 also if smart pc was not enabled.

(Maybe you wanted to say it's okay to change the returned value from 0 to 
-EINVAL but it's notindicated by your words, thus reiterating the 
question.)

-- 
 i.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
  2025-09-11  6:59       ` Ilpo Järvinen
@ 2025-09-11  7:38         ` Shyam Sundar S K
  0 siblings, 0 replies; 15+ messages in thread
From: Shyam Sundar S K @ 2025-09-11  7:38 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello, Yijun Shen

Hi Ilpo,

On 9/11/2025 12:29, Ilpo Järvinen wrote:
> On Wed, 10 Sep 2025, Shyam Sundar S K wrote:
>> On 9/10/2025 16:01, Ilpo Järvinen wrote:
>>> On Mon, 1 Sep 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 | 58 ++++++++++++++++++++++++++---
>>>>  drivers/platform/x86/amd/pmf/pmf.h  | 22 +++++++++++
>>>>  drivers/platform/x86/amd/pmf/spc.c  | 36 +++++++++++++++---
>>>>  3 files changed, 105 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
>>>> index 4982311ac045..41c34c26ceec 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;
>>>> @@ -427,6 +444,11 @@ int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_
>>>>  	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
>>>>  }
>>>>  
>>>> +static apmf_event_handler_t apmf_event_handlers[] = {
>>>> +	[PMF_IF_V1] = apmf_event_handler_v1,
>>>> +	[PMF_IF_V2] = apmf_event_handler_v2,
>>>> +};
>>>> +
>>>>  int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
>>>>  {
>>>>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
>>>> @@ -446,13 +468,26 @@ 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_V2) {
>>>> +	if (!pmf_dev->smart_pc_enabled)
>>>> +		return -EINVAL;
>>>
>>> Hi,
>>>
>>> Is this change okay? Previously this function returned 0 in this case.
>>>
>>
>> Yes - this change is okay and was introduced to address your v4
>> remarks w.r.t to code optimization.
>>
>> This function still returns 0 upon success but this additional check
>> is to make sure we don't enter the underlying code block for smart pc
>> if the feature is not enabled.
> 
> Code flow within this function is fine but this doesn't answer my main 
> concern related to the returned value. Is it okay for this function to 
> return -EINVAL if smart pc feature is not enabled? Previously this 
> function returned 0 also if smart pc was not enabled.
> 
> (Maybe you wanted to say it's okay to change the returned value from 0 to 
> -EINVAL but it's notindicated by your words, thus reiterating the 
> question.)
> 

Yes. I think its okay to return -EINVAL in this case if the smart pc
feature is not enabled.

Thanks,
Shyam

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling
  2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
                   ` (8 preceding siblings ...)
  2025-09-01 11:01 ` [PATCH v5 RESEND 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
@ 2025-09-11  8:51 ` Ilpo Järvinen
  9 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2025-09-11  8:51 UTC (permalink / raw)
  To: Hans de Goede, Shyam Sundar S K
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello, Yijun.Shen

On Mon, 01 Sep 2025 16:31:31 +0530, 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
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds
      commit: f10ea2df9e4d28964e2a02abaf32100953885989
[2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
      commit: d82e3d2dd0ba019ac6cdd81e47bf4c8ac895cfa0
[3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies
      commit: ebc68a3451ce419fe2e7a7d3f06df408fb36399e
[4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member
      commit: 37336ecb06a81e7c4fb3e89dbb04169c0e523069
[5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable
      commit: 4389d38080d72a818de2731663d0b5571f66db31
[6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS
      commit: 04199ef48ac2c5f0985a54171da47a218c37b00f
[7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies
      commit: b21ec88340b7e9dbaac13d9902f1e8166932c277
[8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests
      commit: 62214d942d2bebbed1798eef711dd82aa493a616
[9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs
      commit: 2ab7713d6e9408587731c186b9a5a208f04a6b33

--
 i.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-09-11  8:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 11:01 [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
2025-09-10 10:31   ` Ilpo Järvinen
2025-09-10 13:58     ` Shyam Sundar S K
2025-09-11  6:59       ` Ilpo Järvinen
2025-09-11  7:38         ` Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-09-01 11:01 ` [PATCH v5 RESEND 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K
2025-09-11  8:51 ` [PATCH v5 RESEND 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox