* [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining
@ 2026-09-01 15:02 Rong Zhang
2026-09-01 15:02 ` [PATCH 1/5] platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub Rong Zhang
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
The amd-pmf driver is notably bloated due to undesirable function
outlining and linkage. Simple and dump helper functions as well as
wrappers should really be static inline functions instead of global ones
from the very beginning, or else they are prone to the overhead of
function outlining and linkage, which bloats themselves and their
callers.
The series converts all these helper functions and wrappers into static
inline functions, and shrink the module (!CONFIG_AMD_PMF_DEBUG &&
CONFIG_AMD_PMF_UTIL_SUPPORT) size by 1472 Bytes (GCC 16 -O2):
text data bss total filename (before)
26810 31672 2768 61250 amd-pmf.ko
text data bss total filename (after)
26046 30964 2768 59778 amd-pmf.ko
As for CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT builds, the
module size is shrunk by 1187 Bytes:
text data bss total filename (before)
34593 45500 2784 82877 amd-pmf.ko
text data bss total filename (after)
33988 44918 2784 81690 amd-pmf.ko
This should also optimize the performance a little bit theoretically,
though it's probably not very important on modern hardware anyway.
Signed-off-by: Rong Zhang <i@rong.moe>
---
Rong Zhang (5):
platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub
platform/x86/amd/pmf: Inline simple helper functions of Core Layer
platform/x86/amd/pmf: Inline simple helper function of SPS Layer
platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces
platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer()
drivers/platform/x86/amd/pmf/acpi.c | 76 +-----------------
drivers/platform/x86/amd/pmf/core.c | 22 ------
drivers/platform/x86/amd/pmf/pmf.h | 150 +++++++++++++++++++++++++++++++-----
drivers/platform/x86/amd/pmf/spc.c | 15 ----
drivers/platform/x86/amd/pmf/sps.c | 5 --
5 files changed, 131 insertions(+), 137 deletions(-)
---
base-commit: 9ffed84a24d60ec506d8961fe138f0baa92fdbd0
change-id: 6f1861db-amd-pmf-fix-outlining-204546e884cf
Thanks,
Rong
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
@ 2026-09-01 15:02 ` Rong Zhang
2026-09-01 15:02 ` [PATCH 2/5] platform/x86/amd/pmf: Inline simple helper functions of Core Layer Rong Zhang
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
A !CONFIG_AMD_PMF_DEBUG build compiles amd_pmf_dump_ta_inputs() as a
stub. However, the stub is implemented as a global function and becomes
a symbol against linkage. This bloats the size of the module.
As a best practice, convert the stub into a static inline function to
get rid of the overhead of function outlining and linkage, and shrink
the module (!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size
by 65 Bytes (GCC 16 -O2):
text data bss total filename (before)
26810 31672 2768 61250 amd-pmf.ko
text data bss total filename (after)
26781 31636 2768 61185 amd-pmf.ko
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/amd/pmf/pmf.h | 7 ++++++-
drivers/platform/x86/amd/pmf/spc.c | 2 --
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 07ec00684233..4da2ef1abb50 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -1137,10 +1137,15 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq
/* Smart PC - TA interfaces */
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
-void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev);
u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index);
+#ifdef CONFIG_AMD_PMF_DEBUG
+void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
+#else
+static inline void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
+#endif
+
int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid);
void amd_pmf_tee_deinit(struct amd_pmf_dev *dev);
int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev);
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index 592ba4de4c7f..ea11d29633c8 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -60,8 +60,6 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
amd_pmf_get_ta_custom_bios_inputs(in, i));
dev_dbg(dev->dev, "==== TA inputs END ====\n");
}
-#else
-void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
#endif
/*
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] platform/x86/amd/pmf: Inline simple helper functions of Core Layer
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
2026-09-01 15:02 ` [PATCH 1/5] platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub Rong Zhang
@ 2026-09-01 15:02 ` Rong Zhang
2026-09-01 15:02 ` [PATCH 3/5] platform/x86/amd/pmf: Inline simple helper function of SPS Layer Rong Zhang
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
The Core Layer has simple and dumb helper functions defined as global
symbols, which are heavily used by other layers and become symbols
against linkage. This bloats the size of the module.
Convert them into static inline functions to get rid of the overhead of
function outlining and linkage, and shrink the module
(!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size by 432 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26781 31636 2768 61185 amd-pmf.ko
text data bss total filename (after)
26533 31452 2768 60753 amd-pmf.ko
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/amd/pmf/acpi.c | 11 -----------
drivers/platform/x86/amd/pmf/core.c | 22 ---------------------
drivers/platform/x86/amd/pmf/pmf.h | 39 +++++++++++++++++++++++++++++++++----
3 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 3d94b03cf794..6a2c11e75eea 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -158,17 +158,6 @@ static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
return err;
}
-int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index)
-{
- /* If bit-n is set, that indicates function n+1 is supported */
- return !!(pdev->supported_func & BIT(index - 1));
-}
-
-int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev)
-{
- return !!(pdev->notifications & CUSTOM_BIOS_INPUT_BITS);
-}
-
int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
struct amd_pmf_apts_granular_output *data, u32 apts_idx)
{
diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index b4eae65e675b..ec2ce7fa3dee 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -138,14 +138,6 @@ static void amd_pmf_dbgfs_register(struct amd_pmf_dev *dev)
¤t_power_limits_fops);
}
-int amd_pmf_get_power_source(void)
-{
- if (power_supply_is_system_supplied() > 0)
- return POWER_SOURCE_AC;
- else
- return POWER_SOURCE_DC;
-}
-
static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset)
{
return ioread32(dev->regbase + reg_offset);
@@ -176,20 +168,6 @@ static void __maybe_unused amd_pmf_dump_registers(struct amd_pmf_dev *dev)
dev_dbg(dev->dev, "AMD_PMF_REGISTER_MESSAGE:%x\n", value);
}
-/**
- * fixp_q88_fromint: Convert integer to Q8.8
- * @val: input value
- *
- * Converts an integer into binary fixed point format where 8 bits
- * are used for integer and 8 bits are used for the decimal.
- *
- * Return: unsigned integer converted to Q8.8 format
- */
-u32 fixp_q88_fromint(u32 val)
-{
- return val << 8;
-}
-
int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data)
{
int rc;
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 4da2ef1abb50..024f20306e11 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -13,11 +13,13 @@
#include <linux/acpi.h>
#include <linux/amd-pmf-io.h>
+#include <linux/bits.h>
#include <linux/circ_buf.h>
#include <linux/compiler_attributes.h>
#include <linux/compiler_types.h>
#include <linux/input.h>
#include <linux/mutex_types.h>
+#include <linux/power_supply.h>
#include <linux/platform_device.h>
#include <linux/platform_profile.h>
#include <linux/types.h>
@@ -1073,18 +1075,47 @@ struct ta_pmf_shared_memory {
/* Core Layer */
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
-int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index);
int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data);
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev);
-int amd_pmf_get_power_source(void);
int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);
int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer);
int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag);
-u32 fixp_q88_fromint(u32 val);
-int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev);
void amd_pmf_set_device(struct device *p_device);
+static inline int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index)
+{
+ /* If bit-n is set, that indicates function n+1 is supported */
+ return !!(pdev->supported_func & BIT(index - 1));
+}
+
+static inline int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev)
+{
+ return !!(pdev->notifications & CUSTOM_BIOS_INPUT_BITS);
+}
+
+static inline int amd_pmf_get_power_source(void)
+{
+ if (power_supply_is_system_supplied() > 0)
+ return POWER_SOURCE_AC;
+ else
+ return POWER_SOURCE_DC;
+}
+
+/**
+ * fixp_q88_fromint: Convert integer to Q8.8
+ * @val: input value
+ *
+ * Converts an integer into binary fixed point format where 8 bits
+ * are used for integer and 8 bits are used for the decimal.
+ *
+ * Return: unsigned integer converted to Q8.8 format
+ */
+static inline u32 fixp_q88_fromint(u32 val)
+{
+ return val << 8;
+}
+
/* Metrics layer */
int amd_pmf_get_tbl_dram_addr(struct amd_pmf_dev *dev);
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] platform/x86/amd/pmf: Inline simple helper function of SPS Layer
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
2026-09-01 15:02 ` [PATCH 1/5] platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub Rong Zhang
2026-09-01 15:02 ` [PATCH 2/5] platform/x86/amd/pmf: Inline simple helper functions of Core Layer Rong Zhang
@ 2026-09-01 15:02 ` Rong Zhang
2026-09-01 15:02 ` [PATCH 4/5] platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces Rong Zhang
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
The SPS Layer has a simple and dumb helper function defined as a global
symbol, which is heavily used by other layers and becomes a symbol
against linkage. This bloats the size of the module.
Convert it into a static inline function to get rid of the overhead of
function outlining and linkage, and shrink the module
(!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size by 252 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26533 31452 2768 60753 amd-pmf.ko
text data bss total filename (after)
26341 31392 2768 60501 amd-pmf.ko
There are also two duplicated prototypes, so remove one of them as well.
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/amd/pmf/pmf.h | 8 +++++---
drivers/platform/x86/amd/pmf/sps.c | 5 -----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 024f20306e11..4a4c3aeadecc 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -1126,12 +1126,9 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
int amd_pmf_init_sps(struct amd_pmf_dev *dev);
int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
struct apmf_static_slider_granular_output *output);
-bool is_pprof_balanced(struct amd_pmf_dev *pmf);
int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev);
const char *amd_pmf_source_as_str(unsigned int state);
-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);
int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev,
@@ -1139,6 +1136,11 @@ int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev,
int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
struct amd_pmf_apts_granular_output *data, u32 apts_idx);
+static inline bool is_pprof_balanced(struct amd_pmf_dev *pmf)
+{
+ return pmf->current_profile == PLATFORM_PROFILE_BALANCED;
+}
+
/* Auto Mode Layer */
int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);
void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev);
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index 0b70a5153f46..035272d37867 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -281,11 +281,6 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
return 0;
}
-bool is_pprof_balanced(struct amd_pmf_dev *pmf)
-{
- return pmf->current_profile == PLATFORM_PROFILE_BALANCED;
-}
-
static int amd_pmf_profile_get(struct device *dev,
enum platform_profile_option *profile)
{
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
` (2 preceding siblings ...)
2026-09-01 15:02 ` [PATCH 3/5] platform/x86/amd/pmf: Inline simple helper function of SPS Layer Rong Zhang
@ 2026-09-01 15:02 ` Rong Zhang
2026-09-01 15:02 ` [PATCH 5/5] platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer() Rong Zhang
2026-09-01 15:09 ` [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Mario Limonciello
5 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
The Smart PC TA interfaces have a simple and dumb helper function
defined as a global symbol, which is used by other layers and becomes a
symbol against linkage. This bloats the size of the module.
Convert it into a static inline function to get rid of the overhead of
function outlining and linkage, and shrink the module
(!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size by 208 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26341 31392 2768 60501 amd-pmf.ko
text data bss total filename (after)
26261 31264 2768 60293 amd-pmf.ko
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/amd/pmf/pmf.h | 13 ++++++++++++-
drivers/platform/x86/amd/pmf/spc.c | 13 -------------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 4a4c3aeadecc..6d9963677a46 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -1171,7 +1171,18 @@ 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);
-u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index);
+
+static inline u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
+{
+ switch (index) {
+ case 0 ... 1:
+ return in->ev_info.bios_input_1[index];
+ 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);
diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
index ea11d29633c8..c939c5379151 100644
--- a/drivers/platform/x86/amd/pmf/spc.c
+++ b/drivers/platform/x86/amd/pmf/spc.c
@@ -17,19 +17,6 @@
#include <linux/units.h>
#include "pmf.h"
-u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
-{
- switch (index) {
- case 0 ... 1:
- return in->ev_info.bios_input_1[index];
- case 2 ... 9:
- return in->ev_info.bios_input_2[index - 2];
- default:
- return 0;
- }
-}
-EXPORT_SYMBOL(amd_pmf_get_ta_custom_bios_inputs);
-
#ifdef CONFIG_AMD_PMF_DEBUG
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer()
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
` (3 preceding siblings ...)
2026-09-01 15:02 ` [PATCH 4/5] platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces Rong Zhang
@ 2026-09-01 15:02 ` Rong Zhang
2026-09-01 15:09 ` [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Mario Limonciello
5 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-09-01 15:02 UTC (permalink / raw)
To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami, Mario Limonciello (AMD)
Cc: platform-driver-x86, linux-kernel, Rong Zhang
There are several simple and dumb wrappers of
ap{mf,ts}_if_call_store_buffer() defined as global symbols, which are
heavily used by multiple layers and become symbols against linkage. This
bloats the size of the module.
Since is_apmf_func_supported() has been converted, convert the mentioned
wrappers into static inline functions to get rid of the overhead of
function outlining and linkage, and shrink the module
(!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size by 515 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26261 31264 2768 60293 amd-pmf.ko
text data bss total filename (after)
26046 30964 2768 59778 amd-pmf.ko
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/amd/pmf/acpi.c | 65 +----------------------------
drivers/platform/x86/amd/pmf/pmf.h | 83 +++++++++++++++++++++++++++++++------
2 files changed, 73 insertions(+), 75 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 6a2c11e75eea..4392bf0bc0bf 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -50,7 +50,7 @@ static union acpi_object *apmf_if_call(struct amd_pmf_dev *pdev, int fn, struct
return buffer.pointer;
}
-static int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz)
+int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz)
{
union acpi_object *info;
size_t size;
@@ -121,8 +121,7 @@ static union acpi_object *apts_if_call(struct amd_pmf_dev *pdev, u32 state_index
return buffer.pointer;
}
-static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
- u32 index, void *data, size_t out_sz)
+int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, size_t out_sz)
{
union acpi_object *info;
size_t size;
@@ -158,35 +157,6 @@ static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
return err;
}
-int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct amd_pmf_apts_granular_output *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));
-}
-
-int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output_v2 *data)
-{
- if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
- return -EINVAL;
-
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
- data, sizeof(*data));
-}
-
-int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output *data)
-{
- if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
- return -EINVAL;
-
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
- data, sizeof(*data));
-}
-
int apmf_os_power_slider_update(struct amd_pmf_dev *pdev, u8 event)
{
struct os_power_slider args;
@@ -302,27 +272,6 @@ static int apmf_notify_smart_pc_update(struct amd_pmf_dev *pdev, u32 val, u32 pr
return 0;
}
-int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
-}
-
-int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
-}
-
-int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
-}
-
-int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS,
- req, sizeof(*req));
-}
-
/* Store custom BIOS inputs data in ring buffer */
static void amd_pmf_custom_bios_inputs_rb(struct amd_pmf_dev *pmf_dev)
{
@@ -484,16 +433,6 @@ static int apmf_get_system_params(struct amd_pmf_dev *dev)
return 0;
}
-int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_AC, data, sizeof(*data));
-}
-
-int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
-}
-
static apmf_event_handler_t apmf_event_handlers[] = {
[PMF_IF_V1] = apmf_event_handler_v1,
[PMF_IF_V2] = apmf_event_handler_v2,
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 6d9963677a46..9f64ab833c08 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -17,6 +17,7 @@
#include <linux/circ_buf.h>
#include <linux/compiler_attributes.h>
#include <linux/compiler_types.h>
+#include <linux/errno.h>
#include <linux/input.h>
#include <linux/mutex_types.h>
#include <linux/power_supply.h>
@@ -1075,6 +1076,8 @@ struct ta_pmf_shared_memory {
/* Core Layer */
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
+int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz);
+int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, size_t out_sz);
int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data);
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev);
int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
@@ -1124,17 +1127,43 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);
void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
struct amd_pmf_static_slider_granular *table);
int amd_pmf_init_sps(struct amd_pmf_dev *dev);
-int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output *output);
int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev);
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);
-int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev,
- struct apmf_static_slider_granular_output_v2 *data);
-int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct amd_pmf_apts_granular_output *data, u32 apts_idx);
+
+static inline int
+apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
+ struct amd_pmf_apts_granular_output *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
+apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
+ struct apmf_static_slider_granular_output_v2 *data)
+{
+ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+ return -EINVAL;
+
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
+ data, sizeof(*data));
+}
+
+static inline int
+apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
+ struct apmf_static_slider_granular_output *data)
+{
+ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+ return -EINVAL;
+
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
+ data, sizeof(*data));
+}
static inline bool is_pprof_balanced(struct amd_pmf_dev *pmf)
{
@@ -1142,26 +1171,56 @@ static inline bool is_pprof_balanced(struct amd_pmf_dev *pmf)
}
/* Auto Mode Layer */
-int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);
void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t time_elapsed_ms);
-int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req);
-int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req);
-int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req);
void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event);
int amd_pmf_reset_amt(struct amd_pmf_dev *dev);
void amd_pmf_handle_amt(struct amd_pmf_dev *dev);
+static inline int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
+}
+
+static inline int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req_v2 *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
+static inline int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req_v1 *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
+static inline int apmf_get_sbios_requests(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS,
+ req, sizeof(*req));
+}
+
/* CnQF Layer */
-int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data);
-int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data);
int amd_pmf_init_cnqf(struct amd_pmf_dev *dev);
void amd_pmf_deinit_cnqf(struct amd_pmf_dev *dev);
int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_lapsed_ms);
extern const struct attribute_group cnqf_feature_attribute_group;
+static inline int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev,
+ struct apmf_dyn_slider_output *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_AC, data, sizeof(*data));
+}
+
+static inline int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev,
+ struct apmf_dyn_slider_output *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
+}
+
/* Smart PC builder Layer */
int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev);
void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev);
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
` (4 preceding siblings ...)
2026-09-01 15:02 ` [PATCH 5/5] platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer() Rong Zhang
@ 2026-09-01 15:09 ` Mario Limonciello
5 siblings, 0 replies; 7+ messages in thread
From: Mario Limonciello @ 2026-09-01 15:09 UTC (permalink / raw)
To: Rong Zhang, Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
Sanket Goswami
Cc: platform-driver-x86, linux-kernel
On 9/1/26 10:02, Rong Zhang wrote:
> The amd-pmf driver is notably bloated due to undesirable function
> outlining and linkage. Simple and dump helper functions as well as
> wrappers should really be static inline functions instead of global ones
> from the very beginning, or else they are prone to the overhead of
> function outlining and linkage, which bloats themselves and their
> callers.
>
> The series converts all these helper functions and wrappers into static
> inline functions, and shrink the module (!CONFIG_AMD_PMF_DEBUG &&
> CONFIG_AMD_PMF_UTIL_SUPPORT) size by 1472 Bytes (GCC 16 -O2):
>
> text data bss total filename (before)
> 26810 31672 2768 61250 amd-pmf.ko
>
> text data bss total filename (after)
> 26046 30964 2768 59778 amd-pmf.ko
>
> As for CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT builds, the
> module size is shrunk by 1187 Bytes:
>
> text data bss total filename (before)
> 34593 45500 2784 82877 amd-pmf.ko
>
> text data bss total filename (after)
> 33988 44918 2784 81690 amd-pmf.ko
>
> This should also optimize the performance a little bit theoretically,
> though it's probably not very important on modern hardware anyway.
>
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> Rong Zhang (5):
> platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub
> platform/x86/amd/pmf: Inline simple helper functions of Core Layer
> platform/x86/amd/pmf: Inline simple helper function of SPS Layer
> platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces
> platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer()
>
> drivers/platform/x86/amd/pmf/acpi.c | 76 +-----------------
> drivers/platform/x86/amd/pmf/core.c | 22 ------
> drivers/platform/x86/amd/pmf/pmf.h | 150 +++++++++++++++++++++++++++++++-----
> drivers/platform/x86/amd/pmf/spc.c | 15 ----
> drivers/platform/x86/amd/pmf/sps.c | 5 --
> 5 files changed, 131 insertions(+), 137 deletions(-)
> ---
> base-commit: 9ffed84a24d60ec506d8961fe138f0baa92fdbd0
> change-id: 6f1861db-amd-pmf-fix-outlining-204546e884cf
>
> Thanks,
> Rong
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-01 15:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01 15:02 [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Rong Zhang
2026-09-01 15:02 ` [PATCH 1/5] platform/x86/amd/pmf: Inline !AMD_PMF_DEBUG stub Rong Zhang
2026-09-01 15:02 ` [PATCH 2/5] platform/x86/amd/pmf: Inline simple helper functions of Core Layer Rong Zhang
2026-09-01 15:02 ` [PATCH 3/5] platform/x86/amd/pmf: Inline simple helper function of SPS Layer Rong Zhang
2026-09-01 15:02 ` [PATCH 4/5] platform/x86/amd/pmf: Inline simple helper function of Smart PC TA interfaces Rong Zhang
2026-09-01 15:02 ` [PATCH 5/5] platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer() Rong Zhang
2026-09-01 15:09 ` [PATCH 0/5] platform/x86/amd/pmf: Clean up undesirable function outlining Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®