All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support
@ 2026-11-30  7:52 Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 01/12] platform/x86/amd/pmf: Fix clamping of Q10 accumulator values Shyam Sundar S K
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K

This series enables the PMF driver features on the 1AH_M80H platform.

Patch 1 fixes the clamping of the Q10 accumulator values.
Patch 2 stops sending the legacy DRAM address commands on 1AH_M80H.
Patches 3-4 move the static slider handling to per version ops and add
the 1AH_M80H static slider support as per APMF 2.03.
Patches 5-6 add per-platform TA ops and the signature size handling for
RSA4K and alternatively signed policy binaries.
Patch 7 uses the system state enum in the TA policy action code.
Patch 8 adds the Smart PC builder support for the new TA.
Patch 9 remaps the metrics table on resume.
Patch 10 passes the custom BIOS inputs to the TA on 1AH_M80H.
Patch 11 shares the TA policy apply code between the TA versions.
Patch 12 extends the custom BIOS inputs to 20 on 1AH_M80H (APMF 2.03).

---
v5:
 - Rebase on the latest review-ilpo-next
 - New patch 1: use min() instead of min_t(u16, ...) in the Q10
   accumulator helpers, which truncated the value before clamping (Ilpo)
 - Patch 4: drop the fan index handling from the 1AH_M80H static slider,
   the existing v2 static slider does not set it either
 - Patch 8: report a TA init/enact failure as an error when the TEE call
   itself succeeded, and pass the skin temperature in centidegrees

v4: https://lore.kernel.org/all/20261124075213.2317127-1-Shyam-sundar.S-k@amd.com/
 - Rebase on the latest review-ilpo-next
 - New patch 2: move the static slider handling to per version sps_ops (Ilpo)
 - Patch 3: add the 1AH_M80H static slider support as a new set of sps_ops
 - Patch 11: add apmf_get_custom_policy_ext() and read the SBIOS requests
   through one helper so that the event handler has a single path (Ilpo)
 - Pick Mario's Reviewed-by for patch 5

v3: https://lore.kernel.org/all/20261118143034.3566684-1-Shyam-sundar.S-k@amd.com/
 - Rebase on the latest review-ilpo-next
 - Patch 4: also handle policy binaries signed with the alternative
   signing mechanism
 - Pick Mario's Reviewed-by for patches 5 and 10

v2: https://lore.kernel.org/all/20261106164429.30738-1-Shyam-sundar.S-k@amd.com/
 - Rebase on the latest review-ilpo-next
 - Pick Mario's Reviewed-by
 - Use ARRAY_SIZE() and rename the APTS state array to states[] (Ilpo)
 - Use SZ_256/SZ_512 for the PSP header and signature sizes (Ilpo)
 - Use max(), sizeof() of the destination, and a single update of the
   previous sample in amd_pmf_get_smu_info_v2() (Ilpo)
 - New patch 5: use enum system_state instead of literals (Ilpo)
 - Keep allocating the metrics buffer on 1AH_M80H and only skip the
   SET_DRAM_ADDR commands, the existing metrics paths still use it
 - Keep the power source notifier registration unchanged, skip the
   1AH_M80H slider update instead when the APTS defaults were not read
 - Read the v2 TA layout in the util interface on 1AH_M80H
 - Do not fail resume/restore when the metrics table remap fails
 - New patch 10: add the custom BIOS inputs 11-20 of APMF 2.03

v1: https://lore.kernel.org/all/20261011100554.1841309-1-Shyam-sundar.S-k@amd.com/

Patil Rajesh Reddy (1):
  platform/x86/amd/pmf: Abstract static slider handling through sps_ops

Shyam Sundar S K (11):
  platform/x86/amd/pmf: Fix clamping of Q10 accumulator values
  platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H
  platform/x86/amd/pmf: Add 1AH_M80H static slider support
  platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table
  platform/x86/amd/pmf: Get policy binary signature size from PSP header
  platform/x86/amd/pmf: Use enum system_state for the TA system state
    action
  platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H
  platform/x86/amd/pmf: Remap metrics table on resume for 1AH_M80H
  platform/x86/amd/pmf: Add custom BIOS input support for 1AH_M80H
  platform/x86/amd/pmf: Share TA policy apply code between TA versions
  platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H

 drivers/platform/x86/amd/pmf/acpi.c    |  32 ++-
 drivers/platform/x86/amd/pmf/core.c    |  38 ++-
 drivers/platform/x86/amd/pmf/metrics.c |  20 +-
 drivers/platform/x86/amd/pmf/pmf.h     | 328 ++++++++++++++++++++++++-
 drivers/platform/x86/amd/pmf/spc.c     | 211 ++++++++++++++++
 drivers/platform/x86/amd/pmf/sps.c     | 177 ++++++++++++-
 drivers/platform/x86/amd/pmf/tee-if.c  | 261 +++++++++++++++++---
 drivers/platform/x86/amd/pmf/util.c    |  83 +++++--
 8 files changed, 1056 insertions(+), 94 deletions(-)


base-commit: 6fc627bda235ac5b6f43b5f784b81d6c2450ae5a
-- 
2.34.1


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

* [PATCH v5 01/12] platform/x86/amd/pmf: Fix clamping of Q10 accumulator values
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 02/12] platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H Shyam Sundar S K
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K

min_t(u16, val, U16_MAX) casts val to u16 before the comparison, so a
value above U16_MAX wraps around instead of being clamped. For example,
an NPU power of 66 W is reported as 464 mW.

Use min() so that the value is compared as u64 and clamped to U16_MAX.

Fixes: 641b41a7a125 ("platform/x86/amd/pmf: Add 1AH_M80H metrics table and NPU metrics support")
Suggested-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/metrics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/metrics.c b/drivers/platform/x86/amd/pmf/metrics.c
index 6bad7a409ddd..43064d8e1eef 100644
--- a/drivers/platform/x86/amd/pmf/metrics.c
+++ b/drivers/platform/x86/amd/pmf/metrics.c
@@ -32,14 +32,14 @@ static u16 amd_pmf_q10_acc_to_mW(u64 avg_acc)
 {
 	u64 val = DIV_U64_ROUND_CLOSEST(avg_acc, 1024) * MILLIWATT_PER_WATT;
 
-	return min_t(u16, val, U16_MAX);
+	return min(val, U16_MAX);
 }
 
 static u16 amd_pmf_q10_acc_to_int(u64 avg_acc)
 {
 	u64 val = DIV_U64_ROUND_CLOSEST(avg_acc, 1024);
 
-	return min_t(u16, val, U16_MAX);
+	return min(val, U16_MAX);
 }
 
 static u64 amd_pmf_avg_acc_metric(u32 curr_counter, u32 prev_counter,
-- 
2.34.1


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

* [PATCH v5 02/12] platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 01/12] platform/x86/amd/pmf: Fix clamping of Q10 accumulator values Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 03/12] platform/x86/amd/pmf: Abstract static slider handling through sps_ops Shyam Sundar S K
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

1AH_M80H gets the metrics table address from PMFW through
GET_1AH_M80H_METRICS_TABLE_DRAM_ADDR and does not support the
SET_DRAM_ADDR_HIGH/LOW commands used by earlier platforms.

amd_pmf_set_dram_addr() is still called on this platform from the
Smart PC and auto mode/CnQF init paths. It logs an "Invalid CPU id"
error and sends the address of its local buffer to PMFW using message
IDs that mean something else on 1AH_M80H.

Do not send these commands on platforms that use accumulator based
metrics. The buffer is still allocated, as the existing metrics paths
use it. Add the 1AH_M80H case to the size switch, and move
amd_pmf_supports_accumulator_metrics() to pmf.h so that it can be used
from metrics.c.

Fixes: 641b41a7a125 ("platform/x86/amd/pmf: Add 1AH_M80H metrics table and NPU metrics support")
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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/core.c    | 10 ----------
 drivers/platform/x86/amd/pmf/metrics.c |  7 +++++++
 drivers/platform/x86/amd/pmf/pmf.h     | 10 ++++++++++
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index 926de4de2cdb..19b75609f554 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -68,16 +68,6 @@ static bool smart_pc_support = true;
 module_param(smart_pc_support, bool, 0444);
 MODULE_PARM_DESC(smart_pc_support, "Smart PC Support (default = true)");
 
-static bool amd_pmf_supports_accumulator_metrics(struct amd_pmf_dev *pdev)
-{
-	switch (pdev->cpu_id) {
-	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
-		return true;
-	default:
-		return false;
-	}
-}
-
 static int amd_pmf_pwr_src_notify_call(struct notifier_block *nb, unsigned long event, void *data)
 {
 	struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);
diff --git a/drivers/platform/x86/amd/pmf/metrics.c b/drivers/platform/x86/amd/pmf/metrics.c
index 43064d8e1eef..a620272b6d67 100644
--- a/drivers/platform/x86/amd/pmf/metrics.c
+++ b/drivers/platform/x86/amd/pmf/metrics.c
@@ -158,6 +158,9 @@ int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer)
 		case PCI_DEVICE_ID_AMD_1AH_M60H_ROOT:
 			dev->mtable_size = sizeof(dev->m_table_v2);
 			break;
+		case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
+			dev->mtable_size = sizeof(dev->mtable_v3);
+			break;
 		default:
 			dev_err(dev->dev, "Invalid CPU id: 0x%x\n", dev->cpu_id);
 		}
@@ -167,6 +170,10 @@ int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer)
 			return -ENOMEM;
 	}
 
+	/* Accumulator based platforms get the table address from PMFW instead */
+	if (amd_pmf_supports_accumulator_metrics(dev))
+		return 0;
+
 	phys_addr = virt_to_phys(dev->buf);
 	hi = upper_32_bits(phys_addr);
 	low = lower_32_bits(phys_addr);
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 9f64ab833c08..b29c5192d878 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -1105,6 +1105,16 @@ static inline int amd_pmf_get_power_source(void)
 		return POWER_SOURCE_DC;
 }
 
+static inline bool amd_pmf_supports_accumulator_metrics(struct amd_pmf_dev *pdev)
+{
+	switch (pdev->cpu_id) {
+	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /**
  * fixp_q88_fromint: Convert integer to Q8.8
  * @val: input value
-- 
2.34.1


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

* [PATCH v5 03/12] platform/x86/amd/pmf: Abstract static slider handling through sps_ops
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 01/12] platform/x86/amd/pmf: Fix clamping of Q10 accumulator values Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 02/12] platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 04/12] platform/x86/amd/pmf: Add 1AH_M80H static slider support Shyam Sundar S K
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K

From: Patil Rajesh Reddy <Patil.Reddy@amd.com>

amd_pmf_init_sps() and amd_pmf_set_sps_power_limits() check the PMF
interface version to decide how to load the BIOS defaults and how to
program the static slider power limits.

Move these two operations into a per version struct amd_pmf_sps_ops and
select it once in amd_pmf_init_sps(). This makes it simple to add
platforms that have their own APTS table layout and SMU messages.

No functional changes.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.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 | 17 +++++++++
 drivers/platform/x86/amd/pmf/sps.c | 59 ++++++++++++++++++++++++------
 2 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index b29c5192d878..215dedba5779 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -620,6 +620,22 @@ struct amd_pmf_arg_data {
 	u32 size;
 };
 
+struct amd_pmf_dev;
+
+/**
+ * struct amd_pmf_sps_ops - Static slider operations
+ * @load_defaults: Read the static slider defaults advertised by the BIOS
+ * @set_power_limits: Program the power limits of the given power mode
+ *
+ * The layout of the static slider tables and the SMU messages used to
+ * program them differ between the PMF interface versions, so the static
+ * slider handling is selected per version.
+ */
+struct amd_pmf_sps_ops {
+	int (*load_defaults)(struct amd_pmf_dev *dev);
+	int (*set_power_limits)(struct amd_pmf_dev *dev, int pwr_mode);
+};
+
 struct amd_pmf_dev {
 	void __iomem *regbase;
 	void __iomem *smu_virt_addr;
@@ -630,6 +646,7 @@ struct amd_pmf_dev {
 	struct mutex lock; /* protects the PMF interface */
 	u32 supported_func;
 	enum platform_profile_option current_profile;
+	const struct amd_pmf_sps_ops *sps_ops;
 	struct device *ppdev; /* platform profile class device */
 	struct dentry *dbgfs_dir;
 	int hb_interval; /* SBIOS heartbeat interval */
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index b0031afae33b..2006aca200c9 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -239,6 +239,13 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
 	}
 }
 
+static int amd_pmf_update_sps_power_limits_v1(struct amd_pmf_dev *pdev, int pwr_mode)
+{
+	amd_pmf_update_slider(pdev, SLIDER_OP_SET, pwr_mode, NULL);
+
+	return 0;
+}
+
 static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode)
 {
 	int src, index;
@@ -269,6 +276,39 @@ static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_
 	return 0;
 }
 
+static int amd_pmf_sps_load_defaults_v1(struct amd_pmf_dev *dev)
+{
+	amd_pmf_load_defaults_sps(dev);
+
+	return 0;
+}
+
+static int amd_pmf_sps_load_defaults_v2(struct amd_pmf_dev *dev)
+{
+	amd_pmf_load_defaults_sps_v2(dev);
+	amd_pmf_load_apts_defaults_sps_v2(dev);
+
+	return 0;
+}
+
+static const struct amd_pmf_sps_ops amd_pmf_sps_ops_v1 = {
+	.load_defaults = amd_pmf_sps_load_defaults_v1,
+	.set_power_limits = amd_pmf_update_sps_power_limits_v1,
+};
+
+static const struct amd_pmf_sps_ops amd_pmf_sps_ops_v2 = {
+	.load_defaults = amd_pmf_sps_load_defaults_v2,
+	.set_power_limits = amd_pmf_update_sps_power_limits_v2,
+};
+
+static void amd_pmf_select_sps_ops(struct amd_pmf_dev *dev)
+{
+	if (dev->pmf_if_version == PMF_IF_V2)
+		dev->sps_ops = &amd_pmf_sps_ops_v2;
+	else
+		dev->sps_ops = &amd_pmf_sps_ops_v1;
+}
+
 int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
 {
 	int mode;
@@ -277,12 +317,7 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
 	if (mode < 0)
 		return mode;
 
-	if (pmf->pmf_if_version == PMF_IF_V2)
-		return amd_pmf_update_sps_power_limits_v2(pmf, mode);
-
-	amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
-
-	return 0;
+	return pmf->sps_ops->set_power_limits(pmf, mode);
 }
 
 static int amd_pmf_profile_get(struct device *dev,
@@ -418,15 +453,15 @@ static const struct platform_profile_ops amd_pmf_profile_ops = {
 
 int amd_pmf_init_sps(struct amd_pmf_dev *dev)
 {
+	int ret;
+
 	dev->current_profile = PLATFORM_PROFILE_BALANCED;
+	amd_pmf_select_sps_ops(dev);
 
 	if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
-		if (dev->pmf_if_version == PMF_IF_V2) {
-			amd_pmf_load_defaults_sps_v2(dev);
-			amd_pmf_load_apts_defaults_sps_v2(dev);
-		} else {
-			amd_pmf_load_defaults_sps(dev);
-		}
+		ret = dev->sps_ops->load_defaults(dev);
+		if (ret)
+			return ret;
 
 		/* update SPS balanced power mode thermals */
 		amd_pmf_set_sps_power_limits(dev);
-- 
2.34.1


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

* [PATCH v5 04/12] platform/x86/amd/pmf: Add 1AH_M80H static slider support
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (2 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 03/12] platform/x86/amd/pmf: Abstract static slider handling through sps_ops Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 05/12] platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table Shyam Sundar S K
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

1AH_M80H follows APMF 2.03, which changes the APTS table layout and uses
new SMU messages to program the static slider power limits.

Add the APMF 2.03 APTS structures and a new set of static slider ops
that read the defaults with them and program the limits with the new
SMU messages. Select these ops on 1AH_M80H.

Move the APTS index lookup out of amd_pmf_update_sps_power_limits_v2()
into amd_pmf_get_apts_idx(), so that it can be shared with the new ops.

If the APTS defaults could not be read, do not program the slider limits
so that zero limits are not sent to the SMU.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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 |  45 +++++++++++
 drivers/platform/x86/amd/pmf/sps.c | 124 ++++++++++++++++++++++++++++-
 2 files changed, 165 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 215dedba5779..dcae081a4806 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -82,8 +82,15 @@ struct cookie_header {
 #define SET_PMF_PPT_APU_ONLY   0x26
 
 /* Message IDs for 1AH_M80H platform */
+#define SET_1AH_M80H_STT_MIN_LIMIT		0x06
+#define SET_1AH_M80H_STT_LIMIT_APU		0x07
+#define SET_1AH_M80H_STT_LIMIT_HS2		0x08
 #define GET_1AH_M80H_METRICS_TABLE_LOG_SAMPLE	0x0E
 #define GET_1AH_M80H_METRICS_TABLE_DRAM_ADDR	0x0F
+#define SET_1AH_M80H_PMF_FPPT_APU_ONLY		0x10
+#define SET_1AH_M80H_PMF_SPPT_APU_ONLY		0x11
+#define SET_1AH_M80H_PMF_FPPT_SPM		0x12
+#define SET_1AH_M80H_PMF_SPPT_SPM		0x13
 
 /* OS slider update notification */
 #define DC_BEST_PERF		0
@@ -173,11 +180,34 @@ struct amd_pmf_apts_output {
 	u8 stt_skin_temp_limit_hs2;
 } __packed;
 
+/* As per APMF Spec 2.03 */
+struct amd_pmf_apts_output_v2 {
+	u16 table_version;
+	u32 fan_table_idx;
+	u32 pmf_slow_ppt;
+	u32 ppt_pmf_apu_only;
+	u32 stt_min_limit;
+	u8 stt_skin_temp_limit_apu;
+	u8 stt_skin_temp_limit_hs2;
+	u32 pmf_fast_ppt;
+	u32 ppt_fast_pmf_apu_only;
+} __packed;
+
+struct amd_pmf_apts_granular_output_v2 {
+	u16 size;
+	struct amd_pmf_apts_output_v2 val;
+} __packed;
+
 struct amd_pmf_apts_granular_output {
 	u16 size;
 	struct amd_pmf_apts_output val;
 } __packed;
 
+struct amd_pmf_apts_granular_v2 {
+	u16 size;
+	struct amd_pmf_apts_output_v2 states[APTS_MAX_STATES];
+};
+
 struct amd_pmf_apts_granular {
 	u16 size;
 	struct amd_pmf_apts_output val[APTS_MAX_STATES];
@@ -1132,6 +1162,11 @@ static inline bool amd_pmf_supports_accumulator_metrics(struct amd_pmf_dev *pdev
 	}
 }
 
+static inline bool is_amd_pmf_1ah_m80h(struct amd_pmf_dev *pdev)
+{
+	return pdev->cpu_id == PCI_DEVICE_ID_AMD_1AH_M80H_ROOT;
+}
+
 /**
  * fixp_q88_fromint: Convert integer to Q8.8
  * @val: input value
@@ -1160,6 +1195,16 @@ const char *amd_pmf_source_as_str(unsigned int state);
 int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
 int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);
 
+static inline int
+apts_get_static_slider_granular_v3(struct amd_pmf_dev *pdev,
+				   struct amd_pmf_apts_granular_output_v2 *data, u32 apts_idx)
+{
+	if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+		return -EINVAL;
+
+	return apts_if_call_store_buffer(pdev, apts_idx, data, sizeof(*data));
+}
+
 static inline int
 apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
 				   struct amd_pmf_apts_granular_output *data, u32 apts_idx)
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index 2006aca200c9..d097b3f3be24 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -8,11 +8,18 @@
  * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
  */
 
+#include <linux/array_size.h>
+#include <linux/dev_printk.h>
+#include <linux/printk.h>
+#include <linux/string.h>
+
 #include "pmf.h"
 
 static struct amd_pmf_static_slider_granular_v2 config_store_v2;
 static struct amd_pmf_static_slider_granular config_store;
 static struct amd_pmf_apts_granular apts_config_store;
+static struct amd_pmf_apts_granular_v2 apts_config_store_v2;
+static bool apts_config_store_v2_valid;
 
 #ifdef CONFIG_AMD_PMF_DEBUG
 static const char *slider_v2_as_str(unsigned int state)
@@ -97,6 +104,27 @@ static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v
 	pr_debug("Static Slider APTS state index data - END\n");
 }
 
+static void amd_pmf_dump_apts_sps_defaults_v2(struct amd_pmf_apts_granular_v2 *info)
+{
+	int i;
+
+	pr_debug("Static Slider APTS index default v2 values data - BEGIN\n");
+
+	for (i = 0; i < ARRAY_SIZE(info->states); i++) {
+		pr_debug("Table Version[%d] = %u\n", i, info->states[i].table_version);
+		pr_debug("Fan Index[%d] = %u\n", i, info->states[i].fan_table_idx);
+		pr_debug("PMF Slow PPT[%d] = %u\n", i, info->states[i].pmf_slow_ppt);
+		pr_debug("PPT PMF APU[%d] = %u\n", i, info->states[i].ppt_pmf_apu_only);
+		pr_debug("STT Min[%d] = %u\n", i, info->states[i].stt_min_limit);
+		pr_debug("STT APU[%d] = %u\n", i, info->states[i].stt_skin_temp_limit_apu);
+		pr_debug("STT HS2[%d] = %u\n", i, info->states[i].stt_skin_temp_limit_hs2);
+		pr_debug("PMF Fast PPT[%d] = %u\n", i, info->states[i].pmf_fast_ppt);
+		pr_debug("PPT Fast PMF APU[%d] = %u\n", i, info->states[i].ppt_fast_pmf_apu_only);
+	}
+
+	pr_debug("Static Slider APTS index default v2 values data - END\n");
+}
+
 static void amd_pmf_dump_apts_sps_defaults(struct amd_pmf_apts_granular *info)
 {
 	int i;
@@ -119,8 +147,34 @@ static void amd_pmf_dump_apts_sps_defaults(struct amd_pmf_apts_granular *info)
 static void amd_pmf_dump_sps_defaults(struct amd_pmf_static_slider_granular *data) {}
 static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v2 *data) {}
 static void amd_pmf_dump_apts_sps_defaults(struct amd_pmf_apts_granular *info) {}
+static void amd_pmf_dump_apts_sps_defaults_v2(struct amd_pmf_apts_granular_v2 *info) {}
 #endif
 
+static int amd_pmf_load_apts_defaults_sps_v3(struct amd_pmf_dev *pdev)
+{
+	struct amd_pmf_apts_granular_output_v2 output;
+	int i, ret;
+
+	memset(&apts_config_store_v2, 0, sizeof(apts_config_store_v2));
+	apts_config_store_v2_valid = false;
+
+	for (i = 0; i < ARRAY_SIZE(apts_config_store_v2.states); i++) {
+		ret = apts_get_static_slider_granular_v3(pdev, &output, i);
+		if (ret) {
+			dev_err(pdev->dev, "Failed to read APTS v2 defaults: %d\n", ret);
+			return ret;
+		}
+
+		apts_config_store_v2.states[i] = output.val;
+	}
+
+	apts_config_store_v2_valid = true;
+
+	amd_pmf_dump_apts_sps_defaults_v2(&apts_config_store_v2);
+
+	return 0;
+}
+
 static void amd_pmf_load_apts_defaults_sps_v2(struct amd_pmf_dev *pdev)
 {
 	struct amd_pmf_apts_granular_output output;
@@ -190,6 +244,26 @@ static void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev)
 	amd_pmf_dump_sps_defaults(&config_store);
 }
 
+static void amd_pmf_update_slider_v3(struct amd_pmf_dev *dev, int idx)
+{
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_SPM, SET_CMD,
+			 apts_config_store_v2.states[idx].pmf_slow_ppt, NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_APU_ONLY, SET_CMD,
+			 apts_config_store_v2.states[idx].ppt_pmf_apu_only, NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_MIN_LIMIT, SET_CMD,
+			 apts_config_store_v2.states[idx].stt_min_limit, NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_APU, SET_CMD,
+			 fixp_q88_fromint(apts_config_store_v2.states[idx].stt_skin_temp_limit_apu),
+			 NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_HS2, SET_CMD,
+			 fixp_q88_fromint(apts_config_store_v2.states[idx].stt_skin_temp_limit_hs2),
+			 NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_FPPT_SPM, SET_CMD,
+			 apts_config_store_v2.states[idx].pmf_fast_ppt, NULL);
+	amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_FPPT_APU_ONLY, SET_CMD,
+			 apts_config_store_v2.states[idx].ppt_fast_pmf_apu_only, NULL);
+}
+
 static void amd_pmf_update_slider_v2(struct amd_pmf_dev *dev, int idx)
 {
 	amd_pmf_send_cmd(dev, SET_PMF_PPT, SET_CMD, apts_config_store.val[idx].pmf_ppt, NULL);
@@ -246,7 +320,7 @@ static int amd_pmf_update_sps_power_limits_v1(struct amd_pmf_dev *pdev, int pwr_
 	return 0;
 }
 
-static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode)
+static int amd_pmf_get_apts_idx(struct amd_pmf_dev *pdev, int pwr_mode)
 {
 	int src, index;
 
@@ -271,11 +345,39 @@ static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_
 		return -EINVAL;
 	}
 
+	return index;
+}
+
+static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode)
+{
+	int index;
+
+	index = amd_pmf_get_apts_idx(pdev, pwr_mode);
+	if (index < 0)
+		return index;
+
 	amd_pmf_update_slider_v2(pdev, index);
 
 	return 0;
 }
 
+static int amd_pmf_update_sps_power_limits_v3(struct amd_pmf_dev *pdev, int pwr_mode)
+{
+	int index;
+
+	index = amd_pmf_get_apts_idx(pdev, pwr_mode);
+	if (index < 0)
+		return index;
+
+	/* Do not send zero limits when the APTS defaults were not read */
+	if (!apts_config_store_v2_valid)
+		return -ENODATA;
+
+	amd_pmf_update_slider_v3(pdev, index);
+
+	return 0;
+}
+
 static int amd_pmf_sps_load_defaults_v1(struct amd_pmf_dev *dev)
 {
 	amd_pmf_load_defaults_sps(dev);
@@ -291,6 +393,13 @@ static int amd_pmf_sps_load_defaults_v2(struct amd_pmf_dev *dev)
 	return 0;
 }
 
+static int amd_pmf_sps_load_defaults_v3(struct amd_pmf_dev *dev)
+{
+	amd_pmf_load_defaults_sps_v2(dev);
+
+	return amd_pmf_load_apts_defaults_sps_v3(dev);
+}
+
 static const struct amd_pmf_sps_ops amd_pmf_sps_ops_v1 = {
 	.load_defaults = amd_pmf_sps_load_defaults_v1,
 	.set_power_limits = amd_pmf_update_sps_power_limits_v1,
@@ -301,12 +410,19 @@ static const struct amd_pmf_sps_ops amd_pmf_sps_ops_v2 = {
 	.set_power_limits = amd_pmf_update_sps_power_limits_v2,
 };
 
+static const struct amd_pmf_sps_ops amd_pmf_sps_ops_v3 = {
+	.load_defaults = amd_pmf_sps_load_defaults_v3,
+	.set_power_limits = amd_pmf_update_sps_power_limits_v3,
+};
+
 static void amd_pmf_select_sps_ops(struct amd_pmf_dev *dev)
 {
-	if (dev->pmf_if_version == PMF_IF_V2)
-		dev->sps_ops = &amd_pmf_sps_ops_v2;
-	else
+	if (dev->pmf_if_version != PMF_IF_V2)
 		dev->sps_ops = &amd_pmf_sps_ops_v1;
+	else if (is_amd_pmf_1ah_m80h(dev))
+		dev->sps_ops = &amd_pmf_sps_ops_v3;
+	else
+		dev->sps_ops = &amd_pmf_sps_ops_v2;
 }
 
 int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
-- 
2.34.1


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

* [PATCH v5 05/12] platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (3 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 04/12] platform/x86/amd/pmf: Add 1AH_M80H static slider support Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 06/12] platform/x86/amd/pmf: Get policy binary signature size from PSP header Shyam Sundar S K
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

The UUID list, the shared memory size and the init/enact calls of the
PMF Trusted Application (TA) are hardcoded in the driver. Upcoming
platforms use a different TA with its own shared memory layout, so
these need to be selected per platform.

Add struct amd_pmf_ta_ops to hold the per-platform TA details and use
it in place of the direct calls. All existing platforms use the
default ops, which point to the current functions.

No functional changes.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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   |  2 +-
 drivers/platform/x86/amd/pmf/core.c   |  4 ++--
 drivers/platform/x86/amd/pmf/pmf.h    |  9 +++++++++
 drivers/platform/x86/amd/pmf/tee-if.c | 27 +++++++++++++++++++++------
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index d71d592857c7..11df1b74bb18 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -300,7 +300,7 @@ static void amd_pmf_handle_early_preq(struct amd_pmf_dev *pdev)
 	if (!pdev->cb_flag)
 		return;
 
-	amd_pmf_invoke_cmd_enact(pdev);
+	pdev->ta_ops->invoke_enact(pdev);
 	pdev->cb_flag = false;
 }
 
diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index 19b75609f554..55c893552050 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -259,8 +259,8 @@ static int amd_pmf_reinit_ta(struct amd_pmf_dev *pdev)
 	bool status;
 	int ret, i;
 
-	for (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) {
-		ret = amd_pmf_tee_init(pdev, &amd_pmf_ta_uuid[i]);
+	for (i = 0; i < pdev->ta_ops->num_uuids; i++) {
+		ret = amd_pmf_tee_init(pdev, &pdev->ta_ops->uuids[i]);
 		if (ret) {
 			dev_err(pdev->dev, "TEE init failed for UUID[%d] ret: %d\n", i, ret);
 			return ret;
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index dcae081a4806..5de862187c4c 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -666,6 +666,14 @@ struct amd_pmf_sps_ops {
 	int (*set_power_limits)(struct amd_pmf_dev *dev, int pwr_mode);
 };
 
+struct amd_pmf_ta_ops {
+	const uuid_t *uuids;
+	int num_uuids;
+	size_t shm_size;
+	int (*invoke_init)(struct amd_pmf_dev *dev);
+	int (*invoke_enact)(struct amd_pmf_dev *dev);
+};
+
 struct amd_pmf_dev {
 	void __iomem *regbase;
 	void __iomem *smu_virt_addr;
@@ -726,6 +734,7 @@ struct amd_pmf_dev {
 	struct amd_pmf_arg_data dram_addr;
 	struct amd_pmf_metrics_v3 prev_metrics;	/* Previous metrics for delta calculation */
 	bool npu_metrics_have_prev;
+	const struct amd_pmf_ta_ops *ta_ops;
 };
 
 struct apmf_sps_prop_granular_v2 {
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 2ed2ea4abeb6..a0f2b4be1369 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -55,7 +55,7 @@ static void amd_pmf_prepare_args(struct amd_pmf_dev *dev, int cmd,
 	arg->num_params = MAX_TEE_PARAM;
 
 	/* Fill invoke cmd params */
-	param[0].u.memref.size = sizeof(struct ta_pmf_shared_memory);
+	param[0].u.memref.size = dev->ta_ops->shm_size;
 	param[0].attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT;
 	param[0].u.memref.shm = dev->fw_shm_pool;
 	param[0].u.memref.shm_offs = 0;
@@ -323,7 +323,7 @@ static void amd_pmf_invoke_cmd(struct work_struct *work)
 {
 	struct amd_pmf_dev *dev = container_of(work, struct amd_pmf_dev, pb_work.work);
 
-	amd_pmf_invoke_cmd_enact(dev);
+	dev->ta_ops->invoke_enact(dev);
 	schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms));
 }
 
@@ -347,7 +347,7 @@ int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
 
 	/* Update the actual length */
 	dev->policy_sz = header->length + 512;
-	res = amd_pmf_invoke_cmd_init(dev);
+	res = dev->ta_ops->invoke_init(dev);
 	if (res == TA_PMF_TYPE_SUCCESS) {
 		/* Now its safe to announce that smart pc is enabled */
 		dev->smart_pc_enabled = true;
@@ -503,7 +503,7 @@ int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
 		goto out_ctx;
 	}
 
-	size = sizeof(struct ta_pmf_shared_memory) + dev->policy_sz;
+	size = dev->ta_ops->shm_size + dev->policy_sz;
 	dev->fw_shm_pool = tee_shm_alloc_kernel_buf(dev->tee_ctx, size);
 	if (IS_ERR(dev->fw_shm_pool)) {
 		dev_err(dev->dev, "Failed to alloc TEE shared memory\n");
@@ -541,6 +541,19 @@ void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)
 	dev->tee_ctx = NULL;
 }
 
+static const struct amd_pmf_ta_ops amd_pmf_ta_default_ops = {
+	.uuids = amd_pmf_ta_uuid,
+	.num_uuids = ARRAY_SIZE(amd_pmf_ta_uuid),
+	.shm_size = sizeof(struct ta_pmf_shared_memory),
+	.invoke_init = amd_pmf_invoke_cmd_init,
+	.invoke_enact = amd_pmf_invoke_cmd_enact,
+};
+
+static void amd_pmf_select_ta_ops(struct amd_pmf_dev *dev)
+{
+	dev->ta_ops = &amd_pmf_ta_default_ops;
+}
+
 int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
 {
 	bool status;
@@ -584,8 +597,10 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
 	if (!dev->prev_data)
 		return -ENOMEM;
 
-	for (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) {
-		ret = amd_pmf_tee_init(dev, &amd_pmf_ta_uuid[i]);
+	amd_pmf_select_ta_ops(dev);
+
+	for (i = 0; i < dev->ta_ops->num_uuids; i++) {
+		ret = amd_pmf_tee_init(dev, &dev->ta_ops->uuids[i]);
 		if (ret)
 			return ret;
 
-- 
2.34.1


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

* [PATCH v5 06/12] platform/x86/amd/pmf: Get policy binary signature size from PSP header
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (4 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 05/12] platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 07/12] platform/x86/amd/pmf: Use enum system_state for the TA system state action Shyam Sundar S K
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

The policy binary size is calculated as the payload length plus a fixed
512 bytes, which assumes a 256 byte PSP header and a 256 byte RSA2K
signature. Newer policy binaries can be signed with RSA4K, which has a
512 byte signature, or with an alternative signing mechanism, which has
a signature size of its own.

Read the signature algorithm from the PSP header and use it to get the
signature size. Check that the buffer is large enough before reading
the header field, and that the size calculation does not overflow.

Policy binaries with an unknown signature algorithm are now rejected.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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    | 11 ++++++++
 drivers/platform/x86/amd/pmf/tee-if.c | 37 +++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 5de862187c4c..16ac9bac9496 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -23,12 +23,23 @@
 #include <linux/power_supply.h>
 #include <linux/platform_device.h>
 #include <linux/platform_profile.h>
+#include <linux/sizes.h>
 #include <linux/types.h>
 
 #define POLICY_BUF_MAX_SZ		0x4b000
 #define POLICY_SIGN_COOKIE		0x31535024
 #define POLICY_COOKIE_OFFSET		0x10
 
+/* Policy binary PSP header */
+#define POLICY_PSP_HEADER_SIZE		SZ_256
+#define POLICY_PSP_SIG_ALG_OFFSET	0x34
+#define POLICY_PSP_SIG_ALG_RSA2K	0
+#define POLICY_PSP_SIG_ALG_RSA4K	2
+#define POLICY_PSP_SIG_ALG_ALT		12
+#define POLICY_PSP_SIG_SIZE_RSA2K	SZ_256
+#define POLICY_PSP_SIG_SIZE_RSA4K	SZ_512
+#define POLICY_PSP_SIG_SIZE_ALT		1932
+
 /* List of supported CPU ids */
 #define AMD_CPU_ID_RMB                  0x14b5
 #define AMD_CPU_ID_PS                   0x14e8
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index a0f2b4be1369..3c26296a5815 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -11,7 +11,9 @@
 #include <linux/array_size.h>
 #include <linux/debugfs.h>
 #include <linux/dev_printk.h>
+#include <linux/overflow.h>
 #include <linux/tee_drv.h>
+#include <linux/unaligned.h>
 #include <linux/uuid.h>
 #include "pmf.h"
 
@@ -327,9 +329,35 @@ static void amd_pmf_invoke_cmd(struct work_struct *work)
 	schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms));
 }
 
+static int amd_pmf_get_pb_sig_size(struct amd_pmf_dev *dev, u32 *sig_size)
+{
+	u32 sig_alg;
+
+	if (dev->policy_sz < POLICY_PSP_SIG_ALG_OFFSET + sizeof(sig_alg))
+		return -EINVAL;
+
+	sig_alg = get_unaligned_le32(dev->policy_buf + POLICY_PSP_SIG_ALG_OFFSET);
+
+	switch (sig_alg) {
+	case POLICY_PSP_SIG_ALG_RSA2K:
+		*sig_size = POLICY_PSP_SIG_SIZE_RSA2K;
+		return 0;
+	case POLICY_PSP_SIG_ALG_RSA4K:
+		*sig_size = POLICY_PSP_SIG_SIZE_RSA4K;
+		return 0;
+	case POLICY_PSP_SIG_ALG_ALT:
+		*sig_size = POLICY_PSP_SIG_SIZE_ALT;
+		return 0;
+	default:
+		dev_dbg(dev->dev, "Unknown PSP signature algorithm: %u\n", sig_alg);
+		return -EINVAL;
+	}
+}
+
 int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
 {
 	struct cookie_header *header;
+	u32 sig_size, total_sz;
 	int res;
 
 	if (dev->policy_sz < POLICY_COOKIE_OFFSET + sizeof(*header))
@@ -342,11 +370,16 @@ int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
 		return -EINVAL;
 	}
 
-	if (dev->policy_sz < header->length + 512)
+	res = amd_pmf_get_pb_sig_size(dev, &sig_size);
+	if (res)
+		return res;
+
+	if (check_add_overflow(header->length, POLICY_PSP_HEADER_SIZE + sig_size, &total_sz) ||
+	    dev->policy_sz < total_sz)
 		return -EINVAL;
 
 	/* Update the actual length */
-	dev->policy_sz = header->length + 512;
+	dev->policy_sz = total_sz;
 	res = dev->ta_ops->invoke_init(dev);
 	if (res == TA_PMF_TYPE_SUCCESS) {
 		/* Now its safe to announce that smart pc is enabled */
-- 
2.34.1


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

* [PATCH v5 07/12] platform/x86/amd/pmf: Use enum system_state for the TA system state action
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (5 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 06/12] platform/x86/amd/pmf: Get policy binary signature size from PSP header Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 08/12] platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H Shyam Sundar S K
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

The TA reports the requested system state as 0, 1 or 2, which are the
values of enum system_state. Use the enum names instead of the literals
when handling PMF_POLICY_SYSTEM_STATE.

No functional changes.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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/tee-if.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 3c26296a5815..c0ecfefe0f1d 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -209,13 +209,13 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 
 		case PMF_POLICY_SYSTEM_STATE:
 			switch (val) {
-			case 0:
+			case SYSTEM_STATE_S0i3:
 				amd_pmf_update_uevents(dev, KEY_SLEEP);
 				break;
-			case 1:
+			case SYSTEM_STATE_S4:
 				amd_pmf_update_uevents(dev, KEY_SUSPEND);
 				break;
-			case 2:
+			case SYSTEM_STATE_SCREEN_LOCK:
 				amd_pmf_update_uevents(dev, KEY_SCREENLOCK);
 				break;
 			default:
-- 
2.34.1


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

* [PATCH v5 08/12] platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (6 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 07/12] platform/x86/amd/pmf: Use enum system_state for the TA system state action Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 09/12] platform/x86/amd/pmf: Remap metrics table on resume " Shyam Sundar S K
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

1AH_M80H uses a new PMF Trusted Application (TA) with its own UUID, a
larger shared memory layout and an extended set of policy conditions.

Add the v2 TA structures and the init/enact callbacks for this TA, and
select them through ta_ops on 1AH_M80H.

Battery, slider and sensor inputs reuse the existing helpers. SMU inputs
(socket power, skin temperature, GFX busy and C0 residency) are taken
from the accumulator based metrics table. Smart PC keeps its own
previous sample, so that it does not disturb the delta calculation of
the NPU metrics interface which reads the same table.
The skin temperature is passed in centidegrees, as on the earlier
platforms.

Key changes include:
 - Add the v2 TA shared memory, condition and result structures
 - Add amd_pmf_invoke_cmd_init_v2() and amd_pmf_invoke_cmd_enact_v2()
 - Add amd_pmf_get_smu_info_v2() to read the accumulator metrics
 - Apply the TA actions with the 1AH_M80H SMU message IDs
 - Read the v2 layout in the util interface on 1AH_M80H
 - Make the Q10 accumulator helpers and
   amd_pmf_get_metrics_table_log_sample() available to spc.c

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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/metrics.c |   9 +-
 drivers/platform/x86/amd/pmf/pmf.h     | 157 +++++++++++++++++++
 drivers/platform/x86/amd/pmf/spc.c     | 147 ++++++++++++++++++
 drivers/platform/x86/amd/pmf/tee-if.c  | 200 ++++++++++++++++++++++++-
 drivers/platform/x86/amd/pmf/util.c    |  80 +++++++---
 5 files changed, 565 insertions(+), 28 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/metrics.c b/drivers/platform/x86/amd/pmf/metrics.c
index a620272b6d67..847bc178e2f7 100644
--- a/drivers/platform/x86/amd/pmf/metrics.c
+++ b/drivers/platform/x86/amd/pmf/metrics.c
@@ -28,22 +28,21 @@
 
 static struct device *pmf_device;
 
-static u16 amd_pmf_q10_acc_to_mW(u64 avg_acc)
+u16 amd_pmf_q10_acc_to_mW(u64 avg_acc)
 {
 	u64 val = DIV_U64_ROUND_CLOSEST(avg_acc, 1024) * MILLIWATT_PER_WATT;
 
 	return min(val, U16_MAX);
 }
 
-static u16 amd_pmf_q10_acc_to_int(u64 avg_acc)
+u16 amd_pmf_q10_acc_to_int(u64 avg_acc)
 {
 	u64 val = DIV_U64_ROUND_CLOSEST(avg_acc, 1024);
 
 	return min(val, U16_MAX);
 }
 
-static u64 amd_pmf_avg_acc_metric(u32 curr_counter, u32 prev_counter,
-				  u64 curr_value, u64 prev_value)
+u64 amd_pmf_avg_acc_metric(u32 curr_counter, u32 prev_counter, u64 curr_value, u64 prev_value)
 {
 	u32 counter_diff;
 	u64 val_diff;
@@ -92,7 +91,7 @@ int amd_pmf_get_tbl_dram_addr(struct amd_pmf_dev *dev)
 	return 0;
 }
 
-static int amd_pmf_get_metrics_table_log_sample(struct amd_pmf_dev *dev)
+int amd_pmf_get_metrics_table_log_sample(struct amd_pmf_dev *dev)
 {
 	int ret;
 
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 16ac9bac9496..733bc518ddec 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -150,6 +150,15 @@ struct cookie_header {
 #define TA_ERROR_CRYPTO_INVALID_PARAM				0x20002
 #define TA_ERROR_CRYPTO_BIN_TOO_LARGE				0x2000d
 
+/* TA version-2 array sizes */
+#define TA_PMF_NUM_ACPI_SENSOR_DATA	3
+#define TA_PMF_ACPI_SENSOR_MAX		4
+#define TA_PMF_ACTION_MAX_V2		100
+#define TA_PMF_UNDO_MAX_V2		100
+#define TA_PMF_NAME_TRACKING_MAX	100
+#define TA_PMF_NAME_LENGTH_MAX		256
+#define SIDELOAD_POLICY_MAX		400
+
 #define PMF_IF_V1		1
 #define PMF_IF_V2		2
 
@@ -180,6 +189,11 @@ static const uuid_t amd_pmf_ta_uuid[] __used = { UUID_INIT(0xd9b39bf2, 0x66bd, 0
 							   0xc5, 0x29, 0xb1, 0x3d, 0x85, 0x43),
 					       };
 
+static const uuid_t amd_pmf_ta_uuid_v2[] __used = { UUID_INIT(0xf51cad64, 0xea14, 0x4789, 0xb6,
+							      0xae, 0x89, 0xec, 0x7a, 0x1b, 0x8b,
+							      0x94),
+						  };
+
 /* APTS PMF BIOS Interface */
 struct amd_pmf_apts_output {
 	u16 table_version;
@@ -746,6 +760,8 @@ struct amd_pmf_dev {
 	struct amd_pmf_metrics_v3 prev_metrics;	/* Previous metrics for delta calculation */
 	bool npu_metrics_have_prev;
 	const struct amd_pmf_ta_ops *ta_ops;
+	struct amd_pmf_metrics_v3 smartpc_prev_metrics;	/* Smart PC delta baseline */
+	bool smartpc_metrics_have_prev;
 };
 
 struct apmf_sps_prop_granular_v2 {
@@ -1140,6 +1156,138 @@ struct ta_pmf_shared_memory {
 	union ta_pmf_input pmf_input;
 };
 
+struct ta_pmf_name_eval_info {
+	u32 value1;
+	u32 value2;
+	u32 value3;
+};
+
+struct ta_pmf_name_eval_table {
+	s32 result_count;
+	struct ta_pmf_name_eval_info eval_results[TA_PMF_NAME_TRACKING_MAX];
+};
+
+struct ta_pmf_condition_info_v2 {
+	u32 power_source;
+	u32 bat_percentage;
+	u32 power_slider;
+	u32 lid_state;
+	u32 user_present;
+	u32 bios_input_1[2];
+	u32 monitor_count;
+	u32 mouse_count;
+	u32 keyboard_count;
+	u32 bat_design;
+	u32 full_charge_capacity;
+	s32 drain_rate;
+	u32 user_engaged;
+	u32 device_state;
+	u32 socket_power;
+	u32 skin_temperature;
+	u32 day_of_week;
+	u32 sys_time_minutes;
+	u32 platform_type;
+	u32 app_input1;
+	u32 app_input2;
+	u32 ambient_light;
+	u32 proc_queue_len;
+	u32 avg_c0residency;
+	u32 max_c0residency;
+	u32 s0i3_entry;
+	u32 gfx_busy;
+	u32 proc_time_avg;
+	u32 proc_time_max;
+	u32 irq_per_sec_avg;
+	u32 irq_per_sec_max;
+	u32 gpu_engine_time;
+	u32 gpu_engine_util;
+	u32 user_input_delay;
+	u32 camera_state;
+	u32 workload_type;
+	u32 display_type;
+	u32 display_state;
+	u32 asm_state;
+	u32 sensor_data[TA_PMF_ACPI_SENSOR_MAX * TA_PMF_NUM_ACPI_SENSOR_DATA];
+	u32 sensor_status[TA_PMF_ACPI_SENSOR_MAX];
+	u32 combined_socket_pwr;
+	u32 bios_input_2[8];
+	u32 hetero_state;
+	u32 game_mode;
+	u32 activity_balance;
+	u32 pepl_level;
+	u32 transport_mode;
+	u32 asm_supported;
+	u32 workload_class;
+	u32 video_enc_sessions;
+	u32 video_dec_sessions;
+	u32 rsvd[10];
+};
+
+struct ta_pmf_enact_table_v2 {
+	struct ta_pmf_condition_info_v2	ev_info;
+	struct ta_pmf_name_eval_table name_ev_info;
+};
+
+union ta_pmf_input_v2 {
+	struct ta_pmf_enact_table_v2 enact_table;
+	struct ta_pmf_init_table init_table;
+};
+
+struct ta_pmf_sideload_policy_info {
+	u16 num_policies;
+	u32 priorities[SIDELOAD_POLICY_MAX];
+	bool expression_result[SIDELOAD_POLICY_MAX];
+	bool policy_applied[SIDELOAD_POLICY_MAX];
+};
+
+struct ta_pmf_agm_log_table {
+	s32 policies_applied_count;
+	u32 policy_priority_list[TA_PMF_ACTION_MAX_V2];
+};
+
+struct ta_pmf_enact_result_v2 {
+	u32 actions_count;
+	struct ta_pmf_action actions_list[TA_PMF_ACTION_MAX_V2];
+	u32 undo_count;
+	struct ta_pmf_action undo_list[TA_PMF_UNDO_MAX_V2];
+	struct ta_pmf_agm_log_table agm_log_table;
+	struct ta_pmf_sideload_policy_info sideload_policy_info;
+};
+
+struct ta_pmf_name_info {
+	u32 type;
+	u16 name[TA_PMF_NAME_LENGTH_MAX];
+};
+
+struct ta_pmf_oem_debug_table {
+	u16 oem_major_version;
+	u16 oem_minor_version;
+};
+
+struct ta_pmf_load_policy_result {
+	bool add_policy_success;
+	bool sideload_enabled;
+	struct ta_pmf_oem_debug_table oem_table;
+	u64 conditions_to_track[8];
+	u32 max_policy_sppt_limit;
+	s32 name_count;
+	struct ta_pmf_name_info name_table;
+};
+
+union ta_pmf_output_v2 {
+	struct ta_pmf_load_policy_result load_policy_result;
+	struct ta_pmf_enact_result_v2 policy_apply_table;
+};
+
+struct ta_pmf_shared_memory_v2 {
+	int command_id;
+	int resp_id;
+	u32 pmf_result;
+	u32 if_version;
+	union ta_pmf_output_v2 pmf_output;
+	union ta_pmf_input_v2 pmf_input;
+};
+
 /* Core Layer */
 int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
 void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
@@ -1203,6 +1351,10 @@ static inline u32 fixp_q88_fromint(u32 val)
 
 /* Metrics layer */
 int amd_pmf_get_tbl_dram_addr(struct amd_pmf_dev *dev);
+int amd_pmf_get_metrics_table_log_sample(struct amd_pmf_dev *dev);
+u64 amd_pmf_avg_acc_metric(u32 curr_counter, u32 prev_counter, u64 curr_value, u64 prev_value);
+u16 amd_pmf_q10_acc_to_mW(u64 avg_acc);
+u16 amd_pmf_q10_acc_to_int(u64 avg_acc);
 
 /* SPS Layer */
 int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);
@@ -1322,6 +1474,8 @@ 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);
 int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev);
+void amd_pmf_populate_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in);
+int amd_pmf_invoke_cmd_enact_v2(struct amd_pmf_dev *dev);
 
 static inline u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
 {
@@ -1337,8 +1491,11 @@ static inline u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *i
 
 #ifdef CONFIG_AMD_PMF_DEBUG
 void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
+void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in);
 #else
 static inline void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
+static inline void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev,
+					     struct ta_pmf_enact_table_v2 *in) {}
 #endif
 
 int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid);
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index a12b4ee965a2..688001e98edf 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -12,12 +12,48 @@
 #include <acpi/button.h>
 #include <linux/amd-pmf.h>
 #include <linux/amd-pmf-io.h>
+#include <linux/array_size.h>
 #include <linux/cleanup.h>
+#include <linux/io.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
 #include <linux/power_supply.h>
 #include <linux/units.h>
 #include "pmf.h"
 
+/*
+ * The metrics table reports C0 residency per CCX, while the enabled cores
+ * are reported per core type. Core types 0-2 belong to CCX0 and type 3
+ * to CCX1.
+ */
+static const u8 core_type_to_ccx[AMD_PMF_METRIC_CORE_TYPE_MAX] = { 0, 0, 0, 1 };
+
 #ifdef CONFIG_AMD_PMF_DEBUG
+void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in)
+{
+	dev_dbg(dev->dev, "==== TA v2 inputs START ====\n");
+	dev_dbg(dev->dev, "Slider State: %s\n",
+		amd_pmf_get_slider_position(in->ev_info.power_slider));
+	dev_dbg(dev->dev, "Power Source: %s\n", amd_pmf_source_as_str(in->ev_info.power_source));
+	dev_dbg(dev->dev, "Battery Percentage: %u\n", in->ev_info.bat_percentage);
+	dev_dbg(dev->dev, "Designed Battery Capacity: %u\n", in->ev_info.bat_design);
+	dev_dbg(dev->dev, "Fully Charged Capacity: %u\n", in->ev_info.full_charge_capacity);
+	dev_dbg(dev->dev, "Drain Rate: %d\n", in->ev_info.drain_rate);
+	dev_dbg(dev->dev, "Socket Power: %u\n", in->ev_info.socket_power);
+	dev_dbg(dev->dev, "Skin Temperature: %u\n", in->ev_info.skin_temperature);
+	dev_dbg(dev->dev, "Avg C0 Residency: %u\n", in->ev_info.avg_c0residency);
+	dev_dbg(dev->dev, "Max C0 Residency: %u\n", in->ev_info.max_c0residency);
+	dev_dbg(dev->dev, "GFX Busy: %u\n", in->ev_info.gfx_busy);
+	dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open");
+	dev_dbg(dev->dev, "User Presence: %s\n", in->ev_info.user_present ? "Present" : "Away");
+	dev_dbg(dev->dev, "Ambient Light: %u\n", in->ev_info.ambient_light);
+	dev_dbg(dev->dev, "Platform type: %s\n",
+		amd_pmf_get_platform_type(in->ev_info.platform_type));
+	dev_dbg(dev->dev, "Laptop placement: %s\n",
+		amd_pmf_get_laptop_placement(in->ev_info.device_state));
+	dev_dbg(dev->dev, "==== TA v2 inputs END ====\n");
+}
+
 void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
 {
 	int i;
@@ -121,6 +157,48 @@ static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
 	rb->tail = (rb->tail + 1) & (CUSTOM_BIOS_INPUT_RING_ENTRIES - 1);
 }
 
+static void amd_pmf_get_c0_residency_v2(struct amd_pmf_metrics_v3 *curr,
+					struct amd_pmf_metrics_v3 *prev,
+					struct ta_pmf_enact_table_v2 *in)
+{
+	u32 curr_counter = curr->iod.counter_acc;
+	u32 prev_counter = prev->iod.counter_acc;
+	int active_cores = 0, core, type;
+	u64 sum_of_avgs = 0;
+	u32 local_max = 0;
+
+	if (!curr_counter) {
+		in->ev_info.avg_c0residency = 0;
+		in->ev_info.max_c0residency = 0;
+		return;
+	}
+
+	for (type = 0; type < ARRAY_SIZE(core_type_to_ccx); type++) {
+		u8 ccx = core_type_to_ccx[type];
+
+		for (core = 0; core < AMD_PMF_NUM_MAX_CORES; core++) {
+			u32 core_avg;
+			u64 avg_acc;
+
+			/* Skip cores which are not enabled */
+			if (!curr->iod.cclk_core_enabled[type][core])
+				continue;
+
+			avg_acc = amd_pmf_avg_acc_metric(curr_counter, prev_counter,
+							 curr->ccx[ccx].core_c0[core],
+							 prev->ccx[ccx].core_c0[core]);
+			core_avg = amd_pmf_q10_acc_to_int(avg_acc);
+			sum_of_avgs += core_avg;
+			active_cores++;
+
+			local_max = max(core_avg, local_max);
+		}
+	}
+
+	in->ev_info.avg_c0residency = active_cores ? div_u64(sum_of_avgs, active_cores) : 0;
+	in->ev_info.max_c0residency = local_max;
+}
+
 static void amd_pmf_get_c0_residency(u16 *core_res, size_t size, struct ta_pmf_enact_table *in)
 {
 	u16 max, avg = 0;
@@ -138,6 +216,51 @@ static void amd_pmf_get_c0_residency(u16 *core_res, size_t size, struct ta_pmf_e
 	in->ev_info.max_c0residency = max;
 }
 
+static void amd_pmf_get_smu_info_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in)
+{
+	struct amd_pmf_metrics_iod *curr, *prev;
+	u64 val;
+	int ret;
+
+	guard(mutex)(&dev->metrics_mutex);
+
+	ret = amd_pmf_get_metrics_table_log_sample(dev);
+	if (ret)
+		return;
+
+	memcpy_fromio(&dev->mtable_v3, dev->metrics_table_virt, sizeof(dev->mtable_v3));
+
+	if (!dev->smartpc_metrics_have_prev) {
+		dev->smartpc_metrics_have_prev = true;
+		goto out_update_prev;
+	}
+
+	curr = &dev->mtable_v3.iod;
+	prev = &dev->smartpc_prev_metrics.iod;
+
+	val = amd_pmf_avg_acc_metric(curr->counter_acc, prev->counter_acc,
+				     curr->apu_power_acc, prev->apu_power_acc);
+	in->ev_info.socket_power = amd_pmf_q10_acc_to_mW(val);
+
+	val = amd_pmf_avg_acc_metric(curr->counter_acc, prev->counter_acc,
+				     curr->dgpu_power_acc, prev->dgpu_power_acc);
+	in->ev_info.socket_power += amd_pmf_q10_acc_to_mW(val);
+
+	val = amd_pmf_avg_acc_metric(curr->counter_acc, prev->counter_acc,
+				     curr->stt_apu_skin_temp_acc, prev->stt_apu_skin_temp_acc);
+	/* Q10 degrees C to centidegrees, as on the earlier platforms */
+	in->ev_info.skin_temperature = DIV_U64_ROUND_CLOSEST(val * 100, 1024);
+
+	val = amd_pmf_avg_acc_metric(curr->counter_acc, prev->counter_acc,
+				     curr->gfx_busy_acc, prev->gfx_busy_acc);
+	in->ev_info.gfx_busy = amd_pmf_q10_acc_to_int(val);
+
+	amd_pmf_get_c0_residency_v2(&dev->mtable_v3, &dev->smartpc_prev_metrics, in);
+
+out_update_prev:
+	memcpy(&dev->smartpc_prev_metrics, &dev->mtable_v3, sizeof(dev->smartpc_prev_metrics));
+}
+
 static void amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
 {
 	/* Get the updated metrics table data */
@@ -268,6 +391,30 @@ static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact
 	}
 }
 
+void amd_pmf_populate_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in)
+{
+	struct ta_pmf_enact_table tmp = { };
+
+	in->ev_info.lid_state = !acpi_lid_open();
+	in->ev_info.power_source = amd_pmf_get_power_source();
+
+	amd_pmf_get_battery_info(dev, &tmp);
+	amd_pmf_get_slider_info(dev, &tmp);
+	amd_pmf_get_sensor_info(dev, &tmp);
+
+	in->ev_info.bat_percentage = tmp.ev_info.bat_percentage;
+	in->ev_info.bat_design = tmp.ev_info.bat_design;
+	in->ev_info.full_charge_capacity = tmp.ev_info.full_charge_capacity;
+	in->ev_info.drain_rate = tmp.ev_info.drain_rate;
+	in->ev_info.power_slider = tmp.ev_info.power_slider;
+	in->ev_info.user_present = tmp.ev_info.user_present;
+	in->ev_info.ambient_light = tmp.ev_info.ambient_light;
+	in->ev_info.platform_type = tmp.ev_info.platform_type;
+	in->ev_info.device_state = tmp.ev_info.device_state;
+
+	amd_pmf_get_smu_info_v2(dev, in);
+}
+
 void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
 {
 	/* TA side lid open is 1 and close is 0, hence the ! here */
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index c0ecfefe0f1d..5a9a4461438f 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -115,6 +115,110 @@ static void amd_pmf_update_bios_output(struct amd_pmf_dev *pdev, struct ta_pmf_a
 		pdev->bios_output[bios_idx] = action->value;
 }
 
+static void amd_pmf_apply_policies_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_result_v2 *out)
+{
+	struct ta_pmf_action *action;
+	u32 val;
+	int idx;
+
+	if (out->actions_count > TA_PMF_ACTION_MAX_V2) {
+		dev_err(dev->dev, "TA actions count %u exceeds max %u\n",
+			out->actions_count, TA_PMF_ACTION_MAX_V2);
+		return;
+	}
+
+	for (idx = 0; idx < out->actions_count; idx++) {
+		action = &out->actions_list[idx];
+		val = action->value;
+		switch (action->action_index) {
+		case PMF_POLICY_SPPT:
+			if (dev->prev_data->sppt != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_SPM,
+						 SET_CMD, val, NULL);
+				dev_dbg(dev->dev, "update SPPT: %u\n", val);
+				dev->prev_data->sppt = val;
+			}
+			break;
+
+		case PMF_POLICY_FPPT:
+			if (dev->prev_data->fppt != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_FPPT_SPM,
+						 SET_CMD, val, NULL);
+				dev_dbg(dev->dev, "update FPPT: %u\n", val);
+				dev->prev_data->fppt = val;
+			}
+			break;
+
+		case PMF_POLICY_SPPT_APU_ONLY:
+			if (dev->prev_data->sppt_apuonly != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_APU_ONLY,
+						 SET_CMD, val, NULL);
+				dev_dbg(dev->dev, "update SPPT_APU_ONLY: %u\n", val);
+				dev->prev_data->sppt_apuonly = val;
+			}
+			break;
+
+		case PMF_POLICY_STT_MIN:
+			if (dev->prev_data->stt_minlimit != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_MIN_LIMIT,
+						 SET_CMD, val, NULL);
+				dev_dbg(dev->dev, "update STT_MIN: %u\n", val);
+				dev->prev_data->stt_minlimit = val;
+			}
+			break;
+
+		case PMF_POLICY_STT_SKINTEMP_APU:
+			if (dev->prev_data->stt_skintemp_apu != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_APU, SET_CMD,
+						 fixp_q88_fromint(val), NULL);
+				dev_dbg(dev->dev, "update STT_LIMIT_APU: %u\n", val);
+				dev->prev_data->stt_skintemp_apu = val;
+			}
+			break;
+
+		case PMF_POLICY_STT_SKINTEMP_HS2:
+			if (dev->prev_data->stt_skintemp_hs2 != val) {
+				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_HS2, SET_CMD,
+						 fixp_q88_fromint(val), NULL);
+				dev_dbg(dev->dev, "update STT_LIMIT_HS2: %u\n", val);
+				dev->prev_data->stt_skintemp_hs2 = val;
+			}
+			break;
+
+		case PMF_POLICY_SYSTEM_STATE:
+			switch (val) {
+			case SYSTEM_STATE_S0i3:
+				amd_pmf_update_uevents(dev, KEY_SLEEP);
+				break;
+			case SYSTEM_STATE_S4:
+				amd_pmf_update_uevents(dev, KEY_SUSPEND);
+				break;
+			case SYSTEM_STATE_SCREEN_LOCK:
+				amd_pmf_update_uevents(dev, KEY_SCREENLOCK);
+				break;
+			default:
+				dev_err(dev->dev, "Invalid PMF policy system state: %u\n", val);
+			}
+
+			dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n", amd_pmf_uevent_as_str(val));
+			break;
+
+		case PMF_POLICY_BIOS_OUTPUT_1:
+		case PMF_POLICY_BIOS_OUTPUT_2:
+		case PMF_POLICY_BIOS_OUTPUT_3:
+		case PMF_POLICY_BIOS_OUTPUT_4:
+		case PMF_POLICY_BIOS_OUTPUT_5:
+		case PMF_POLICY_BIOS_OUTPUT_6:
+		case PMF_POLICY_BIOS_OUTPUT_7:
+		case PMF_POLICY_BIOS_OUTPUT_8:
+		case PMF_POLICY_BIOS_OUTPUT_9:
+		case PMF_POLICY_BIOS_OUTPUT_10:
+			amd_pmf_update_bios_output(dev, action);
+			break;
+		}
+	}
+}
+
 static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out)
 {
 	struct ta_pmf_action *action;
@@ -242,6 +346,46 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 	}
 }
 
+int amd_pmf_invoke_cmd_enact_v2(struct amd_pmf_dev *dev)
+{
+	struct ta_pmf_shared_memory_v2 *ta_sm = NULL;
+	struct ta_pmf_enact_result_v2 *out = NULL;
+	struct ta_pmf_enact_table_v2 *in = NULL;
+	struct tee_param param[MAX_TEE_PARAM];
+	struct tee_ioctl_invoke_arg arg;
+	int ret = 0;
+
+	if (!dev->tee_ctx)
+		return -ENODEV;
+
+	memset(dev->shbuf, 0, dev->policy_sz);
+	ta_sm = dev->shbuf;
+	in = &ta_sm->pmf_input.enact_table;
+	out = &ta_sm->pmf_output.policy_apply_table;
+
+	memset(ta_sm, 0, sizeof(*ta_sm));
+	ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES;
+	ta_sm->if_version = PMF_TA_IF_VERSION_MAJOR;
+
+	amd_pmf_populate_ta_inputs_v2(dev, in);
+	amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES, &arg, param);
+
+	ret = tee_client_invoke_func(dev->tee_ctx, &arg, param);
+	if (ret < 0 || arg.ret != 0) {
+		dev_err(dev->dev, "TEE enact cmd failed. err: %x, ret:%d\n", arg.ret, ret);
+		return ret ?: -EIO;
+	}
+
+	if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) {
+		amd_pmf_dump_ta_inputs_v2(dev, in);
+		dev_dbg(dev->dev, "TA v2 action count:%u result:%x\n", out->actions_count,
+			ta_sm->pmf_result);
+		amd_pmf_apply_policies_v2(dev, out);
+	}
+
+	return 0;
+}
+
 int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
 {
 	struct ta_pmf_shared_memory *ta_sm = NULL;
@@ -282,6 +426,45 @@ int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
 	return 0;
 }
 
+static int amd_pmf_invoke_cmd_init_v2(struct amd_pmf_dev *dev)
+{
+	struct ta_pmf_shared_memory_v2 *ta_sm = NULL;
+	struct tee_param param[MAX_TEE_PARAM];
+	struct ta_pmf_init_table *in = NULL;
+	struct tee_ioctl_invoke_arg arg;
+	int ret = 0;
+
+	if (!dev->tee_ctx) {
+		dev_err(dev->dev, "Failed to get TEE context\n");
+		return -ENODEV;
+	}
+
+	dev_dbg(dev->dev, "Policy Binary size: %llu bytes\n", (unsigned long long)dev->policy_sz);
+	memset(dev->shbuf, 0, dev->policy_sz);
+	ta_sm = dev->shbuf;
+
+	ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER_INITIALIZE;
+	ta_sm->if_version = PMF_TA_IF_VERSION_MAJOR;
+	in = &ta_sm->pmf_input.init_table;
+
+	in->metadata_macrocheck = false;
+	in->sku_check = false;
+	in->validate = true;
+	in->frequency = pb_actions_ms;
+	in->policies_table.table_size = dev->policy_sz;
+
+	memcpy(in->policies_table.table, dev->policy_buf, dev->policy_sz);
+	amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER_INITIALIZE, &arg, param);
+
+	ret = tee_client_invoke_func(dev->tee_ctx, &arg, param);
+	if (ret < 0 || arg.ret != 0) {
+		dev_err(dev->dev, "Failed to invoke TEE init cmd. err: %x, ret:%d\n", arg.ret, ret);
+		return ret ?: -EIO;
+	}
+
+	return ta_sm->pmf_result;
+}
+
 static int amd_pmf_invoke_cmd_init(struct amd_pmf_dev *dev)
 {
 	struct ta_pmf_shared_memory *ta_sm = NULL;
@@ -582,9 +765,24 @@ static const struct amd_pmf_ta_ops amd_pmf_ta_default_ops = {
 	.invoke_enact = amd_pmf_invoke_cmd_enact,
 };
 
+static const struct amd_pmf_ta_ops amd_pmf_ta_ops_v2 = {
+	.uuids = amd_pmf_ta_uuid_v2,
+	.num_uuids = ARRAY_SIZE(amd_pmf_ta_uuid_v2),
+	.shm_size = sizeof(struct ta_pmf_shared_memory_v2),
+	.invoke_enact = amd_pmf_invoke_cmd_enact_v2,
+	.invoke_init = amd_pmf_invoke_cmd_init_v2,
+};
+
 static void amd_pmf_select_ta_ops(struct amd_pmf_dev *dev)
 {
-	dev->ta_ops = &amd_pmf_ta_default_ops;
+	switch (dev->cpu_id) {
+	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
+		dev->ta_ops = &amd_pmf_ta_ops_v2;
+		break;
+	default:
+		dev->ta_ops = &amd_pmf_ta_default_ops;
+		break;
+	}
 }
 
 int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
diff --git a/drivers/platform/x86/amd/pmf/util.c b/drivers/platform/x86/amd/pmf/util.c
index 2befc1b14842..f6244d2f4c22 100644
--- a/drivers/platform/x86/amd/pmf/util.c
+++ b/drivers/platform/x86/amd/pmf/util.c
@@ -20,36 +20,15 @@
 static struct amd_pmf_dev *pmf_dev_handle;
 static DEFINE_MUTEX(pmf_util_lock);
 
-static int amd_pmf_populate_data(struct amd_pmf_dev *pdev, struct amd_pmf_info *info)
+static void amd_pmf_populate_ta_data(struct amd_pmf_dev *pdev, struct amd_pmf_info *info)
 {
 	struct ta_pmf_shared_memory *ta_sm = NULL;
 	struct ta_pmf_enact_table *in = NULL;
 	int idx;
 
-	if (!pdev || !info)
-		return -EINVAL;
-
-	if (!pdev->shbuf)
-		return -EINVAL;
-
 	ta_sm = pdev->shbuf;
 	in = &ta_sm->pmf_input.enact_table;
 
-	/* Set size */
-	info->size = sizeof(*info);
-
-	/* PMF Feature support flags */
-	if (is_apmf_func_supported(pdev, APMF_FUNC_AUTO_MODE))
-		info->features_supported |= AMD_PMF_FEAT_AUTO_MODE;
-	if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
-		info->features_supported |= AMD_PMF_FEAT_STATIC_POWER_SLIDER;
-	if (pdev->smart_pc_enabled)
-		info->features_supported |= AMD_PMF_FEAT_POLICY_BUILDER;
-	if (is_apmf_func_supported(pdev, APMF_FUNC_DYN_SLIDER_AC))
-		info->features_supported |= AMD_PMF_FEAT_DYNAMIC_POWER_SLIDER_AC;
-	if (is_apmf_func_supported(pdev, APMF_FUNC_DYN_SLIDER_DC))
-		info->features_supported |= AMD_PMF_FEAT_DYNAMIC_POWER_SLIDER_DC;
-
 	/* Device States */
 	info->platform_type = in->ev_info.platform_type;
 	info->laptop_placement = in->ev_info.device_state;
@@ -69,6 +48,63 @@ static int amd_pmf_populate_data(struct amd_pmf_dev *pdev, struct amd_pmf_info *
 	/* Custom BIOS input parameters */
 	for (idx = 0; idx < AMD_PMF_BIOS_PARAMS_MAX; idx++)
 		info->bios_input[idx] = amd_pmf_get_ta_custom_bios_inputs(in, idx);
+}
+
+static void amd_pmf_populate_ta_data_v2(struct amd_pmf_dev *pdev, struct amd_pmf_info *info)
+{
+	struct ta_pmf_shared_memory_v2 *ta_sm = NULL;
+	struct ta_pmf_enact_table_v2 *in = NULL;
+
+	ta_sm = pdev->shbuf;
+	in = &ta_sm->pmf_input.enact_table;
+
+	/* Device States */
+	info->platform_type = in->ev_info.platform_type;
+	info->laptop_placement = in->ev_info.device_state;
+	info->lid_state = in->ev_info.lid_state;
+	info->user_presence = in->ev_info.user_present;
+	info->slider_position = in->ev_info.power_slider;
+
+	/* Thermal and Power Metrics */
+	info->power_source = in->ev_info.power_source;
+	info->skin_temp = in->ev_info.skin_temperature;
+	info->gfx_busy = in->ev_info.gfx_busy;
+	info->ambient_light = in->ev_info.ambient_light;
+	info->avg_c0_residency = in->ev_info.avg_c0residency;
+	info->max_c0_residency = in->ev_info.max_c0residency;
+	info->socket_power = in->ev_info.socket_power;
+}
+
+static int amd_pmf_populate_data(struct amd_pmf_dev *pdev, struct amd_pmf_info *info)
+{
+	int idx;
+
+	if (!pdev || !info)
+		return -EINVAL;
+
+	if (!pdev->shbuf)
+		return -EINVAL;
+
+	/* Set size */
+	info->size = sizeof(*info);
+
+	/* PMF Feature support flags */
+	if (is_apmf_func_supported(pdev, APMF_FUNC_AUTO_MODE))
+		info->features_supported |= AMD_PMF_FEAT_AUTO_MODE;
+	if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+		info->features_supported |= AMD_PMF_FEAT_STATIC_POWER_SLIDER;
+	if (pdev->smart_pc_enabled)
+		info->features_supported |= AMD_PMF_FEAT_POLICY_BUILDER;
+	if (is_apmf_func_supported(pdev, APMF_FUNC_DYN_SLIDER_AC))
+		info->features_supported |= AMD_PMF_FEAT_DYNAMIC_POWER_SLIDER_AC;
+	if (is_apmf_func_supported(pdev, APMF_FUNC_DYN_SLIDER_DC))
+		info->features_supported |= AMD_PMF_FEAT_DYNAMIC_POWER_SLIDER_DC;
+
+	/* 1AH_M80H uses the v2 TA shared memory layout */
+	if (is_amd_pmf_1ah_m80h(pdev))
+		amd_pmf_populate_ta_data_v2(pdev, info);
+	else
+		amd_pmf_populate_ta_data(pdev, info);
 
 	/* BIOS output parameters */
 	for (idx = 0; idx < AMD_PMF_BIOS_PARAMS_MAX; idx++)
-- 
2.34.1


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

* [PATCH v5 09/12] platform/x86/amd/pmf: Remap metrics table on resume for 1AH_M80H
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (7 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 08/12] platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 10/12] platform/x86/amd/pmf: Add custom BIOS input support " Shyam Sundar S K
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

On 1AH_M80H the metrics table address is provided by PMFW, and PMFW may
place the table at a different address after a suspend/resume or
hibernate cycle. Reading through the old mapping then returns wrong
accumulator values, which end up as wrong inputs to the TA and the NPU
metrics interface.

Add amd_pmf_remap_metrics_table() and call it from the resume and
restore handlers. It gets the table address from PMFW again and maps
it under metrics_mutex. The previous samples of Smart PC and NPU
metrics are dropped, so that the first sample after resume starts a
new baseline.

A failure to get the new address is logged and does not fail the
resume, so that Smart PC keeps running with the other inputs.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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/core.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index 55c893552050..26ce4132b809 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -12,6 +12,7 @@
 #include <linux/cleanup.h>
 #include <linux/debugfs.h>
 #include <linux/dev_printk.h>
+#include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
@@ -277,6 +278,25 @@ static int amd_pmf_reinit_ta(struct amd_pmf_dev *pdev)
 	return 0;
 }
 
+static void amd_pmf_remap_metrics_table(struct amd_pmf_dev *pdev)
+{
+	if (!amd_pmf_supports_accumulator_metrics(pdev))
+		return;
+
+	guard(mutex)(&pdev->metrics_mutex);
+
+	if (pdev->metrics_table_virt) {
+		devm_iounmap(pdev->dev, pdev->metrics_table_virt);
+		pdev->metrics_table_virt = NULL;
+	}
+
+	pdev->smartpc_metrics_have_prev = false;
+	pdev->npu_metrics_have_prev = false;
+
+	/* On failure, metrics stay unavailable until the next resume */
+	amd_pmf_get_tbl_dram_addr(pdev);
+}
+
 static int amd_pmf_restore_handler(struct device *dev)
 {
 	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
@@ -288,6 +308,8 @@ static int amd_pmf_restore_handler(struct device *dev)
 			return ret;
 	}
 
+	amd_pmf_remap_metrics_table(pdev);
+
 	if (pdev->smart_pc_enabled)
 		amd_pmf_reinit_ta(pdev);
 
@@ -336,6 +358,8 @@ static int amd_pmf_resume_handler(struct device *dev)
 	if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
 		amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_RESUME);
 
+	amd_pmf_remap_metrics_table(pdev);
+
 	if (pdev->smart_pc_enabled)
 		schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000));
 
-- 
2.34.1


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

* [PATCH v5 10/12] platform/x86/amd/pmf: Add custom BIOS input support for 1AH_M80H
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (8 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 09/12] platform/x86/amd/pmf: Remap metrics table on resume " Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 11/12] platform/x86/amd/pmf: Share TA policy apply code between TA versions Shyam Sundar S K
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

Custom BIOS inputs 1-10 are reported through the APMF SBIOS requests
function in the same way as on 1AH_M20H and 1AH_M60H, but on 1AH_M80H
they are not passed to the TA yet.

Store the inputs in the existing ring buffer on 1AH_M80H and fill them
into the v2 TA condition table. Also report them through the util
interface. The SBIOS request layout up to the custom inputs is the
same, so the existing structure is used.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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 |  1 +
 drivers/platform/x86/amd/pmf/pmf.h  | 12 ++++++
 drivers/platform/x86/amd/pmf/spc.c  | 61 +++++++++++++++++++++++++++++
 drivers/platform/x86/amd/pmf/util.c |  5 +++
 4 files changed, 79 insertions(+)

diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 11df1b74bb18..d2462ad7695d 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -278,6 +278,7 @@ static void amd_pmf_custom_bios_inputs_rb(struct amd_pmf_dev *pmf_dev)
 		break;
 	case PCI_DEVICE_ID_AMD_1AH_M20H_ROOT:
 	case PCI_DEVICE_ID_AMD_1AH_M60H_ROOT:
+	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
 		for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
 			rb->data[rb->head].val[i] = pmf_dev->req.custom_policy[i];
 		rb->data[rb->head].preq = pmf_dev->req.pending_req;
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 733bc518ddec..dcd468864074 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -1489,6 +1489,18 @@ static inline u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *i
 	}
 }
 
+static inline u32 amd_pmf_get_ta_custom_bios_inputs_v2(struct ta_pmf_enact_table_v2 *in, int index)
+{
+	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;
+	}
+}
+
 #ifdef CONFIG_AMD_PMF_DEBUG
 void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
 void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in);
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 688001e98edf..da3793b77fd7 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -31,6 +31,8 @@ static const u8 core_type_to_ccx[AMD_PMF_METRIC_CORE_TYPE_MAX] = { 0, 0, 0, 1 };
 #ifdef CONFIG_AMD_PMF_DEBUG
 void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_table_v2 *in)
 {
+	int i;
+
 	dev_dbg(dev->dev, "==== TA v2 inputs START ====\n");
 	dev_dbg(dev->dev, "Slider State: %s\n",
 		amd_pmf_get_slider_position(in->ev_info.power_slider));
@@ -51,6 +53,9 @@ void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_tabl
 		amd_pmf_get_platform_type(in->ev_info.platform_type));
 	dev_dbg(dev->dev, "Laptop placement: %s\n",
 		amd_pmf_get_laptop_placement(in->ev_info.device_state));
+	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_v2(in, i));
 	dev_dbg(dev->dev, "==== TA v2 inputs END ====\n");
 }
 
@@ -85,6 +90,19 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
 }
 #endif
 
+static void amd_pmf_set_ta_custom_bios_input_v2(struct ta_pmf_enact_table_v2 *in,
+						int index, u32 value)
+{
+	switch (index) {
+	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;
+	}
+}
+
 /*
  * 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
@@ -104,6 +122,21 @@ static void amd_pmf_set_ta_custom_bios_input(struct ta_pmf_enact_table *in, int
 	}
 }
 
+static void amd_pmf_update_bios_inputs_v2(struct amd_pmf_dev *pdev,
+					  struct pmf_bios_input_entry *data,
+					  struct ta_pmf_enact_table_v2 *in)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
+		if (!(data->preq & custom_bios_inputs[i].bit_mask))
+			continue;
+		amd_pmf_set_ta_custom_bios_input_v2(in, i, data->val[i]);
+		pdev->cb_prev.custom_bios_inputs[i] = data->val[i];
+		dev_dbg(pdev->dev, "Custom BIOS Input[%d]: %u\n", i, data->val[i]);
+	}
+}
+
 static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, struct pmf_bios_input_entry *data,
 				       const struct amd_pmf_pb_bitmap *inputs,
 				       struct ta_pmf_enact_table *in)
@@ -119,6 +152,33 @@ static void amd_pmf_update_bios_inputs(struct amd_pmf_dev *pdev, struct pmf_bios
 	}
 }
 
+static void amd_pmf_get_custom_bios_inputs_v2(struct amd_pmf_dev *pdev,
+					      struct ta_pmf_enact_table_v2 *in)
+{
+	struct pmf_cbi_ring_buffer *rb = &pdev->cbi_buf;
+	unsigned int i;
+
+	guard(mutex)(&pdev->cbi_mutex);
+
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
+		amd_pmf_set_ta_custom_bios_input_v2(in, i, pdev->cb_prev.custom_bios_inputs[i]);
+
+	if (CIRC_CNT(rb->head, rb->tail, CUSTOM_BIOS_INPUT_RING_ENTRIES) == 0)
+		return;
+
+	/* If no active custom BIOS input pending request, do not consume further work */
+	if (!rb->data[rb->tail].preq)
+		goto out_rbadvance;
+
+	if (!pdev->smart_pc_enabled)
+		return;
+
+	amd_pmf_update_bios_inputs_v2(pdev, &rb->data[rb->tail], in);
+
+out_rbadvance:
+	rb->tail = (rb->tail + 1) & (CUSTOM_BIOS_INPUT_RING_ENTRIES - 1);
+}
+
 static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
 					   struct ta_pmf_enact_table *in)
 {
@@ -413,6 +473,7 @@ void amd_pmf_populate_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 	in->ev_info.device_state = tmp.ev_info.device_state;
 
 	amd_pmf_get_smu_info_v2(dev, in);
+	amd_pmf_get_custom_bios_inputs_v2(dev, in);
 }
 
 void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
diff --git a/drivers/platform/x86/amd/pmf/util.c b/drivers/platform/x86/amd/pmf/util.c
index f6244d2f4c22..f8b716ad6d3a 100644
--- a/drivers/platform/x86/amd/pmf/util.c
+++ b/drivers/platform/x86/amd/pmf/util.c
@@ -54,6 +54,7 @@ static void amd_pmf_populate_ta_data_v2(struct amd_pmf_dev *pdev, struct amd_pmf
 {
 	struct ta_pmf_shared_memory_v2 *ta_sm = NULL;
 	struct ta_pmf_enact_table_v2 *in = NULL;
+	int idx;
 
 	ta_sm = pdev->shbuf;
 	in = &ta_sm->pmf_input.enact_table;
@@ -73,6 +74,10 @@ static void amd_pmf_populate_ta_data_v2(struct amd_pmf_dev *pdev, struct amd_pmf
 	info->avg_c0_residency = in->ev_info.avg_c0residency;
 	info->max_c0_residency = in->ev_info.max_c0residency;
 	info->socket_power = in->ev_info.socket_power;
+
+	/* Custom BIOS input parameters */
+	for (idx = 0; idx < AMD_PMF_BIOS_PARAMS_MAX; idx++)
+		info->bios_input[idx] = amd_pmf_get_ta_custom_bios_inputs_v2(in, idx);
 }
 
 static int amd_pmf_populate_data(struct amd_pmf_dev *pdev, struct amd_pmf_info *info)
-- 
2.34.1


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

* [PATCH v5 11/12] platform/x86/amd/pmf: Share TA policy apply code between TA versions
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (9 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 10/12] platform/x86/amd/pmf: Add custom BIOS input support " Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-11-30  7:52 ` [PATCH v5 12/12] platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H Shyam Sundar S K
  2026-12-01 11:35 ` [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Ilpo Järvinen
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

amd_pmf_apply_policies() and amd_pmf_apply_policies_v2() handle the
same TA actions and differ only in the SMU message IDs used to program
the limits.

Add a table of SMU message IDs to ta_ops and use a single function for
both TA versions. Actions without a message ID on a platform are
ignored, as before. The check on the number of actions returned by
the TA now applies to all platforms.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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    |   3 +
 drivers/platform/x86/amd/pmf/tee-if.c | 197 +++++++++-----------------
 2 files changed, 73 insertions(+), 127 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index dcd468864074..00e2b161c4e5 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -677,6 +677,8 @@ struct amd_pmf_arg_data {
 
 struct amd_pmf_dev;
 
+struct amd_pmf_policy_msg_ids;
+
 /**
  * struct amd_pmf_sps_ops - Static slider operations
  * @load_defaults: Read the static slider defaults advertised by the BIOS
@@ -695,6 +697,7 @@ struct amd_pmf_ta_ops {
 	const uuid_t *uuids;
 	int num_uuids;
 	size_t shm_size;
+	const struct amd_pmf_policy_msg_ids *msg_ids;
 	int (*invoke_init)(struct amd_pmf_dev *dev);
 	int (*invoke_enact)(struct amd_pmf_dev *dev);
 };
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 5a9a4461438f..38c5c884f8f8 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -115,163 +115,102 @@ static void amd_pmf_update_bios_output(struct amd_pmf_dev *pdev, struct ta_pmf_a
 		pdev->bios_output[bios_idx] = action->value;
 }
 
-static void amd_pmf_apply_policies_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_result_v2 *out)
-{
-	struct ta_pmf_action *action;
-	u32 val;
-	int idx;
-
-	if (out->actions_count > TA_PMF_ACTION_MAX_V2) {
-		dev_err(dev->dev, "TA actions count %u exceeds max %u\n",
-			out->actions_count, TA_PMF_ACTION_MAX_V2);
-		return;
-	}
-
-	for (idx = 0; idx < out->actions_count; idx++) {
-		action = &out->actions_list[idx];
-		val = action->value;
-		switch (action->action_index) {
-		case PMF_POLICY_SPPT:
-			if (dev->prev_data->sppt != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_SPM,
-						 SET_CMD, val, NULL);
-				dev_dbg(dev->dev, "update SPPT: %u\n", val);
-				dev->prev_data->sppt = val;
-			}
-			break;
-
-		case PMF_POLICY_FPPT:
-			if (dev->prev_data->fppt != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_FPPT_SPM,
-						 SET_CMD, val, NULL);
-				dev_dbg(dev->dev, "update FPPT: %u\n", val);
-				dev->prev_data->fppt = val;
-			}
-			break;
-
-		case PMF_POLICY_SPPT_APU_ONLY:
-			if (dev->prev_data->sppt_apuonly != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_PMF_SPPT_APU_ONLY,
-						 SET_CMD, val, NULL);
-				dev_dbg(dev->dev, "update SPPT_APU_ONLY: %u\n", val);
-				dev->prev_data->sppt_apuonly = val;
-			}
-			break;
-
-		case PMF_POLICY_STT_MIN:
-			if (dev->prev_data->stt_minlimit != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_MIN_LIMIT,
-						 SET_CMD, val, NULL);
-				dev_dbg(dev->dev, "update STT_MIN: %u\n", val);
-				dev->prev_data->stt_minlimit = val;
-			}
-			break;
-
-		case PMF_POLICY_STT_SKINTEMP_APU:
-			if (dev->prev_data->stt_skintemp_apu != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_APU, SET_CMD,
-						 fixp_q88_fromint(val), NULL);
-				dev_dbg(dev->dev, "update STT_LIMIT_APU: %u\n", val);
-				dev->prev_data->stt_skintemp_apu = val;
-			}
-			break;
-
-		case PMF_POLICY_STT_SKINTEMP_HS2:
-			if (dev->prev_data->stt_skintemp_hs2 != val) {
-				amd_pmf_send_cmd(dev, SET_1AH_M80H_STT_LIMIT_HS2, SET_CMD,
-						 fixp_q88_fromint(val), NULL);
-				dev_dbg(dev->dev, "update STT_LIMIT_HS2: %u\n", val);
-				dev->prev_data->stt_skintemp_hs2 = val;
-			}
-			break;
-
-		case PMF_POLICY_SYSTEM_STATE:
-			switch (val) {
-			case SYSTEM_STATE_S0i3:
-				amd_pmf_update_uevents(dev, KEY_SLEEP);
-				break;
-			case SYSTEM_STATE_S4:
-				amd_pmf_update_uevents(dev, KEY_SUSPEND);
-				break;
-			case SYSTEM_STATE_SCREEN_LOCK:
-				amd_pmf_update_uevents(dev, KEY_SCREENLOCK);
-				break;
-			default:
-				dev_err(dev->dev, "Invalid PMF policy system state: %u\n", val);
-			}
+/* SMU message IDs used to apply the TA policy actions, 0 if not supported */
+struct amd_pmf_policy_msg_ids {
+	u8 spl;
+	u8 sppt;
+	u8 fppt;
+	u8 sppt_apu_only;
+	u8 stt_min;
+	u8 stt_skintemp_apu;
+	u8 stt_skintemp_hs2;
+	u8 p3t;
+	u8 pmf_ppt;
+	u8 pmf_ppt_apu_only;
+};
 
-			dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n", amd_pmf_uevent_as_str(val));
-			break;
+static const struct amd_pmf_policy_msg_ids amd_pmf_policy_default_msg_ids = {
+	.spl = SET_SPL,
+	.sppt = SET_SPPT,
+	.fppt = SET_FPPT,
+	.sppt_apu_only = SET_SPPT_APU_ONLY,
+	.stt_min = SET_STT_MIN_LIMIT,
+	.stt_skintemp_apu = SET_STT_LIMIT_APU,
+	.stt_skintemp_hs2 = SET_STT_LIMIT_HS2,
+	.p3t = SET_P3T,
+	.pmf_ppt = SET_PMF_PPT,
+	.pmf_ppt_apu_only = SET_PMF_PPT_APU_ONLY,
+};
 
-		case PMF_POLICY_BIOS_OUTPUT_1:
-		case PMF_POLICY_BIOS_OUTPUT_2:
-		case PMF_POLICY_BIOS_OUTPUT_3:
-		case PMF_POLICY_BIOS_OUTPUT_4:
-		case PMF_POLICY_BIOS_OUTPUT_5:
-		case PMF_POLICY_BIOS_OUTPUT_6:
-		case PMF_POLICY_BIOS_OUTPUT_7:
-		case PMF_POLICY_BIOS_OUTPUT_8:
-		case PMF_POLICY_BIOS_OUTPUT_9:
-		case PMF_POLICY_BIOS_OUTPUT_10:
-			amd_pmf_update_bios_output(dev, action);
-			break;
-		}
-	}
-}
+static const struct amd_pmf_policy_msg_ids amd_pmf_policy_msg_ids_v2 = {
+	.sppt = SET_1AH_M80H_PMF_SPPT_SPM,
+	.fppt = SET_1AH_M80H_PMF_FPPT_SPM,
+	.sppt_apu_only = SET_1AH_M80H_PMF_SPPT_APU_ONLY,
+	.stt_min = SET_1AH_M80H_STT_MIN_LIMIT,
+	.stt_skintemp_apu = SET_1AH_M80H_STT_LIMIT_APU,
+	.stt_skintemp_hs2 = SET_1AH_M80H_STT_LIMIT_HS2,
+};
 
-static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out)
+static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_action *actions,
+				   u32 count, u32 max)
 {
+	const struct amd_pmf_policy_msg_ids *ids = dev->ta_ops->msg_ids;
 	struct ta_pmf_action *action;
 	u32 val;
 	int idx;
 
-	for (idx = 0; idx < out->actions_count; idx++) {
-		action = &out->actions_list[idx];
+	if (count > max) {
+		dev_err(dev->dev, "TA actions count %u exceeds max %u\n", count, max);
+		return;
+	}
+
+	for (idx = 0; idx < count; idx++) {
+		action = &actions[idx];
 		val = action->value;
 		switch (action->action_index) {
 		case PMF_POLICY_SPL:
-			if (dev->prev_data->spl != val) {
-				amd_pmf_send_cmd(dev, SET_SPL, SET_CMD, val, NULL);
+			if (ids->spl && dev->prev_data->spl != val) {
+				amd_pmf_send_cmd(dev, ids->spl, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update SPL: %u\n", val);
 				dev->prev_data->spl = val;
 			}
 			break;
 
 		case PMF_POLICY_SPPT:
-			if (dev->prev_data->sppt != val) {
-				amd_pmf_send_cmd(dev, SET_SPPT, SET_CMD, val, NULL);
+			if (ids->sppt && dev->prev_data->sppt != val) {
+				amd_pmf_send_cmd(dev, ids->sppt, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update SPPT: %u\n", val);
 				dev->prev_data->sppt = val;
 			}
 			break;
 
 		case PMF_POLICY_FPPT:
-			if (dev->prev_data->fppt != val) {
-				amd_pmf_send_cmd(dev, SET_FPPT, SET_CMD, val, NULL);
+			if (ids->fppt && dev->prev_data->fppt != val) {
+				amd_pmf_send_cmd(dev, ids->fppt, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update FPPT: %u\n", val);
 				dev->prev_data->fppt = val;
 			}
 			break;
 
 		case PMF_POLICY_SPPT_APU_ONLY:
-			if (dev->prev_data->sppt_apuonly != val) {
-				amd_pmf_send_cmd(dev, SET_SPPT_APU_ONLY, SET_CMD, val, NULL);
+			if (ids->sppt_apu_only && dev->prev_data->sppt_apuonly != val) {
+				amd_pmf_send_cmd(dev, ids->sppt_apu_only, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update SPPT_APU_ONLY: %u\n", val);
 				dev->prev_data->sppt_apuonly = val;
 			}
 			break;
 
 		case PMF_POLICY_STT_MIN:
-			if (dev->prev_data->stt_minlimit != val) {
-				amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, SET_CMD, val, NULL);
+			if (ids->stt_min && dev->prev_data->stt_minlimit != val) {
+				amd_pmf_send_cmd(dev, ids->stt_min, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update STT_MIN: %u\n", val);
 				dev->prev_data->stt_minlimit = val;
 			}
 			break;
 
 		case PMF_POLICY_STT_SKINTEMP_APU:
-			if (dev->prev_data->stt_skintemp_apu != val) {
-				amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, SET_CMD,
+			if (ids->stt_skintemp_apu && dev->prev_data->stt_skintemp_apu != val) {
+				amd_pmf_send_cmd(dev, ids->stt_skintemp_apu, SET_CMD,
 						 fixp_q88_fromint(val), NULL);
 				dev_dbg(dev->dev, "update STT_SKINTEMP_APU: %u\n", val);
 				dev->prev_data->stt_skintemp_apu = val;
@@ -279,8 +218,8 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 			break;
 
 		case PMF_POLICY_STT_SKINTEMP_HS2:
-			if (dev->prev_data->stt_skintemp_hs2 != val) {
-				amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, SET_CMD,
+			if (ids->stt_skintemp_hs2 && dev->prev_data->stt_skintemp_hs2 != val) {
+				amd_pmf_send_cmd(dev, ids->stt_skintemp_hs2, SET_CMD,
 						 fixp_q88_fromint(val), NULL);
 				dev_dbg(dev->dev, "update STT_SKINTEMP_HS2: %u\n", val);
 				dev->prev_data->stt_skintemp_hs2 = val;
@@ -288,24 +227,24 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 			break;
 
 		case PMF_POLICY_P3T:
-			if (dev->prev_data->p3t_limit != val) {
-				amd_pmf_send_cmd(dev, SET_P3T, SET_CMD, val, NULL);
+			if (ids->p3t && dev->prev_data->p3t_limit != val) {
+				amd_pmf_send_cmd(dev, ids->p3t, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update P3T: %u\n", val);
 				dev->prev_data->p3t_limit = val;
 			}
 			break;
 
 		case PMF_POLICY_PMF_PPT:
-			if (dev->prev_data->pmf_ppt != val) {
-				amd_pmf_send_cmd(dev, SET_PMF_PPT, SET_CMD, val, NULL);
+			if (ids->pmf_ppt && dev->prev_data->pmf_ppt != val) {
+				amd_pmf_send_cmd(dev, ids->pmf_ppt, SET_CMD, 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, SET_CMD, val, NULL);
+			if (ids->pmf_ppt_apu_only && dev->prev_data->pmf_ppt_apu_only != val) {
+				amd_pmf_send_cmd(dev, ids->pmf_ppt_apu_only, SET_CMD, val, NULL);
 				dev_dbg(dev->dev, "update PMF PPT APU ONLY: %u\n", val);
 				dev->prev_data->pmf_ppt_apu_only = val;
 			}
@@ -323,7 +262,7 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 				amd_pmf_update_uevents(dev, KEY_SCREENLOCK);
 				break;
 			default:
-				dev_err(dev->dev, "Invalid PMF policy system state: %d\n", val);
+				dev_err(dev->dev, "Invalid PMF policy system state: %u\n", val);
 			}
 
 			dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n",
@@ -380,7 +319,8 @@ int amd_pmf_invoke_cmd_enact_v2(struct amd_pmf_dev *dev)
 		amd_pmf_dump_ta_inputs_v2(dev, in);
 		dev_dbg(dev->dev, "TA v2 action count:%u result:%x\n", out->actions_count,
 			ta_sm->pmf_result);
-		amd_pmf_apply_policies_v2(dev, out);
+		amd_pmf_apply_policies(dev, out->actions_list, out->actions_count,
+				       ARRAY_SIZE(out->actions_list));
 	}
 
 	return 0;
@@ -420,7 +360,8 @@ int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
 		amd_pmf_dump_ta_inputs(dev, in);
 		dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count,
 			ta_sm->pmf_result);
-		amd_pmf_apply_policies(dev, out);
+		amd_pmf_apply_policies(dev, out->actions_list, out->actions_count,
+				       ARRAY_SIZE(out->actions_list));
 	}
 
 	return 0;
@@ -761,6 +702,7 @@ static const struct amd_pmf_ta_ops amd_pmf_ta_default_ops = {
 	.uuids = amd_pmf_ta_uuid,
 	.num_uuids = ARRAY_SIZE(amd_pmf_ta_uuid),
 	.shm_size = sizeof(struct ta_pmf_shared_memory),
+	.msg_ids = &amd_pmf_policy_default_msg_ids,
 	.invoke_init = amd_pmf_invoke_cmd_init,
 	.invoke_enact = amd_pmf_invoke_cmd_enact,
 };
@@ -769,6 +711,7 @@ static const struct amd_pmf_ta_ops amd_pmf_ta_ops_v2 = {
 	.uuids = amd_pmf_ta_uuid_v2,
 	.num_uuids = ARRAY_SIZE(amd_pmf_ta_uuid_v2),
 	.shm_size = sizeof(struct ta_pmf_shared_memory_v2),
+	.msg_ids = &amd_pmf_policy_msg_ids_v2,
 	.invoke_enact = amd_pmf_invoke_cmd_enact_v2,
 	.invoke_init = amd_pmf_invoke_cmd_init_v2,
 };
-- 
2.34.1


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

* [PATCH v5 12/12] platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (10 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 11/12] platform/x86/amd/pmf: Share TA policy apply code between TA versions Shyam Sundar S K
@ 2026-11-30  7:52 ` Shyam Sundar S K
  2026-12-01 11:35 ` [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Ilpo Järvinen
  12 siblings, 0 replies; 16+ messages in thread
From: Shyam Sundar S K @ 2026-11-30  7:52 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: platform-driver-x86, Patil.Reddy, mario.limonciello,
	Shyam Sundar S K, Mario Limonciello

Earlier platforms support up to 10 custom BIOS inputs through the APMF
SBIOS requests function. APMF 2.03 extends this to 20 inputs on
1AH_M80H: the SBIOS request structure gets a second set of 10 values,
and inputs 11-20 have their own notification bits (16-25).

Add the APMF 2.03 SBIOS request structure and use it on 1AH_M80H. Size
the ring buffer entries and the saved values for 20 inputs. Older
platforms keep filling only the first 10 entries. Pass inputs 11-20 to
the TA in the bios_input_3 fields of the v2 condition table, which were
reserved until now.

Add apmf_get_custom_policy_ext() to get an input from the set it belongs
to, and read the SBIOS requests through amd_pmf_read_sbios_requests_v2()
so that the event handler stays the same for all platforms.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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 | 31 ++++++++++++--
 drivers/platform/x86/amd/pmf/pmf.h  | 66 +++++++++++++++++++++++++++--
 drivers/platform/x86/amd/pmf/spc.c  | 11 +++--
 3 files changed, 98 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index d2462ad7695d..c920e824a80a 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -278,11 +278,16 @@ static void amd_pmf_custom_bios_inputs_rb(struct amd_pmf_dev *pmf_dev)
 		break;
 	case PCI_DEVICE_ID_AMD_1AH_M20H_ROOT:
 	case PCI_DEVICE_ID_AMD_1AH_M60H_ROOT:
-	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
 		for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
 			rb->data[rb->head].val[i] = pmf_dev->req.custom_policy[i];
 		rb->data[rb->head].preq = pmf_dev->req.pending_req;
 		break;
+	case PCI_DEVICE_ID_AMD_1AH_M80H_ROOT:
+		for (i = 0; i < ARRAY_SIZE(custom_bios_inputs_ext); i++)
+			rb->data[rb->head].val[i] =
+				apmf_get_custom_policy_ext(&pmf_dev->req_ext, i);
+		rb->data[rb->head].preq = pmf_dev->req_ext.pending_req;
+		break;
 	default:
 		return;
 	}
@@ -305,20 +310,40 @@ static void amd_pmf_handle_early_preq(struct amd_pmf_dev *pdev)
 	pdev->cb_flag = false;
 }
 
+static int amd_pmf_read_sbios_requests_v2(struct amd_pmf_dev *pdev, u32 *preq)
+{
+	int ret;
+
+	if (is_amd_pmf_1ah_m80h(pdev)) {
+		ret = apmf_get_sbios_requests_v2_ext(pdev, &pdev->req_ext);
+		if (ret)
+			return ret;
+		*preq = pdev->req_ext.pending_req;
+	} else {
+		ret = apmf_get_sbios_requests_v2(pdev, &pdev->req);
+		if (ret)
+			return ret;
+		*preq = pdev->req.pending_req;
+	}
+
+	return 0;
+}
+
 static void apmf_event_handler_v2(acpi_handle handle, u32 event, void *data)
 {
 	struct amd_pmf_dev *pmf_dev = data;
+	u32 preq;
 	int ret;
 
 	guard(mutex)(&pmf_dev->cb_mutex);
 
-	ret = apmf_get_sbios_requests_v2(pmf_dev, &pmf_dev->req);
+	ret = amd_pmf_read_sbios_requests_v2(pmf_dev, &preq);
 	if (ret) {
 		dev_err(pmf_dev->dev, "Failed to get v2 SBIOS requests: %d\n", ret);
 		return;
 	}
 
-	dev_dbg(pmf_dev->dev, "Pending request (preq): 0x%x\n", pmf_dev->req.pending_req);
+	dev_dbg(pmf_dev->dev, "Pending request (preq): 0x%x\n", preq);
 
 	amd_pmf_handle_early_preq(pmf_dev);
 
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 00e2b161c4e5..4412f9e47e84 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -165,6 +165,7 @@ struct cookie_header {
 #define APTS_MAX_STATES		16
 #define CUSTOM_BIOS_INPUT_BITS	GENMASK(16, 7)
 #define BIOS_INPUTS_MAX		10
+#define BIOS_INPUTS_EXT_MAX	20
 #define CUSTOM_BIOS_INPUT_RING_ENTRIES	64	/* Must be power of two for CIRC_* macros */
 
 /* amd_pmf_send_cmd() set/get */
@@ -314,6 +315,21 @@ struct apmf_sbios_req_v2 {
 	u32 custom_policy[BIOS_INPUTS_MAX];
 } __packed;
 
+/* As per APMF 2.03 */
+struct apmf_sbios_req_v2_ext {
+	u16 size;
+	u32 pending_req;
+	u8 rsvd;
+	u32 ppt_pmf;
+	u32 ppt_pmf_apu_only;
+	u32 stt_min_limit;
+	u8 skin_temp_apu;
+	u8 skin_temp_hs2;
+	u32 custom_policy[BIOS_INPUTS_MAX];	/* inputs 1-10 */
+	u8 asm_lite_ctrl;
+	u32 custom_policy_ext[BIOS_INPUTS_MAX];	/* inputs 11-20 */
+} __packed;
+
 struct apmf_fan_idx {
 	u16 size;
 	u8 fan_ctl_mode;
@@ -643,7 +659,7 @@ enum power_modes_v2 {
 };
 
 struct pmf_bios_inputs_prev {
-	u32 custom_bios_inputs[BIOS_INPUTS_MAX];
+	u32 custom_bios_inputs[BIOS_INPUTS_EXT_MAX];
 };
 
 /**
@@ -652,7 +668,7 @@ struct pmf_bios_inputs_prev {
  * @preq: Pending request value associated with this event
  */
 struct pmf_bios_input_entry {
-	u32 val[BIOS_INPUTS_MAX];
+	u32 val[BIOS_INPUTS_EXT_MAX];
 	u32 preq;
 };
 
@@ -765,6 +781,7 @@ struct amd_pmf_dev {
 	const struct amd_pmf_ta_ops *ta_ops;
 	struct amd_pmf_metrics_v3 smartpc_prev_metrics;	/* Smart PC delta baseline */
 	bool smartpc_metrics_have_prev;
+	struct apmf_sbios_req_v2_ext req_ext;
 };
 
 struct apmf_sps_prop_granular_v2 {
@@ -1034,6 +1051,29 @@ static const struct amd_pmf_pb_bitmap custom_bios_inputs_v1[] __used = {
 	{"NOTIFY_CUSTOM_BIOS_INPUT10",    BIT(16)},
 };
 
+static const struct amd_pmf_pb_bitmap custom_bios_inputs_ext[] __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)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT11", BIT(16)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT12", BIT(17)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT13", BIT(18)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT14", BIT(19)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT15", BIT(20)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT16", BIT(21)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT17", BIT(22)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT18", BIT(23)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT19", BIT(24)},
+	{"NOTIFY_CUSTOM_BIOS_INPUT20", BIT(25)},
+};
+
 /* Command ids for TA communication */
 enum ta_pmf_command {
 	TA_PMF_COMMAND_POLICY_BUILDER_INITIALIZE,
@@ -1223,7 +1263,7 @@ struct ta_pmf_condition_info_v2 {
 	u32 workload_class;
 	u32 video_enc_sessions;
 	u32 video_dec_sessions;
-	u32 rsvd[10];
+	u32 bios_input_3[10];
 };
 
 struct ta_pmf_enact_table_v2 {
@@ -1431,6 +1471,24 @@ static inline int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_a
 	return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
 }
 
+static inline u32 apmf_get_custom_policy_ext(struct apmf_sbios_req_v2_ext *req, int index)
+{
+	switch (index) {
+	case 0 ... BIOS_INPUTS_MAX - 1:
+		return req->custom_policy[index];
+	case BIOS_INPUTS_MAX ... BIOS_INPUTS_EXT_MAX - 1:
+		return req->custom_policy_ext[index - BIOS_INPUTS_MAX];
+	default:
+		return 0;
+	}
+}
+
+static inline int apmf_get_sbios_requests_v2_ext(struct amd_pmf_dev *pdev,
+						 struct apmf_sbios_req_v2_ext *req)
+{
+	return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
 static inline int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev,
 					     struct apmf_sbios_req_v2 *req)
 {
@@ -1499,6 +1557,8 @@ static inline u32 amd_pmf_get_ta_custom_bios_inputs_v2(struct ta_pmf_enact_table
 		return in->ev_info.bios_input_1[index];
 	case 2 ... 9:
 		return in->ev_info.bios_input_2[index - 2];
+	case 10 ... 19:
+		return in->ev_info.bios_input_3[index - 10];
 	default:
 		return 0;
 	}
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index da3793b77fd7..24b289f715f8 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -53,7 +53,7 @@ void amd_pmf_dump_ta_inputs_v2(struct amd_pmf_dev *dev, struct ta_pmf_enact_tabl
 		amd_pmf_get_platform_type(in->ev_info.platform_type));
 	dev_dbg(dev->dev, "Laptop placement: %s\n",
 		amd_pmf_get_laptop_placement(in->ev_info.device_state));
-	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs_ext); i++)
 		dev_dbg(dev->dev, "Custom BIOS input%d: %u\n", i + 1,
 			amd_pmf_get_ta_custom_bios_inputs_v2(in, i));
 	dev_dbg(dev->dev, "==== TA v2 inputs END ====\n");
@@ -100,6 +100,9 @@ static void amd_pmf_set_ta_custom_bios_input_v2(struct ta_pmf_enact_table_v2 *in
 	case 2 ... 9:
 		in->ev_info.bios_input_2[index - 2] = value;
 		break;
+	case 10 ... 19:
+		in->ev_info.bios_input_3[index - 10] = value;
+		break;
 	}
 }
 
@@ -128,8 +131,8 @@ static void amd_pmf_update_bios_inputs_v2(struct amd_pmf_dev *pdev,
 {
 	unsigned int i;
 
-	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
-		if (!(data->preq & custom_bios_inputs[i].bit_mask))
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs_ext); i++) {
+		if (!(data->preq & custom_bios_inputs_ext[i].bit_mask))
 			continue;
 		amd_pmf_set_ta_custom_bios_input_v2(in, i, data->val[i]);
 		pdev->cb_prev.custom_bios_inputs[i] = data->val[i];
@@ -160,7 +163,7 @@ static void amd_pmf_get_custom_bios_inputs_v2(struct amd_pmf_dev *pdev,
 
 	guard(mutex)(&pdev->cbi_mutex);
 
-	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++)
+	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs_ext); i++)
 		amd_pmf_set_ta_custom_bios_input_v2(in, i, pdev->cb_prev.custom_bios_inputs[i]);
 
 	if (CIRC_CNT(rb->head, rb->tail, CUSTOM_BIOS_INPUT_RING_ENTRIES) == 0)
-- 
2.34.1


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

* Re: [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support
  2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
                   ` (11 preceding siblings ...)
  2026-11-30  7:52 ` [PATCH v5 12/12] platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H Shyam Sundar S K
@ 2026-12-01 11:35 ` Ilpo Järvinen
  2026-12-01 13:54   ` Shyam Sundar S K
  12 siblings, 1 reply; 16+ messages in thread
From: Ilpo Järvinen @ 2026-12-01 11:35 UTC (permalink / raw)
  To: Shyam Sundar S K
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello

On Mon, 30 Nov 2026, Shyam Sundar S K wrote:

> This series enables the PMF driver features on the 1AH_M80H platform.
> 
> Patch 1 fixes the clamping of the Q10 accumulator values.
> Patch 2 stops sending the legacy DRAM address commands on 1AH_M80H.
> Patches 3-4 move the static slider handling to per version ops and add
> the 1AH_M80H static slider support as per APMF 2.03.
> Patches 5-6 add per-platform TA ops and the signature size handling for
> RSA4K and alternatively signed policy binaries.
> Patch 7 uses the system state enum in the TA policy action code.
> Patch 8 adds the Smart PC builder support for the new TA.
> Patch 9 remaps the metrics table on resume.
> Patch 10 passes the custom BIOS inputs to the TA on 1AH_M80H.
> Patch 11 shares the TA policy apply code between the TA versions.
> Patch 12 extends the custom BIOS inputs to 20 on 1AH_M80H (APMF 2.03).
> 
> ---
> v5:
>  - Rebase on the latest review-ilpo-next
>  - New patch 1: use min() instead of min_t(u16, ...) in the Q10
>    accumulator helpers, which truncated the value before clamping (Ilpo)
>  - Patch 4: drop the fan index handling from the 1AH_M80H static slider,
>    the existing v2 static slider does not set it either
>  - Patch 8: report a TA init/enact failure as an error when the TEE call
>    itself succeeded, and pass the skin temperature in centidegrees

This looks better wrt. ops.

Checking out sashiko's findings, there seems to be a bit more work to do.

-- 
 i.

> v4: https://lore.kernel.org/all/20261124075213.2317127-1-Shyam-sundar.S-k@amd.com/
>  - Rebase on the latest review-ilpo-next
>  - New patch 2: move the static slider handling to per version sps_ops (Ilpo)
>  - Patch 3: add the 1AH_M80H static slider support as a new set of sps_ops
>  - Patch 11: add apmf_get_custom_policy_ext() and read the SBIOS requests
>    through one helper so that the event handler has a single path (Ilpo)
>  - Pick Mario's Reviewed-by for patch 5
> 
> v3: https://lore.kernel.org/all/20261118143034.3566684-1-Shyam-sundar.S-k@amd.com/
>  - Rebase on the latest review-ilpo-next
>  - Patch 4: also handle policy binaries signed with the alternative
>    signing mechanism
>  - Pick Mario's Reviewed-by for patches 5 and 10
> 
> v2: https://lore.kernel.org/all/20261106164429.30738-1-Shyam-sundar.S-k@amd.com/
>  - Rebase on the latest review-ilpo-next
>  - Pick Mario's Reviewed-by
>  - Use ARRAY_SIZE() and rename the APTS state array to states[] (Ilpo)
>  - Use SZ_256/SZ_512 for the PSP header and signature sizes (Ilpo)
>  - Use max(), sizeof() of the destination, and a single update of the
>    previous sample in amd_pmf_get_smu_info_v2() (Ilpo)
>  - New patch 5: use enum system_state instead of literals (Ilpo)
>  - Keep allocating the metrics buffer on 1AH_M80H and only skip the
>    SET_DRAM_ADDR commands, the existing metrics paths still use it
>  - Keep the power source notifier registration unchanged, skip the
>    1AH_M80H slider update instead when the APTS defaults were not read
>  - Read the v2 TA layout in the util interface on 1AH_M80H
>  - Do not fail resume/restore when the metrics table remap fails
>  - New patch 10: add the custom BIOS inputs 11-20 of APMF 2.03
> 
> v1: https://lore.kernel.org/all/20261011100554.1841309-1-Shyam-sundar.S-k@amd.com/
> 
> Patil Rajesh Reddy (1):
>   platform/x86/amd/pmf: Abstract static slider handling through sps_ops
> 
> Shyam Sundar S K (11):
>   platform/x86/amd/pmf: Fix clamping of Q10 accumulator values
>   platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H
>   platform/x86/amd/pmf: Add 1AH_M80H static slider support
>   platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table
>   platform/x86/amd/pmf: Get policy binary signature size from PSP header
>   platform/x86/amd/pmf: Use enum system_state for the TA system state
>     action
>   platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H
>   platform/x86/amd/pmf: Remap metrics table on resume for 1AH_M80H
>   platform/x86/amd/pmf: Add custom BIOS input support for 1AH_M80H
>   platform/x86/amd/pmf: Share TA policy apply code between TA versions
>   platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H
> 
>  drivers/platform/x86/amd/pmf/acpi.c    |  32 ++-
>  drivers/platform/x86/amd/pmf/core.c    |  38 ++-
>  drivers/platform/x86/amd/pmf/metrics.c |  20 +-
>  drivers/platform/x86/amd/pmf/pmf.h     | 328 ++++++++++++++++++++++++-
>  drivers/platform/x86/amd/pmf/spc.c     | 211 ++++++++++++++++
>  drivers/platform/x86/amd/pmf/sps.c     | 177 ++++++++++++-
>  drivers/platform/x86/amd/pmf/tee-if.c  | 261 +++++++++++++++++---
>  drivers/platform/x86/amd/pmf/util.c    |  83 +++++--
>  8 files changed, 1056 insertions(+), 94 deletions(-)
> 
> 
> base-commit: 6fc627bda235ac5b6f43b5f784b81d6c2450ae5a
> 

-- 
 i.


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

* Re: [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support
  2026-12-01 11:35 ` [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Ilpo Järvinen
@ 2026-12-01 13:54   ` Shyam Sundar S K
  2026-12-01 14:35     ` Ilpo Järvinen
  0 siblings, 1 reply; 16+ messages in thread
From: Shyam Sundar S K @ 2026-12-01 13:54 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello

Hi Ilpo,

On 01-12-2026 17:05, Ilpo Järvinen wrote:
> On Mon, 30 Nov 2026, Shyam Sundar S K wrote:
> 
>> This series enables the PMF driver features on the 1AH_M80H platform.
>>
>> Patch 1 fixes the clamping of the Q10 accumulator values.
>> Patch 2 stops sending the legacy DRAM address commands on 1AH_M80H.
>> Patches 3-4 move the static slider handling to per version ops and add
>> the 1AH_M80H static slider support as per APMF 2.03.
>> Patches 5-6 add per-platform TA ops and the signature size handling for
>> RSA4K and alternatively signed policy binaries.
>> Patch 7 uses the system state enum in the TA policy action code.
>> Patch 8 adds the Smart PC builder support for the new TA.
>> Patch 9 remaps the metrics table on resume.
>> Patch 10 passes the custom BIOS inputs to the TA on 1AH_M80H.
>> Patch 11 shares the TA policy apply code between the TA versions.
>> Patch 12 extends the custom BIOS inputs to 20 on 1AH_M80H (APMF 2.03).
>>
>> ---
>> v5:
>>  - Rebase on the latest review-ilpo-next
>>  - New patch 1: use min() instead of min_t(u16, ...) in the Q10
>>    accumulator helpers, which truncated the value before clamping (Ilpo)
>>  - Patch 4: drop the fan index handling from the 1AH_M80H static slider,
>>    the existing v2 static slider does not set it either
>>  - Patch 8: report a TA init/enact failure as an error when the TEE call
>>    itself succeeded, and pass the skin temperature in centidegrees
> 
> This looks better wrt. ops.
> 
> Checking out sashiko's findings, there seems to be a bit more work to do.
> 

Thanks. I went through the sashiko findings on v5. Two of them are in
the code added by this series, and I will fix them in v6:

 - The socket power is built from amd_pmf_q10_acc_to_mW(), which clamps
   to U16_MAX, so APU or dGPU power above 65.5 W gets clamped. I will
   compute the value without the u16 helper.
 - The v2 TA init/enact clear dev->shbuf with the policy size. I will
   clear sizeof(*ta_sm) in init and drop the redundant memset in enact.

The other three are in existing code that the earlier platforms use as
well:

 - amd_pmf_load_defaults_sps_v2() does not check the return value of
   apmf_get_static_slider_granular_v2(). The new 1AH_M80H slider ops use
   it the same way the existing v2 ops do, and the v1 loader has the
   same pattern.
 - The enact from the periodic work and from amd_pmf_handle_early_preq()
   are not serialized against each other.
 - The util interface reads the shared buffer without holding the lock
   that the enact path uses.

These are the same for the v1 TA paths. Since this series is meant to
add support for a new SoC, I would like to keep the fixes for existing
code out of it. 

I plan to run sashiko once on the whole driver and address all the
flagged issues for all platforms in a separate series after this one.

Would that be OK with you, with v6 having only the two fixes above?

Thanks,
Shyam


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

* Re: [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support
  2026-12-01 13:54   ` Shyam Sundar S K
@ 2026-12-01 14:35     ` Ilpo Järvinen
  0 siblings, 0 replies; 16+ messages in thread
From: Ilpo Järvinen @ 2026-12-01 14:35 UTC (permalink / raw)
  To: Shyam Sundar S K
  Cc: Hans de Goede, platform-driver-x86, Patil.Reddy,
	mario.limonciello

[-- Attachment #1: Type: text/plain, Size: 3443 bytes --]

On Tue, 1 Dec 2026, Shyam Sundar S K wrote:
> On 01-12-2026 17:05, Ilpo Järvinen wrote:
> > On Mon, 30 Nov 2026, Shyam Sundar S K wrote:
> > 
> >> This series enables the PMF driver features on the 1AH_M80H platform.
> >>
> >> Patch 1 fixes the clamping of the Q10 accumulator values.
> >> Patch 2 stops sending the legacy DRAM address commands on 1AH_M80H.
> >> Patches 3-4 move the static slider handling to per version ops and add
> >> the 1AH_M80H static slider support as per APMF 2.03.
> >> Patches 5-6 add per-platform TA ops and the signature size handling for
> >> RSA4K and alternatively signed policy binaries.
> >> Patch 7 uses the system state enum in the TA policy action code.
> >> Patch 8 adds the Smart PC builder support for the new TA.
> >> Patch 9 remaps the metrics table on resume.
> >> Patch 10 passes the custom BIOS inputs to the TA on 1AH_M80H.
> >> Patch 11 shares the TA policy apply code between the TA versions.
> >> Patch 12 extends the custom BIOS inputs to 20 on 1AH_M80H (APMF 2.03).
> >>
> >> ---
> >> v5:
> >>  - Rebase on the latest review-ilpo-next
> >>  - New patch 1: use min() instead of min_t(u16, ...) in the Q10
> >>    accumulator helpers, which truncated the value before clamping (Ilpo)
> >>  - Patch 4: drop the fan index handling from the 1AH_M80H static slider,
> >>    the existing v2 static slider does not set it either
> >>  - Patch 8: report a TA init/enact failure as an error when the TEE call
> >>    itself succeeded, and pass the skin temperature in centidegrees
> > 
> > This looks better wrt. ops.
> > 
> > Checking out sashiko's findings, there seems to be a bit more work to do.
> > 
> 
> Thanks. I went through the sashiko findings on v5. Two of them are in
> the code added by this series, and I will fix them in v6:
> 
>  - The socket power is built from amd_pmf_q10_acc_to_mW(), which clamps
>    to U16_MAX, so APU or dGPU power above 65.5 W gets clamped. I will
>    compute the value without the u16 helper.
>  - The v2 TA init/enact clear dev->shbuf with the policy size. I will
>    clear sizeof(*ta_sm) in init and drop the redundant memset in enact.
> 
> The other three are in existing code that the earlier platforms use as
> well:
> 
>  - amd_pmf_load_defaults_sps_v2() does not check the return value of
>    apmf_get_static_slider_granular_v2(). The new 1AH_M80H slider ops use
>    it the same way the existing v2 ops do, and the v1 loader has the
>    same pattern.
>  - The enact from the periodic work and from amd_pmf_handle_early_preq()
>    are not serialized against each other.
>  - The util interface reads the shared buffer without holding the lock
>    that the enact path uses.
> 
> These are the same for the v1 TA paths. Since this series is meant to
> add support for a new SoC, I would like to keep the fixes for existing
> code out of it. 
> 
> I plan to run sashiko once on the whole driver and address all the
> flagged issues for all platforms in a separate series after this one.
> 
> Would that be OK with you, with v6 having only the two fixes above?

I'm fine with not addressing existing issues, even better if you plan to 
address them anyway, even if separately. ...Though usually if new stuff 
adds to the problem, it would be better to cover that part within the 
series even if it's also a pre-existing issue. But I guess I can make an 
exception here.

-- 
 i.

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

end of thread, other threads:[~2026-12-01 14:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  7:52 [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 01/12] platform/x86/amd/pmf: Fix clamping of Q10 accumulator values Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 02/12] platform/x86/amd/pmf: Skip legacy DRAM address commands on 1AH_M80H Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 03/12] platform/x86/amd/pmf: Abstract static slider handling through sps_ops Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 04/12] platform/x86/amd/pmf: Add 1AH_M80H static slider support Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 05/12] platform/x86/amd/pmf: Abstract TA dispatch through ta_ops table Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 06/12] platform/x86/amd/pmf: Get policy binary signature size from PSP header Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 07/12] platform/x86/amd/pmf: Use enum system_state for the TA system state action Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 08/12] platform/x86/amd/pmf: Add Smart PC builder support for 1AH_M80H Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 09/12] platform/x86/amd/pmf: Remap metrics table on resume " Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 10/12] platform/x86/amd/pmf: Add custom BIOS input support " Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 11/12] platform/x86/amd/pmf: Share TA policy apply code between TA versions Shyam Sundar S K
2026-11-30  7:52 ` [PATCH v5 12/12] platform/x86/amd/pmf: Add extended custom BIOS inputs for 1AH_M80H Shyam Sundar S K
2026-12-01 11:35 ` [PATCH v5 00/12] platform/x86/amd/pmf: Add 1AH_M80H support Ilpo Järvinen
2026-12-01 13:54   ` Shyam Sundar S K
2026-12-01 14:35     ` Ilpo Järvinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.